qlogicagent 2.10.12 → 2.10.13
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/agent.js +14 -14
- package/dist/cli.js +344 -363
- package/dist/index.js +343 -362
- package/dist/orchestration.js +6 -6
- package/dist/protocol.js +1 -1
- package/dist/types/agent/agent.d.ts +1 -1
- package/dist/types/agent/tool-loop.d.ts +1 -1
- package/dist/types/agent/types.d.ts +1 -1
- package/dist/types/cli/handlers/memory-handler.d.ts +1 -0
- package/dist/types/cli/handlers/turn-handler.d.ts +1 -1
- package/dist/types/cli/tool-bootstrap.d.ts +3 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/llm/index.d.ts +1 -1
- package/dist/types/orchestration/tool-cascade.d.ts +2 -2
- package/dist/types/protocol/wire/gateway-rpc.d.ts +14 -0
- package/dist/types/runtime/execution/dream-agent.d.ts +1 -1
- package/dist/types/runtime/execution/forked-agent.d.ts +1 -1
- package/dist/types/runtime/hooks/context-compression.d.ts +1 -1
- package/dist/types/runtime/session/session-persistence.d.ts +1 -1
- package/package.json +3 -2
- package/dist/types/provider-core/adapters/aliyun-oss-file-upload-adapter.d.ts +0 -44
- package/dist/types/provider-core/adapters/gemini-file-upload-adapter.d.ts +0 -26
- package/dist/types/provider-core/adapters/hub-oss-file-upload-adapter.d.ts +0 -29
- package/dist/types/provider-core/adapters/index.d.ts +0 -10
- package/dist/types/provider-core/adapters/openai-file-upload-adapter.d.ts +0 -38
- package/dist/types/provider-core/adapters/volcengine-file-upload-adapter.d.ts +0 -24
- package/dist/types/provider-core/builtin-providers.d.ts +0 -8
- package/dist/types/provider-core/constants.d.ts +0 -1
- package/dist/types/provider-core/credentials.d.ts +0 -1
- package/dist/types/provider-core/debug-transport.d.ts +0 -12
- package/dist/types/provider-core/errors.d.ts +0 -11
- package/dist/types/provider-core/events.d.ts +0 -48
- package/dist/types/provider-core/file-upload-service.d.ts +0 -68
- package/dist/types/provider-core/gemini-schema-utils.d.ts +0 -17
- package/dist/types/provider-core/index.d.ts +0 -37
- package/dist/types/provider-core/llm-client.d.ts +0 -43
- package/dist/types/provider-core/media-client.d.ts +0 -42
- package/dist/types/provider-core/media-transport.d.ts +0 -176
- package/dist/types/provider-core/media.d.ts +0 -2
- package/dist/types/provider-core/model-detection.d.ts +0 -22
- package/dist/types/provider-core/paths.d.ts +0 -2
- package/dist/types/provider-core/provider-def.d.ts +0 -220
- package/dist/types/provider-core/provider-registry.d.ts +0 -50
- package/dist/types/provider-core/provider-tool-api.d.ts +0 -44
- package/dist/types/provider-core/provider-variant-resolver.d.ts +0 -35
- package/dist/types/provider-core/retry.d.ts +0 -37
- package/dist/types/provider-core/transport.d.ts +0 -281
- package/dist/types/provider-core/transports/anthropic-messages.d.ts +0 -65
- package/dist/types/provider-core/transports/gemini-cache-api.d.ts +0 -86
- package/dist/types/provider-core/transports/gemini-file-api.d.ts +0 -90
- package/dist/types/provider-core/transports/gemini-generatecontent.d.ts +0 -56
- package/dist/types/provider-core/transports/gemini-lyria-realtime.d.ts +0 -117
- package/dist/types/provider-core/transports/gemini-media.d.ts +0 -53
- package/dist/types/provider-core/transports/media-resolve.d.ts +0 -50
- package/dist/types/provider-core/transports/minimax-media.d.ts +0 -56
- package/dist/types/provider-core/transports/openai-chat.d.ts +0 -81
- package/dist/types/provider-core/transports/openai-media.d.ts +0 -24
- package/dist/types/provider-core/transports/openai-responses.d.ts +0 -63
- package/dist/types/provider-core/transports/qwen-media.d.ts +0 -59
- package/dist/types/provider-core/transports/realtime-transport.d.ts +0 -183
- package/dist/types/provider-core/transports/volcengine-grounding.d.ts +0 -58
- package/dist/types/provider-core/transports/volcengine-media.d.ts +0 -94
- package/dist/types/provider-core/transports/volcengine-responses.d.ts +0 -64
- package/dist/types/provider-core/transports/zhipu-media.d.ts +0 -82
- package/dist/types/provider-core/transports/zhipu-tool-api.d.ts +0 -35
- package/dist/types/provider-core/wire-types.d.ts +0 -51
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anthropic Messages TransportSSE streaming for Claude API.
|
|
3
|
-
*
|
|
4
|
-
* Aligned with CC (claude-code-haha) src/services/api/claude.ts:
|
|
5
|
-
* - cache_control ephemeral injection on system prompt blocks
|
|
6
|
-
* - ensureToolResultPairing() conversation repair before every request
|
|
7
|
-
* - Retry with exponential backoff on transient errors (429/529/overloaded)
|
|
8
|
-
* - Non-streaming fallback when stream errors out
|
|
9
|
-
* - 90s idle watchdog timeout for silently dropped connections
|
|
10
|
-
* - Adaptive/budget thinking with temperature omit
|
|
11
|
-
* - Cache token extraction with >0 guard (CC updateUsage parity)
|
|
12
|
-
* - signature_delta handling for thinking blocks
|
|
13
|
-
*/
|
|
14
|
-
import type { LLMChunk, LLMRequest, LLMTransport } from "../transport.js";
|
|
15
|
-
import type { ProviderQuirks } from "../provider-def.js";
|
|
16
|
-
import type { FileUploadAdapter } from "../file-upload-service.js";
|
|
17
|
-
export interface AnthropicTransportConfig {
|
|
18
|
-
baseUrl: string;
|
|
19
|
-
/** anthropic-version header (default "2023-06-01") */
|
|
20
|
-
apiVersion?: string;
|
|
21
|
-
/** Per-request timeout in ms (default 180_000) */
|
|
22
|
-
timeoutMs?: number;
|
|
23
|
-
/** Stream idle watchdog timeout in ms (default 90_000, CC parity) */
|
|
24
|
-
streamIdleTimeoutMs?: number;
|
|
25
|
-
/** Enable prompt caching via cache_control ephemeral (default true) */
|
|
26
|
-
enablePromptCaching?: boolean;
|
|
27
|
-
/** Max retry attempts on transient errors (default 3) */
|
|
28
|
-
maxRetries?: number;
|
|
29
|
-
/** Omit temperature when it equals 0MiniMax rejects temperature=0 */
|
|
30
|
-
omitZeroTemperature?: boolean;
|
|
31
|
-
/** Provider-specific quirks for conditional logic (CC/altcode parity) */
|
|
32
|
-
quirks?: ProviderQuirks;
|
|
33
|
-
/** File upload adapter (Hub OSS relay for Anthropic). */
|
|
34
|
-
fileUploadAdapter?: FileUploadAdapter;
|
|
35
|
-
}
|
|
36
|
-
export declare class AnthropicMessagesTransport implements LLMTransport {
|
|
37
|
-
private baseUrl;
|
|
38
|
-
private apiVersion;
|
|
39
|
-
private timeoutMs;
|
|
40
|
-
private streamIdleTimeoutMs;
|
|
41
|
-
private enablePromptCaching;
|
|
42
|
-
private maxRetries;
|
|
43
|
-
private omitZeroTemperature;
|
|
44
|
-
private quirks;
|
|
45
|
-
private fileUploadAdapter?;
|
|
46
|
-
constructor(config: AnthropicTransportConfig);
|
|
47
|
-
stream(request: LLMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<LLMChunk>;
|
|
48
|
-
/**
|
|
49
|
-
* Stream with idle watchdog timer (CC parity: 90s default).
|
|
50
|
-
* Throws if no chunks received for streamIdleTimeoutMs.
|
|
51
|
-
*/
|
|
52
|
-
private streamWithWatchdog;
|
|
53
|
-
/**
|
|
54
|
-
* Non-streaming fallback (CC executeNonStreamingRequest parity).
|
|
55
|
-
* Used when streaming fails after all retries.
|
|
56
|
-
* Caps max_tokens at 64K and adjusts thinking budget accordingly.
|
|
57
|
-
*/
|
|
58
|
-
private nonStreamingFallback;
|
|
59
|
-
/**
|
|
60
|
-
* Convert a non-streaming API response to LLMChunk sequence.
|
|
61
|
-
*/
|
|
62
|
-
private mapNonStreamingResponse;
|
|
63
|
-
private parseSSEStream;
|
|
64
|
-
private mapEvent;
|
|
65
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GeminiCacheAPI 鈥?Explicit Context Caching for Gemini generateContent.
|
|
3
|
-
*
|
|
4
|
-
* Manages named cached content resources that can be referenced in
|
|
5
|
-
* generateContent requests via the `cachedContent` field.
|
|
6
|
-
*
|
|
7
|
-
* REST endpoints:
|
|
8
|
-
* POST /v1beta/cachedContents 鈥?create cache
|
|
9
|
-
* GET /v1beta/cachedContents 鈥?list caches
|
|
10
|
-
* GET /v1beta/cachedContents/{name} 鈥?get cache metadata
|
|
11
|
-
* PATCH /v1beta/cachedContents/{name} 鈥?update TTL
|
|
12
|
-
* DELETE /v1beta/cachedContents/{name} 鈥?delete cache
|
|
13
|
-
*
|
|
14
|
-
* Minimum cacheable content: 1024 tokens (Flash) / 4096 tokens (Pro).
|
|
15
|
-
* TTL default: 1 hour. Storage: ~$1.00/hour/MTok (Flash series).
|
|
16
|
-
*
|
|
17
|
-
* Docs: https://ai.google.dev/gemini-api/docs/caching
|
|
18
|
-
*/
|
|
19
|
-
export interface GeminiCacheCreateOptions {
|
|
20
|
-
/** Model to use, e.g. "models/gemini-3-flash-preview" */
|
|
21
|
-
model: string;
|
|
22
|
-
/** Contents to cache (same format as generateContent contents) */
|
|
23
|
-
contents: Array<Record<string, unknown>>;
|
|
24
|
-
/** Optional system instruction to include in cache */
|
|
25
|
-
systemInstruction?: Record<string, unknown>;
|
|
26
|
-
/** Time-to-live, e.g. "300s" for 5 minutes. Default: "3600s" (1 hour) */
|
|
27
|
-
ttl?: string;
|
|
28
|
-
/** Human-readable name for identifying the cache */
|
|
29
|
-
displayName?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface GeminiCachedContent {
|
|
32
|
-
/** Resource name, e.g. "cachedContents/abc123" */
|
|
33
|
-
name: string;
|
|
34
|
-
/** Model this cache is bound to */
|
|
35
|
-
model: string;
|
|
36
|
-
/** Display name (if set) */
|
|
37
|
-
displayName?: string;
|
|
38
|
-
/** Token usage metadata */
|
|
39
|
-
usageMetadata?: {
|
|
40
|
-
totalTokenCount?: number;
|
|
41
|
-
};
|
|
42
|
-
/** Creation time (ISO 8601) */
|
|
43
|
-
createTime?: string;
|
|
44
|
-
/** Last update time (ISO 8601) */
|
|
45
|
-
updateTime?: string;
|
|
46
|
-
/** Expiration time (ISO 8601) */
|
|
47
|
-
expireTime?: string;
|
|
48
|
-
}
|
|
49
|
-
export declare class GeminiCacheAPI {
|
|
50
|
-
private baseUrl;
|
|
51
|
-
private timeoutMs;
|
|
52
|
-
constructor(config: {
|
|
53
|
-
baseUrl: string;
|
|
54
|
-
timeoutMs?: number;
|
|
55
|
-
});
|
|
56
|
-
/**
|
|
57
|
-
* Create a new cached content resource.
|
|
58
|
-
* The cache name returned can be passed as `cachedContent` in generateContent.
|
|
59
|
-
*/
|
|
60
|
-
createCache(options: GeminiCacheCreateOptions, apiKey: string, signal?: AbortSignal): Promise<GeminiCachedContent>;
|
|
61
|
-
/**
|
|
62
|
-
* Get metadata for a cached content resource.
|
|
63
|
-
*/
|
|
64
|
-
getCache(name: string, apiKey: string, signal?: AbortSignal): Promise<GeminiCachedContent>;
|
|
65
|
-
/**
|
|
66
|
-
* List all cached content resources.
|
|
67
|
-
*/
|
|
68
|
-
listCaches(apiKey: string, options?: {
|
|
69
|
-
pageSize?: number;
|
|
70
|
-
pageToken?: string;
|
|
71
|
-
}, signal?: AbortSignal): Promise<{
|
|
72
|
-
cachedContents: GeminiCachedContent[];
|
|
73
|
-
nextPageToken?: string;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Update a cache's TTL or expiration time.
|
|
77
|
-
*/
|
|
78
|
-
updateCache(name: string, update: {
|
|
79
|
-
ttl?: string;
|
|
80
|
-
expireTime?: string;
|
|
81
|
-
}, apiKey: string, signal?: AbortSignal): Promise<GeminiCachedContent>;
|
|
82
|
-
/**
|
|
83
|
-
* Delete a cached content resource.
|
|
84
|
-
*/
|
|
85
|
-
deleteCache(name: string, apiKey: string, signal?: AbortSignal): Promise<void>;
|
|
86
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GeminiFileAPI 鈥?Gemini File API for uploading and managing files.
|
|
3
|
-
*
|
|
4
|
-
* Files uploaded via this API can be referenced in generateContent requests
|
|
5
|
-
* using `file_data: { file_uri, mime_type }` parts.
|
|
6
|
-
*
|
|
7
|
-
* Upload uses the resumable upload protocol (2-step):
|
|
8
|
-
* 1. POST /upload/v1beta/files 鈫?get upload URL (response header)
|
|
9
|
-
* 2. PUT {upload_url} with file bytes 鈫?get file info
|
|
10
|
-
*
|
|
11
|
-
* Other operations:
|
|
12
|
-
* GET /v1beta/files 鈥?list files
|
|
13
|
-
* GET /v1beta/files/{name} 鈥?get file metadata
|
|
14
|
-
* DELETE /v1beta/files/{name} 鈥?delete file
|
|
15
|
-
*
|
|
16
|
-
* Files expire after 48 hours. Max 2GB per file, 20GB per project.
|
|
17
|
-
*
|
|
18
|
-
* Docs: https://ai.google.dev/gemini-api/docs/files
|
|
19
|
-
*/
|
|
20
|
-
export interface GeminiFileInfo {
|
|
21
|
-
/** Resource name, e.g. "files/abc123" */
|
|
22
|
-
name: string;
|
|
23
|
-
/** Display name (set during upload) */
|
|
24
|
-
displayName?: string;
|
|
25
|
-
/** MIME type */
|
|
26
|
-
mimeType: string;
|
|
27
|
-
/** File size in bytes */
|
|
28
|
-
sizeBytes?: string;
|
|
29
|
-
/** File URI for use in generateContent, e.g. "https://generativelanguage.googleapis.com/v1beta/files/abc123" */
|
|
30
|
-
uri: string;
|
|
31
|
-
/** Processing state: PROCESSING | ACTIVE | FAILED */
|
|
32
|
-
state: string;
|
|
33
|
-
/** Creation time (ISO 8601) */
|
|
34
|
-
createTime?: string;
|
|
35
|
-
/** Last update time (ISO 8601) */
|
|
36
|
-
updateTime?: string;
|
|
37
|
-
/** Expiration time (ISO 8601) */
|
|
38
|
-
expirationTime?: string;
|
|
39
|
-
/** Error info if state is FAILED */
|
|
40
|
-
error?: {
|
|
41
|
-
code: number;
|
|
42
|
-
message: string;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export declare class GeminiFileAPI {
|
|
46
|
-
private baseUrl;
|
|
47
|
-
private timeoutMs;
|
|
48
|
-
constructor(config: {
|
|
49
|
-
baseUrl: string;
|
|
50
|
-
timeoutMs?: number;
|
|
51
|
-
});
|
|
52
|
-
/**
|
|
53
|
-
* Upload a file using the resumable upload protocol.
|
|
54
|
-
*
|
|
55
|
-
* Step 1: Initiate upload 鈫?get upload URL from response header
|
|
56
|
-
* Step 2: Upload bytes to that URL 鈫?get file metadata
|
|
57
|
-
*
|
|
58
|
-
* @returns GeminiFileInfo with .uri for use in generateContent
|
|
59
|
-
*/
|
|
60
|
-
uploadFile(file: Blob | Buffer, apiKey: string, options?: {
|
|
61
|
-
mimeType?: string;
|
|
62
|
-
displayName?: string;
|
|
63
|
-
}, signal?: AbortSignal): Promise<GeminiFileInfo>;
|
|
64
|
-
/**
|
|
65
|
-
* Wait for a file to finish processing (state 鈫?ACTIVE).
|
|
66
|
-
* Some file types (video, audio) require server-side processing.
|
|
67
|
-
*/
|
|
68
|
-
waitForProcessing(name: string, apiKey: string, options?: {
|
|
69
|
-
pollIntervalMs?: number;
|
|
70
|
-
maxWaitMs?: number;
|
|
71
|
-
}): Promise<GeminiFileInfo>;
|
|
72
|
-
/**
|
|
73
|
-
* Get metadata for an uploaded file.
|
|
74
|
-
*/
|
|
75
|
-
getFile(name: string, apiKey: string, signal?: AbortSignal): Promise<GeminiFileInfo>;
|
|
76
|
-
/**
|
|
77
|
-
* List uploaded files.
|
|
78
|
-
*/
|
|
79
|
-
listFiles(apiKey: string, options?: {
|
|
80
|
-
pageSize?: number;
|
|
81
|
-
pageToken?: string;
|
|
82
|
-
}, signal?: AbortSignal): Promise<{
|
|
83
|
-
files: GeminiFileInfo[];
|
|
84
|
-
nextPageToken?: string;
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* Delete an uploaded file.
|
|
88
|
-
*/
|
|
89
|
-
deleteFile(name: string, apiKey: string, signal?: AbortSignal): Promise<void>;
|
|
90
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini generateContent TransportNative Gemini API streaming implementation.
|
|
3
|
-
*
|
|
4
|
-
* Targets Gemini 3 series exclusively (3.1 Pro, 3 Flash, 3.1 Flash-Lite).
|
|
5
|
-
* Uses the native Gemini REST API instead of the OpenAI compatibility layer,
|
|
6
|
-
* unlocking Gemini-exclusive features unavailable via the compat endpoint:
|
|
7
|
-
* - thinkingConfig (thinkingLevelG3 native control)
|
|
8
|
-
* - Google Search / Maps Grounding
|
|
9
|
-
* - Code Execution
|
|
10
|
-
* - Safety Settings fine-grained control
|
|
11
|
-
* - Thought Signatures for multi-turn reasoning continuity
|
|
12
|
-
* - URL Context / File Search
|
|
13
|
-
* - systemInstruction top-level field
|
|
14
|
-
*
|
|
15
|
-
* Streaming endpoint: POST .../models/{model}:streamGenerateContent?alt=sse
|
|
16
|
-
* Non-streaming: POST .../models/{model}:generateContent
|
|
17
|
-
* Auth: x-goog-api-key header
|
|
18
|
-
*
|
|
19
|
-
* Protocol reference: https://ai.google.dev/gemini-api/docs
|
|
20
|
-
* Aligned with gemini-ProviderMax.md native protocol strategy.
|
|
21
|
-
*/
|
|
22
|
-
import type { LLMChunk, LLMRequest, LLMTransport } from "../transport.js";
|
|
23
|
-
import type { ProviderQuirks } from "../provider-def.js";
|
|
24
|
-
import type { FileUploadAdapter } from "../file-upload-service.js";
|
|
25
|
-
export interface GeminiGenerateContentTransportConfig {
|
|
26
|
-
/** Base URL, e.g. "https://generativelanguage.googleapis.com/v1beta" */
|
|
27
|
-
baseUrl: string;
|
|
28
|
-
/** Per-request timeout in ms (default 180_000) */
|
|
29
|
-
timeoutMs?: number;
|
|
30
|
-
/** Provider-specific quirks */
|
|
31
|
-
quirks?: ProviderQuirks;
|
|
32
|
-
/** File upload adapter for resolving local media URLs via upload instead of base64. */
|
|
33
|
-
fileUploadAdapter?: FileUploadAdapter;
|
|
34
|
-
}
|
|
35
|
-
export declare class GeminiGenerateContentTransport implements LLMTransport {
|
|
36
|
-
private baseUrl;
|
|
37
|
-
private timeoutMs;
|
|
38
|
-
private quirks;
|
|
39
|
-
private fileUploadAdapter?;
|
|
40
|
-
constructor(config: GeminiGenerateContentTransportConfig);
|
|
41
|
-
stream(request: LLMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<LLMChunk>;
|
|
42
|
-
private buildRequestBody;
|
|
43
|
-
private buildTools;
|
|
44
|
-
private buildToolConfig;
|
|
45
|
-
private buildGenerationConfig;
|
|
46
|
-
private fetchAndStream;
|
|
47
|
-
/**
|
|
48
|
-
* Parse SSE stream with 90s idle watchdog (CC parity).
|
|
49
|
-
*/
|
|
50
|
-
private parseSSEStreamWithWatchdog;
|
|
51
|
-
/**
|
|
52
|
-
* Process a single Gemini response chunk, yielding LLMChunk events.
|
|
53
|
-
*/
|
|
54
|
-
private processResponse;
|
|
55
|
-
private nonStreamingFallback;
|
|
56
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GeminiLyriaRealtimeSession 鈥?WebSocket-based real-time streaming music generation.
|
|
3
|
-
*
|
|
4
|
-
* Uses Lyria RealTime (`lyria-realtime-exp`) via the Gemini Live API WebSocket.
|
|
5
|
-
* Provides both a full interactive session API and a one-shot convenience method.
|
|
6
|
-
*
|
|
7
|
-
* Protocol:
|
|
8
|
-
* - WebSocket URL: wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1alpha.GenerativeService.BidiGenerateContent
|
|
9
|
-
* - Auth: API key as query parameter
|
|
10
|
-
* - Client 鈫?Server: setup, musicInput (weightedPrompts, musicGenerationConfig, playbackControl)
|
|
11
|
-
* - Server 鈫?Client: serverContent.audioChunks (base64 PCM s16le, 48kHz, stereo)
|
|
12
|
-
*
|
|
13
|
-
* Docs: https://ai.google.dev/gemini-api/docs/realtime-music-generation
|
|
14
|
-
*/
|
|
15
|
-
export interface WeightedPrompt {
|
|
16
|
-
text: string;
|
|
17
|
-
weight: number;
|
|
18
|
-
}
|
|
19
|
-
export type MusicScale = "C_MAJOR_A_MINOR" | "D_FLAT_MAJOR_B_FLAT_MINOR" | "D_MAJOR_B_MINOR" | "E_FLAT_MAJOR_C_MINOR" | "E_MAJOR_D_FLAT_MINOR" | "F_MAJOR_D_MINOR" | "G_FLAT_MAJOR_E_FLAT_MINOR" | "G_MAJOR_E_MINOR" | "A_FLAT_MAJOR_F_MINOR" | "A_MAJOR_G_FLAT_MINOR" | "B_FLAT_MAJOR_G_MINOR" | "B_MAJOR_A_FLAT_MINOR" | "SCALE_UNSPECIFIED";
|
|
20
|
-
export type MusicGenerationMode = "QUALITY" | "DIVERSITY" | "VOCALIZATION";
|
|
21
|
-
export interface MusicGenerationConfig {
|
|
22
|
-
bpm?: number;
|
|
23
|
-
density?: number;
|
|
24
|
-
brightness?: number;
|
|
25
|
-
guidance?: number;
|
|
26
|
-
scale?: MusicScale;
|
|
27
|
-
temperature?: number;
|
|
28
|
-
topK?: number;
|
|
29
|
-
seed?: number;
|
|
30
|
-
muteBass?: boolean;
|
|
31
|
-
muteDrums?: boolean;
|
|
32
|
-
onlyBassAndDrums?: boolean;
|
|
33
|
-
musicGenerationMode?: MusicGenerationMode;
|
|
34
|
-
audioFormat?: string;
|
|
35
|
-
sampleRateHz?: number;
|
|
36
|
-
}
|
|
37
|
-
export interface LyriaRealtimeConfig {
|
|
38
|
-
/** Base URL (REST), e.g. "https://generativelanguage.googleapis.com/v1beta" */
|
|
39
|
-
baseUrl: string;
|
|
40
|
-
}
|
|
41
|
-
export interface LyriaRealtimeSessionOptions {
|
|
42
|
-
model?: string;
|
|
43
|
-
prompts: WeightedPrompt[];
|
|
44
|
-
config?: MusicGenerationConfig;
|
|
45
|
-
}
|
|
46
|
-
/** Audio chunk received from the server. */
|
|
47
|
-
export interface AudioChunk {
|
|
48
|
-
/** Raw PCM s16le data (48kHz, stereo) */
|
|
49
|
-
data: Buffer;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Interactive Lyria RealTime session over WebSocket.
|
|
53
|
-
*
|
|
54
|
-
* Usage:
|
|
55
|
-
* const session = new GeminiLyriaRealtimeSession({ baseUrl: "..." });
|
|
56
|
-
* await session.connect(apiKey, { prompts: [{ text: "jazz", weight: 1 }] });
|
|
57
|
-
* session.onAudioChunk = (chunk) => { ... };
|
|
58
|
-
* await session.play();
|
|
59
|
-
* // ... later
|
|
60
|
-
* await session.stop();
|
|
61
|
-
* session.close();
|
|
62
|
-
*/
|
|
63
|
-
export declare class GeminiLyriaRealtimeSession {
|
|
64
|
-
private ws;
|
|
65
|
-
private wsUrl;
|
|
66
|
-
private model;
|
|
67
|
-
/** Called for each audio chunk received from the server. */
|
|
68
|
-
onAudioChunk: ((chunk: AudioChunk) => void) | null;
|
|
69
|
-
/** Called when the server reports a filtered prompt. */
|
|
70
|
-
onFilteredPrompt: ((reason: string) => void) | null;
|
|
71
|
-
/** Called on WebSocket error. */
|
|
72
|
-
onError: ((error: Error) => void) | null;
|
|
73
|
-
/** Called when the WebSocket connection closes. */
|
|
74
|
-
onClose: (() => void) | null;
|
|
75
|
-
constructor(config: LyriaRealtimeConfig);
|
|
76
|
-
/**
|
|
77
|
-
* Connect to the Lyria RealTime WebSocket and send setup + initial config.
|
|
78
|
-
*/
|
|
79
|
-
connect(apiKey: string, options: LyriaRealtimeSessionOptions): Promise<void>;
|
|
80
|
-
/** Set or update weighted prompts (smooth transition). */
|
|
81
|
-
setWeightedPrompts(prompts: WeightedPrompt[]): Promise<void>;
|
|
82
|
-
/** Set or update music generation config. */
|
|
83
|
-
setMusicGenerationConfig(config: MusicGenerationConfig): Promise<void>;
|
|
84
|
-
/** Start streaming music. */
|
|
85
|
-
play(): Promise<void>;
|
|
86
|
-
/** Pause music streaming (can resume with play). */
|
|
87
|
-
pause(): Promise<void>;
|
|
88
|
-
/** Stop music streaming (terminates the current piece). */
|
|
89
|
-
stop(): Promise<void>;
|
|
90
|
-
/** Reset model context (for BPM/scale changes). */
|
|
91
|
-
resetContext(): Promise<void>;
|
|
92
|
-
/** Close the WebSocket connection. */
|
|
93
|
-
close(): void;
|
|
94
|
-
/** Whether the session is connected. */
|
|
95
|
-
get connected(): boolean;
|
|
96
|
-
private send;
|
|
97
|
-
private handleMessage;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Generate a fixed-duration music clip using Lyria RealTime.
|
|
101
|
-
*
|
|
102
|
-
* Connects, plays for the specified duration (default 30s), collects all
|
|
103
|
-
* audio chunks, assembles into a WAV file, and returns the file path.
|
|
104
|
-
*
|
|
105
|
-
* Output: 48kHz, stereo, 16-bit PCM wrapped in WAV.
|
|
106
|
-
*/
|
|
107
|
-
export declare function generateRealtimeMusic(apiKey: string, config: LyriaRealtimeConfig, options: {
|
|
108
|
-
prompts: WeightedPrompt[];
|
|
109
|
-
durationSeconds?: number;
|
|
110
|
-
musicConfig?: MusicGenerationConfig;
|
|
111
|
-
model?: string;
|
|
112
|
-
signal?: AbortSignal;
|
|
113
|
-
onProgress?: (percent: number, status: string) => void;
|
|
114
|
-
}): Promise<{
|
|
115
|
-
filePath: string;
|
|
116
|
-
durationMs: number;
|
|
117
|
-
}>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini Media Transport 鈥?unified media generation for all Gemini media APIs.
|
|
3
|
-
*
|
|
4
|
-
* Supported media types and endpoints:
|
|
5
|
-
* image 鈥?POST /models/{model}:generateContent (responseModalities: ["TEXT","IMAGE"])
|
|
6
|
-
* video 鈥?POST /models/{model}:predictLongRunning 鈫?poll operations 鈫?download URI
|
|
7
|
-
* music 鈥?POST /models/{model}:generateContent (Lyria 3 鈥?inlineData audio)
|
|
8
|
-
* music_realtime 鈥?WebSocket session (Lyria RealTime 鈥?streaming PCM 鈫?WAV)
|
|
9
|
-
* tts 鈥?POST /models/{model}:generateContent (speechConfig 鈥?inlineData PCM)
|
|
10
|
-
* embedding 鈥?POST /models/{model}:embedContent (float vector)
|
|
11
|
-
*
|
|
12
|
-
* Auth: x-goog-api-key header for all endpoints.
|
|
13
|
-
*/
|
|
14
|
-
import type { AsyncMediaTransport, MediaRequest, MediaResult, MediaType } from "../media-transport.js";
|
|
15
|
-
export interface GeminiMediaConfig {
|
|
16
|
-
/** Base URL, e.g. "https://generativelanguage.googleapis.com/v1beta" */
|
|
17
|
-
baseUrl: string;
|
|
18
|
-
timeoutMs?: number;
|
|
19
|
-
}
|
|
20
|
-
export declare class GeminiMediaTransport implements AsyncMediaTransport {
|
|
21
|
-
readonly supportedTypes: readonly MediaType[];
|
|
22
|
-
private apiBase;
|
|
23
|
-
private timeoutMs;
|
|
24
|
-
constructor(config: GeminiMediaConfig);
|
|
25
|
-
generate(request: MediaRequest, apiKey: string, signal?: AbortSignal): Promise<MediaResult>;
|
|
26
|
-
deleteVideoTask(_taskId: string, _apiKey: string, _signal?: AbortSignal): Promise<void>;
|
|
27
|
-
listVideoTasks(_apiKey: string, _options?: {
|
|
28
|
-
after?: string;
|
|
29
|
-
limit?: number;
|
|
30
|
-
status?: string;
|
|
31
|
-
}, _signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
32
|
-
getTaskStatus(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
33
|
-
status: string;
|
|
34
|
-
task: Record<string, unknown>;
|
|
35
|
-
}>;
|
|
36
|
-
private generateImage;
|
|
37
|
-
private generateVideo;
|
|
38
|
-
private generateMusic;
|
|
39
|
-
private generateMusicRealtime;
|
|
40
|
-
private generateTTS;
|
|
41
|
-
private generateEmbedding;
|
|
42
|
-
private postJson;
|
|
43
|
-
private pollOperation;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve an image URL to inline data for the Veo API.
|
|
46
|
-
* Supports file:// paths and https:// URLs.
|
|
47
|
-
*/
|
|
48
|
-
private resolveImageData;
|
|
49
|
-
/** Extract base64 image data from generateContent response 鈫?persist to cache files. */
|
|
50
|
-
private extractInlineImages;
|
|
51
|
-
/** Extract base64 audio data from generateContent response 鈫?persist to cache files. */
|
|
52
|
-
private extractInlineAudio;
|
|
53
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Media URL Resolution 鈥?resolves local/private URLs for cloud LLM APIs.
|
|
3
|
-
*
|
|
4
|
-
* Cloud LLM APIs (OpenAI, Anthropic, DeepSeek, etc.) cannot fetch content
|
|
5
|
-
* from localhost or private networks.
|
|
6
|
-
*
|
|
7
|
-
* **Primary approach (upload-based):**
|
|
8
|
-
* Local URLs are fetched 鈫?uploaded to provider's File API or Aliyun OSS 鈫?public URL returned.
|
|
9
|
-
* This is the ONLY approach for images, video, and documents.
|
|
10
|
-
*
|
|
11
|
-
* **Audio exception (base64):**
|
|
12
|
-
* OpenAI's input_audio.data API field mandates base64 encoding.
|
|
13
|
-
* resolveMediaUrl() is retained ONLY for this case.
|
|
14
|
-
*
|
|
15
|
-
* URL-first design: the gateway stores media as HTTP URLs; this layer handles
|
|
16
|
-
* the last-mile transformation before sending to provider APIs.
|
|
17
|
-
*/
|
|
18
|
-
import type { FileUploadAdapter } from "../file-upload-service.js";
|
|
19
|
-
/** Check if a URL points to a local/private address that cloud APIs cannot reach. */
|
|
20
|
-
export declare function isLocalUrl(url: string): boolean;
|
|
21
|
-
export interface MediaResolveContext {
|
|
22
|
-
/** Provider-specific upload adapter. */
|
|
23
|
-
uploadAdapter: FileUploadAdapter;
|
|
24
|
-
/** API key for the upload. */
|
|
25
|
-
apiKey: string;
|
|
26
|
-
/** Abort signal. */
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Resolve a local URL by uploading to the provider's File API.
|
|
31
|
-
* This is the **preferred** method for all media types.
|
|
32
|
-
*
|
|
33
|
-
* Public URLs pass through unchanged.
|
|
34
|
-
* Local URLs are uploaded 鈫?public URL or file_id returned.
|
|
35
|
-
*/
|
|
36
|
-
export declare function resolveMediaUrlViaUpload(url: string, ctx: MediaResolveContext): Promise<string>;
|
|
37
|
-
/**
|
|
38
|
-
* Batch-resolve URLs via upload. Best-effort: failures return original URL.
|
|
39
|
-
*/
|
|
40
|
-
export declare function resolveMediaUrlsViaUpload(urls: string[], ctx: MediaResolveContext): Promise<string[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Resolve local audio URL to base64 data URL.
|
|
43
|
-
*
|
|
44
|
-
* ONLY for audio 鈥?OpenAI's input_audio.data API field mandates base64 encoding.
|
|
45
|
-
* There is no upload alternative for audio in the OpenAI API.
|
|
46
|
-
*
|
|
47
|
-
* For images/video/documents: ALWAYS use resolveMediaUrlViaUpload() instead.
|
|
48
|
-
* base64 is forbidden for non-audio media per project architecture rules.
|
|
49
|
-
*/
|
|
50
|
-
export declare function resolveMediaUrl(url: string, fallbackMime?: string): Promise<string>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MiniMax Media Transport 鈥?Music + Video + TTS Generation.
|
|
3
|
-
*
|
|
4
|
-
* Music: POST /v1/music_generation (sync or async poll)
|
|
5
|
-
* Video: POST /v1/video_generation (4 modes: text, image, first-last-frame, subject-ref)
|
|
6
|
-
* Video Query: GET /v1/query/video_generation?task_id=XXX
|
|
7
|
-
* File Retrieve: GET /v1/files/retrieve?file_id=XXX (get download_url)
|
|
8
|
-
*
|
|
9
|
-
* Auth: Authorization: Bearer $MINIMAX_API_KEY
|
|
10
|
-
* Docs: minimax-ProviderMax.md 搂13-18 (video), 搂21 (music), 搂24-28 (files)
|
|
11
|
-
*/
|
|
12
|
-
import type { AsyncMediaTransport, MediaRequest, MediaResult, MediaType } from "../media-transport.js";
|
|
13
|
-
export interface MiniMaxMediaConfig {
|
|
14
|
-
/** Base URL, e.g. "https://api.minimaxi.com" */
|
|
15
|
-
baseUrl: string;
|
|
16
|
-
timeoutMs?: number;
|
|
17
|
-
}
|
|
18
|
-
export declare class MiniMaxMediaTransport implements AsyncMediaTransport {
|
|
19
|
-
readonly supportedTypes: readonly MediaType[];
|
|
20
|
-
private baseUrl;
|
|
21
|
-
private timeoutMs;
|
|
22
|
-
constructor(config: MiniMaxMediaConfig);
|
|
23
|
-
generate(request: MediaRequest, apiKey: string, signal?: AbortSignal): Promise<MediaResult>;
|
|
24
|
-
private generateTTS;
|
|
25
|
-
private generateMusic;
|
|
26
|
-
private pollTask;
|
|
27
|
-
/**
|
|
28
|
-
* Generate lyrics from a text prompt via MiniMax Lyrics Generation API.
|
|
29
|
-
* POST /v1/lyrics_generation 鈥?returns structured lyrics with tags.
|
|
30
|
-
*/
|
|
31
|
-
generateLyrics(prompt: string, apiKey: string, signal?: AbortSignal): Promise<string>;
|
|
32
|
-
private generateVideo;
|
|
33
|
-
private pollVideoTask;
|
|
34
|
-
private getFileDownloadUrl;
|
|
35
|
-
/**
|
|
36
|
-
* Query a single video task by ID.
|
|
37
|
-
* GET /v1/query/video_generation?task_id=XXX
|
|
38
|
-
*/
|
|
39
|
-
getTaskStatus(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
40
|
-
status: string;
|
|
41
|
-
task: Record<string, unknown>;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* List tasks 鈥?MiniMax does not have a bulk list endpoint.
|
|
45
|
-
* Each task must be queried individually with getTaskStatus().
|
|
46
|
-
*/
|
|
47
|
-
listVideoTasks(_apiKey: string, _options?: {
|
|
48
|
-
after?: string;
|
|
49
|
-
limit?: number;
|
|
50
|
-
status?: string;
|
|
51
|
-
}, _signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
52
|
-
/**
|
|
53
|
-
* Cancel/delete is not natively supported by MiniMax video API.
|
|
54
|
-
*/
|
|
55
|
-
deleteVideoTask(_taskId: string, _apiKey: string, _signal?: AbortSignal): Promise<void>;
|
|
56
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI Chat Completions TransportSSE streaming implementation.
|
|
3
|
-
*
|
|
4
|
-
* Covers all OpenAI-compatible providers:
|
|
5
|
-
* DeepSeek, Qwen, Minimax, Moonshot, OpenRouter, etc.
|
|
6
|
-
*
|
|
7
|
-
* POST {baseUrl}/v1/chat/completions with stream: true
|
|
8
|
-
* Auth: Authorization: Bearer {apiKey}
|
|
9
|
-
*
|
|
10
|
-
* SSE format: lines prefixed with "data: ", JSON parsing per event.
|
|
11
|
-
*
|
|
12
|
-
* Adapted from admin-infer-proxy-client.ts SSE logic + Hermes openai_chat.py transport.
|
|
13
|
-
*/
|
|
14
|
-
import type { LLMChunk, LLMRequest, LLMTransport, FIMRequest, FIMChunk } from "../transport.js";
|
|
15
|
-
import type { ProviderQuirks } from "../provider-def.js";
|
|
16
|
-
import type { FileUploadAdapter } from "../file-upload-service.js";
|
|
17
|
-
export interface OpenAIChatTransportConfig {
|
|
18
|
-
baseUrl: string;
|
|
19
|
-
/** Additional headers (e.g. for specific providers) */
|
|
20
|
-
extraHeaders?: Record<string, string>;
|
|
21
|
-
/** Timeout in ms (default 180_000) */
|
|
22
|
-
timeoutMs?: number;
|
|
23
|
-
/** Whether to include stream_options (default true). Set false for providers that reject it. */
|
|
24
|
-
supportsStreamOptions?: boolean;
|
|
25
|
-
/** Whether to omit temperature when it equals 0 (e.g. Moonshot rejects 0) */
|
|
26
|
-
omitZeroTemperature?: boolean;
|
|
27
|
-
/** Provider-specific quirks (CC/altcode parity) */
|
|
28
|
-
quirks?: ProviderQuirks;
|
|
29
|
-
/** File upload adapter for resolving local media URLs via upload instead of base64. */
|
|
30
|
-
fileUploadAdapter?: FileUploadAdapter;
|
|
31
|
-
}
|
|
32
|
-
export declare class OpenAIChatTransport implements LLMTransport {
|
|
33
|
-
private baseUrl;
|
|
34
|
-
private extraHeaders;
|
|
35
|
-
private timeoutMs;
|
|
36
|
-
private supportsStreamOptions;
|
|
37
|
-
private omitZeroTemperature;
|
|
38
|
-
private quirks;
|
|
39
|
-
private fileUploadAdapter?;
|
|
40
|
-
private cumulativeReasoningLen;
|
|
41
|
-
private cumulativeContentLen;
|
|
42
|
-
constructor(config: OpenAIChatTransportConfig);
|
|
43
|
-
stream(request: LLMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<LLMChunk>;
|
|
44
|
-
private fetchAndStream;
|
|
45
|
-
/**
|
|
46
|
-
* Handle non-streaming JSON response from providers that ignore stream:true.
|
|
47
|
-
* Synthesize the same LLMChunk events a streaming response would produce.
|
|
48
|
-
*/
|
|
49
|
-
private handleNonStreamingResponse;
|
|
50
|
-
/**
|
|
51
|
-
* Parse SSE stream with 90s idle watchdog (CC parity).
|
|
52
|
-
* If no data arrives within STREAM_IDLE_TIMEOUT_MS, throw to trigger retry.
|
|
53
|
-
*/
|
|
54
|
-
private parseSSEStreamWithWatchdog;
|
|
55
|
-
private processChunk;
|
|
56
|
-
/**
|
|
57
|
-
* FIM completion via /beta/v1/completions.
|
|
58
|
-
* Only works with DeepSeek (requires supportsPrefixCompletion quirk).
|
|
59
|
-
* Non-thinking mode only; max completion 4K tokens.
|
|
60
|
-
*/
|
|
61
|
-
complete(request: FIMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<FIMChunk>;
|
|
62
|
-
/**
|
|
63
|
-
* Upload a file for use in conversations (Kimi File API).
|
|
64
|
-
* Returns a file_id that can be referenced in user messages.
|
|
65
|
-
* POST /v1/files with multipart/form-data.
|
|
66
|
-
*/
|
|
67
|
-
uploadFile(fileBlob: Blob, filename: string, purpose: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
68
|
-
fileId: string;
|
|
69
|
-
filename: string;
|
|
70
|
-
bytes: number;
|
|
71
|
-
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Get file content/statusGET /v1/files/{file_id}
|
|
74
|
-
*/
|
|
75
|
-
getFileInfo(fileId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
76
|
-
id: string;
|
|
77
|
-
filename: string;
|
|
78
|
-
bytes: number;
|
|
79
|
-
status: string;
|
|
80
|
-
}>;
|
|
81
|
-
}
|