@yuva-devlab/ai-client 0.2.6 → 0.4.0
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/dist/index.cjs +283 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -2
- package/dist/index.d.ts +143 -2
- package/dist/index.js +276 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,8 @@ declare const AI_ENDPOINTS: Readonly<{
|
|
|
24
24
|
ANTHROPIC_DEFAULT_BASE_URL: "https://api.anthropic.com/v1";
|
|
25
25
|
/** Google Gemini Generative Language v1beta endpoint */
|
|
26
26
|
GOOGLE_GEMINI_DEFAULT_BASE_URL: "https://generativelanguage.googleapis.com/v1beta";
|
|
27
|
+
/** Cline API Gateway v1 chat completions endpoint */
|
|
28
|
+
CLINE_DEFAULT_BASE_URL: "https://api.cline.bot/api/v1";
|
|
27
29
|
/** Required Anthropic API version header value */
|
|
28
30
|
ANTHROPIC_VERSION_HEADER: "2023-06-01";
|
|
29
31
|
}>;
|
|
@@ -50,6 +52,8 @@ declare const AI_DEFAULT_MODELS: Readonly<{
|
|
|
50
52
|
OPENAI: "gpt-4o-mini";
|
|
51
53
|
/** Default Anthropic Claude model */
|
|
52
54
|
ANTHROPIC: "claude-3-5-haiku-latest";
|
|
55
|
+
/** Default Cline API Gateway model (NVIDIA 120B reasoning model, free tier) */
|
|
56
|
+
CLINE: "nvidia/nemotron-3.5-super-vl:free";
|
|
53
57
|
}>;
|
|
54
58
|
|
|
55
59
|
/**
|
|
@@ -515,6 +519,10 @@ type LLMResponse = z.infer<typeof LLMResponseSchema>;
|
|
|
515
519
|
interface LLMStreamChunk {
|
|
516
520
|
/** Delta text token */
|
|
517
521
|
delta: string;
|
|
522
|
+
/** Optional reasoning or thinking delta emitted by reasoning-capable models */
|
|
523
|
+
reasoningDelta?: string;
|
|
524
|
+
/** Optional tool invocations emitted during streaming */
|
|
525
|
+
toolCalls?: ToolCall[];
|
|
518
526
|
/** Finish reason if this chunk is the final stream message */
|
|
519
527
|
finishReason?: FinishReason;
|
|
520
528
|
/** Cumulative token usage if supplied by the provider */
|
|
@@ -675,6 +683,7 @@ interface OllamaAdapterConfig {
|
|
|
675
683
|
interface OllamaWireMessage {
|
|
676
684
|
role: string;
|
|
677
685
|
content: string;
|
|
686
|
+
thinking?: string;
|
|
678
687
|
tool_name?: string;
|
|
679
688
|
}
|
|
680
689
|
/**
|
|
@@ -863,6 +872,7 @@ interface GeminiCandidate {
|
|
|
863
872
|
content?: {
|
|
864
873
|
parts?: Array<{
|
|
865
874
|
text?: string;
|
|
875
|
+
thought?: boolean;
|
|
866
876
|
}>;
|
|
867
877
|
};
|
|
868
878
|
finishReason?: string;
|
|
@@ -882,6 +892,13 @@ interface GeminiResponse {
|
|
|
882
892
|
* @returns JSON-serializable Gemini request body.
|
|
883
893
|
*/
|
|
884
894
|
declare function buildGeminiRequestBody(request: LLMRequest): Record<string, unknown>;
|
|
895
|
+
/**
|
|
896
|
+
* Parses a single Google Gemini SSE data payload into a normalized stream chunk.
|
|
897
|
+
*
|
|
898
|
+
* @param jsonStr - Raw JSON payload stripped of the SSE `data:` prefix.
|
|
899
|
+
* @returns Normalized stream chunk when content/reasoning/usage is present, or `null`.
|
|
900
|
+
*/
|
|
901
|
+
declare function parseGeminiSseChunk(jsonStr: string): LLMStreamChunk | null;
|
|
885
902
|
|
|
886
903
|
/**
|
|
887
904
|
* @file packages/ai-client/src/adapters/google/google.adapter.ts
|
|
@@ -1111,6 +1128,128 @@ declare class AnthropicAdapter implements ILLMProvider {
|
|
|
1111
1128
|
stream(request: LLMRequest): AsyncIterable<LLMStreamChunk>;
|
|
1112
1129
|
}
|
|
1113
1130
|
|
|
1131
|
+
/**
|
|
1132
|
+
* @file packages/ai-client/src/adapters/cline/cline.types.ts
|
|
1133
|
+
* @description Wire types, configuration interfaces, and tool name normalization helpers for Cline API.
|
|
1134
|
+
* @module @yuva-devlab/ai-client
|
|
1135
|
+
*/
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Configuration options for initializing the ClineAdapter.
|
|
1139
|
+
*/
|
|
1140
|
+
interface ClineAdapterConfig {
|
|
1141
|
+
/** Cline API Gateway authentication key */
|
|
1142
|
+
apiKey?: string;
|
|
1143
|
+
/** Custom base URL (defaults to AI_ENDPOINTS.CLINE_DEFAULT_BASE_URL) */
|
|
1144
|
+
baseUrl?: string;
|
|
1145
|
+
/** Default model identifier (defaults to AI_DEFAULT_MODELS.CLINE) */
|
|
1146
|
+
defaultModel?: string;
|
|
1147
|
+
/** Optional dynamic credential resolver for secret managers */
|
|
1148
|
+
credentials?: CredentialResolver;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Expected response structure from Cline Chat Completions endpoint.
|
|
1152
|
+
*/
|
|
1153
|
+
interface ClineCompletionResponse {
|
|
1154
|
+
/** Completion candidates list */
|
|
1155
|
+
choices?: Array<{
|
|
1156
|
+
message?: {
|
|
1157
|
+
content?: string | null;
|
|
1158
|
+
tool_calls?: Array<{
|
|
1159
|
+
id?: string;
|
|
1160
|
+
type?: string;
|
|
1161
|
+
function?: {
|
|
1162
|
+
name?: string;
|
|
1163
|
+
arguments?: string;
|
|
1164
|
+
};
|
|
1165
|
+
}>;
|
|
1166
|
+
};
|
|
1167
|
+
finish_reason?: string | null;
|
|
1168
|
+
}>;
|
|
1169
|
+
/** Data envelope wrapper when returned by certain Cline gateway routes */
|
|
1170
|
+
data?: {
|
|
1171
|
+
choices?: ClineCompletionResponse["choices"];
|
|
1172
|
+
};
|
|
1173
|
+
/** Token accounting and usage details */
|
|
1174
|
+
usage?: {
|
|
1175
|
+
prompt_tokens?: number;
|
|
1176
|
+
completion_tokens?: number;
|
|
1177
|
+
total_tokens?: number;
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Normalizes a canonical tool name to OpenAPI specification pattern (alphanumeric and underscores only).
|
|
1182
|
+
* Converts dots to underscores (e.g. "transactions.create" -> "transactions_create").
|
|
1183
|
+
*
|
|
1184
|
+
* @param name - Canonical tool name with domain dot separators.
|
|
1185
|
+
* @returns OpenAPI-compliant tool name.
|
|
1186
|
+
*/
|
|
1187
|
+
declare function sanitizeClineToolName(name: string): string;
|
|
1188
|
+
/**
|
|
1189
|
+
* Restores canonical tool name from OpenAPI normalized string.
|
|
1190
|
+
* Converts underscores to dots (e.g. "transactions_create" -> "transactions.create").
|
|
1191
|
+
*
|
|
1192
|
+
* @param name - Normalized tool name from model invocation.
|
|
1193
|
+
* @returns Canonical tool name.
|
|
1194
|
+
*/
|
|
1195
|
+
declare function restoreClineToolName(name: string): string;
|
|
1196
|
+
/**
|
|
1197
|
+
* Converts canonical messages to Cline/OpenAI wire format.
|
|
1198
|
+
*
|
|
1199
|
+
* @param messages - Canonical conversation history turns.
|
|
1200
|
+
* @returns Array of OpenAI-compatible wire messages.
|
|
1201
|
+
*/
|
|
1202
|
+
declare function mapClineMessages(messages: LLMRequest["messages"]): {
|
|
1203
|
+
role: string;
|
|
1204
|
+
content: string;
|
|
1205
|
+
}[];
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* @file packages/ai-client/src/adapters/cline/cline.adapter.ts
|
|
1209
|
+
* @description Standard Cline API Gateway adapter supporting Nemotron, Solar, DeepSeek, and Qwen.
|
|
1210
|
+
* @module @yuva-devlab/ai-client
|
|
1211
|
+
*/
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Cline adapter executing completions and streaming via the Cline API Gateway.
|
|
1215
|
+
*/
|
|
1216
|
+
declare class ClineAdapter implements ILLMProvider {
|
|
1217
|
+
readonly name = "cline";
|
|
1218
|
+
private readonly config;
|
|
1219
|
+
constructor(config?: ClineAdapterConfig);
|
|
1220
|
+
private resolveCredentials;
|
|
1221
|
+
complete(request: LLMRequest): Promise<LLMResponse>;
|
|
1222
|
+
stream(request: LLMRequest): AsyncIterable<LLMStreamChunk>;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* @file packages/ai-client/src/adapters/cline/cline.helpers.ts
|
|
1227
|
+
* @description Helper functions for Cline completion parsing, error mapping, and tool extraction.
|
|
1228
|
+
* @module @yuva-devlab/ai-client
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Parses and restores canonical tool calls from Cline model output.
|
|
1233
|
+
*
|
|
1234
|
+
* @param choices - Candidate completions from Cline API.
|
|
1235
|
+
* @returns Array of parsed ToolCall objects or undefined.
|
|
1236
|
+
*/
|
|
1237
|
+
declare function extractClineToolCalls(choices?: ClineCompletionResponse["choices"]): ToolCall[] | undefined;
|
|
1238
|
+
/**
|
|
1239
|
+
* Maps raw finish_reason string to canonical FinishReason enum.
|
|
1240
|
+
*
|
|
1241
|
+
* @param reason - Raw finish reason from API response.
|
|
1242
|
+
* @returns Canonical FinishReason member.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function mapClineFinishReason(reason?: string | null): FinishReason;
|
|
1245
|
+
/**
|
|
1246
|
+
* Extracts rate limit reset delays or retry-after headers from HTTP response.
|
|
1247
|
+
*
|
|
1248
|
+
* @param response - Fetch response instance.
|
|
1249
|
+
* @returns Informational suffix string or empty string.
|
|
1250
|
+
*/
|
|
1251
|
+
declare function extractClineRetrySuffix(response: Response): string;
|
|
1252
|
+
|
|
1114
1253
|
/**
|
|
1115
1254
|
* @file packages/ai-client/src/cascade/fallback-cascade.ts
|
|
1116
1255
|
* @description Intelligent multi-tier fallback cascade routing across local and cloud providers.
|
|
@@ -1213,7 +1352,7 @@ declare function extractStructuredOutput<T>(options: ExtractStructuredOutputOpti
|
|
|
1213
1352
|
/**
|
|
1214
1353
|
* Standard provider type identifiers.
|
|
1215
1354
|
*/
|
|
1216
|
-
type ProviderType = "ollama" | "groq" | "google" | "openai" | "anthropic" | "cascade";
|
|
1355
|
+
type ProviderType = "ollama" | "groq" | "google" | "openai" | "anthropic" | "cline" | "cascade";
|
|
1217
1356
|
/**
|
|
1218
1357
|
* Creates an instance of an LLM provider adapter matching the specified type.
|
|
1219
1358
|
*
|
|
@@ -1242,6 +1381,8 @@ interface CascadeCandidatesConfig {
|
|
|
1242
1381
|
openai?: Record<string, unknown>;
|
|
1243
1382
|
/** Optional Anthropic credentials and configuration */
|
|
1244
1383
|
anthropic?: Record<string, unknown>;
|
|
1384
|
+
/** Optional Cline API Gateway credentials and configuration */
|
|
1385
|
+
cline?: Record<string, unknown>;
|
|
1245
1386
|
}
|
|
1246
1387
|
/**
|
|
1247
1388
|
* Builds an ordered cascade of provider candidates based on explicit consumer configuration.
|
|
@@ -1275,4 +1416,4 @@ interface DefaultProviderOptions {
|
|
|
1275
1416
|
*/
|
|
1276
1417
|
declare function createDefaultProvider(options?: DefaultProviderOptions): ILLMProvider;
|
|
1277
1418
|
|
|
1278
|
-
export { type AIMessage, AIMessageSchema, AI_DEFAULT_MODELS, AI_ENDPOINTS, AI_EXECUTION_DEFAULTS, AnthropicAdapter, type AnthropicAdapterConfig, type AnthropicResponse, type CascadeCandidatesConfig, type CredentialResolver, type DefaultProviderOptions, type ExtractStructuredOutputOptions, FallbackCascade, type FallbackCascadeOptions, FinishReason, type GeminiCandidate, type GeminiResponse, GoogleAdapter, type GoogleAdapterConfig, GroqAdapter, type GroqAdapterConfig, type GroqCompletionResponse, type ILLMProvider, type LLMRequest, type LLMRequestOptions, LLMRequestOptionsSchema, LLMRequestSchema, type LLMResponse, LLMResponseSchema, type LLMStreamChunk, type LLMUsage, LLMUsageSchema, MessageRole, MissingCredentialError, OllamaAdapter, type OllamaAdapterConfig, type OllamaChatResponseChunk, type OllamaWireMessage, OpenAIAdapter, type OpenAIAdapterConfig, type OpenAiCompletionResponse, type OpenAiWireMessage, type ProviderCredentials, type ProviderType, type ToolCall, ToolCallSchema, buildGeminiRequestBody, createAssistantMessage, createCascadeCandidates, createDefaultProvider, createProvider, createSystemMessage, createToolResultMessage, createUserMessage, extractAnthropicSystemAndMessages, extractStructuredOutput, mapGroqMessages, mapOllamaMessages, mapOpenAiMessages, resolveEnvCredentials };
|
|
1419
|
+
export { type AIMessage, AIMessageSchema, AI_DEFAULT_MODELS, AI_ENDPOINTS, AI_EXECUTION_DEFAULTS, AnthropicAdapter, type AnthropicAdapterConfig, type AnthropicResponse, type CascadeCandidatesConfig, ClineAdapter, type ClineAdapterConfig, type ClineCompletionResponse, type CredentialResolver, type DefaultProviderOptions, type ExtractStructuredOutputOptions, FallbackCascade, type FallbackCascadeOptions, FinishReason, type GeminiCandidate, type GeminiResponse, GoogleAdapter, type GoogleAdapterConfig, GroqAdapter, type GroqAdapterConfig, type GroqCompletionResponse, type ILLMProvider, type LLMRequest, type LLMRequestOptions, LLMRequestOptionsSchema, LLMRequestSchema, type LLMResponse, LLMResponseSchema, type LLMStreamChunk, type LLMUsage, LLMUsageSchema, MessageRole, MissingCredentialError, OllamaAdapter, type OllamaAdapterConfig, type OllamaChatResponseChunk, type OllamaWireMessage, OpenAIAdapter, type OpenAIAdapterConfig, type OpenAiCompletionResponse, type OpenAiWireMessage, type ProviderCredentials, type ProviderType, type ToolCall, ToolCallSchema, buildGeminiRequestBody, createAssistantMessage, createCascadeCandidates, createDefaultProvider, createProvider, createSystemMessage, createToolResultMessage, createUserMessage, extractAnthropicSystemAndMessages, extractClineRetrySuffix, extractClineToolCalls, extractStructuredOutput, mapClineFinishReason, mapClineMessages, mapGroqMessages, mapOllamaMessages, mapOpenAiMessages, parseGeminiSseChunk, resolveEnvCredentials, restoreClineToolName, sanitizeClineToolName };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ declare const AI_ENDPOINTS: Readonly<{
|
|
|
24
24
|
ANTHROPIC_DEFAULT_BASE_URL: "https://api.anthropic.com/v1";
|
|
25
25
|
/** Google Gemini Generative Language v1beta endpoint */
|
|
26
26
|
GOOGLE_GEMINI_DEFAULT_BASE_URL: "https://generativelanguage.googleapis.com/v1beta";
|
|
27
|
+
/** Cline API Gateway v1 chat completions endpoint */
|
|
28
|
+
CLINE_DEFAULT_BASE_URL: "https://api.cline.bot/api/v1";
|
|
27
29
|
/** Required Anthropic API version header value */
|
|
28
30
|
ANTHROPIC_VERSION_HEADER: "2023-06-01";
|
|
29
31
|
}>;
|
|
@@ -50,6 +52,8 @@ declare const AI_DEFAULT_MODELS: Readonly<{
|
|
|
50
52
|
OPENAI: "gpt-4o-mini";
|
|
51
53
|
/** Default Anthropic Claude model */
|
|
52
54
|
ANTHROPIC: "claude-3-5-haiku-latest";
|
|
55
|
+
/** Default Cline API Gateway model (NVIDIA 120B reasoning model, free tier) */
|
|
56
|
+
CLINE: "nvidia/nemotron-3.5-super-vl:free";
|
|
53
57
|
}>;
|
|
54
58
|
|
|
55
59
|
/**
|
|
@@ -515,6 +519,10 @@ type LLMResponse = z.infer<typeof LLMResponseSchema>;
|
|
|
515
519
|
interface LLMStreamChunk {
|
|
516
520
|
/** Delta text token */
|
|
517
521
|
delta: string;
|
|
522
|
+
/** Optional reasoning or thinking delta emitted by reasoning-capable models */
|
|
523
|
+
reasoningDelta?: string;
|
|
524
|
+
/** Optional tool invocations emitted during streaming */
|
|
525
|
+
toolCalls?: ToolCall[];
|
|
518
526
|
/** Finish reason if this chunk is the final stream message */
|
|
519
527
|
finishReason?: FinishReason;
|
|
520
528
|
/** Cumulative token usage if supplied by the provider */
|
|
@@ -675,6 +683,7 @@ interface OllamaAdapterConfig {
|
|
|
675
683
|
interface OllamaWireMessage {
|
|
676
684
|
role: string;
|
|
677
685
|
content: string;
|
|
686
|
+
thinking?: string;
|
|
678
687
|
tool_name?: string;
|
|
679
688
|
}
|
|
680
689
|
/**
|
|
@@ -863,6 +872,7 @@ interface GeminiCandidate {
|
|
|
863
872
|
content?: {
|
|
864
873
|
parts?: Array<{
|
|
865
874
|
text?: string;
|
|
875
|
+
thought?: boolean;
|
|
866
876
|
}>;
|
|
867
877
|
};
|
|
868
878
|
finishReason?: string;
|
|
@@ -882,6 +892,13 @@ interface GeminiResponse {
|
|
|
882
892
|
* @returns JSON-serializable Gemini request body.
|
|
883
893
|
*/
|
|
884
894
|
declare function buildGeminiRequestBody(request: LLMRequest): Record<string, unknown>;
|
|
895
|
+
/**
|
|
896
|
+
* Parses a single Google Gemini SSE data payload into a normalized stream chunk.
|
|
897
|
+
*
|
|
898
|
+
* @param jsonStr - Raw JSON payload stripped of the SSE `data:` prefix.
|
|
899
|
+
* @returns Normalized stream chunk when content/reasoning/usage is present, or `null`.
|
|
900
|
+
*/
|
|
901
|
+
declare function parseGeminiSseChunk(jsonStr: string): LLMStreamChunk | null;
|
|
885
902
|
|
|
886
903
|
/**
|
|
887
904
|
* @file packages/ai-client/src/adapters/google/google.adapter.ts
|
|
@@ -1111,6 +1128,128 @@ declare class AnthropicAdapter implements ILLMProvider {
|
|
|
1111
1128
|
stream(request: LLMRequest): AsyncIterable<LLMStreamChunk>;
|
|
1112
1129
|
}
|
|
1113
1130
|
|
|
1131
|
+
/**
|
|
1132
|
+
* @file packages/ai-client/src/adapters/cline/cline.types.ts
|
|
1133
|
+
* @description Wire types, configuration interfaces, and tool name normalization helpers for Cline API.
|
|
1134
|
+
* @module @yuva-devlab/ai-client
|
|
1135
|
+
*/
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Configuration options for initializing the ClineAdapter.
|
|
1139
|
+
*/
|
|
1140
|
+
interface ClineAdapterConfig {
|
|
1141
|
+
/** Cline API Gateway authentication key */
|
|
1142
|
+
apiKey?: string;
|
|
1143
|
+
/** Custom base URL (defaults to AI_ENDPOINTS.CLINE_DEFAULT_BASE_URL) */
|
|
1144
|
+
baseUrl?: string;
|
|
1145
|
+
/** Default model identifier (defaults to AI_DEFAULT_MODELS.CLINE) */
|
|
1146
|
+
defaultModel?: string;
|
|
1147
|
+
/** Optional dynamic credential resolver for secret managers */
|
|
1148
|
+
credentials?: CredentialResolver;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Expected response structure from Cline Chat Completions endpoint.
|
|
1152
|
+
*/
|
|
1153
|
+
interface ClineCompletionResponse {
|
|
1154
|
+
/** Completion candidates list */
|
|
1155
|
+
choices?: Array<{
|
|
1156
|
+
message?: {
|
|
1157
|
+
content?: string | null;
|
|
1158
|
+
tool_calls?: Array<{
|
|
1159
|
+
id?: string;
|
|
1160
|
+
type?: string;
|
|
1161
|
+
function?: {
|
|
1162
|
+
name?: string;
|
|
1163
|
+
arguments?: string;
|
|
1164
|
+
};
|
|
1165
|
+
}>;
|
|
1166
|
+
};
|
|
1167
|
+
finish_reason?: string | null;
|
|
1168
|
+
}>;
|
|
1169
|
+
/** Data envelope wrapper when returned by certain Cline gateway routes */
|
|
1170
|
+
data?: {
|
|
1171
|
+
choices?: ClineCompletionResponse["choices"];
|
|
1172
|
+
};
|
|
1173
|
+
/** Token accounting and usage details */
|
|
1174
|
+
usage?: {
|
|
1175
|
+
prompt_tokens?: number;
|
|
1176
|
+
completion_tokens?: number;
|
|
1177
|
+
total_tokens?: number;
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Normalizes a canonical tool name to OpenAPI specification pattern (alphanumeric and underscores only).
|
|
1182
|
+
* Converts dots to underscores (e.g. "transactions.create" -> "transactions_create").
|
|
1183
|
+
*
|
|
1184
|
+
* @param name - Canonical tool name with domain dot separators.
|
|
1185
|
+
* @returns OpenAPI-compliant tool name.
|
|
1186
|
+
*/
|
|
1187
|
+
declare function sanitizeClineToolName(name: string): string;
|
|
1188
|
+
/**
|
|
1189
|
+
* Restores canonical tool name from OpenAPI normalized string.
|
|
1190
|
+
* Converts underscores to dots (e.g. "transactions_create" -> "transactions.create").
|
|
1191
|
+
*
|
|
1192
|
+
* @param name - Normalized tool name from model invocation.
|
|
1193
|
+
* @returns Canonical tool name.
|
|
1194
|
+
*/
|
|
1195
|
+
declare function restoreClineToolName(name: string): string;
|
|
1196
|
+
/**
|
|
1197
|
+
* Converts canonical messages to Cline/OpenAI wire format.
|
|
1198
|
+
*
|
|
1199
|
+
* @param messages - Canonical conversation history turns.
|
|
1200
|
+
* @returns Array of OpenAI-compatible wire messages.
|
|
1201
|
+
*/
|
|
1202
|
+
declare function mapClineMessages(messages: LLMRequest["messages"]): {
|
|
1203
|
+
role: string;
|
|
1204
|
+
content: string;
|
|
1205
|
+
}[];
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* @file packages/ai-client/src/adapters/cline/cline.adapter.ts
|
|
1209
|
+
* @description Standard Cline API Gateway adapter supporting Nemotron, Solar, DeepSeek, and Qwen.
|
|
1210
|
+
* @module @yuva-devlab/ai-client
|
|
1211
|
+
*/
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Cline adapter executing completions and streaming via the Cline API Gateway.
|
|
1215
|
+
*/
|
|
1216
|
+
declare class ClineAdapter implements ILLMProvider {
|
|
1217
|
+
readonly name = "cline";
|
|
1218
|
+
private readonly config;
|
|
1219
|
+
constructor(config?: ClineAdapterConfig);
|
|
1220
|
+
private resolveCredentials;
|
|
1221
|
+
complete(request: LLMRequest): Promise<LLMResponse>;
|
|
1222
|
+
stream(request: LLMRequest): AsyncIterable<LLMStreamChunk>;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* @file packages/ai-client/src/adapters/cline/cline.helpers.ts
|
|
1227
|
+
* @description Helper functions for Cline completion parsing, error mapping, and tool extraction.
|
|
1228
|
+
* @module @yuva-devlab/ai-client
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Parses and restores canonical tool calls from Cline model output.
|
|
1233
|
+
*
|
|
1234
|
+
* @param choices - Candidate completions from Cline API.
|
|
1235
|
+
* @returns Array of parsed ToolCall objects or undefined.
|
|
1236
|
+
*/
|
|
1237
|
+
declare function extractClineToolCalls(choices?: ClineCompletionResponse["choices"]): ToolCall[] | undefined;
|
|
1238
|
+
/**
|
|
1239
|
+
* Maps raw finish_reason string to canonical FinishReason enum.
|
|
1240
|
+
*
|
|
1241
|
+
* @param reason - Raw finish reason from API response.
|
|
1242
|
+
* @returns Canonical FinishReason member.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function mapClineFinishReason(reason?: string | null): FinishReason;
|
|
1245
|
+
/**
|
|
1246
|
+
* Extracts rate limit reset delays or retry-after headers from HTTP response.
|
|
1247
|
+
*
|
|
1248
|
+
* @param response - Fetch response instance.
|
|
1249
|
+
* @returns Informational suffix string or empty string.
|
|
1250
|
+
*/
|
|
1251
|
+
declare function extractClineRetrySuffix(response: Response): string;
|
|
1252
|
+
|
|
1114
1253
|
/**
|
|
1115
1254
|
* @file packages/ai-client/src/cascade/fallback-cascade.ts
|
|
1116
1255
|
* @description Intelligent multi-tier fallback cascade routing across local and cloud providers.
|
|
@@ -1213,7 +1352,7 @@ declare function extractStructuredOutput<T>(options: ExtractStructuredOutputOpti
|
|
|
1213
1352
|
/**
|
|
1214
1353
|
* Standard provider type identifiers.
|
|
1215
1354
|
*/
|
|
1216
|
-
type ProviderType = "ollama" | "groq" | "google" | "openai" | "anthropic" | "cascade";
|
|
1355
|
+
type ProviderType = "ollama" | "groq" | "google" | "openai" | "anthropic" | "cline" | "cascade";
|
|
1217
1356
|
/**
|
|
1218
1357
|
* Creates an instance of an LLM provider adapter matching the specified type.
|
|
1219
1358
|
*
|
|
@@ -1242,6 +1381,8 @@ interface CascadeCandidatesConfig {
|
|
|
1242
1381
|
openai?: Record<string, unknown>;
|
|
1243
1382
|
/** Optional Anthropic credentials and configuration */
|
|
1244
1383
|
anthropic?: Record<string, unknown>;
|
|
1384
|
+
/** Optional Cline API Gateway credentials and configuration */
|
|
1385
|
+
cline?: Record<string, unknown>;
|
|
1245
1386
|
}
|
|
1246
1387
|
/**
|
|
1247
1388
|
* Builds an ordered cascade of provider candidates based on explicit consumer configuration.
|
|
@@ -1275,4 +1416,4 @@ interface DefaultProviderOptions {
|
|
|
1275
1416
|
*/
|
|
1276
1417
|
declare function createDefaultProvider(options?: DefaultProviderOptions): ILLMProvider;
|
|
1277
1418
|
|
|
1278
|
-
export { type AIMessage, AIMessageSchema, AI_DEFAULT_MODELS, AI_ENDPOINTS, AI_EXECUTION_DEFAULTS, AnthropicAdapter, type AnthropicAdapterConfig, type AnthropicResponse, type CascadeCandidatesConfig, type CredentialResolver, type DefaultProviderOptions, type ExtractStructuredOutputOptions, FallbackCascade, type FallbackCascadeOptions, FinishReason, type GeminiCandidate, type GeminiResponse, GoogleAdapter, type GoogleAdapterConfig, GroqAdapter, type GroqAdapterConfig, type GroqCompletionResponse, type ILLMProvider, type LLMRequest, type LLMRequestOptions, LLMRequestOptionsSchema, LLMRequestSchema, type LLMResponse, LLMResponseSchema, type LLMStreamChunk, type LLMUsage, LLMUsageSchema, MessageRole, MissingCredentialError, OllamaAdapter, type OllamaAdapterConfig, type OllamaChatResponseChunk, type OllamaWireMessage, OpenAIAdapter, type OpenAIAdapterConfig, type OpenAiCompletionResponse, type OpenAiWireMessage, type ProviderCredentials, type ProviderType, type ToolCall, ToolCallSchema, buildGeminiRequestBody, createAssistantMessage, createCascadeCandidates, createDefaultProvider, createProvider, createSystemMessage, createToolResultMessage, createUserMessage, extractAnthropicSystemAndMessages, extractStructuredOutput, mapGroqMessages, mapOllamaMessages, mapOpenAiMessages, resolveEnvCredentials };
|
|
1419
|
+
export { type AIMessage, AIMessageSchema, AI_DEFAULT_MODELS, AI_ENDPOINTS, AI_EXECUTION_DEFAULTS, AnthropicAdapter, type AnthropicAdapterConfig, type AnthropicResponse, type CascadeCandidatesConfig, ClineAdapter, type ClineAdapterConfig, type ClineCompletionResponse, type CredentialResolver, type DefaultProviderOptions, type ExtractStructuredOutputOptions, FallbackCascade, type FallbackCascadeOptions, FinishReason, type GeminiCandidate, type GeminiResponse, GoogleAdapter, type GoogleAdapterConfig, GroqAdapter, type GroqAdapterConfig, type GroqCompletionResponse, type ILLMProvider, type LLMRequest, type LLMRequestOptions, LLMRequestOptionsSchema, LLMRequestSchema, type LLMResponse, LLMResponseSchema, type LLMStreamChunk, type LLMUsage, LLMUsageSchema, MessageRole, MissingCredentialError, OllamaAdapter, type OllamaAdapterConfig, type OllamaChatResponseChunk, type OllamaWireMessage, OpenAIAdapter, type OpenAIAdapterConfig, type OpenAiCompletionResponse, type OpenAiWireMessage, type ProviderCredentials, type ProviderType, type ToolCall, ToolCallSchema, buildGeminiRequestBody, createAssistantMessage, createCascadeCandidates, createDefaultProvider, createProvider, createSystemMessage, createToolResultMessage, createUserMessage, extractAnthropicSystemAndMessages, extractClineRetrySuffix, extractClineToolCalls, extractStructuredOutput, mapClineFinishReason, mapClineMessages, mapGroqMessages, mapOllamaMessages, mapOpenAiMessages, parseGeminiSseChunk, resolveEnvCredentials, restoreClineToolName, sanitizeClineToolName };
|