@robota-sdk/agent-provider 3.0.0-beta.64
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/LICENSE +21 -0
- package/dist/browser/index.d.ts +1104 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +7 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/loggers/index.cjs +1 -0
- package/dist/loggers/index.d.ts +151 -0
- package/dist/loggers/index.d.ts.map +1 -0
- package/dist/loggers/index.js +2 -0
- package/dist/loggers/index.js.map +1 -0
- package/dist/node/anthropic/index.cjs +1 -0
- package/dist/node/anthropic/index.d.ts +158 -0
- package/dist/node/anthropic/index.d.ts.map +1 -0
- package/dist/node/anthropic/index.js +1 -0
- package/dist/node/anthropic--1vgLC-e.js +5 -0
- package/dist/node/anthropic--1vgLC-e.js.map +1 -0
- package/dist/node/anthropic-BFQ6DSCP.cjs +4 -0
- package/dist/node/bytedance/index.cjs +1 -0
- package/dist/node/bytedance/index.d.ts +74 -0
- package/dist/node/bytedance/index.d.ts.map +1 -0
- package/dist/node/bytedance/index.js +1 -0
- package/dist/node/bytedance-C_0sF_pJ.js +2 -0
- package/dist/node/bytedance-C_0sF_pJ.js.map +1 -0
- package/dist/node/bytedance-DVPxqEiC.cjs +1 -0
- package/dist/node/chunk-Bmb41Sf3.cjs +1 -0
- package/dist/node/deepseek/index.cjs +1 -0
- package/dist/node/deepseek/index.d.ts +2 -0
- package/dist/node/deepseek/index.js +1 -0
- package/dist/node/deepseek-_8Ixx7rA.js +2 -0
- package/dist/node/deepseek-_8Ixx7rA.js.map +1 -0
- package/dist/node/deepseek-oA2Y6bD0.cjs +1 -0
- package/dist/node/gemini/index.cjs +1 -0
- package/dist/node/gemini/index.d.ts +173 -0
- package/dist/node/gemini/index.d.ts.map +1 -0
- package/dist/node/gemini/index.js +1 -0
- package/dist/node/gemini-Bh2U87MY.js +4 -0
- package/dist/node/gemini-Bh2U87MY.js.map +1 -0
- package/dist/node/gemini-DSaNCxZj.cjs +3 -0
- package/dist/node/gemma/index.cjs +1 -0
- package/dist/node/gemma/index.d.ts +2 -0
- package/dist/node/gemma/index.js +1 -0
- package/dist/node/gemma-Dp_AfCUR.js +2 -0
- package/dist/node/gemma-Dp_AfCUR.js.map +1 -0
- package/dist/node/gemma-G-Pf_PnX.cjs +1 -0
- package/dist/node/google/index.cjs +1 -0
- package/dist/node/google/index.d.ts +14 -0
- package/dist/node/google/index.d.ts.map +1 -0
- package/dist/node/google/index.js +2 -0
- package/dist/node/google/index.js.map +1 -0
- package/dist/node/index-B6PnlDMd.d.ts +82 -0
- package/dist/node/index-B6PnlDMd.d.ts.map +1 -0
- package/dist/node/index-B7UvPJcI.d.ts +315 -0
- package/dist/node/index-B7UvPJcI.d.ts.map +1 -0
- package/dist/node/index-BLPOTNb5.d.ts +98 -0
- package/dist/node/index-BLPOTNb5.d.ts.map +1 -0
- package/dist/node/index-BqixM_XD.d.ts +231 -0
- package/dist/node/index-BqixM_XD.d.ts.map +1 -0
- package/dist/node/index-C3beaqKO.d.ts +231 -0
- package/dist/node/index-C3beaqKO.d.ts.map +1 -0
- package/dist/node/index-Cp2XRh9G.d.ts +82 -0
- package/dist/node/index-Cp2XRh9G.d.ts.map +1 -0
- package/dist/node/index-DSv5xruI.d.ts +98 -0
- package/dist/node/index-DSv5xruI.d.ts.map +1 -0
- package/dist/node/index-w0bV1uaP.d.ts +315 -0
- package/dist/node/index-w0bV1uaP.d.ts.map +1 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.js +1 -0
- package/dist/node/openai/index.cjs +1 -0
- package/dist/node/openai/index.d.ts +2 -0
- package/dist/node/openai/index.js +1 -0
- package/dist/node/openai-CRQjg4xF.js +2 -0
- package/dist/node/openai-CRQjg4xF.js.map +1 -0
- package/dist/node/openai-compatible-BYfyY5lb.cjs +1 -0
- package/dist/node/openai-compatible-Dm4Sof9e.js +2 -0
- package/dist/node/openai-compatible-Dm4Sof9e.js.map +1 -0
- package/dist/node/openai-xWC6pY7r.cjs +1 -0
- package/dist/node/qwen/index.cjs +1 -0
- package/dist/node/qwen/index.d.ts +2 -0
- package/dist/node/qwen/index.js +1 -0
- package/dist/node/qwen-ChUZobTL.js +2 -0
- package/dist/node/qwen-ChUZobTL.js.map +1 -0
- package/dist/node/qwen-CjT71vSM.cjs +1 -0
- package/package.json +157 -0
- package/src/anthropic/__tests__/abort-streaming.test.ts +199 -0
- package/src/anthropic/__tests__/model-catalog-refresh.test.ts +92 -0
- package/src/anthropic/__tests__/provider-definition.test.ts +55 -0
- package/src/anthropic/__tests__/provider.test.ts +1357 -0
- package/src/anthropic/__tests__/response-parser.test.ts +326 -0
- package/src/anthropic/index.ts +22 -0
- package/src/anthropic/message-converter.ts +181 -0
- package/src/anthropic/model-catalog-refresh.ts +128 -0
- package/src/anthropic/parsers/response-parser.ts +184 -0
- package/src/anthropic/provider-definition.ts +93 -0
- package/src/anthropic/provider.ts +290 -0
- package/src/anthropic/streaming-handler.ts +204 -0
- package/src/anthropic/types/api-types.ts +158 -0
- package/src/anthropic/types.ts +79 -0
- package/src/bytedance/http-client.test.ts +288 -0
- package/src/bytedance/http-client.ts +163 -0
- package/src/bytedance/index.ts +2 -0
- package/src/bytedance/provider.spec.ts +320 -0
- package/src/bytedance/provider.ts +171 -0
- package/src/bytedance/status-mapper.test.ts +299 -0
- package/src/bytedance/status-mapper.ts +141 -0
- package/src/bytedance/types.ts +68 -0
- package/src/deepseek/defaults.ts +4 -0
- package/src/deepseek/index.ts +22 -0
- package/src/deepseek/model-catalog-refresh.test.ts +57 -0
- package/src/deepseek/model-catalog-refresh.ts +105 -0
- package/src/deepseek/model-catalog.ts +55 -0
- package/src/deepseek/provider-definition.test.ts +109 -0
- package/src/deepseek/provider-definition.ts +132 -0
- package/src/deepseek/provider.test.ts +324 -0
- package/src/deepseek/provider.ts +298 -0
- package/src/deepseek/types.ts +37 -0
- package/src/gemini/execution-helpers.ts +233 -0
- package/src/gemini/genai-transport.test.ts +208 -0
- package/src/gemini/image-operations.test.ts +448 -0
- package/src/gemini/image-operations.ts +261 -0
- package/src/gemini/index.ts +11 -0
- package/src/gemini/message-converter.test.ts +616 -0
- package/src/gemini/message-converter.ts +140 -0
- package/src/gemini/model-catalog-refresh.test.ts +107 -0
- package/src/gemini/model-catalog-refresh.ts +92 -0
- package/src/gemini/provider-definition.test.ts +70 -0
- package/src/gemini/provider-definition.ts +78 -0
- package/src/gemini/provider-extended.test.ts +898 -0
- package/src/gemini/provider.spec.ts +216 -0
- package/src/gemini/provider.ts +279 -0
- package/src/gemini/request-converter.ts +226 -0
- package/src/gemini/tool-schema-converter.ts +78 -0
- package/src/gemini/types/api-types.ts +235 -0
- package/src/gemini/types.ts +121 -0
- package/src/gemma/index.ts +5 -0
- package/src/gemma/message-factory.ts +38 -0
- package/src/gemma/provider-definition.test.ts +43 -0
- package/src/gemma/provider-definition.ts +84 -0
- package/src/gemma/provider-projection.ts +49 -0
- package/src/gemma/provider.test.ts +628 -0
- package/src/gemma/provider.ts +308 -0
- package/src/gemma/pseudo-command-envelope.ts +58 -0
- package/src/gemma/pseudo-tool-call-projector.ts +243 -0
- package/src/gemma/pseudo-tool-call-tag-parser.ts +153 -0
- package/src/gemma/pseudo-tool-call-types.ts +31 -0
- package/src/gemma/reasoning-projector.test.ts +52 -0
- package/src/gemma/reasoning-projector.ts +144 -0
- package/src/gemma/streaming-projection.ts +79 -0
- package/src/gemma/tool-call-argument-parser.ts +126 -0
- package/src/gemma/tool-call-projector.test.ts +227 -0
- package/src/gemma/tool-call-projector.ts +264 -0
- package/src/gemma/types.ts +27 -0
- package/src/google/index.ts +11 -0
- package/src/google/provider-compat.test.ts +19 -0
- package/src/google/provider-definition.ts +6 -0
- package/src/google/provider.ts +10 -0
- package/src/google/types.ts +5 -0
- package/src/index.ts +9 -0
- package/src/openai/adapter.test.ts +494 -0
- package/src/openai/adapter.ts +145 -0
- package/src/openai/chat-completions-chat.ts +189 -0
- package/src/openai/executor-integration.test.ts +206 -0
- package/src/openai/index.ts +21 -0
- package/src/openai/interfaces/payload-logger.ts +48 -0
- package/src/openai/loggers/console-payload-logger.test.ts +173 -0
- package/src/openai/loggers/console-payload-logger.ts +94 -0
- package/src/openai/loggers/console.ts +9 -0
- package/src/openai/loggers/file-payload-logger.test.ts +238 -0
- package/src/openai/loggers/file-payload-logger.ts +112 -0
- package/src/openai/loggers/file.ts +9 -0
- package/src/openai/loggers/index.ts +12 -0
- package/src/openai/loggers/sanitize-openai-log-data.test.ts +89 -0
- package/src/openai/loggers/sanitize-openai-log-data.ts +14 -0
- package/src/openai/message-converter.ts +22 -0
- package/src/openai/model-catalog-refresh.test.ts +92 -0
- package/src/openai/model-catalog-refresh.ts +115 -0
- package/src/openai/openai-request-format.ts +92 -0
- package/src/openai/parsers/response-parser.test.ts +407 -0
- package/src/openai/parsers/response-parser.ts +47 -0
- package/src/openai/provider-definition.test.ts +75 -0
- package/src/openai/provider-definition.ts +132 -0
- package/src/openai/provider.test.ts +1402 -0
- package/src/openai/provider.ts +237 -0
- package/src/openai/responses-chat.ts +258 -0
- package/src/openai/responses-converter.ts +112 -0
- package/src/openai/responses-parser.ts +285 -0
- package/src/openai/responses-stream-utils.ts +45 -0
- package/src/openai/responses-types.ts +195 -0
- package/src/openai/streaming/stream-assembler.ts +3 -0
- package/src/openai/streaming/stream-handler.test.ts +367 -0
- package/src/openai/streaming/stream-handler.ts +119 -0
- package/src/openai/types/api-types.ts +112 -0
- package/src/openai/types.ts +194 -0
- package/src/qwen/defaults.ts +26 -0
- package/src/qwen/index.ts +5 -0
- package/src/qwen/model-catalog-refresh.test.ts +91 -0
- package/src/qwen/model-catalog-refresh.ts +97 -0
- package/src/qwen/provider-capabilities.ts +34 -0
- package/src/qwen/provider-definition.test.ts +139 -0
- package/src/qwen/provider-definition.ts +173 -0
- package/src/qwen/provider-streaming-assembly.ts +40 -0
- package/src/qwen/provider.test.ts +640 -0
- package/src/qwen/provider.ts +293 -0
- package/src/qwen/responses-chat.ts +194 -0
- package/src/qwen/responses-converter.ts +104 -0
- package/src/qwen/responses-parser.ts +299 -0
- package/src/qwen/responses-stream-utils.ts +38 -0
- package/src/qwen/types.ts +228 -0
- package/src/shared/openai-compatible/endpoint-probe.test.ts +52 -0
- package/src/shared/openai-compatible/endpoint-probe.ts +43 -0
- package/src/shared/openai-compatible/index.ts +6 -0
- package/src/shared/openai-compatible/message-converter.test.ts +111 -0
- package/src/shared/openai-compatible/message-converter.ts +84 -0
- package/src/shared/openai-compatible/native-payload-observer.test.ts +43 -0
- package/src/shared/openai-compatible/native-payload-observer.ts +26 -0
- package/src/shared/openai-compatible/response-parser.test.ts +172 -0
- package/src/shared/openai-compatible/response-parser.ts +180 -0
- package/src/shared/openai-compatible/stream-assembler.test.ts +266 -0
- package/src/shared/openai-compatible/stream-assembler.ts +248 -0
- package/src/shared/openai-compatible/types.ts +59 -0
|
@@ -0,0 +1,1104 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import { AbstractAIProvider, IChatOptions, IExecutor, IImageComposeRequest, IImageEditRequest, IImageGenerationProvider, IImageGenerationRequest, IImageGenerationResult, ILogger, IProviderCapabilities, IProviderDefinition, IProviderModelCatalog, IProviderNativeWebToolRequest, IProviderProfileConfig, IToolCall, IToolSchema, IVideoGenerationProvider, IVideoGenerationRequest, IVideoJobAccepted, IVideoJobSnapshot, TProviderMediaResult, TProviderOptionValueBase, TTextDeltaCallback, TUniversalMessage, TUniversalValue } from "@robota-sdk/agent-core";
|
|
3
|
+
import OpenAI from "openai";
|
|
4
|
+
|
|
5
|
+
//#region src/anthropic/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Valid provider option value types
|
|
8
|
+
*/
|
|
9
|
+
type TAnthropicProviderOptionValue = string | number | boolean | undefined | null | Anthropic | IExecutor | TProviderOptionValueBase | TAnthropicProviderOptionValue[] | {
|
|
10
|
+
[key: string]: TAnthropicProviderOptionValue;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Anthropic provider options
|
|
14
|
+
*
|
|
15
|
+
* Note: Anthropic API doesn't support response format configuration.
|
|
16
|
+
* JSON output can be requested through prompt instructions.
|
|
17
|
+
*/
|
|
18
|
+
interface IAnthropicProviderOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Additional provider-specific options
|
|
21
|
+
*/
|
|
22
|
+
[key: string]: TAnthropicProviderOptionValue;
|
|
23
|
+
/**
|
|
24
|
+
* Anthropic API key (required when client and executor are not provided)
|
|
25
|
+
*/
|
|
26
|
+
apiKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* API request timeout (milliseconds)
|
|
29
|
+
*/
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/**
|
|
32
|
+
* API base URL
|
|
33
|
+
*/
|
|
34
|
+
baseURL?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Anthropic client instance (optional: will be created from apiKey if not provided)
|
|
37
|
+
* Use this path for advanced Anthropic SDK authentication that is outside
|
|
38
|
+
* Robota's normal API-key setup flow.
|
|
39
|
+
*/
|
|
40
|
+
client?: Anthropic;
|
|
41
|
+
/**
|
|
42
|
+
* Optional executor for handling AI requests
|
|
43
|
+
*
|
|
44
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
45
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { LocalExecutor, RemoteExecutor } from '@robota-sdk/agent-core';
|
|
50
|
+
*
|
|
51
|
+
* // Local execution (registers this provider)
|
|
52
|
+
* const localExecutor = new LocalExecutor();
|
|
53
|
+
* localExecutor.registerProvider('anthropic', new AnthropicProvider({ apiKey: 'sk-ant-...' }));
|
|
54
|
+
*
|
|
55
|
+
* // Remote execution
|
|
56
|
+
* const remoteExecutor = new RemoteExecutor({
|
|
57
|
+
* serverUrl: 'https://api.robota.io',
|
|
58
|
+
* userApiKey: 'user-token-123'
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* const provider = new AnthropicProvider({
|
|
62
|
+
* executor: remoteExecutor // No direct API key needed
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
executor?: IExecutor;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/anthropic/provider.d.ts
|
|
70
|
+
/**
|
|
71
|
+
* Anthropic provider implementation for Robota
|
|
72
|
+
*
|
|
73
|
+
* IMPORTANT PROVIDER-SPECIFIC RULES:
|
|
74
|
+
* 1. This provider MUST extend BaseAIProvider from @robota-sdk/agent-core
|
|
75
|
+
* 2. Content handling for Anthropic API:
|
|
76
|
+
* - When tool_calls are present: content MUST be null (not empty string)
|
|
77
|
+
* - For regular assistant messages: content should be a string
|
|
78
|
+
* 3. Use override keyword for all methods inherited from BaseAIProvider
|
|
79
|
+
* 4. Provider-specific API behavior should be documented here
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
declare class AnthropicProvider extends AbstractAIProvider {
|
|
84
|
+
readonly name = "anthropic";
|
|
85
|
+
readonly version = "1.0.0";
|
|
86
|
+
private readonly client?;
|
|
87
|
+
private readonly options;
|
|
88
|
+
/**
|
|
89
|
+
* When true, Anthropic server tools (web_search) are included in every request.
|
|
90
|
+
* The server executes these tools internally — no local tool registration needed.
|
|
91
|
+
*/
|
|
92
|
+
enableWebTools: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Optional callback for text deltas during streaming.
|
|
95
|
+
* Set by the consumer (e.g., Session) to receive real-time text chunks.
|
|
96
|
+
* When set, chat() uses streaming internally while still returning
|
|
97
|
+
* the complete assembled message.
|
|
98
|
+
*/
|
|
99
|
+
onTextDelta?: TTextDeltaCallback;
|
|
100
|
+
/** Callback when a server tool (web_search etc.) is invoked by the API */
|
|
101
|
+
onServerToolUse?: (toolName: string, input: Record<string, string>) => void;
|
|
102
|
+
constructor(options: IAnthropicProviderOptions);
|
|
103
|
+
/**
|
|
104
|
+
* Generate response using TUniversalMessage
|
|
105
|
+
*/
|
|
106
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
107
|
+
/**
|
|
108
|
+
* Generate streaming response using TUniversalMessage
|
|
109
|
+
*/
|
|
110
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
111
|
+
supportsTools(): boolean;
|
|
112
|
+
getCapabilities(): IProviderCapabilities;
|
|
113
|
+
configureNativeWebTools(request: IProviderNativeWebToolRequest): IProviderCapabilities;
|
|
114
|
+
validateConfig(): boolean;
|
|
115
|
+
dispose(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Validate TUniversalMessage array
|
|
118
|
+
*/
|
|
119
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/anthropic/provider-definition.d.ts
|
|
123
|
+
declare const DEFAULT_ANTHROPIC_PROVIDER_MODEL = "claude-sonnet-4-6";
|
|
124
|
+
declare const DEFAULT_ANTHROPIC_PROVIDER_API_KEY_ENV = "ANTHROPIC_API_KEY";
|
|
125
|
+
declare const DEFAULT_ANTHROPIC_PROVIDER_API_KEY_REFERENCE = "$ENV:ANTHROPIC_API_KEY";
|
|
126
|
+
declare const ANTHROPIC_MODEL_SOURCE_URL = "https://platform.claude.com/docs/en/api/models/list";
|
|
127
|
+
declare const ANTHROPIC_MODEL_LAST_VERIFIED_AT = "2026-05-04";
|
|
128
|
+
declare function createAnthropicProviderDefinition(): IProviderDefinition;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/anthropic/model-catalog-refresh.d.ts
|
|
131
|
+
interface IAnthropicModelsResponse {
|
|
132
|
+
data?: Array<{
|
|
133
|
+
id?: string;
|
|
134
|
+
display_name?: string;
|
|
135
|
+
type?: string;
|
|
136
|
+
}>;
|
|
137
|
+
has_more?: boolean;
|
|
138
|
+
}
|
|
139
|
+
interface IAnthropicFetchInit {
|
|
140
|
+
headers?: Record<string, string>;
|
|
141
|
+
}
|
|
142
|
+
interface IAnthropicFetchResponse {
|
|
143
|
+
ok: boolean;
|
|
144
|
+
status: number;
|
|
145
|
+
json: () => Promise<IAnthropicModelsResponse>;
|
|
146
|
+
}
|
|
147
|
+
type TAnthropicFetch = (url: string, init?: IAnthropicFetchInit) => Promise<IAnthropicFetchResponse>;
|
|
148
|
+
declare function refreshAnthropicModelCatalog(profile: IProviderProfileConfig, fetcher?: TAnthropicFetch): Promise<IProviderModelCatalog>;
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/anthropic/index.d.ts
|
|
151
|
+
/**
|
|
152
|
+
* Factory function for creating an AnthropicProvider instance.
|
|
153
|
+
* @param _options - Configuration options for the Anthropic provider
|
|
154
|
+
* @returns An AnthropicProvider instance
|
|
155
|
+
*/
|
|
156
|
+
declare function createAnthropicProvider(_options: IAnthropicProviderOptions): void;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/openai/types/api-types.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* Payload logging data structure
|
|
161
|
+
*/
|
|
162
|
+
interface IOpenAILogData {
|
|
163
|
+
model: string;
|
|
164
|
+
messagesCount: number;
|
|
165
|
+
hasTools: boolean;
|
|
166
|
+
temperature?: number | undefined;
|
|
167
|
+
maxTokens?: number | undefined;
|
|
168
|
+
timestamp: string;
|
|
169
|
+
requestId?: string | undefined;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/openai/interfaces/payload-logger.d.ts
|
|
173
|
+
/**
|
|
174
|
+
* IPayloadLogger interface for logging OpenAI API payloads
|
|
175
|
+
*
|
|
176
|
+
* This interface provides a contract for different logging implementations:
|
|
177
|
+
* - FilePayloadLogger: Node.js file-based logging
|
|
178
|
+
* - ConsolePayloadLogger: Browser console-based logging
|
|
179
|
+
* - Custom implementations: User-defined loggers
|
|
180
|
+
*/
|
|
181
|
+
interface IPayloadLogger {
|
|
182
|
+
/**
|
|
183
|
+
* Check if logging is enabled
|
|
184
|
+
* @returns true if logging is active, false otherwise
|
|
185
|
+
*/
|
|
186
|
+
isEnabled(): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Log API payload data
|
|
189
|
+
* @param payload - The API request/response payload data
|
|
190
|
+
* @param type - Type of operation ('chat' or 'stream')
|
|
191
|
+
*/
|
|
192
|
+
logPayload(payload: IOpenAILogData, type: 'chat' | 'stream'): Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Configuration options for payload loggers
|
|
196
|
+
*/
|
|
197
|
+
interface IPayloadLoggerOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Whether logging is enabled
|
|
200
|
+
* @defaultValue true
|
|
201
|
+
*/
|
|
202
|
+
enabled?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Include timestamp in log entries
|
|
205
|
+
* @defaultValue true
|
|
206
|
+
*/
|
|
207
|
+
includeTimestamp?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Logger instance for console output
|
|
210
|
+
* @defaultValue SilentLogger
|
|
211
|
+
*/
|
|
212
|
+
logger?: ILogger;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/openai/types.d.ts
|
|
216
|
+
type TOpenAIApiSurface = 'responses' | 'chat-completions';
|
|
217
|
+
interface IOpenAIJsonSchemaDefinition {
|
|
218
|
+
name: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
schema?: Record<string, TOpenAIProviderOptionValue>;
|
|
221
|
+
strict?: boolean;
|
|
222
|
+
}
|
|
223
|
+
interface IOpenAIResponsesReasoningOptions {
|
|
224
|
+
effort?: 'low' | 'medium' | 'high';
|
|
225
|
+
summary?: 'auto' | 'concise' | 'detailed';
|
|
226
|
+
}
|
|
227
|
+
interface IOpenAINativeWebToolsOptions {
|
|
228
|
+
webSearch?: boolean;
|
|
229
|
+
webFetch?: boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Valid provider option value types
|
|
233
|
+
*/
|
|
234
|
+
type TOpenAIProviderOptionValue = string | number | boolean | undefined | null | IOpenAIJsonSchemaDefinition | IOpenAINativeWebToolsOptions | IOpenAIResponsesReasoningOptions | OpenAI | IPayloadLogger | ILogger | IExecutor | TProviderOptionValueBase | TOpenAIProviderOptionValue[] | {
|
|
235
|
+
[key: string]: TOpenAIProviderOptionValue;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* OpenAI provider options
|
|
239
|
+
*/
|
|
240
|
+
interface IOpenAIProviderOptions {
|
|
241
|
+
/**
|
|
242
|
+
* Additional provider-specific options
|
|
243
|
+
*/
|
|
244
|
+
[key: string]: TOpenAIProviderOptionValue;
|
|
245
|
+
/**
|
|
246
|
+
* OpenAI API key (required when client is not provided)
|
|
247
|
+
*/
|
|
248
|
+
apiKey?: string;
|
|
249
|
+
/**
|
|
250
|
+
* OpenAI organization ID (optional)
|
|
251
|
+
*/
|
|
252
|
+
organization?: string;
|
|
253
|
+
/**
|
|
254
|
+
* API request timeout (milliseconds)
|
|
255
|
+
*/
|
|
256
|
+
timeout?: number;
|
|
257
|
+
/**
|
|
258
|
+
* API base URL (default: 'https://api.openai.com/v1')
|
|
259
|
+
*/
|
|
260
|
+
baseURL?: string;
|
|
261
|
+
/**
|
|
262
|
+
* Default model used when chat options do not provide a model.
|
|
263
|
+
*/
|
|
264
|
+
defaultModel?: string;
|
|
265
|
+
/**
|
|
266
|
+
* API surface to use for direct OpenAI calls.
|
|
267
|
+
*
|
|
268
|
+
* Defaults to Responses for official OpenAI calls. Profiles with baseURL use
|
|
269
|
+
* Chat Completions by default for OpenAI-compatible endpoint compatibility.
|
|
270
|
+
*/
|
|
271
|
+
apiSurface?: TOpenAIApiSurface;
|
|
272
|
+
/**
|
|
273
|
+
* Response format (default: 'text')
|
|
274
|
+
* - 'text': Plain text response
|
|
275
|
+
* - 'json_object': JSON object mode (requires system message)
|
|
276
|
+
* - 'json_schema': Structured Outputs with schema validation
|
|
277
|
+
*/
|
|
278
|
+
responseFormat?: 'text' | 'json_object' | 'json_schema';
|
|
279
|
+
/**
|
|
280
|
+
* JSON schema for structured outputs (required when responseFormat is 'json_schema')
|
|
281
|
+
*/
|
|
282
|
+
jsonSchema?: IOpenAIJsonSchemaDefinition;
|
|
283
|
+
/**
|
|
284
|
+
* Responses API reasoning controls. Hidden reasoning is never exposed in message
|
|
285
|
+
* content; only explicit summaries/encrypted items requested here are represented.
|
|
286
|
+
*/
|
|
287
|
+
reasoning?: IOpenAIResponsesReasoningOptions;
|
|
288
|
+
/**
|
|
289
|
+
* Whether OpenAI should store Responses API results. Defaults to OpenAI API behavior.
|
|
290
|
+
*/
|
|
291
|
+
store?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Include encrypted reasoning items for stateless reasoning continuation.
|
|
294
|
+
*/
|
|
295
|
+
includeEncryptedReasoning?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Opt into strict custom function parameter validation where supported.
|
|
298
|
+
*/
|
|
299
|
+
strictTools?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Provider-native hosted web tool request from provider profile options.
|
|
302
|
+
*
|
|
303
|
+
* OpenAI-compatible Chat Completions endpoints do not support this Robota
|
|
304
|
+
* native web contract. The provider rejects unsupported configurations before
|
|
305
|
+
* any model request is sent.
|
|
306
|
+
*/
|
|
307
|
+
nativeWebTools?: IOpenAINativeWebToolsOptions;
|
|
308
|
+
/**
|
|
309
|
+
* OpenAI client instance (optional: will be created from apiKey if not provided)
|
|
310
|
+
*/
|
|
311
|
+
client?: OpenAI;
|
|
312
|
+
/**
|
|
313
|
+
* Payload logger instance for debugging API requests/responses
|
|
314
|
+
*
|
|
315
|
+
* Use different implementations based on your environment:
|
|
316
|
+
* - FilePayloadLogger: Node.js file-based logging
|
|
317
|
+
* - ConsolePayloadLogger: Browser console-based logging
|
|
318
|
+
* - Custom: Implement IPayloadLogger interface
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* // Node.js
|
|
323
|
+
* import { FilePayloadLogger } from '@robota-sdk/agent-provider/openai/loggers';
|
|
324
|
+
* const provider = new OpenAIProvider({
|
|
325
|
+
* client: openaiClient,
|
|
326
|
+
* payloadLogger: new FilePayloadLogger({ logDir: './logs/openai' })
|
|
327
|
+
* });
|
|
328
|
+
*
|
|
329
|
+
* // Browser
|
|
330
|
+
* import { ConsolePayloadLogger } from '@robota-sdk/agent-provider/openai/loggers';
|
|
331
|
+
* const provider = new OpenAIProvider({
|
|
332
|
+
* client: openaiClient,
|
|
333
|
+
* payloadLogger: new ConsolePayloadLogger()
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
payloadLogger?: IPayloadLogger;
|
|
338
|
+
/**
|
|
339
|
+
* Optional executor for handling AI requests
|
|
340
|
+
*
|
|
341
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
342
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* import { LocalExecutor, RemoteExecutor } from '@robota-sdk/agent-core';
|
|
347
|
+
*
|
|
348
|
+
* // Local execution (registers this provider)
|
|
349
|
+
* const localExecutor = new LocalExecutor();
|
|
350
|
+
* localExecutor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
|
|
351
|
+
*
|
|
352
|
+
* // Remote execution
|
|
353
|
+
* const remoteExecutor = new RemoteExecutor({
|
|
354
|
+
* serverUrl: 'https://api.robota.io',
|
|
355
|
+
* userApiKey: 'user-token-123'
|
|
356
|
+
* });
|
|
357
|
+
*
|
|
358
|
+
* const provider = new OpenAIProvider({
|
|
359
|
+
* executor: remoteExecutor // No direct API key needed
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
executor?: IExecutor;
|
|
364
|
+
/**
|
|
365
|
+
* Logger instance for internal OpenAI provider logging
|
|
366
|
+
* @defaultValue SilentLogger
|
|
367
|
+
*/
|
|
368
|
+
logger?: ILogger;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/openai/provider.d.ts
|
|
372
|
+
/**
|
|
373
|
+
* OpenAI provider implementation for Robota
|
|
374
|
+
*
|
|
375
|
+
* Provides integration with OpenAI models through the Robota provider contract.
|
|
376
|
+
* Uses OpenAI SDK native types internally for optimal performance and feature support.
|
|
377
|
+
*
|
|
378
|
+
* @public
|
|
379
|
+
*/
|
|
380
|
+
declare class OpenAIProvider extends AbstractAIProvider {
|
|
381
|
+
readonly name = "openai";
|
|
382
|
+
readonly version = "1.0.0";
|
|
383
|
+
private readonly client?;
|
|
384
|
+
private readonly options;
|
|
385
|
+
private readonly apiSurface;
|
|
386
|
+
private readonly payloadLogger;
|
|
387
|
+
private readonly responseParser;
|
|
388
|
+
/**
|
|
389
|
+
* Optional callback for text deltas during streaming.
|
|
390
|
+
* Set by the consumer (e.g., Session) to receive real-time text chunks.
|
|
391
|
+
* When set, chat() uses streaming internally while still returning
|
|
392
|
+
* the complete assembled message.
|
|
393
|
+
*/
|
|
394
|
+
onTextDelta?: TTextDeltaCallback;
|
|
395
|
+
constructor(options: IOpenAIProviderOptions);
|
|
396
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
397
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
398
|
+
supportsTools(): boolean;
|
|
399
|
+
getCapabilities(): IProviderCapabilities;
|
|
400
|
+
validateConfig(): boolean;
|
|
401
|
+
dispose(): Promise<void>;
|
|
402
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/openai/adapter.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* OpenAI Conversation Adapter
|
|
408
|
+
*
|
|
409
|
+
* Converts between TUniversalMessage format and OpenAI native types.
|
|
410
|
+
* Provides bidirectional conversion for seamless integration.
|
|
411
|
+
*
|
|
412
|
+
* @public
|
|
413
|
+
*/
|
|
414
|
+
declare class OpenAIConversationAdapter {
|
|
415
|
+
/**
|
|
416
|
+
* Filter messages for OpenAI compatibility
|
|
417
|
+
*
|
|
418
|
+
* OpenAI has specific requirements:
|
|
419
|
+
* - Tool messages must have valid toolCallId
|
|
420
|
+
* - Messages must be in proper sequence
|
|
421
|
+
* - Tool messages without toolCallId should be excluded
|
|
422
|
+
*/
|
|
423
|
+
static filterMessagesForOpenAI(messages: TUniversalMessage[]): TUniversalMessage[];
|
|
424
|
+
/**
|
|
425
|
+
* Convert TUniversalMessage array to OpenAI message format
|
|
426
|
+
* Now properly handles tool messages for OpenAI's tool calling feature
|
|
427
|
+
*/
|
|
428
|
+
static toOpenAIFormat(messages: TUniversalMessage[]): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
429
|
+
/**
|
|
430
|
+
* Convert a single TUniversalMessage to OpenAI format
|
|
431
|
+
* Handles all message types including tool messages
|
|
432
|
+
*/
|
|
433
|
+
static convertMessage(msg: TUniversalMessage): OpenAI.Chat.ChatCompletionMessageParam;
|
|
434
|
+
/**
|
|
435
|
+
* Add system prompt to message array if needed
|
|
436
|
+
*/
|
|
437
|
+
static addSystemPromptIfNeeded(messages: OpenAI.Chat.ChatCompletionMessageParam[], systemPrompt?: string): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/openai/model-catalog-refresh.d.ts
|
|
441
|
+
interface IOpenAIModelCatalogResponse {
|
|
442
|
+
data?: readonly IOpenAIModelCatalogResource[];
|
|
443
|
+
}
|
|
444
|
+
interface IOpenAIModelCatalogResource {
|
|
445
|
+
id?: string;
|
|
446
|
+
}
|
|
447
|
+
interface IOpenAIModelCatalogFetchInit {
|
|
448
|
+
headers: Record<string, string>;
|
|
449
|
+
}
|
|
450
|
+
interface IOpenAIModelCatalogFetchResponse {
|
|
451
|
+
ok: boolean;
|
|
452
|
+
status: number;
|
|
453
|
+
statusText?: string;
|
|
454
|
+
json: () => Promise<IOpenAIModelCatalogResponse>;
|
|
455
|
+
}
|
|
456
|
+
type TOpenAIModelCatalogFetch = (url: string, init: IOpenAIModelCatalogFetchInit) => Promise<IOpenAIModelCatalogFetchResponse>;
|
|
457
|
+
interface IRefreshOpenAIModelCatalogOptions {
|
|
458
|
+
fetcher?: TOpenAIModelCatalogFetch;
|
|
459
|
+
now?: () => Date;
|
|
460
|
+
}
|
|
461
|
+
declare function refreshOpenAIModelCatalog(profile: IProviderProfileConfig, options?: IRefreshOpenAIModelCatalogOptions): Promise<IProviderModelCatalog>;
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/openai/provider-definition.d.ts
|
|
464
|
+
declare const DEFAULT_OPENAI_PROVIDER_MODEL: string | undefined;
|
|
465
|
+
declare const DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE = "$ENV:OPENAI_API_KEY";
|
|
466
|
+
declare function createOpenAIProviderDefinition(): IProviderDefinition;
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/deepseek/types.d.ts
|
|
469
|
+
type TDeepSeekThinkingMode = 'enabled' | 'disabled';
|
|
470
|
+
type TDeepSeekReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
471
|
+
interface IDeepSeekThinkingConfig {
|
|
472
|
+
type: TDeepSeekThinkingMode;
|
|
473
|
+
}
|
|
474
|
+
type TDeepSeekProviderOptionValue = string | number | boolean | undefined | null | IDeepSeekThinkingConfig | OpenAI | ILogger | IExecutor | TProviderOptionValueBase | TDeepSeekProviderOptionValue[] | {
|
|
475
|
+
[key: string]: TDeepSeekProviderOptionValue;
|
|
476
|
+
};
|
|
477
|
+
interface IDeepSeekProviderOptions {
|
|
478
|
+
[key: string]: TDeepSeekProviderOptionValue;
|
|
479
|
+
apiKey?: string;
|
|
480
|
+
baseURL?: string;
|
|
481
|
+
timeout?: number;
|
|
482
|
+
defaultModel?: string;
|
|
483
|
+
thinking?: TDeepSeekThinkingMode;
|
|
484
|
+
reasoningEffort?: TDeepSeekReasoningEffort;
|
|
485
|
+
client?: OpenAI;
|
|
486
|
+
executor?: IExecutor;
|
|
487
|
+
logger?: ILogger;
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/deepseek/provider.d.ts
|
|
491
|
+
declare class DeepSeekProvider extends AbstractAIProvider {
|
|
492
|
+
readonly name = "deepseek";
|
|
493
|
+
readonly version = "1.0.0";
|
|
494
|
+
private readonly client?;
|
|
495
|
+
private readonly options;
|
|
496
|
+
private readonly responseParser;
|
|
497
|
+
onTextDelta?: TTextDeltaCallback;
|
|
498
|
+
constructor(options: IDeepSeekProviderOptions);
|
|
499
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
500
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
501
|
+
supportsTools(): boolean;
|
|
502
|
+
getCapabilities(): IProviderCapabilities;
|
|
503
|
+
validateConfig(): boolean;
|
|
504
|
+
dispose(): Promise<void>;
|
|
505
|
+
private buildRequestParams;
|
|
506
|
+
private buildStreamingRequestParams;
|
|
507
|
+
private getClient;
|
|
508
|
+
private chatWithStreamingAssembly;
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/deepseek/provider-definition.d.ts
|
|
512
|
+
declare function createDeepSeekProviderDefinition(): IProviderDefinition;
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/deepseek/defaults.d.ts
|
|
515
|
+
declare const DEFAULT_DEEPSEEK_PROVIDER_MODEL = "deepseek-v4-flash";
|
|
516
|
+
declare const DEFAULT_DEEPSEEK_PROVIDER_API_KEY_ENV = "DEEPSEEK_API_KEY";
|
|
517
|
+
declare const DEFAULT_DEEPSEEK_PROVIDER_API_KEY_REFERENCE = "$ENV:DEEPSEEK_API_KEY";
|
|
518
|
+
declare const DEFAULT_DEEPSEEK_PROVIDER_BASE_URL = "https://api.deepseek.com";
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/deepseek/model-catalog-refresh.d.ts
|
|
521
|
+
interface IDeepSeekModelsResponse {
|
|
522
|
+
data?: Array<{
|
|
523
|
+
id?: string;
|
|
524
|
+
object?: string;
|
|
525
|
+
owned_by?: string;
|
|
526
|
+
}>;
|
|
527
|
+
}
|
|
528
|
+
interface IDeepSeekFetchInit {
|
|
529
|
+
headers?: Record<string, string>;
|
|
530
|
+
}
|
|
531
|
+
interface IDeepSeekFetchResponse {
|
|
532
|
+
ok: boolean;
|
|
533
|
+
status: number;
|
|
534
|
+
json: () => Promise<IDeepSeekModelsResponse>;
|
|
535
|
+
}
|
|
536
|
+
type TDeepSeekFetch = (url: string, init?: IDeepSeekFetchInit) => Promise<IDeepSeekFetchResponse>;
|
|
537
|
+
declare function refreshDeepSeekModelCatalog(profile: IProviderProfileConfig, fetcher?: TDeepSeekFetch): Promise<IProviderModelCatalog>;
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/deepseek/model-catalog.d.ts
|
|
540
|
+
declare const DEEPSEEK_MODEL_CATALOG_SOURCE_URL = "https://api-docs.deepseek.com/quick_start/pricing";
|
|
541
|
+
declare const DEEPSEEK_MODEL_LIST_SOURCE_URL = "https://api-docs.deepseek.com/api/list-models";
|
|
542
|
+
declare const DEEPSEEK_MODEL_LAST_VERIFIED_AT = "2026-05-07";
|
|
543
|
+
declare const DEEPSEEK_DEPRECATED_ALIAS_RETIREMENT_DATE = "2026-07-24";
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/gemini/model-catalog-refresh.d.ts
|
|
546
|
+
interface IGeminiModelInfo {
|
|
547
|
+
name?: string;
|
|
548
|
+
displayName?: string;
|
|
549
|
+
description?: string;
|
|
550
|
+
inputTokenLimit?: number;
|
|
551
|
+
outputTokenLimit?: number;
|
|
552
|
+
supportedGenerationMethods?: string[];
|
|
553
|
+
}
|
|
554
|
+
interface IGeminiModelsResponse {
|
|
555
|
+
models?: IGeminiModelInfo[];
|
|
556
|
+
nextPageToken?: string;
|
|
557
|
+
}
|
|
558
|
+
interface IGeminiFetchInit {
|
|
559
|
+
headers?: Record<string, string>;
|
|
560
|
+
}
|
|
561
|
+
interface IGeminiFetchResponse {
|
|
562
|
+
ok: boolean;
|
|
563
|
+
status: number;
|
|
564
|
+
json: () => Promise<IGeminiModelsResponse>;
|
|
565
|
+
}
|
|
566
|
+
type TGeminiFetch = (url: string, init?: IGeminiFetchInit) => Promise<IGeminiFetchResponse>;
|
|
567
|
+
declare function refreshGeminiModelCatalog(profile: IProviderProfileConfig, fetcher?: TGeminiFetch): Promise<IProviderModelCatalog>;
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region src/gemini/types.d.ts
|
|
570
|
+
/**
|
|
571
|
+
* Valid provider option value types
|
|
572
|
+
*/
|
|
573
|
+
type TGeminiProviderOptionValue = string | number | boolean | undefined | null | IExecutor | TProviderOptionValueBase | TGeminiProviderOptionValue[] | {
|
|
574
|
+
[key: string]: TGeminiProviderOptionValue;
|
|
575
|
+
};
|
|
576
|
+
interface IGeminiSafetySetting {
|
|
577
|
+
[key: string]: TGeminiProviderOptionValue;
|
|
578
|
+
category: string;
|
|
579
|
+
threshold: string;
|
|
580
|
+
method?: string;
|
|
581
|
+
}
|
|
582
|
+
interface IGeminiThinkingConfig {
|
|
583
|
+
[key: string]: TGeminiProviderOptionValue;
|
|
584
|
+
includeThoughts?: boolean;
|
|
585
|
+
thinkingBudget?: number;
|
|
586
|
+
thinkingLevel?: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Gemini API provider options
|
|
590
|
+
*/
|
|
591
|
+
interface IGeminiProviderOptions {
|
|
592
|
+
/**
|
|
593
|
+
* Additional provider-specific options
|
|
594
|
+
*/
|
|
595
|
+
[key: string]: TGeminiProviderOptionValue;
|
|
596
|
+
/** Google AI API key */
|
|
597
|
+
apiKey: string;
|
|
598
|
+
/**
|
|
599
|
+
* Default model used when chat options do not provide a model.
|
|
600
|
+
*/
|
|
601
|
+
defaultModel?: string;
|
|
602
|
+
/**
|
|
603
|
+
* Response MIME type
|
|
604
|
+
* - 'text/plain': Plain text response (default)
|
|
605
|
+
* - 'application/json': JSON response format
|
|
606
|
+
*/
|
|
607
|
+
responseMimeType?: 'text/plain' | 'application/json';
|
|
608
|
+
/**
|
|
609
|
+
* Response schema for JSON output (only used when responseMimeType is 'application/json')
|
|
610
|
+
*/
|
|
611
|
+
responseSchema?: Record<string, TGeminiProviderOptionValue>;
|
|
612
|
+
/**
|
|
613
|
+
* JSON Schema response format for current Gemini structured output support.
|
|
614
|
+
* Mutually exclusive with responseSchema.
|
|
615
|
+
*/
|
|
616
|
+
responseJsonSchema?: Record<string, TGeminiProviderOptionValue>;
|
|
617
|
+
/**
|
|
618
|
+
* Default safety settings applied to every direct Gemini request.
|
|
619
|
+
* Per-request google.safetySettings overrides this value.
|
|
620
|
+
*/
|
|
621
|
+
safetySettings?: IGeminiSafetySetting[];
|
|
622
|
+
/**
|
|
623
|
+
* Default thinking configuration for Gemini models that support thinking.
|
|
624
|
+
*/
|
|
625
|
+
thinkingConfig?: IGeminiThinkingConfig;
|
|
626
|
+
/**
|
|
627
|
+
* Provider-level function calling config passed through to Gemini config.
|
|
628
|
+
*/
|
|
629
|
+
toolConfig?: Record<string, TGeminiProviderOptionValue>;
|
|
630
|
+
/**
|
|
631
|
+
* Optional default response modalities for Gemini generation config.
|
|
632
|
+
* Example: ['TEXT', 'IMAGE']
|
|
633
|
+
*/
|
|
634
|
+
defaultResponseModalities?: Array<'TEXT' | 'IMAGE'>;
|
|
635
|
+
/**
|
|
636
|
+
* Optional allowlist of models that support image generation/editing.
|
|
637
|
+
* If not provided, provider validates using model name heuristics.
|
|
638
|
+
*/
|
|
639
|
+
imageCapableModels?: string[];
|
|
640
|
+
/**
|
|
641
|
+
* Optional executor for handling AI requests
|
|
642
|
+
*
|
|
643
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
644
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```typescript
|
|
648
|
+
* import { LocalExecutor, RemoteExecutor } from '@robota-sdk/agent-core';
|
|
649
|
+
*
|
|
650
|
+
* // Local execution (registers this provider)
|
|
651
|
+
* const localExecutor = new LocalExecutor();
|
|
652
|
+
* localExecutor.registerProvider('gemini', new GeminiProvider({ apiKey: 'AIza...' }));
|
|
653
|
+
*
|
|
654
|
+
* // Remote execution
|
|
655
|
+
* const remoteExecutor = new RemoteExecutor({
|
|
656
|
+
* serverUrl: 'https://api.robota.io',
|
|
657
|
+
* userApiKey: 'user-token-123'
|
|
658
|
+
* });
|
|
659
|
+
*
|
|
660
|
+
* const provider = new GeminiProvider({
|
|
661
|
+
* apiKey: 'placeholder', // Required for type safety but not used
|
|
662
|
+
* executor: remoteExecutor
|
|
663
|
+
* });
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
executor?: IExecutor;
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/gemini/provider.d.ts
|
|
670
|
+
/**
|
|
671
|
+
* Gemini provider implementation for Robota
|
|
672
|
+
*
|
|
673
|
+
* IMPORTANT PROVIDER-SPECIFIC RULES:
|
|
674
|
+
* 1. This provider MUST extend BaseAIProvider from @robota-sdk/agent-core
|
|
675
|
+
* 2. Content handling for Google Gemini API:
|
|
676
|
+
* - Function calls can have content (text) along with function calls
|
|
677
|
+
* - Content can be empty string or actual text, NOT null
|
|
678
|
+
* 3. Use override keyword for all methods inherited from BaseAIProvider
|
|
679
|
+
* 4. Provider-specific API behavior should be documented here
|
|
680
|
+
*
|
|
681
|
+
* @public
|
|
682
|
+
*/
|
|
683
|
+
declare class GeminiProvider extends AbstractAIProvider implements IImageGenerationProvider {
|
|
684
|
+
readonly name: string;
|
|
685
|
+
readonly version = "1.0.0";
|
|
686
|
+
onTextDelta?: TTextDeltaCallback;
|
|
687
|
+
private readonly client?;
|
|
688
|
+
private readonly options;
|
|
689
|
+
constructor(options: IGeminiProviderOptions);
|
|
690
|
+
/** Generate response using TUniversalMessage */
|
|
691
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
692
|
+
/** Generate streaming response using TUniversalMessage */
|
|
693
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
694
|
+
/** Generate an image from a text prompt using the Gemini API. */
|
|
695
|
+
generateImage(request: IImageGenerationRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
696
|
+
/** Edit an existing image based on a text prompt using the Gemini API. */
|
|
697
|
+
editImage(request: IImageEditRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
698
|
+
/** Compose multiple images together based on a text prompt using the Gemini API. */
|
|
699
|
+
composeImage(request: IImageComposeRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
700
|
+
supportsTools(): boolean;
|
|
701
|
+
validateConfig(): boolean;
|
|
702
|
+
dispose(): Promise<void>;
|
|
703
|
+
private withProviderCallbacks;
|
|
704
|
+
}
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/gemini/provider-definition.d.ts
|
|
707
|
+
declare const DEFAULT_GEMINI_PROVIDER_API_KEY_ENV = "GEMINI_API_KEY";
|
|
708
|
+
declare const DEFAULT_GEMINI_PROVIDER_API_KEY_REFERENCE = "$ENV:GEMINI_API_KEY";
|
|
709
|
+
declare const DEFAULT_GEMINI_PROVIDER_MODEL = "gemini-3-flash-preview";
|
|
710
|
+
declare const GEMINI_MODEL_SOURCE_URL = "https://ai.google.dev/api/models";
|
|
711
|
+
declare const GEMINI_MODEL_LAST_VERIFIED_AT = "2026-05-04";
|
|
712
|
+
declare function createGeminiProviderDefinition(): IProviderDefinition;
|
|
713
|
+
//#endregion
|
|
714
|
+
//#region src/gemma/types.d.ts
|
|
715
|
+
type TGemmaProviderOptionValue = string | number | boolean | undefined | null | OpenAI | ILogger | IExecutor | TProviderOptionValueBase | TGemmaProviderOptionValue[] | {
|
|
716
|
+
[key: string]: TGemmaProviderOptionValue;
|
|
717
|
+
};
|
|
718
|
+
interface IGemmaProviderOptions {
|
|
719
|
+
[key: string]: TGemmaProviderOptionValue;
|
|
720
|
+
apiKey?: string;
|
|
721
|
+
baseURL?: string;
|
|
722
|
+
timeout?: number;
|
|
723
|
+
defaultModel?: string;
|
|
724
|
+
client?: OpenAI;
|
|
725
|
+
executor?: IExecutor;
|
|
726
|
+
logger?: ILogger;
|
|
727
|
+
}
|
|
728
|
+
//#endregion
|
|
729
|
+
//#region src/gemma/reasoning-projector.d.ts
|
|
730
|
+
interface IGemmaReasoningProjection {
|
|
731
|
+
rawText: string;
|
|
732
|
+
visibleText: string;
|
|
733
|
+
removedReasoning: boolean;
|
|
734
|
+
}
|
|
735
|
+
declare function projectGemmaReasoningText(rawText: string): IGemmaReasoningProjection;
|
|
736
|
+
declare class GemmaReasoningProjector {
|
|
737
|
+
private buffer;
|
|
738
|
+
private emittedVisibleText;
|
|
739
|
+
private hasRemovedReasoning;
|
|
740
|
+
get rawText(): string;
|
|
741
|
+
get removedReasoning(): boolean;
|
|
742
|
+
project(delta: string): string;
|
|
743
|
+
flush(): string;
|
|
744
|
+
private projectVisibleText;
|
|
745
|
+
}
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/shared/openai-compatible/types.d.ts
|
|
748
|
+
interface IOpenAICompatibleToolCallTextProjection {
|
|
749
|
+
visibleText: string;
|
|
750
|
+
toolCalls: IToolCall[];
|
|
751
|
+
removedToolCallText: boolean;
|
|
752
|
+
rawToolCallText?: string | undefined;
|
|
753
|
+
}
|
|
754
|
+
interface IOpenAICompatibleToolCallTextProjector {
|
|
755
|
+
project(text: string): IOpenAICompatibleToolCallTextProjection;
|
|
756
|
+
flush(): IOpenAICompatibleToolCallTextProjection;
|
|
757
|
+
}
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/gemma/tool-call-projector.d.ts
|
|
760
|
+
interface IGemmaToolCallProjectorOptions {
|
|
761
|
+
toolNames: readonly string[];
|
|
762
|
+
callIdPrefix?: string;
|
|
763
|
+
}
|
|
764
|
+
interface IGemmaToolCallProjection extends IOpenAICompatibleToolCallTextProjection {
|
|
765
|
+
rawText: string;
|
|
766
|
+
}
|
|
767
|
+
declare function createGemmaToolCallProjector(tools: readonly IToolSchema[] | undefined): GemmaToolCallProjector | undefined;
|
|
768
|
+
declare function projectGemmaToolCallText(rawText: string, options: IGemmaToolCallProjectorOptions): IGemmaToolCallProjection;
|
|
769
|
+
declare class GemmaToolCallProjector implements IOpenAICompatibleToolCallTextProjector {
|
|
770
|
+
private readonly options;
|
|
771
|
+
private buffer;
|
|
772
|
+
private emittedVisibleText;
|
|
773
|
+
private emittedRawToolCallText;
|
|
774
|
+
private readonly emittedToolCallIds;
|
|
775
|
+
constructor(options: IGemmaToolCallProjectorOptions);
|
|
776
|
+
project(delta: string): IOpenAICompatibleToolCallTextProjection;
|
|
777
|
+
flush(): IOpenAICompatibleToolCallTextProjection;
|
|
778
|
+
private projectVisibleText;
|
|
779
|
+
}
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region src/gemma/provider.d.ts
|
|
782
|
+
declare class GemmaProvider extends AbstractAIProvider {
|
|
783
|
+
readonly name = "gemma";
|
|
784
|
+
readonly version = "1.0.0";
|
|
785
|
+
private readonly client?;
|
|
786
|
+
private readonly options;
|
|
787
|
+
onTextDelta?: TTextDeltaCallback;
|
|
788
|
+
constructor(options: IGemmaProviderOptions);
|
|
789
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
790
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
791
|
+
supportsTools(): boolean;
|
|
792
|
+
getCapabilities(): IProviderCapabilities;
|
|
793
|
+
validateConfig(): boolean;
|
|
794
|
+
dispose(): Promise<void>;
|
|
795
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
796
|
+
private buildRequestParams;
|
|
797
|
+
private buildStreamingRequestParams;
|
|
798
|
+
private chatWithStreamingAssembly;
|
|
799
|
+
}
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region src/gemma/provider-definition.d.ts
|
|
802
|
+
declare const DEFAULT_GEMMA_PROVIDER_MODEL = "supergemma4-26b-uncensored-v2";
|
|
803
|
+
declare const DEFAULT_GEMMA_PROVIDER_API_KEY = "lm-studio";
|
|
804
|
+
declare const DEFAULT_GEMMA_PROVIDER_BASE_URL = "http://localhost:1234/v1";
|
|
805
|
+
declare function createGemmaProviderDefinition(): IProviderDefinition;
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/bytedance/types.d.ts
|
|
808
|
+
interface IBytedanceProviderOptions {
|
|
809
|
+
apiKey: string;
|
|
810
|
+
baseUrl: string;
|
|
811
|
+
createVideoPath?: string;
|
|
812
|
+
getVideoTaskPathTemplate?: string;
|
|
813
|
+
cancelVideoTaskPathTemplate?: string;
|
|
814
|
+
cancelVideoTaskMethod?: 'POST' | 'DELETE';
|
|
815
|
+
timeoutMs?: number;
|
|
816
|
+
defaultHeaders?: Record<string, string>;
|
|
817
|
+
}
|
|
818
|
+
interface IBytedanceTaskContentText {
|
|
819
|
+
type: 'text';
|
|
820
|
+
text: string;
|
|
821
|
+
}
|
|
822
|
+
interface IBytedanceTaskContentImageUrl {
|
|
823
|
+
type: 'image_url';
|
|
824
|
+
image_url: {
|
|
825
|
+
url: string;
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
type TBytedanceTaskContent = IBytedanceTaskContentText | IBytedanceTaskContentImageUrl;
|
|
829
|
+
interface IBytedanceCreateVideoTaskRequest {
|
|
830
|
+
model: string;
|
|
831
|
+
content: TBytedanceTaskContent[];
|
|
832
|
+
generate_audio?: boolean;
|
|
833
|
+
ratio?: string;
|
|
834
|
+
duration?: number;
|
|
835
|
+
watermark?: boolean;
|
|
836
|
+
}
|
|
837
|
+
interface IBytedanceCreateVideoTaskResponse {
|
|
838
|
+
id: string;
|
|
839
|
+
status?: string;
|
|
840
|
+
created_at?: string | number;
|
|
841
|
+
}
|
|
842
|
+
interface IBytedanceTaskContentVideoUrl {
|
|
843
|
+
type: 'video_url';
|
|
844
|
+
video_url: {
|
|
845
|
+
url: string;
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
interface IBytedanceVideoTaskResponse {
|
|
849
|
+
id: string;
|
|
850
|
+
status: string;
|
|
851
|
+
video_url?: string;
|
|
852
|
+
content?: {
|
|
853
|
+
video_url?: string;
|
|
854
|
+
};
|
|
855
|
+
mime_type?: string;
|
|
856
|
+
bytes?: number;
|
|
857
|
+
error_message?: string;
|
|
858
|
+
created_at?: string | number;
|
|
859
|
+
updated_at?: string | number;
|
|
860
|
+
}
|
|
861
|
+
interface IBytedanceApiErrorResponse {
|
|
862
|
+
code?: string;
|
|
863
|
+
message?: string;
|
|
864
|
+
details?: Record<string, TUniversalValue>;
|
|
865
|
+
}
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region src/bytedance/provider.d.ts
|
|
868
|
+
declare class BytedanceProvider implements IVideoGenerationProvider {
|
|
869
|
+
private readonly options;
|
|
870
|
+
constructor(options: IBytedanceProviderOptions);
|
|
871
|
+
createVideo(request: IVideoGenerationRequest): Promise<TProviderMediaResult<IVideoJobAccepted>>;
|
|
872
|
+
getVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
|
|
873
|
+
cancelVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
|
|
874
|
+
private buildContentPayload;
|
|
875
|
+
}
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/qwen/defaults.d.ts
|
|
878
|
+
declare const QWEN_PROVIDER_BASE_URLS: {
|
|
879
|
+
readonly singapore: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
|
|
880
|
+
readonly usVirginia: "https://dashscope-us.aliyuncs.com/compatible-mode/v1";
|
|
881
|
+
readonly beijing: "https://dashscope.aliyuncs.com/compatible-mode/v1";
|
|
882
|
+
readonly hongKong: "https://cn-hongkong.dashscope.aliyuncs.com/compatible-mode/v1";
|
|
883
|
+
};
|
|
884
|
+
type TQwenProviderRegion = keyof typeof QWEN_PROVIDER_BASE_URLS;
|
|
885
|
+
declare const QWEN_PROVIDER_RESPONSES_BASE_URLS: {
|
|
886
|
+
readonly singapore: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1";
|
|
887
|
+
readonly usVirginia: "https://dashscope-us.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1";
|
|
888
|
+
readonly beijing: "https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1";
|
|
889
|
+
};
|
|
890
|
+
type TQwenProviderResponsesRegion = keyof typeof QWEN_PROVIDER_RESPONSES_BASE_URLS;
|
|
891
|
+
declare const DEFAULT_QWEN_PROVIDER_MODEL = "qwen-plus";
|
|
892
|
+
declare const DEFAULT_QWEN_PROVIDER_API_KEY_ENV = "DASHSCOPE_API_KEY";
|
|
893
|
+
declare const DEFAULT_QWEN_PROVIDER_API_KEY_REFERENCE = "$ENV:DASHSCOPE_API_KEY";
|
|
894
|
+
declare const DEFAULT_QWEN_PROVIDER_BASE_URL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
|
|
895
|
+
declare const DEFAULT_QWEN_PROVIDER_RESPONSES_BASE_URL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1";
|
|
896
|
+
declare const QWEN_MODEL_SOURCE_URL = "https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope";
|
|
897
|
+
declare const QWEN_MODEL_LAST_VERIFIED_AT = "2026-05-04";
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/qwen/types.d.ts
|
|
900
|
+
type TQwenBuiltInWebToolName = 'web_search' | 'web_extractor';
|
|
901
|
+
interface IQwenBuiltInWebToolsOptions {
|
|
902
|
+
webSearch?: boolean;
|
|
903
|
+
webFetch?: boolean;
|
|
904
|
+
enableThinking?: boolean;
|
|
905
|
+
}
|
|
906
|
+
interface IQwenResponsesWebSearchTool {
|
|
907
|
+
type: 'web_search';
|
|
908
|
+
}
|
|
909
|
+
interface IQwenResponsesWebExtractorTool {
|
|
910
|
+
type: 'web_extractor';
|
|
911
|
+
}
|
|
912
|
+
interface IQwenResponsesFunctionTool {
|
|
913
|
+
type: 'function';
|
|
914
|
+
name: string;
|
|
915
|
+
description?: string;
|
|
916
|
+
parameters: IToolSchema['parameters'];
|
|
917
|
+
}
|
|
918
|
+
type TQwenResponsesTool = IQwenResponsesWebSearchTool | IQwenResponsesWebExtractorTool | IQwenResponsesFunctionTool;
|
|
919
|
+
interface IQwenResponsesMessageInput {
|
|
920
|
+
type?: 'message';
|
|
921
|
+
role: 'user' | 'assistant' | 'system' | 'developer';
|
|
922
|
+
content: string;
|
|
923
|
+
}
|
|
924
|
+
interface IQwenResponsesFunctionCallInput {
|
|
925
|
+
type: 'function_call';
|
|
926
|
+
call_id: string;
|
|
927
|
+
name: string;
|
|
928
|
+
arguments: string;
|
|
929
|
+
}
|
|
930
|
+
interface IQwenResponsesFunctionCallOutputInput {
|
|
931
|
+
type: 'function_call_output';
|
|
932
|
+
call_id: string;
|
|
933
|
+
output: string;
|
|
934
|
+
}
|
|
935
|
+
type TQwenResponsesInputItem = IQwenResponsesMessageInput | IQwenResponsesFunctionCallInput | IQwenResponsesFunctionCallOutputInput;
|
|
936
|
+
interface IQwenResponsesRequestBase {
|
|
937
|
+
model: string;
|
|
938
|
+
input: TQwenResponsesInputItem[];
|
|
939
|
+
tools?: TQwenResponsesTool[];
|
|
940
|
+
temperature?: number;
|
|
941
|
+
max_output_tokens?: number;
|
|
942
|
+
enable_thinking?: boolean;
|
|
943
|
+
}
|
|
944
|
+
interface IQwenResponsesRequestNonStreaming extends IQwenResponsesRequestBase {
|
|
945
|
+
stream?: false;
|
|
946
|
+
}
|
|
947
|
+
interface IQwenResponsesRequestStreaming extends IQwenResponsesRequestBase {
|
|
948
|
+
stream: true;
|
|
949
|
+
}
|
|
950
|
+
interface IQwenResponsesTextContent {
|
|
951
|
+
type: 'output_text' | 'text' | 'input_text';
|
|
952
|
+
text: string;
|
|
953
|
+
}
|
|
954
|
+
interface IQwenResponsesMessageOutputItem {
|
|
955
|
+
type: 'message';
|
|
956
|
+
content: IQwenResponsesTextContent[];
|
|
957
|
+
}
|
|
958
|
+
interface IQwenResponsesFunctionCallOutputItem {
|
|
959
|
+
type: 'function_call';
|
|
960
|
+
call_id: string;
|
|
961
|
+
name: string;
|
|
962
|
+
arguments: string;
|
|
963
|
+
id?: string;
|
|
964
|
+
status?: string;
|
|
965
|
+
}
|
|
966
|
+
interface IQwenResponsesWebSearchAction {
|
|
967
|
+
query?: string;
|
|
968
|
+
}
|
|
969
|
+
interface IQwenResponsesWebSearchOutputItem {
|
|
970
|
+
type: 'web_search_call';
|
|
971
|
+
id?: string;
|
|
972
|
+
status?: string;
|
|
973
|
+
action?: IQwenResponsesWebSearchAction;
|
|
974
|
+
}
|
|
975
|
+
interface IQwenResponsesWebExtractorOutputItem {
|
|
976
|
+
type: 'web_extractor_call';
|
|
977
|
+
id?: string;
|
|
978
|
+
status?: string;
|
|
979
|
+
goal?: string;
|
|
980
|
+
output?: string;
|
|
981
|
+
}
|
|
982
|
+
interface IQwenResponsesGenericOutputItem {
|
|
983
|
+
type: string;
|
|
984
|
+
id?: string;
|
|
985
|
+
status?: string;
|
|
986
|
+
}
|
|
987
|
+
type TQwenResponsesOutputItem = IQwenResponsesMessageOutputItem | IQwenResponsesFunctionCallOutputItem | IQwenResponsesWebSearchOutputItem | IQwenResponsesWebExtractorOutputItem | IQwenResponsesGenericOutputItem;
|
|
988
|
+
interface IQwenResponsesToolUsageCount {
|
|
989
|
+
count?: number;
|
|
990
|
+
}
|
|
991
|
+
interface IQwenResponsesUsage {
|
|
992
|
+
input_tokens?: number;
|
|
993
|
+
output_tokens?: number;
|
|
994
|
+
total_tokens?: number;
|
|
995
|
+
x_tools?: Record<string, IQwenResponsesToolUsageCount>;
|
|
996
|
+
}
|
|
997
|
+
interface IQwenResponsesResponse {
|
|
998
|
+
id?: string;
|
|
999
|
+
model?: string;
|
|
1000
|
+
output_text?: string;
|
|
1001
|
+
output?: TQwenResponsesOutputItem[];
|
|
1002
|
+
usage?: IQwenResponsesUsage;
|
|
1003
|
+
status?: string;
|
|
1004
|
+
}
|
|
1005
|
+
interface IQwenResponsesTextDeltaEvent {
|
|
1006
|
+
type: 'response.output_text.delta';
|
|
1007
|
+
delta: string;
|
|
1008
|
+
}
|
|
1009
|
+
interface IQwenResponsesCompletedEvent {
|
|
1010
|
+
type: 'response.completed';
|
|
1011
|
+
response: IQwenResponsesResponse;
|
|
1012
|
+
}
|
|
1013
|
+
interface IQwenResponsesOutputItemDoneEvent {
|
|
1014
|
+
type: 'response.output_item.done';
|
|
1015
|
+
item: TQwenResponsesOutputItem;
|
|
1016
|
+
}
|
|
1017
|
+
interface IQwenResponsesErrorEvent {
|
|
1018
|
+
type: 'response.error' | 'response.failed';
|
|
1019
|
+
message?: string;
|
|
1020
|
+
error?: {
|
|
1021
|
+
message?: string;
|
|
1022
|
+
};
|
|
1023
|
+
response?: {
|
|
1024
|
+
error?: {
|
|
1025
|
+
message?: string;
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
interface IQwenResponsesWebSearchEvent {
|
|
1030
|
+
type: 'response.web_search_call.in_progress' | 'response.web_search_call.searching' | 'response.web_search_call.completed';
|
|
1031
|
+
}
|
|
1032
|
+
interface IQwenResponsesGenericEvent {
|
|
1033
|
+
type: string;
|
|
1034
|
+
item?: TQwenResponsesOutputItem;
|
|
1035
|
+
response?: IQwenResponsesResponse;
|
|
1036
|
+
}
|
|
1037
|
+
type TQwenResponsesStreamEvent = IQwenResponsesTextDeltaEvent | IQwenResponsesCompletedEvent | IQwenResponsesOutputItemDoneEvent | IQwenResponsesErrorEvent | IQwenResponsesWebSearchEvent;
|
|
1038
|
+
type TQwenMessagesToResponsesInput = (messages: TUniversalMessage[]) => TQwenResponsesInputItem[];
|
|
1039
|
+
type TQwenProviderOptionValue = string | number | boolean | undefined | null | IQwenBuiltInWebToolsOptions | OpenAI | ILogger | IExecutor | TProviderOptionValueBase | TQwenProviderOptionValue[] | {
|
|
1040
|
+
[key: string]: TQwenProviderOptionValue;
|
|
1041
|
+
};
|
|
1042
|
+
interface IQwenProviderOptions {
|
|
1043
|
+
[key: string]: TQwenProviderOptionValue;
|
|
1044
|
+
apiKey?: string;
|
|
1045
|
+
baseURL?: string;
|
|
1046
|
+
responsesBaseURL?: string;
|
|
1047
|
+
timeout?: number;
|
|
1048
|
+
defaultModel?: string;
|
|
1049
|
+
builtInWebTools?: IQwenBuiltInWebToolsOptions;
|
|
1050
|
+
client?: OpenAI;
|
|
1051
|
+
executor?: IExecutor;
|
|
1052
|
+
logger?: ILogger;
|
|
1053
|
+
}
|
|
1054
|
+
//#endregion
|
|
1055
|
+
//#region src/qwen/provider.d.ts
|
|
1056
|
+
declare class QwenProvider extends AbstractAIProvider {
|
|
1057
|
+
readonly name = "qwen";
|
|
1058
|
+
readonly version = "1.0.0";
|
|
1059
|
+
private readonly client?;
|
|
1060
|
+
private readonly responsesClient?;
|
|
1061
|
+
private readonly options;
|
|
1062
|
+
private readonly responseParser;
|
|
1063
|
+
onTextDelta?: TTextDeltaCallback;
|
|
1064
|
+
constructor(options: IQwenProviderOptions);
|
|
1065
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
1066
|
+
private chatViaExecutor;
|
|
1067
|
+
private chatViaResponsesApi;
|
|
1068
|
+
private chatViaChatCompletions;
|
|
1069
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
1070
|
+
supportsTools(): boolean;
|
|
1071
|
+
getCapabilities(): import("@robota-sdk/agent-core").IProviderCapabilities;
|
|
1072
|
+
validateConfig(): boolean;
|
|
1073
|
+
dispose(): Promise<void>;
|
|
1074
|
+
private buildRequestParams;
|
|
1075
|
+
private buildStreamingRequestParams;
|
|
1076
|
+
private shouldUseResponsesApi;
|
|
1077
|
+
private getClient;
|
|
1078
|
+
private getResponsesClient;
|
|
1079
|
+
}
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/qwen/provider-definition.d.ts
|
|
1082
|
+
declare function createQwenProviderDefinition(): IProviderDefinition;
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region src/qwen/model-catalog-refresh.d.ts
|
|
1085
|
+
interface IQwenModelsResponse {
|
|
1086
|
+
data?: Array<{
|
|
1087
|
+
id?: string;
|
|
1088
|
+
object?: string;
|
|
1089
|
+
owned_by?: string;
|
|
1090
|
+
}>;
|
|
1091
|
+
}
|
|
1092
|
+
interface IQwenFetchInit {
|
|
1093
|
+
headers?: Record<string, string>;
|
|
1094
|
+
}
|
|
1095
|
+
interface IQwenFetchResponse {
|
|
1096
|
+
ok: boolean;
|
|
1097
|
+
status: number;
|
|
1098
|
+
json: () => Promise<IQwenModelsResponse>;
|
|
1099
|
+
}
|
|
1100
|
+
type TQwenFetch = (url: string, init?: IQwenFetchInit) => Promise<IQwenFetchResponse>;
|
|
1101
|
+
declare function refreshQwenModelCatalog(profile: IProviderProfileConfig, fetcher?: TQwenFetch): Promise<IProviderModelCatalog>;
|
|
1102
|
+
//#endregion
|
|
1103
|
+
export { ANTHROPIC_MODEL_LAST_VERIFIED_AT, ANTHROPIC_MODEL_SOURCE_URL, AnthropicProvider, BytedanceProvider, DEEPSEEK_DEPRECATED_ALIAS_RETIREMENT_DATE, DEEPSEEK_MODEL_CATALOG_SOURCE_URL, DEEPSEEK_MODEL_LAST_VERIFIED_AT, DEEPSEEK_MODEL_LIST_SOURCE_URL, DEFAULT_ANTHROPIC_PROVIDER_API_KEY_ENV, DEFAULT_ANTHROPIC_PROVIDER_API_KEY_REFERENCE, DEFAULT_ANTHROPIC_PROVIDER_MODEL, DEFAULT_DEEPSEEK_PROVIDER_API_KEY_ENV, DEFAULT_DEEPSEEK_PROVIDER_API_KEY_REFERENCE, DEFAULT_DEEPSEEK_PROVIDER_BASE_URL, DEFAULT_DEEPSEEK_PROVIDER_MODEL, DEFAULT_GEMINI_PROVIDER_API_KEY_ENV, DEFAULT_GEMINI_PROVIDER_API_KEY_REFERENCE, DEFAULT_GEMINI_PROVIDER_MODEL, DEFAULT_GEMMA_PROVIDER_API_KEY, DEFAULT_GEMMA_PROVIDER_BASE_URL, DEFAULT_GEMMA_PROVIDER_MODEL, DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE, DEFAULT_OPENAI_PROVIDER_MODEL, DEFAULT_QWEN_PROVIDER_API_KEY_ENV, DEFAULT_QWEN_PROVIDER_API_KEY_REFERENCE, DEFAULT_QWEN_PROVIDER_BASE_URL, DEFAULT_QWEN_PROVIDER_MODEL, DEFAULT_QWEN_PROVIDER_RESPONSES_BASE_URL, DeepSeekProvider, GEMINI_MODEL_LAST_VERIFIED_AT, GEMINI_MODEL_SOURCE_URL, GeminiProvider, GemmaProvider, GemmaReasoningProjector, GemmaToolCallProjector, IAnthropicFetchInit, IAnthropicFetchResponse, IAnthropicModelsResponse, IAnthropicProviderOptions, IBytedanceApiErrorResponse, IBytedanceCreateVideoTaskRequest, IBytedanceCreateVideoTaskResponse, IBytedanceProviderOptions, IBytedanceTaskContentImageUrl, IBytedanceTaskContentText, IBytedanceTaskContentVideoUrl, IBytedanceVideoTaskResponse, type IDeepSeekProviderOptions, type IDeepSeekThinkingConfig, IGeminiFetchInit, IGeminiFetchResponse, IGeminiModelInfo, IGeminiModelsResponse, IGeminiProviderOptions, IGeminiSafetySetting, IGeminiThinkingConfig, IGemmaProviderOptions, IGemmaReasoningProjection, IGemmaToolCallProjection, IGemmaToolCallProjectorOptions, IOpenAIJsonSchemaDefinition, IOpenAIModelCatalogFetchInit, IOpenAIModelCatalogFetchResponse, IOpenAIModelCatalogResource, IOpenAIModelCatalogResponse, IOpenAINativeWebToolsOptions, IOpenAIProviderOptions, IOpenAIResponsesReasoningOptions, type IPayloadLogger, type IPayloadLoggerOptions, IQwenBuiltInWebToolsOptions, IQwenFetchInit, IQwenFetchResponse, IQwenModelsResponse, IQwenProviderOptions, IQwenResponsesCompletedEvent, IQwenResponsesErrorEvent, IQwenResponsesFunctionCallInput, IQwenResponsesFunctionCallOutputInput, IQwenResponsesFunctionCallOutputItem, IQwenResponsesFunctionTool, IQwenResponsesGenericEvent, IQwenResponsesGenericOutputItem, IQwenResponsesMessageInput, IQwenResponsesMessageOutputItem, IQwenResponsesOutputItemDoneEvent, IQwenResponsesRequestBase, IQwenResponsesRequestNonStreaming, IQwenResponsesRequestStreaming, IQwenResponsesResponse, IQwenResponsesTextContent, IQwenResponsesTextDeltaEvent, IQwenResponsesToolUsageCount, IQwenResponsesUsage, IQwenResponsesWebExtractorOutputItem, IQwenResponsesWebExtractorTool, IQwenResponsesWebSearchAction, IQwenResponsesWebSearchEvent, IQwenResponsesWebSearchOutputItem, IQwenResponsesWebSearchTool, IRefreshOpenAIModelCatalogOptions, OpenAIConversationAdapter, OpenAIProvider, QWEN_MODEL_LAST_VERIFIED_AT, QWEN_MODEL_SOURCE_URL, QWEN_PROVIDER_BASE_URLS, QWEN_PROVIDER_RESPONSES_BASE_URLS, QwenProvider, TAnthropicFetch, TAnthropicProviderOptionValue, TBytedanceTaskContent, type TDeepSeekProviderOptionValue, type TDeepSeekReasoningEffort, type TDeepSeekThinkingMode, TGeminiFetch, TGeminiProviderOptionValue, TGemmaProviderOptionValue, TOpenAIApiSurface, TOpenAIModelCatalogFetch, TOpenAIProviderOptionValue, TQwenBuiltInWebToolName, TQwenFetch, TQwenMessagesToResponsesInput, TQwenProviderOptionValue, TQwenProviderRegion, TQwenProviderResponsesRegion, TQwenResponsesInputItem, TQwenResponsesOutputItem, TQwenResponsesStreamEvent, TQwenResponsesTool, createAnthropicProvider, createAnthropicProviderDefinition, createDeepSeekProviderDefinition, createGeminiProviderDefinition, createGemmaProviderDefinition, createGemmaToolCallProjector, createOpenAIProviderDefinition, createQwenProviderDefinition, projectGemmaReasoningText, projectGemmaToolCallText, refreshAnthropicModelCatalog, refreshDeepSeekModelCatalog, refreshGeminiModelCatalog, refreshOpenAIModelCatalog, refreshQwenModelCatalog };
|
|
1104
|
+
//# sourceMappingURL=index.d.ts.map
|