@cline/llms 0.0.38-nightly.1778113663
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +219 -0
- package/dist/catalog/catalog-live.d.ts +34 -0
- package/dist/catalog/catalog-live.d.ts.map +1 -0
- package/dist/catalog/catalog.generated-access.d.ts +5 -0
- package/dist/catalog/catalog.generated-access.d.ts.map +1 -0
- package/dist/catalog/catalog.generated.d.ts +17 -0
- package/dist/catalog/catalog.generated.d.ts.map +1 -0
- package/dist/catalog/types.d.ts +263 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/index.browser.d.ts +6 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/models.d.ts +5 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +1 -0
- package/dist/providers/ai-sdk.d.ts +41 -0
- package/dist/providers/ai-sdk.d.ts.map +1 -0
- package/dist/providers/async.d.ts +2 -0
- package/dist/providers/async.d.ts.map +1 -0
- package/dist/providers/billing.d.ts +4 -0
- package/dist/providers/billing.d.ts.map +1 -0
- package/dist/providers/builtins-runtime.d.ts +3 -0
- package/dist/providers/builtins-runtime.d.ts.map +1 -0
- package/dist/providers/builtins.d.ts +28 -0
- package/dist/providers/builtins.d.ts.map +1 -0
- package/dist/providers/compat.d.ts +6 -0
- package/dist/providers/compat.d.ts.map +1 -0
- package/dist/providers/config.d.ts +293 -0
- package/dist/providers/config.d.ts.map +1 -0
- package/dist/providers/factory-registry.d.ts +92 -0
- package/dist/providers/factory-registry.d.ts.map +1 -0
- package/dist/providers/format.d.ts +2 -0
- package/dist/providers/format.d.ts.map +1 -0
- package/dist/providers/gateway.d.ts +24 -0
- package/dist/providers/gateway.d.ts.map +1 -0
- package/dist/providers/handler.d.ts +75 -0
- package/dist/providers/handler.d.ts.map +1 -0
- package/dist/providers/http.d.ts +10 -0
- package/dist/providers/http.d.ts.map +1 -0
- package/dist/providers/ids.d.ts +69 -0
- package/dist/providers/ids.d.ts.map +1 -0
- package/dist/providers/messages.d.ts +5 -0
- package/dist/providers/messages.d.ts.map +1 -0
- package/dist/providers/middleware/split-tool-images.d.ts +29 -0
- package/dist/providers/middleware/split-tool-images.d.ts.map +1 -0
- package/dist/providers/model-registry.d.ts +14 -0
- package/dist/providers/model-registry.d.ts.map +1 -0
- package/dist/providers/provider-keys.d.ts +5 -0
- package/dist/providers/provider-keys.d.ts.map +1 -0
- package/dist/providers/registry.d.ts +19 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/routing/anthropic-compatible.d.ts +46 -0
- package/dist/providers/routing/anthropic-compatible.d.ts.map +1 -0
- package/dist/providers/routing/glm-thinking.d.ts +15 -0
- package/dist/providers/routing/glm-thinking.d.ts.map +1 -0
- package/dist/providers/routing/provider-options.d.ts +21 -0
- package/dist/providers/routing/provider-options.d.ts.map +1 -0
- package/dist/providers/routing/utils.d.ts +8 -0
- package/dist/providers/routing/utils.d.ts.map +1 -0
- package/dist/providers/stream.d.ts +107 -0
- package/dist/providers/stream.d.ts.map +1 -0
- package/dist/providers/types.d.ts +10 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/vendors/anthropic.d.ts +4 -0
- package/dist/providers/vendors/anthropic.d.ts.map +1 -0
- package/dist/providers/vendors/bedrock.d.ts +4 -0
- package/dist/providers/vendors/bedrock.d.ts.map +1 -0
- package/dist/providers/vendors/community.d.ts +7 -0
- package/dist/providers/vendors/community.d.ts.map +1 -0
- package/dist/providers/vendors/google.d.ts +4 -0
- package/dist/providers/vendors/google.d.ts.map +1 -0
- package/dist/providers/vendors/mistral.d.ts +4 -0
- package/dist/providers/vendors/mistral.d.ts.map +1 -0
- package/dist/providers/vendors/openai-compatible.d.ts +4 -0
- package/dist/providers/vendors/openai-compatible.d.ts.map +1 -0
- package/dist/providers/vendors/openai.d.ts +4 -0
- package/dist/providers/vendors/openai.d.ts.map +1 -0
- package/dist/providers/vendors/types.d.ts +134 -0
- package/dist/providers/vendors/types.d.ts.map +1 -0
- package/dist/providers/vendors/vertex.d.ts +4 -0
- package/dist/providers/vendors/vertex.d.ts.map +1 -0
- package/dist/providers.browser.d.ts +2 -0
- package/dist/providers.browser.d.ts.map +1 -0
- package/dist/providers.browser.js +1 -0
- package/dist/providers.d.ts +7 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +85 -0
- package/dist/services/langfuse-telemetry.d.ts +6 -0
- package/dist/services/langfuse-telemetry.d.ts.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GatewayProviderFactory } from "@cline/shared";
|
|
2
|
+
import type { AiSdkStreamTotalUsage, AiSdkStreamUsage } from "./vendors/types";
|
|
3
|
+
interface GatewayNormalizedUsage {
|
|
4
|
+
inputTokens: number;
|
|
5
|
+
outputTokens: number;
|
|
6
|
+
cacheReadTokens: number;
|
|
7
|
+
cacheWriteTokens: number;
|
|
8
|
+
totalCost?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Normalizes usage from various provider formats into a standard structure.
|
|
12
|
+
* Handles multiple naming conventions (e.g., inputTokens vs input_tokens),
|
|
13
|
+
* extracts costs from market_cost/cost/upstream_inference_cost fields,
|
|
14
|
+
* and falls back to pricing-based calculation if no explicit cost is found.
|
|
15
|
+
* For providers that charge both gateway and model costs (e.g., OpenRouter),
|
|
16
|
+
* sums baseCost + upstreamInferenceCost when both are present.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Normalizes usage from various provider formats into a standard structure.
|
|
20
|
+
* Accepts both AI SDK's normalized shapes (AiSdkStreamTotalUsage, AiSdkStreamUsage)
|
|
21
|
+
* and raw provider responses. Handles multiple naming conventions (camelCase vs snake_case),
|
|
22
|
+
* extracts costs from provider-specific fields, and falls back to pricing-based calculation.
|
|
23
|
+
*
|
|
24
|
+
* @param usageValue - AI SDK normalized usage or raw provider response object
|
|
25
|
+
* @param providerMetadata - Provider-specific metadata for cost extraction
|
|
26
|
+
* @param pricingValue - Fallback pricing config (per 1M tokens) when no explicit cost found
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeUsage(usageValue: AiSdkStreamUsage | AiSdkStreamTotalUsage | Record<string, unknown> | undefined, providerMetadata?: unknown, pricingValue?: unknown): GatewayNormalizedUsage;
|
|
29
|
+
export declare const createOpenAIProvider: GatewayProviderFactory;
|
|
30
|
+
export declare const createOpenAICompatibleProvider: GatewayProviderFactory;
|
|
31
|
+
export declare const createAnthropicProvider: GatewayProviderFactory;
|
|
32
|
+
export declare const createGoogleProvider: GatewayProviderFactory;
|
|
33
|
+
export declare const createVertexProvider: GatewayProviderFactory;
|
|
34
|
+
export declare const createBedrockProvider: GatewayProviderFactory;
|
|
35
|
+
export declare const createMistralProvider: GatewayProviderFactory;
|
|
36
|
+
export declare const createClaudeCodeProvider: GatewayProviderFactory;
|
|
37
|
+
export declare const createOpenAICodexProvider: GatewayProviderFactory;
|
|
38
|
+
export declare const createOpenCodeProvider: GatewayProviderFactory;
|
|
39
|
+
export declare const createDifyProvider: GatewayProviderFactory;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=ai-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKX,sBAAsB,EAGtB,MAAM,eAAe,CAAC;AAoBvB,OAAO,KAAK,EAGX,qBAAqB,EACrB,gBAAgB,EAEhB,MAAM,iBAAiB,CAAC;AAEzB,UAAU,sBAAsB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAwWD;;;;;;;GAOG;AACH;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,UAAU,EACP,gBAAgB,GAChB,qBAAqB,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,SAAS,EACZ,gBAAgB,CAAC,EAAE,OAAO,EAC1B,YAAY,CAAC,EAAE,OAAO,GACpB,sBAAsB,CAuGxB;AAwZD,eAAO,MAAM,oBAAoB,wBAAgC,CAAC;AAClE,eAAO,MAAM,8BAA8B,wBACF,CAAC;AAC1C,eAAO,MAAM,uBAAuB,wBAAmC,CAAC;AACxE,eAAO,MAAM,oBAAoB,wBAAgC,CAAC;AAClE,eAAO,MAAM,oBAAoB,wBAAgC,CAAC;AAClE,eAAO,MAAM,qBAAqB,wBAAiC,CAAC;AACpE,eAAO,MAAM,qBAAqB,wBAAiC,CAAC;AACpE,eAAO,MAAM,wBAAwB,wBAAqC,CAAC;AAC3E,eAAO,MAAM,yBAAyB,wBAAsC,CAAC;AAC7E,eAAO,MAAM,sBAAsB,wBAAkC,CAAC;AACtE,eAAO,MAAM,kBAAkB,wBAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/providers/async.ts"],"names":[],"mappings":"AAAA,wBAAuB,eAAe,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GACnC,aAAa,CAAC,CAAC,CAAC,CAIlB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ProviderUsageCostDisplay = "show" | "hide";
|
|
2
|
+
export declare function resolveProviderUsageCostDisplay(providerId: string): ProviderUsageCostDisplay;
|
|
3
|
+
export declare function shouldShowProviderUsageCost(providerId: string): boolean;
|
|
4
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/providers/billing.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,MAAM,CAAC;AAQvD,wBAAgB,+BAA+B,CAC9C,UAAU,EAAE,MAAM,GAChB,wBAAwB,CAK1B;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-runtime.d.ts","sourceRoot":"","sources":["../../src/providers/builtins-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,2BAA2B,EAC3B,MAAM,eAAe,CAAC;AAkFvB,eAAO,MAAM,8BAA8B,EAAE,2BAA2B,EAWpE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GatewayProviderManifest, GatewayProviderMetadata, GatewayProviderSettings, ProviderCapability } from "@cline/shared";
|
|
2
|
+
import type { ModelCollection, ModelInfo, ProviderClient, ProviderProtocol } from "../catalog/types";
|
|
3
|
+
export declare const DEFAULT_INTERNAL_OCA_BASE_URL = "https://code-internal.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
4
|
+
export declare const DEFAULT_EXTERNAL_OCA_BASE_URL = "https://code.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
5
|
+
export type ProviderFamily = "openai" | "openai-compatible" | "anthropic" | "google" | "vertex" | "bedrock" | "mistral" | "claude-code" | "openai-codex" | "opencode" | "dify";
|
|
6
|
+
export interface BuiltinSpec {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
family: ProviderFamily;
|
|
11
|
+
protocol?: ProviderProtocol;
|
|
12
|
+
client?: ProviderClient;
|
|
13
|
+
capabilities?: ProviderCapability[];
|
|
14
|
+
modelsProviderId?: string;
|
|
15
|
+
defaultModelId?: string;
|
|
16
|
+
modelsFactory?: () => Record<string, ModelInfo>;
|
|
17
|
+
env?: readonly ("browser" | "node")[];
|
|
18
|
+
apiKeyEnv?: readonly string[];
|
|
19
|
+
modelsSourceUrl?: string;
|
|
20
|
+
docsUrl?: string;
|
|
21
|
+
defaults?: GatewayProviderSettings;
|
|
22
|
+
metadata?: GatewayProviderMetadata;
|
|
23
|
+
}
|
|
24
|
+
export declare const BUILTIN_SPECS: BuiltinSpec[];
|
|
25
|
+
export declare function toManifest(spec: BuiltinSpec): GatewayProviderManifest;
|
|
26
|
+
export declare const BUILTIN_PROVIDER_COLLECTION_LIST: ModelCollection[];
|
|
27
|
+
export declare const BUILTIN_PROVIDER_COLLECTIONS_BY_ID: Record<string, ModelCollection>;
|
|
28
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/providers/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGX,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EAEvB,kBAAkB,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACX,eAAe,EACf,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,6BAA6B,0FAC8C,CAAC;AACzF,eAAO,MAAM,6BAA6B,iFACqC,CAAC;AAEhF,MAAM,MAAM,cAAc,GACvB,QAAQ,GACR,mBAAmB,GACnB,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,aAAa,GACb,cAAc,GACd,UAAU,GACV,MAAM,CAAC;AAEV,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChD,GAAG,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACnC;AA6fD,eAAO,MAAM,aAAa,EAAE,WAAW,EAgJtC,CAAC;AA+CF,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,uBAAuB,CA+BrE;AAED,eAAO,MAAM,gCAAgC,EAAE,eAAe,EACzB,CAAC;AAEtC,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACtD,MAAM,EACN,eAAe,CAMf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GatewayStreamRequest } from "@cline/shared";
|
|
2
|
+
import { type ApiHandler, type Message, type ProviderConfig } from "./types";
|
|
3
|
+
export declare function toGatewayRequestMessages(messages: Message[]): GatewayStreamRequest["messages"];
|
|
4
|
+
export declare function createGatewayApiHandler(config: ProviderConfig): ApiHandler;
|
|
5
|
+
export declare function createGatewayApiHandlerAsync(config: ProviderConfig): Promise<ApiHandler>;
|
|
6
|
+
//# sourceMappingURL=compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/providers/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKX,oBAAoB,EACpB,MAAM,eAAe,CAAC;AA0BvB,OAAO,EACN,KAAK,UAAU,EAIf,KAAK,OAAO,EAEZ,KAAK,cAAc,EAGnB,MAAM,SAAS,CAAC;AA+PjB,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,OAAO,EAAE,GACjB,oBAAoB,CAAC,UAAU,CAAC,CA+FlC;AAqOD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAE1E;AAED,wBAAsB,4BAA4B,CACjD,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,UAAU,CAAC,CAiCrB"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Unified configuration interface for all providers.
|
|
5
|
+
* This replaces the per-provider config chaos with a single structure.
|
|
6
|
+
*/
|
|
7
|
+
import type { BasicLogger, ExtensionContext } from "@cline/shared";
|
|
8
|
+
import type { ModelInfo, ProviderClient } from "../catalog/types";
|
|
9
|
+
import { BUILT_IN_PROVIDER, BUILT_IN_PROVIDER_IDS, type BuiltInProviderId, isBuiltInProviderId, normalizeProviderId } from "./ids";
|
|
10
|
+
export { BUILT_IN_PROVIDER, BUILT_IN_PROVIDER_IDS, type BuiltInProviderId, isBuiltInProviderId, normalizeProviderId, };
|
|
11
|
+
/**
|
|
12
|
+
* All supported provider IDs (built-in + custom)
|
|
13
|
+
*
|
|
14
|
+
* Custom provider IDs can be registered via `registerHandler()` or `registerAsyncHandler()`.
|
|
15
|
+
* Any string is accepted to allow for custom handlers that extend BaseHandler.
|
|
16
|
+
*/
|
|
17
|
+
export type ProviderId = BuiltInProviderId | (string & {});
|
|
18
|
+
/**
|
|
19
|
+
* Provider categories based on underlying SDK/protocol
|
|
20
|
+
*/
|
|
21
|
+
export type ProviderCategory = "anthropic" | "openai" | "openai-compat" | "openai-responses" | "gemini" | "bedrock" | "custom";
|
|
22
|
+
/**
|
|
23
|
+
* Capabilities that a provider/model may support
|
|
24
|
+
*/
|
|
25
|
+
export type ProviderCapability = "reasoning" | "prompt-cache" | "streaming" | "tools" | "vision" | "computer-use" | "oauth";
|
|
26
|
+
/**
|
|
27
|
+
* Authentication configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface AuthConfig {
|
|
30
|
+
/** API key (most common) */
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/** OAuth access token */
|
|
33
|
+
accessToken?: string;
|
|
34
|
+
/** Refresh token for OAuth */
|
|
35
|
+
refreshToken?: string;
|
|
36
|
+
/** Account ID (for account-based auth) */
|
|
37
|
+
accountId?: string;
|
|
38
|
+
/** OAuth callback path (e.g., for Qwen Code) */
|
|
39
|
+
oauthPath?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Endpoint configuration
|
|
43
|
+
*/
|
|
44
|
+
export interface EndpointConfig {
|
|
45
|
+
/** Base URL for the API */
|
|
46
|
+
baseUrl?: string;
|
|
47
|
+
/** Custom headers to include */
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
/** Request timeout in milliseconds */
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Custom `fetch` implementation used by the AI gateway providers when
|
|
53
|
+
* issuing requests. When supplied, it is forwarded to
|
|
54
|
+
* `GatewayProviderSettings.fetch` (and as a top-level fallback on
|
|
55
|
+
* `GatewayConfig.fetch`) so hosts can inject custom HTTP behavior such
|
|
56
|
+
* as proxies, retries, tracing, or test doubles.
|
|
57
|
+
*/
|
|
58
|
+
fetch?: typeof fetch;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Model configuration
|
|
62
|
+
*/
|
|
63
|
+
export interface ModelConfig {
|
|
64
|
+
/** Model identifier */
|
|
65
|
+
modelId: string;
|
|
66
|
+
/** Pre-fetched model info (optional - will use defaults if not provided) */
|
|
67
|
+
modelInfo?: ModelInfo;
|
|
68
|
+
/** Known models for this provider with their info */
|
|
69
|
+
knownModels?: Record<string, ModelInfo>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Token limits configuration
|
|
73
|
+
*/
|
|
74
|
+
export interface TokenConfig {
|
|
75
|
+
/** Maximum context window tokens (overrides model default) */
|
|
76
|
+
maxContextTokens?: number;
|
|
77
|
+
/** Maximum output tokens (overrides model default) */
|
|
78
|
+
maxOutputTokens?: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reasoning/thinking model configuration
|
|
82
|
+
*/
|
|
83
|
+
export interface ReasoningConfig {
|
|
84
|
+
/** Reasoning effort level */
|
|
85
|
+
reasoningEffort?: "low" | "medium" | "high" | "xhigh";
|
|
86
|
+
/** Extended thinking budget in tokens */
|
|
87
|
+
thinkingBudgetTokens?: number;
|
|
88
|
+
/** Enable thinking with provider/model defaults when supported */
|
|
89
|
+
thinking?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Region configuration (shared across cloud providers)
|
|
93
|
+
*/
|
|
94
|
+
export interface RegionConfig {
|
|
95
|
+
/** Cloud region (AWS, GCP, Azure, or provider-specific like Qwen's china/international) */
|
|
96
|
+
region?: string;
|
|
97
|
+
/** API line for region-specific routing (e.g., "china" | "international" for Qwen) */
|
|
98
|
+
apiLine?: "china" | "international";
|
|
99
|
+
/** Use cross-region inference (Bedrock) */
|
|
100
|
+
useCrossRegionInference?: boolean;
|
|
101
|
+
/** Use global inference (Bedrock) */
|
|
102
|
+
useGlobalInference?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* AWS-specific configuration (for Bedrock)
|
|
106
|
+
*/
|
|
107
|
+
export interface AwsConfig {
|
|
108
|
+
accessKey?: string;
|
|
109
|
+
secretKey?: string;
|
|
110
|
+
sessionToken?: string;
|
|
111
|
+
authentication?: "iam" | "api-key" | "profile";
|
|
112
|
+
profile?: string;
|
|
113
|
+
usePromptCache?: boolean;
|
|
114
|
+
endpoint?: string;
|
|
115
|
+
customModelBaseId?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Google Cloud configuration (for Vertex AI)
|
|
119
|
+
*/
|
|
120
|
+
export interface GcpConfig {
|
|
121
|
+
projectId?: string;
|
|
122
|
+
region?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Azure configuration (for Azure OpenAI)
|
|
126
|
+
*/
|
|
127
|
+
export interface AzureConfig {
|
|
128
|
+
apiVersion?: string;
|
|
129
|
+
useIdentity?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* SAP AI Core configuration
|
|
133
|
+
*/
|
|
134
|
+
export interface SapConfig {
|
|
135
|
+
clientId?: string;
|
|
136
|
+
clientSecret?: string;
|
|
137
|
+
tokenUrl?: string;
|
|
138
|
+
resourceGroup?: string;
|
|
139
|
+
deploymentId?: string;
|
|
140
|
+
useOrchestrationMode?: boolean;
|
|
141
|
+
api?: "orchestration" | "foundation-models";
|
|
142
|
+
defaultSettings?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* OCA (Oracle Cloud AI) configuration
|
|
146
|
+
*/
|
|
147
|
+
export interface OcaConfig {
|
|
148
|
+
mode?: "internal" | "external";
|
|
149
|
+
usePromptCache?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Codex CLI provider options
|
|
153
|
+
*/
|
|
154
|
+
export interface CodexConfig {
|
|
155
|
+
defaultSettings?: Record<string, unknown>;
|
|
156
|
+
modelSettings?: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Claude Code provider options
|
|
160
|
+
*/
|
|
161
|
+
export interface ClaudeCodeConfig {
|
|
162
|
+
[key: string]: unknown;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* OpenCode provider options
|
|
166
|
+
*/
|
|
167
|
+
export interface OpenCodeConfig {
|
|
168
|
+
hostname?: string;
|
|
169
|
+
port?: number;
|
|
170
|
+
autoStartServer?: boolean;
|
|
171
|
+
serverTimeout?: number;
|
|
172
|
+
defaultSettings?: Record<string, unknown>;
|
|
173
|
+
modelSettings?: Record<string, unknown>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Cloud provider configurations (grouped)
|
|
177
|
+
*/
|
|
178
|
+
export interface CloudConfig {
|
|
179
|
+
/** AWS/Bedrock options */
|
|
180
|
+
aws?: AwsConfig;
|
|
181
|
+
/** Google Cloud/Vertex options */
|
|
182
|
+
gcp?: GcpConfig;
|
|
183
|
+
/** Azure options */
|
|
184
|
+
azure?: AzureConfig;
|
|
185
|
+
/** SAP AI Core options */
|
|
186
|
+
sap?: SapConfig;
|
|
187
|
+
/** OCA options */
|
|
188
|
+
oca?: OcaConfig;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Provider-specific options that don't fit other categories
|
|
192
|
+
*/
|
|
193
|
+
export interface ProviderOptions {
|
|
194
|
+
/** OpenRouter provider sorting preference */
|
|
195
|
+
openRouterProviderSorting?: string;
|
|
196
|
+
/** Runtime model catalog refresh configuration */
|
|
197
|
+
modelCatalog?: ModelCatalogConfig;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Runtime model catalog refresh options
|
|
201
|
+
*/
|
|
202
|
+
export interface ModelCatalogConfig {
|
|
203
|
+
/** Fetch latest catalog at handler initialization */
|
|
204
|
+
loadLatestOnInit?: boolean;
|
|
205
|
+
/** Fetch provider-private models when auth is available */
|
|
206
|
+
loadPrivateOnAuth?: boolean;
|
|
207
|
+
/** Catalog endpoint URL */
|
|
208
|
+
url?: string;
|
|
209
|
+
/** Cache TTL for live catalog in milliseconds */
|
|
210
|
+
cacheTtlMs?: number;
|
|
211
|
+
/** Throw when live catalog refresh fails */
|
|
212
|
+
failOnError?: boolean;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Unified provider configuration interface
|
|
216
|
+
*
|
|
217
|
+
* This is the single configuration interface that clients provide.
|
|
218
|
+
* All provider-specific options are grouped into logical sub-interfaces.
|
|
219
|
+
*/
|
|
220
|
+
export interface ProviderConfig extends AuthConfig, EndpointConfig, ModelConfig, TokenConfig, ReasoningConfig, RegionConfig, CloudConfig, ProviderOptions {
|
|
221
|
+
/** Client type - determines which handler to use - OpenAI-Compatible deafult */
|
|
222
|
+
clientType?: ProviderClient;
|
|
223
|
+
/** Provider ID */
|
|
224
|
+
providerId: ProviderId;
|
|
225
|
+
/**
|
|
226
|
+
* Optional built-in provider family to use for handler routing.
|
|
227
|
+
*
|
|
228
|
+
* This lets clients expose a custom provider ID and model catalog while
|
|
229
|
+
* reusing the runtime behavior of a built-in provider implementation.
|
|
230
|
+
*/
|
|
231
|
+
routingProviderId?: ProviderId;
|
|
232
|
+
/** Capabilities this provider/model supports */
|
|
233
|
+
capabilities?: ProviderCapability[];
|
|
234
|
+
/** Task/session ID for telemetry */
|
|
235
|
+
taskId?: string;
|
|
236
|
+
/** Retry callback */
|
|
237
|
+
onRetryAttempt?: (attempt: number, maxRetries: number, delay: number, error: unknown) => void;
|
|
238
|
+
/** AbortSignal for cancelling requests */
|
|
239
|
+
abortSignal?: AbortSignal;
|
|
240
|
+
/** Optional runtime logger for provider-level diagnostics */
|
|
241
|
+
logger?: BasicLogger;
|
|
242
|
+
/**
|
|
243
|
+
* Ambient runtime context: user identity, client surface, workspace info,
|
|
244
|
+
* logger, and telemetry service. Prefer reading logger and telemetry from
|
|
245
|
+
* here when available; the top-level logger field is kept for compatibility.
|
|
246
|
+
*/
|
|
247
|
+
extensionContext?: ExtensionContext;
|
|
248
|
+
/** Codex CLI-specific options */
|
|
249
|
+
codex?: CodexConfig;
|
|
250
|
+
/** Claude Code-specific options */
|
|
251
|
+
claudeCode?: ClaudeCodeConfig;
|
|
252
|
+
/** OpenCode-specific options */
|
|
253
|
+
opencode?: OpenCodeConfig;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Simplified configuration for common use cases
|
|
257
|
+
*/
|
|
258
|
+
export interface SimpleProviderConfig {
|
|
259
|
+
providerId: ProviderId;
|
|
260
|
+
clientType: ProviderClient;
|
|
261
|
+
apiKey: string;
|
|
262
|
+
modelId: string;
|
|
263
|
+
baseUrl?: string;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Create a full ProviderConfig from a simple config
|
|
267
|
+
*/
|
|
268
|
+
export declare function createConfig(simple: SimpleProviderConfig): ProviderConfig;
|
|
269
|
+
/**
|
|
270
|
+
* Check if a provider config has a specific capability
|
|
271
|
+
*/
|
|
272
|
+
export declare function hasCapability(config: ProviderConfig, capability: ProviderCapability): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Check if provider supports reasoning/thinking
|
|
275
|
+
*/
|
|
276
|
+
export declare function supportsReasoning(config: ProviderConfig): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Check if provider supports prompt caching
|
|
279
|
+
*/
|
|
280
|
+
export declare function supportsPromptCache(config: ProviderConfig): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Resolve the provider ID used for handler selection and built-in behavior.
|
|
283
|
+
*/
|
|
284
|
+
export declare function resolveRoutingProviderId(config: Pick<ProviderConfig, "providerId" | "routingProviderId">): string;
|
|
285
|
+
/**
|
|
286
|
+
* @deprecated Use ProviderConfig directly - all fields are now unified
|
|
287
|
+
*/
|
|
288
|
+
export type ProviderSpecificConfig = Pick<ProviderConfig, "aws" | "gcp" | "azure" | "sap" | "oca" | "maxContextTokens" | "apiLine" | "oauthPath" | "openRouterProviderSorting">;
|
|
289
|
+
/**
|
|
290
|
+
* @deprecated Use ProviderConfig directly
|
|
291
|
+
*/
|
|
292
|
+
export type ProviderDefaultsConfig = Pick<ProviderConfig, "baseUrl" | "modelId" | "knownModels" | "headers" | "capabilities">;
|
|
293
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/providers/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAA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kBAAkB,GAClB,SAAS,GACT,WAAW,GACX,2BAA2B,CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,cAAc,EACd,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,cAAc,CAClE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Handler Registry
|
|
3
|
+
*
|
|
4
|
+
* Allows users to register their own custom handlers that extend BaseHandler.
|
|
5
|
+
* This is useful for providers that require dependencies not included in this package
|
|
6
|
+
* (e.g., VSCode LM handler that requires the vscode package).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { registerHandler, BaseHandler, type ProviderConfig, type ApiStream, type Message } from "@cline/providers"
|
|
11
|
+
* import * as vscode from "vscode"
|
|
12
|
+
*
|
|
13
|
+
* class VSCodeLmHandler extends BaseHandler {
|
|
14
|
+
* async *createMessage(systemPrompt: string, messages: Message[]): ApiStream {
|
|
15
|
+
* // Implementation using vscode.lm API
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Register the handler
|
|
20
|
+
* registerHandler("vscode-lm", (config) => new VSCodeLmHandler(config))
|
|
21
|
+
*
|
|
22
|
+
* // Now createHandler will use your custom handler for "vscode-lm"
|
|
23
|
+
* const handler = createHandler({ providerId: "vscode-lm", modelId: "copilot" })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { ApiHandler, HandlerFactory, LazyHandlerFactory, ProviderConfig } from "./types";
|
|
27
|
+
/**
|
|
28
|
+
* Register a custom handler factory for a provider ID
|
|
29
|
+
*
|
|
30
|
+
* Use this to add handlers for providers that require external dependencies
|
|
31
|
+
* not bundled with this package, or to override built-in handlers.
|
|
32
|
+
*
|
|
33
|
+
* @param providerId - The provider ID to register (can be existing or new)
|
|
34
|
+
* @param factory - Factory function that creates the handler
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Simple registration
|
|
39
|
+
* registerHandler("my-provider", (config) => new MyHandler(config))
|
|
40
|
+
*
|
|
41
|
+
* // Override built-in handler
|
|
42
|
+
* registerHandler("anthropic", (config) => new MyCustomAnthropicHandler(config))
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function registerHandler(providerId: string, factory: HandlerFactory<ProviderConfig>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Register an async handler factory for lazy loading
|
|
48
|
+
*
|
|
49
|
+
* Use this when your handler has heavy dependencies that should be
|
|
50
|
+
* loaded only when needed.
|
|
51
|
+
*
|
|
52
|
+
* @param providerId - The provider ID to register
|
|
53
|
+
* @param factory - Async factory function that creates the handler
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* registerAsyncHandler("heavy-provider", async (config) => {
|
|
58
|
+
* const { HeavyHandler } = await import("./heavy-handler")
|
|
59
|
+
* return new HeavyHandler(config)
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function registerAsyncHandler(providerId: string, factory: LazyHandlerFactory<ProviderConfig>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a custom handler is registered for a provider ID
|
|
66
|
+
*
|
|
67
|
+
* @param providerId - The provider ID to check
|
|
68
|
+
*/
|
|
69
|
+
export declare function hasRegisteredHandler(providerId: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get a registered handler (internal use)
|
|
72
|
+
*
|
|
73
|
+
* @param providerId - The provider ID to get
|
|
74
|
+
* @param config - The config to pass to the factory
|
|
75
|
+
* @returns The handler instance, or undefined if not registered
|
|
76
|
+
*/
|
|
77
|
+
export declare function getRegisteredHandler(providerId: string, config: ProviderConfig): ApiHandler | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Get a registered handler asynchronously (internal use)
|
|
80
|
+
*
|
|
81
|
+
* @param providerId - The provider ID to get
|
|
82
|
+
* @param config - The config to pass to the factory
|
|
83
|
+
* @returns The handler instance, or undefined if not registered
|
|
84
|
+
*/
|
|
85
|
+
export declare function getRegisteredHandlerAsync(providerId: string, config: ProviderConfig): Promise<ApiHandler | undefined>;
|
|
86
|
+
/**
|
|
87
|
+
* Check if a registered handler is async
|
|
88
|
+
*
|
|
89
|
+
* @param providerId - The provider ID to check
|
|
90
|
+
*/
|
|
91
|
+
export declare function isRegisteredHandlerAsync(providerId: string): boolean;
|
|
92
|
+
//# sourceMappingURL=factory-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory-registry.d.ts","sourceRoot":"","sources":["../../src/providers/factory-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,MAAM,SAAS,CAAC;AAejB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,CAAC,cAAc,CAAC,GACrC,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,CAAC,cAAc,CAAC,GACzC,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACpB,UAAU,GAAG,SAAS,CAaxB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC9C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAWjC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/providers/format.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqE1D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentModel, AgentModelEvent, GatewayConfig, GatewayModelHandleOptions, GatewayModelSelection, GatewayProviderRegistration, GatewayStreamRequest } from "@cline/shared";
|
|
2
|
+
import { GatewayRegistry } from "./registry";
|
|
3
|
+
export type * from "@cline/shared";
|
|
4
|
+
export interface Gateway {
|
|
5
|
+
registerProvider(registration: GatewayProviderRegistration): this;
|
|
6
|
+
configureProvider(config: NonNullable<GatewayConfig["providerConfigs"]>[number]): this;
|
|
7
|
+
listProviders(): ReturnType<GatewayRegistry["listProviders"]>;
|
|
8
|
+
listModels(providerId?: string): ReturnType<GatewayRegistry["listModels"]>;
|
|
9
|
+
createAgentModel(selection: GatewayModelSelection, options?: GatewayModelHandleOptions): AgentModel;
|
|
10
|
+
stream(request: GatewayStreamRequest): Promise<AsyncIterable<AgentModelEvent>>;
|
|
11
|
+
}
|
|
12
|
+
export declare class DefaultGateway implements Gateway {
|
|
13
|
+
private readonly registry;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
constructor(config?: GatewayConfig);
|
|
16
|
+
registerProvider(registration: GatewayProviderRegistration): this;
|
|
17
|
+
configureProvider(config: NonNullable<GatewayConfig["providerConfigs"]>[number]): this;
|
|
18
|
+
listProviders(): import("@cline/shared").GatewayProviderManifest[];
|
|
19
|
+
listModels(providerId?: string): import("@cline/shared").GatewayModelDefinition[];
|
|
20
|
+
createAgentModel(selection: GatewayModelSelection, options?: GatewayModelHandleOptions): AgentModel;
|
|
21
|
+
stream(request: GatewayStreamRequest): Promise<AsyncIterable<AgentModelEvent>>;
|
|
22
|
+
}
|
|
23
|
+
export declare function createGateway(config?: GatewayConfig): DefaultGateway;
|
|
24
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/providers/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EAGf,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,mBAAmB,eAAe,CAAC;AAEnC,MAAM,WAAW,OAAO;IACvB,gBAAgB,CAAC,YAAY,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAClE,iBAAiB,CAChB,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,GAC3D,IAAI,CAAC;IACR,aAAa,IAAI,UAAU,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,gBAAgB,CACf,SAAS,EAAE,qBAAqB,EAChC,OAAO,CAAC,EAAE,yBAAyB,GACjC,UAAU,CAAC;IACd,MAAM,CACL,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;CAC3C;AAmED,qBAAa,cAAe,YAAW,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;gBAErC,MAAM,GAAE,aAAkB;IA2BtC,gBAAgB,CAAC,YAAY,EAAE,2BAA2B,GAAG,IAAI;IAKjE,iBAAiB,CAChB,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,GAC3D,IAAI;IAKP,aAAa;IAIb,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM;IAI9B,gBAAgB,CACf,SAAS,EAAE,qBAAqB,EAChC,OAAO,CAAC,EAAE,yBAAyB,GACjC,UAAU;IAIP,MAAM,CACX,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;CA0B1C;AAED,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAEpE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler Interface Types
|
|
3
|
+
*
|
|
4
|
+
* Core interfaces that all provider handlers must implement.
|
|
5
|
+
*/
|
|
6
|
+
import type { Message, ModelInfo, ToolDefinition } from "@cline/shared";
|
|
7
|
+
import type { ApiStream, ApiStreamUsageChunk } from "./stream";
|
|
8
|
+
/**
|
|
9
|
+
* Model information returned by handlers
|
|
10
|
+
*/
|
|
11
|
+
export interface HandlerModelInfo {
|
|
12
|
+
/** Model identifier */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Model capabilities and pricing info */
|
|
15
|
+
info: ModelInfo;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Core API Handler interface
|
|
19
|
+
*
|
|
20
|
+
* All providers must implement this interface.
|
|
21
|
+
*/
|
|
22
|
+
export interface ApiHandler {
|
|
23
|
+
/**
|
|
24
|
+
* Convert Cline messages into provider-specific message format
|
|
25
|
+
*
|
|
26
|
+
* @param systemPrompt - The system prompt to use
|
|
27
|
+
* @param messages - Conversation history
|
|
28
|
+
* @returns Provider-specific messages payload
|
|
29
|
+
*/
|
|
30
|
+
getMessages(systemPrompt: string, messages: Message[]): unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Create a streaming message completion
|
|
33
|
+
*
|
|
34
|
+
* @param systemPrompt - The system prompt to use
|
|
35
|
+
* @param messages - Conversation history
|
|
36
|
+
* @param tools - Optional tool definitions for native tool calling
|
|
37
|
+
* @returns An async generator yielding stream chunks
|
|
38
|
+
*/
|
|
39
|
+
createMessage(systemPrompt: string, messages: Message[], tools?: ToolDefinition[]): ApiStream;
|
|
40
|
+
/**
|
|
41
|
+
* Get the current model configuration
|
|
42
|
+
*/
|
|
43
|
+
getModel(): HandlerModelInfo;
|
|
44
|
+
/**
|
|
45
|
+
* Get usage information for the last API call (optional)
|
|
46
|
+
* Some providers can fetch this from a separate endpoint
|
|
47
|
+
*/
|
|
48
|
+
getApiStreamUsage?(): Promise<ApiStreamUsageChunk | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Abort the current request (optional)
|
|
51
|
+
*/
|
|
52
|
+
abort?(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Update the abort signal used for subsequent requests (optional).
|
|
55
|
+
*/
|
|
56
|
+
setAbortSignal?(signal: AbortSignal | undefined): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handler for simple single-turn completions
|
|
60
|
+
*/
|
|
61
|
+
export interface SingleCompletionHandler {
|
|
62
|
+
/**
|
|
63
|
+
* Complete a single prompt without streaming
|
|
64
|
+
*/
|
|
65
|
+
completePrompt(prompt: string): Promise<string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Factory function type for creating handlers
|
|
69
|
+
*/
|
|
70
|
+
export type HandlerFactory<TConfig = unknown> = (config: TConfig) => ApiHandler;
|
|
71
|
+
/**
|
|
72
|
+
* Async factory for lazy-loaded handlers
|
|
73
|
+
*/
|
|
74
|
+
export type LazyHandlerFactory<TConfig = unknown> = (config: TConfig) => Promise<ApiHandler>;
|
|
75
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/providers/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cA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function ensureFetch(fetchImpl?: typeof fetch): typeof fetch;
|
|
3
|
+
export declare function resolveApiKey(settings: GatewayProviderSettings): Promise<string | undefined>;
|
|
4
|
+
export declare function fetchJson(url: string, init: RequestInit, options: {
|
|
5
|
+
fetch: typeof fetch;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}): Promise<unknown>;
|
|
9
|
+
export declare function compactObject<T extends Record<string, unknown>>(value: T): T;
|
|
10
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/providers/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,GAAG,OAAO,KAAK,CAQlE;AAED,wBAAsB,aAAa,CAClC,QAAQ,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoB7B;AAED,wBAAsB,SAAS,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;IACR,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,GACC,OAAO,CAAC,OAAO,CAAC,CA+BlB;AA0BD,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAI5E"}
|