qlogicagent 2.10.11 → 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,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File Upload Adapters 鈥?barrel export.
|
|
3
|
-
*
|
|
4
|
-
* Provider-specific implementations of the FileUploadAdapter interface.
|
|
5
|
-
*/
|
|
6
|
-
export { OpenAIFileUploadAdapter, type OpenAIFileUploadConfig } from "./openai-file-upload-adapter.js";
|
|
7
|
-
export { VolcengineFileUploadAdapter, type VolcengineFileUploadConfig } from "./volcengine-file-upload-adapter.js";
|
|
8
|
-
export { GeminiFileUploadAdapter, type GeminiFileUploadConfig } from "./gemini-file-upload-adapter.js";
|
|
9
|
-
export { HubOSSFileUploadAdapter, type HubOSSFileUploadConfig } from "./hub-oss-file-upload-adapter.js";
|
|
10
|
-
export { AliyunOSSFileUploadAdapter, type AliyunOSSFileUploadConfig, createAliyunOSSAdapterFromEnv } from "./aliyun-oss-file-upload-adapter.js";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI-compatible File Upload Adapter.
|
|
3
|
-
*
|
|
4
|
-
* Implements FileUploadAdapter for providers using the standard
|
|
5
|
-
* POST /v1/files multipart upload endpoint:
|
|
6
|
-
* - OpenAI
|
|
7
|
-
* - Kimi (Moonshot)
|
|
8
|
-
* - Minimax
|
|
9
|
-
* - Qwen (via DashScope compatible endpoint)
|
|
10
|
-
* - GLM (Zhipu)
|
|
11
|
-
* - Any OpenAI-API-compatible provider
|
|
12
|
-
*
|
|
13
|
-
* The uploaded file gets a file_id which can be referenced in messages.
|
|
14
|
-
* Some providers also return a direct download URL.
|
|
15
|
-
*/
|
|
16
|
-
import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
|
|
17
|
-
export interface OpenAIFileUploadConfig {
|
|
18
|
-
/** Base URL (e.g. "https://api.openai.com/v1" or "https://api.moonshot.cn/v1") */
|
|
19
|
-
baseUrl: string;
|
|
20
|
-
/** Provider name for result metadata. */
|
|
21
|
-
provider: string;
|
|
22
|
-
/** Extra headers to include (e.g. for Minimax group_id). */
|
|
23
|
-
extraHeaders?: Record<string, string>;
|
|
24
|
-
/** Upload purpose (default: "file-extract" for document understanding). */
|
|
25
|
-
defaultPurpose?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Whether the provider returns a download URL in the upload response.
|
|
28
|
-
* If false, constructs URL from file_id (provider-specific).
|
|
29
|
-
*/
|
|
30
|
-
returnsUrl?: boolean;
|
|
31
|
-
/** Timeout for upload request (ms). Default: 120_000. */
|
|
32
|
-
timeoutMs?: number;
|
|
33
|
-
}
|
|
34
|
-
export declare class OpenAIFileUploadAdapter implements FileUploadAdapter {
|
|
35
|
-
private readonly config;
|
|
36
|
-
constructor(config: OpenAIFileUploadConfig);
|
|
37
|
-
uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
38
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Volcengine File Upload Adapter.
|
|
3
|
-
*
|
|
4
|
-
* Wraps the Volcengine /v3/files endpoint into the unified
|
|
5
|
-
* FileUploadAdapter interface.
|
|
6
|
-
*
|
|
7
|
-
* Volcengine returns a file_id that can be used in API messages
|
|
8
|
-
* as a file reference. Files uploaded this way can be referenced in
|
|
9
|
-
* multimodal inputs via the file_id field.
|
|
10
|
-
*/
|
|
11
|
-
import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
|
|
12
|
-
export interface VolcengineFileUploadConfig {
|
|
13
|
-
/** Base URL (e.g. "https://ark.cn-beijing.volces.com/api") */
|
|
14
|
-
baseUrl: string;
|
|
15
|
-
/** Upload purpose. Default: "user_data". */
|
|
16
|
-
defaultPurpose?: string;
|
|
17
|
-
/** Timeout ms. Default: 120_000. */
|
|
18
|
-
timeoutMs?: number;
|
|
19
|
-
}
|
|
20
|
-
export declare class VolcengineFileUploadAdapter implements FileUploadAdapter {
|
|
21
|
-
private readonly config;
|
|
22
|
-
constructor(config: VolcengineFileUploadConfig);
|
|
23
|
-
uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
24
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Curated Provider Core model catalog.
|
|
3
|
-
*
|
|
4
|
-
* This is the single source used by qlogicagent direct mode and llmrouter's
|
|
5
|
-
* model catalog API. External broad catalogs are intentionally not merged in.
|
|
6
|
-
*/
|
|
7
|
-
import type { ProviderDef } from "./provider-def.js";
|
|
8
|
-
export declare const BUILTIN_PROVIDERS: ProviderDef[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const MEDIA_MAX_UPLOAD_SIZE: number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveApiKey(envVarNames: string[], env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { LLMTransport } from "./transport.js";
|
|
2
|
-
/**
|
|
3
|
-
* Check whether debug transport should be enabled.
|
|
4
|
-
*/
|
|
5
|
-
export declare function isDebugTransportEnabled(): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Create a DebugTransport decorator that wraps a base LLMTransport,
|
|
8
|
-
* logging request metadata + timing + usage to JSONL.
|
|
9
|
-
*
|
|
10
|
-
* CC parity: createDumpPromptsFetch 鈥?but vendor-agnostic via transport abstraction.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createDebugTransport(base: LLMTransport, sessionId: string): LLMTransport;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class ProviderCoreError extends Error {
|
|
2
|
-
readonly status?: number;
|
|
3
|
-
readonly code?: string;
|
|
4
|
-
readonly provider?: string;
|
|
5
|
-
constructor(message: string, opts?: {
|
|
6
|
-
status?: number;
|
|
7
|
-
code?: string;
|
|
8
|
-
provider?: string;
|
|
9
|
-
cause?: unknown;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface ProviderUsage {
|
|
2
|
-
promptTokens?: number;
|
|
3
|
-
completionTokens?: number;
|
|
4
|
-
reasoningTokens?: number;
|
|
5
|
-
cacheReadTokens?: number;
|
|
6
|
-
cacheCreationTokens?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface ProviderErrorPayload {
|
|
9
|
-
message: string;
|
|
10
|
-
code?: string;
|
|
11
|
-
status?: number;
|
|
12
|
-
provider?: string;
|
|
13
|
-
}
|
|
14
|
-
export type ProviderEvent = {
|
|
15
|
-
type: "response.created";
|
|
16
|
-
id: string;
|
|
17
|
-
model: string;
|
|
18
|
-
provider: string;
|
|
19
|
-
credentialId?: string;
|
|
20
|
-
credentialSource?: string;
|
|
21
|
-
credentialEgressMode?: string;
|
|
22
|
-
credentialEgressRegion?: string;
|
|
23
|
-
} | {
|
|
24
|
-
type: "content.delta";
|
|
25
|
-
index: number;
|
|
26
|
-
text: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: "reasoning.delta";
|
|
29
|
-
text: string;
|
|
30
|
-
} | {
|
|
31
|
-
type: "tool.call.delta";
|
|
32
|
-
id: string;
|
|
33
|
-
name?: string;
|
|
34
|
-
argumentsDelta?: string;
|
|
35
|
-
} | {
|
|
36
|
-
type: "usage.delta";
|
|
37
|
-
usage: ProviderUsage;
|
|
38
|
-
} | {
|
|
39
|
-
type: "annotation";
|
|
40
|
-
annotation: Record<string, unknown>;
|
|
41
|
-
} | {
|
|
42
|
-
type: "response.completed";
|
|
43
|
-
usage?: ProviderUsage;
|
|
44
|
-
finishReason?: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: "error";
|
|
47
|
-
error: ProviderErrorPayload;
|
|
48
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FileUploadService 鈥?Unified file upload abstraction for all LLM providers.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the base64 approach in media-resolve.ts. When a local URL is
|
|
5
|
-
* encountered, this service uploads the file to the current provider's
|
|
6
|
-
* File API and returns a public URL or file_id.
|
|
7
|
-
*
|
|
8
|
-
* Supported providers:
|
|
9
|
-
* - OpenAI-compatible (OpenAI, Kimi, Minimax, Qwen, GLM) 鈥?POST /v1/files
|
|
10
|
-
* - Volcengine 鈥?POST /v3/files
|
|
11
|
-
* - Google Gemini 鈥?Resumable upload protocol
|
|
12
|
-
*
|
|
13
|
-
* Architecture:
|
|
14
|
-
* Transport layer calls resolveLocalMedia() before sending messages.
|
|
15
|
-
* resolveLocalMedia() fetches local content and uploads to provider,
|
|
16
|
-
* returning a public URL the LLM can access.
|
|
17
|
-
*/
|
|
18
|
-
export interface FileUploadResult {
|
|
19
|
-
/** Public URL accessible by the LLM provider. */
|
|
20
|
-
url: string;
|
|
21
|
-
/** Provider-specific file identifier (for reference/deletion). */
|
|
22
|
-
fileId: string;
|
|
23
|
-
/** Original filename. */
|
|
24
|
-
filename: string;
|
|
25
|
-
/** File size in bytes. */
|
|
26
|
-
bytes: number;
|
|
27
|
-
/** MIME type of the uploaded file. */
|
|
28
|
-
mimeType: string;
|
|
29
|
-
/** Provider that stored the file. */
|
|
30
|
-
provider: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Provider-specific upload adapter.
|
|
34
|
-
* Each transport implements this to upload files to its own File API.
|
|
35
|
-
*/
|
|
36
|
-
export interface FileUploadAdapter {
|
|
37
|
-
/**
|
|
38
|
-
* Upload a file buffer and return a publicly accessible URL.
|
|
39
|
-
* @param buffer - File content
|
|
40
|
-
* @param filename - Original filename (used for MIME detection)
|
|
41
|
-
* @param mimeType - MIME type of the file
|
|
42
|
-
* @param apiKey - Provider API key
|
|
43
|
-
* @param signal - Abort signal
|
|
44
|
-
*/
|
|
45
|
-
uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
46
|
-
}
|
|
47
|
-
/** Guess MIME type from filename extension. */
|
|
48
|
-
export declare function guessMimeType(filename: string): string;
|
|
49
|
-
/** Check if a URL points to a local/private address that cloud APIs cannot reach. */
|
|
50
|
-
export declare function isLocalUrl(url: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Resolve a local URL by uploading its content to the provider's File API.
|
|
53
|
-
* Public URLs are returned as-is (the LLM API can fetch them directly).
|
|
54
|
-
*
|
|
55
|
-
* @param url - The URL to resolve (may be local or public)
|
|
56
|
-
* @param adapter - Provider-specific upload adapter
|
|
57
|
-
* @param apiKey - API key for the upload
|
|
58
|
-
* @param signal - Optional abort signal
|
|
59
|
-
* @returns Public URL accessible by the LLM
|
|
60
|
-
*/
|
|
61
|
-
export declare function resolveLocalMedia(url: string, adapter: FileUploadAdapter, apiKey: string, signal?: AbortSignal): Promise<string>;
|
|
62
|
-
/**
|
|
63
|
-
* Batch-resolve multiple URLs concurrently. Returns array in same order.
|
|
64
|
-
* Local URLs are uploaded; public URLs pass through unchanged.
|
|
65
|
-
* Supports concurrent uploads (up to `concurrency` limit, default 3).
|
|
66
|
-
* Failures throw (caller should handle).
|
|
67
|
-
*/
|
|
68
|
-
export declare function resolveLocalMediaBatch(urls: string[], adapter: FileUploadAdapter, apiKey: string, signal?: AbortSignal, concurrency?: number): Promise<string[]>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gemini JSON Schema cleaning utilities.
|
|
3
|
-
*
|
|
4
|
-
* Gemini's generateContent API rejects several standard JSON Schema keywords.
|
|
5
|
-
* This module provides a shared recursive cleaner used by:
|
|
6
|
-
* - GeminiGenerateContentTransport (tool declarations in request body)
|
|
7
|
-
* - tool-schema.ts (provider-aware schema normalization at orchestration level)
|
|
8
|
-
*
|
|
9
|
-
* Keeping a single source of truth avoids drift between the two consumers.
|
|
10
|
-
*/
|
|
11
|
-
/** Keywords that Gemini's generateContent API does not accept in tool schemas. */
|
|
12
|
-
export declare const GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS: Set<string>;
|
|
13
|
-
/**
|
|
14
|
-
* Recursively strip unsupported JSON Schema keywords from a schema object.
|
|
15
|
-
* Safe to call multiple times (idempotent).
|
|
16
|
-
*/
|
|
17
|
-
export declare function cleanSchemaForGemini(schema: unknown): unknown;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Provider layer 鈥?public API surface.
|
|
3
|
-
*
|
|
4
|
-
* Provides: ProviderDef + LLMTransport + ProviderRegistry + LLMClient factory
|
|
5
|
-
*/
|
|
6
|
-
export type { ProviderDef, ModelInfo, TransportType, AuthType, MediaCapability, MediaCapabilities, VideoCapabilities, ImageCapabilities, MusicCapabilities, TtsCapabilities, ThreeDCapabilities, SttCapabilities, EmbeddingCapabilities, VideoUnderstandingCapabilities, ImageUnderstandingCapabilities, VoiceCloneCapabilities, RerankCapabilities, DocumentParsingCapabilities, RealtimeAudioCapabilities, VideoOperation, ImageOperation, MusicOperation, TtsOperation, ThreeDOperation, ProviderVariantKind, ProviderBillingChannelKind, ProviderVariantCapability } from "./provider-def.js";
|
|
7
|
-
export type { LLMTransport, LLMRequest, LLMChunk, AccumulatedToolCall, } from "./transport.js";
|
|
8
|
-
export { accumulateToolCalls } from "./transport.js";
|
|
9
|
-
export type { ChatMessage, ChatMessageRole, ThinkingBlock, ToolCallMessage, ToolDefinition } from "./wire-types.js";
|
|
10
|
-
export type { ProviderEvent, ProviderErrorPayload, ProviderUsage } from "./events.js";
|
|
11
|
-
export { ProviderCoreError } from "./errors.js";
|
|
12
|
-
export { resolveApiKey } from "./credentials.js";
|
|
13
|
-
export type { MediaTransport, MediaRequest, MediaResult, MediaType } from "./media-transport.js";
|
|
14
|
-
export { isAsyncMediaTransport } from "./media-transport.js";
|
|
15
|
-
export { MediaClient, type MediaClientConfig, type ResolvedMediaModel } from "./media-client.js";
|
|
16
|
-
export type { ProviderToolAPI, WebSearchResult, ReaderResult, TokenizerResult, ModerationResult, ProviderToolCapability } from "./provider-tool-api.js";
|
|
17
|
-
export { ProviderRegistry } from "./provider-registry.js";
|
|
18
|
-
export { BUILTIN_PROVIDERS } from "./builtin-providers.js";
|
|
19
|
-
export { ProviderVariantResolver, type ProviderVariantResolverInput, type ProviderVariantResolution, type RequestedProviderProtocol } from "./provider-variant-resolver.js";
|
|
20
|
-
export type { LLMClientConfig, LLMClient } from "./llm-client.js";
|
|
21
|
-
export { createLLMClient } from "./llm-client.js";
|
|
22
|
-
export { OpenAIChatTransport } from "./transports/openai-chat.js";
|
|
23
|
-
export { AnthropicMessagesTransport } from "./transports/anthropic-messages.js";
|
|
24
|
-
export { GeminiGenerateContentTransport } from "./transports/gemini-generatecontent.js";
|
|
25
|
-
export { VolcengineMediaTransport } from "./transports/volcengine-media.js";
|
|
26
|
-
export { OpenAIMediaTransport } from "./transports/openai-media.js";
|
|
27
|
-
export { MiniMaxMediaTransport } from "./transports/minimax-media.js";
|
|
28
|
-
export { GeminiMediaTransport, type GeminiMediaConfig } from "./transports/gemini-media.js";
|
|
29
|
-
export { GeminiLyriaRealtimeSession, generateRealtimeMusic } from "./transports/gemini-lyria-realtime.js";
|
|
30
|
-
export type { WeightedPrompt, MusicGenerationConfig, MusicScale, MusicGenerationMode, LyriaRealtimeConfig, LyriaRealtimeSessionOptions, AudioChunk } from "./transports/gemini-lyria-realtime.js";
|
|
31
|
-
export { RealtimeTransport } from "./transports/realtime-transport.js";
|
|
32
|
-
export type { RealtimeConfig, RealtimeTool, RealtimeEvent, RealtimeUsage } from "./transports/realtime-transport.js";
|
|
33
|
-
export { GeminiCacheAPI } from "./transports/gemini-cache-api.js";
|
|
34
|
-
export type { GeminiCachedContent, GeminiCacheCreateOptions } from "./transports/gemini-cache-api.js";
|
|
35
|
-
export { GeminiFileAPI } from "./transports/gemini-file-api.js";
|
|
36
|
-
export type { GeminiFileInfo } from "./transports/gemini-file-api.js";
|
|
37
|
-
export { isDebugTransportEnabled, createDebugTransport } from "./debug-transport.js";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Client factory 鈥?resolves ProviderDef 鈫?creates LLMTransport instance.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the old createAdminInferProxyClient() call chain.
|
|
5
|
-
* User API key + ProviderDef 鈫?direct provider connection.
|
|
6
|
-
*/
|
|
7
|
-
import type { ProviderDef } from "./provider-def.js";
|
|
8
|
-
import type { LLMTransport } from "./transport.js";
|
|
9
|
-
import { ProviderRegistry } from "./provider-registry.js";
|
|
10
|
-
export interface LLMClientConfig {
|
|
11
|
-
/** Provider id, e.g. "deepseek" */
|
|
12
|
-
provider: string;
|
|
13
|
-
/** Model id, e.g. "deepseek-v4-flash" */
|
|
14
|
-
model: string;
|
|
15
|
-
/** User API key */
|
|
16
|
-
apiKey: string;
|
|
17
|
-
/** Optional base URL override */
|
|
18
|
-
baseUrl?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface LLMClient {
|
|
21
|
-
transport: LLMTransport;
|
|
22
|
-
apiKey: string;
|
|
23
|
-
resolvedModel: string;
|
|
24
|
-
providerDef: ProviderDef;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create an LLM client from config + registry.
|
|
28
|
-
*
|
|
29
|
-
* 1. Look up provider in registry
|
|
30
|
-
* 2. Apply baseUrl override if provided
|
|
31
|
-
* 3. Instantiate the correct transport
|
|
32
|
-
*/
|
|
33
|
-
export declare function createLLMClient(config: LLMClientConfig, registry: ProviderRegistry): LLMClient;
|
|
34
|
-
/**
|
|
35
|
-
* Auto-detect provider from API key environment variables.
|
|
36
|
-
* Scans registry for providers whose env vars are set.
|
|
37
|
-
* Returns the first match.
|
|
38
|
-
*/
|
|
39
|
-
export declare function autoDetectProvider(registry: ProviderRegistry): {
|
|
40
|
-
providerId: string;
|
|
41
|
-
apiKey: string;
|
|
42
|
-
defaultModel: string;
|
|
43
|
-
} | undefined;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Media Client factory 鈥?resolves ProviderDef 鈫?creates MediaTransport instances.
|
|
3
|
-
*
|
|
4
|
-
* Parallel to createLLMClient() but for generation models (image/video/music/3D).
|
|
5
|
-
* Uses the same ProviderRegistry to look up provider config, then instantiates
|
|
6
|
-
* the correct media transport adapter.
|
|
7
|
-
*
|
|
8
|
-
* The MediaClient holds a provider-keyed transport cache so that repeated
|
|
9
|
-
* generation calls reuse the same adapter instance.
|
|
10
|
-
*/
|
|
11
|
-
import type { MediaTransport } from "./media-transport.js";
|
|
12
|
-
import type { ProviderDef, MediaCapability, ModelInfo } from "./provider-def.js";
|
|
13
|
-
import type { ProviderRegistry } from "./provider-registry.js";
|
|
14
|
-
export interface MediaClientConfig {
|
|
15
|
-
registry: ProviderRegistry;
|
|
16
|
-
}
|
|
17
|
-
export interface ResolvedMediaModel {
|
|
18
|
-
providerId: string;
|
|
19
|
-
providerDef: ProviderDef;
|
|
20
|
-
modelInfo: ModelInfo;
|
|
21
|
-
mediaType: MediaCapability;
|
|
22
|
-
}
|
|
23
|
-
export declare class MediaClient {
|
|
24
|
-
private registry;
|
|
25
|
-
private transports;
|
|
26
|
-
constructor(config: MediaClientConfig);
|
|
27
|
-
/**
|
|
28
|
-
* Find a specific model by provider + model id for a given media type.
|
|
29
|
-
* Used by the user-designated model routing (no failover).
|
|
30
|
-
*/
|
|
31
|
-
resolveModelById(providerId: string, modelId: string, mediaType: MediaCapability): ResolvedMediaModel | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Get a MediaTransport for a specific provider.
|
|
34
|
-
* Creates and caches the adapter on first access.
|
|
35
|
-
*/
|
|
36
|
-
getTransport(providerId: string): MediaTransport | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* List all available generation models across all providers.
|
|
39
|
-
*/
|
|
40
|
-
listMediaModels(mediaType?: MediaCapability): ResolvedMediaModel[];
|
|
41
|
-
private findModelInProvider;
|
|
42
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MediaTransport 鈥?transport interface for generation APIs (image, video, music, 3D).
|
|
3
|
-
*
|
|
4
|
-
* Parallel to LLMTransport (chat/reasoning), MediaTransport handles
|
|
5
|
-
* non-chat generation endpoints that each vendor exposes differently:
|
|
6
|
-
* - Sync (OpenAI images, Volcengine Seedream, Gemini generateContent)
|
|
7
|
-
* - Async job (Volcengine Seedance/3D, MiniMax music) 鈥?submit 鈫?poll 鈫?result
|
|
8
|
-
*
|
|
9
|
-
* Each provider adapter implements this interface and hides vendor-specific
|
|
10
|
-
* auth, endpoint paths, request shapes, and polling logic.
|
|
11
|
-
*/
|
|
12
|
-
export type MediaType = "image" | "video" | "music" | "music_realtime" | "tts" | "3d" | "stt" | "embedding" | "video_understanding" | "image_understanding" | "voice_clone" | "rerank" | "document_parsing" | "realtime_audio" | "realtime_video";
|
|
13
|
-
export interface MediaRequest {
|
|
14
|
-
/** Generation model id, e.g. "doubao-seedream-5-0-260128", "gpt-image-2" */
|
|
15
|
-
model: string;
|
|
16
|
-
/** What kind of media to generate */
|
|
17
|
-
mediaType: MediaType;
|
|
18
|
-
/** Text prompt for generation */
|
|
19
|
-
prompt: string;
|
|
20
|
-
/** Optional reference image URL (img2img, i2v, img-to-3d) */
|
|
21
|
-
imageUrl?: string;
|
|
22
|
-
/** Desired dimensions, e.g. "1024x1024" */
|
|
23
|
-
size?: string;
|
|
24
|
-
/** Aspect ratio for video, e.g. "16:9" */
|
|
25
|
-
aspectRatio?: string;
|
|
26
|
-
/** Duration in seconds (video, music) */
|
|
27
|
-
duration?: number;
|
|
28
|
-
/** Number of outputs (image) */
|
|
29
|
-
n?: number;
|
|
30
|
-
/** Visual/musical style */
|
|
31
|
-
style?: string;
|
|
32
|
-
/** Intended use / purpose */
|
|
33
|
-
purpose?: string;
|
|
34
|
-
/** Lyrics for music generation */
|
|
35
|
-
lyrics?: string;
|
|
36
|
-
/** Text for TTS */
|
|
37
|
-
text?: string;
|
|
38
|
-
/** TTS channel hint */
|
|
39
|
-
channel?: string;
|
|
40
|
-
/** Source video URLs for edit/merge operations */
|
|
41
|
-
sourceVideos?: string[];
|
|
42
|
-
/** Reference images (no role / first_frame / last_frame) */
|
|
43
|
-
referenceImages?: string[];
|
|
44
|
-
/** Reference image roles 鈥?parallel array with referenceImages. */
|
|
45
|
-
imageRoles?: Array<"first_frame" | "last_frame" | "reference_image">;
|
|
46
|
-
/** Reference video URLs for multimodal reference generation (Seedance 2.0) */
|
|
47
|
-
referenceVideos?: string[];
|
|
48
|
-
/** Reference audio URLs for multimodal reference generation (Seedance 2.0) */
|
|
49
|
-
referenceAudios?: string[];
|
|
50
|
-
/** Generate synchronized audio track (Seedance 2.0 / 1.5 pro) */
|
|
51
|
-
generateAudio?: boolean;
|
|
52
|
-
/** Output resolution for upscale, e.g. "1080p" */
|
|
53
|
-
resolution?: string;
|
|
54
|
-
/** Operation variant: generate (default), edit, merge, upscale, multimodal_reference, extend */
|
|
55
|
-
operation?: "generate" | "edit" | "merge" | "upscale" | "multimodal_reference" | "extend";
|
|
56
|
-
/** Image/video quality, e.g. "auto", "high", "low", "hd" */
|
|
57
|
-
quality?: string;
|
|
58
|
-
/** Seed for reproducible generation */
|
|
59
|
-
seed?: number;
|
|
60
|
-
/** TTS voice, e.g. "alloy", "nova", "shimmer" */
|
|
61
|
-
voice?: string;
|
|
62
|
-
/** TTS speech speed multiplier */
|
|
63
|
-
speed?: number;
|
|
64
|
-
/** Pure instrumental mode (MiniMax music) */
|
|
65
|
-
isInstrumental?: boolean;
|
|
66
|
-
/** Source audio URL for cover/remix (MiniMax music) */
|
|
67
|
-
audioUrl?: string;
|
|
68
|
-
/** Output audio format, e.g. "mp3", "wav", "flac" */
|
|
69
|
-
audioFormat?: string;
|
|
70
|
-
/** Video frames per second */
|
|
71
|
-
fps?: number;
|
|
72
|
-
/** Whether to add AI watermark */
|
|
73
|
-
watermark?: boolean;
|
|
74
|
-
/** img2img guidance/control strength (0-1), e.g. Volcengine */
|
|
75
|
-
guidanceScale?: number;
|
|
76
|
-
/** Auto-generate lyrics when none provided (MiniMax) */
|
|
77
|
-
lyricsOptimizer?: boolean;
|
|
78
|
-
/** 3D output format, e.g. "glb", "obj", "usd", "usdz" */
|
|
79
|
-
outputFormat?: string;
|
|
80
|
-
/** Image background mode (OpenAI gpt-image-2): "transparent", "opaque", "auto" */
|
|
81
|
-
background?: string;
|
|
82
|
-
/** Provider-specific request metadata (e.g. rerank documents, parsing options) */
|
|
83
|
-
metadata?: Record<string, unknown>;
|
|
84
|
-
/** Ask the provider to optimize/enhance the prompt before generation */
|
|
85
|
-
enhancePrompt?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Progress callback for async polling operations (video gen, 3D gen, etc.).
|
|
88
|
-
* Called periodically with estimated progress percentage, status text, and
|
|
89
|
-
* the provider-specific task ID (available once the task is submitted).
|
|
90
|
-
*/
|
|
91
|
-
onProgress?: (percent: number, status: string, taskId?: string) => void;
|
|
92
|
-
/** Enable progressive/streaming image generation (Volcengine Seedream stream:true) */
|
|
93
|
-
streamImage?: boolean;
|
|
94
|
-
/** Lock camera position (Seedance 1.0/1.5, not Seedance 2.0) */
|
|
95
|
-
cameraFixed?: boolean;
|
|
96
|
-
/** Return last frame URL for chaining continuous video segments */
|
|
97
|
-
returnLastFrame?: boolean;
|
|
98
|
-
/** Service tier: 'default' (online) or 'flex' (offline, ~50% cost) 鈥?not all models support flex */
|
|
99
|
-
serviceTier?: "default" | "flex";
|
|
100
|
-
/** Task expiration in seconds (for flex/offline scheduling) */
|
|
101
|
-
executionExpiresAfterSeconds?: number;
|
|
102
|
-
/** Draft mode 鈥?low-cost preview (Seedance 1.5 pro only) */
|
|
103
|
-
draft?: boolean;
|
|
104
|
-
/** Draft task ID to promote to final video */
|
|
105
|
-
draftTaskId?: string;
|
|
106
|
-
/** Video-level builtin tools, e.g. ["web_search"] (Seedance 2.0) */
|
|
107
|
-
videoTools?: string[];
|
|
108
|
-
/** End-user safety identifier for content moderation */
|
|
109
|
-
safetyIdentifier?: string;
|
|
110
|
-
/** Callback URL for async task status push notifications */
|
|
111
|
-
callbackUrl?: string;
|
|
112
|
-
/** Image detail level control: 'auto' | 'low' | 'high' */
|
|
113
|
-
detail?: "auto" | "low" | "high";
|
|
114
|
-
/** Max image pixels budget (Volcengine image_pixel_limit) */
|
|
115
|
-
imagePixelLimit?: number;
|
|
116
|
-
}
|
|
117
|
-
export interface MediaResult {
|
|
118
|
-
/** URLs of generated media files */
|
|
119
|
-
mediaUrls: string[];
|
|
120
|
-
/** Model actually used */
|
|
121
|
-
model?: string;
|
|
122
|
-
/** Output dimensions / format info */
|
|
123
|
-
size?: string;
|
|
124
|
-
/** Total generation time in ms */
|
|
125
|
-
durationMs?: number;
|
|
126
|
-
/** Billing unit type for non-token models */
|
|
127
|
-
billingUnit?: "per_call" | "per_second" | "per_character" | "per_pixel" | "per_token";
|
|
128
|
-
/** Quantity consumed (seconds, characters, pixels, etc.) */
|
|
129
|
-
billingQuantity?: number;
|
|
130
|
-
/** Provider-specific metadata */
|
|
131
|
-
metadata?: Record<string, unknown>;
|
|
132
|
-
/** Last frame image URL for chaining continuous video generation */
|
|
133
|
-
lastFrameUrl?: string;
|
|
134
|
-
/** Task ID (for continuing draft鈫抐inal or querying) */
|
|
135
|
-
taskId?: string;
|
|
136
|
-
}
|
|
137
|
-
export interface MediaTransport {
|
|
138
|
-
/**
|
|
139
|
-
* Generate media content.
|
|
140
|
-
* Handles sync APIs directly and async job APIs (submit + poll) internally.
|
|
141
|
-
*
|
|
142
|
-
* @param request - Generation parameters
|
|
143
|
-
* @param apiKey - User API key (passed explicitly, not from env)
|
|
144
|
-
* @param signal - Optional abort signal
|
|
145
|
-
*/
|
|
146
|
-
generate(request: MediaRequest, apiKey: string, signal?: AbortSignal): Promise<MediaResult>;
|
|
147
|
-
/**
|
|
148
|
-
* Which media types this transport supports.
|
|
149
|
-
* Used by the media client factory to route requests.
|
|
150
|
-
*/
|
|
151
|
-
readonly supportedTypes: readonly MediaType[];
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Extended transport for providers that support async task management
|
|
155
|
-
* (submit 鈫?poll 鈫?cancel/query). Volcengine Seedance, MiniMax async, etc.
|
|
156
|
-
*/
|
|
157
|
-
export interface AsyncMediaTransport extends MediaTransport {
|
|
158
|
-
/** Cancel / delete an async task. */
|
|
159
|
-
deleteVideoTask(taskId: string, apiKey: string, signal?: AbortSignal): Promise<void>;
|
|
160
|
-
/** List recent tasks for status queries. */
|
|
161
|
-
listVideoTasks(apiKey: string, options?: {
|
|
162
|
-
after?: string;
|
|
163
|
-
limit?: number;
|
|
164
|
-
status?: string;
|
|
165
|
-
}, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
166
|
-
/**
|
|
167
|
-
* Query a single task by ID 鈥?preferred over listVideoTasks for direct lookups.
|
|
168
|
-
* Not all providers support listing; all async providers support single-task queries.
|
|
169
|
-
*/
|
|
170
|
-
getTaskStatus?(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
171
|
-
status: string;
|
|
172
|
-
task: Record<string, unknown>;
|
|
173
|
-
}>;
|
|
174
|
-
}
|
|
175
|
-
/** Type guard for transports that support async task management. */
|
|
176
|
-
export declare function isAsyncMediaTransport(t: MediaTransport): t is AsyncMediaTransport;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model detection helpers shared between OpenAI transport implementations.
|
|
3
|
-
*
|
|
4
|
-
* These are used by both openai-chat.ts and openai-responses.ts to detect
|
|
5
|
-
* model families and apply family-specific constraints:
|
|
6
|
-
* - GPT-5.x: unified reasoning, temperature allowed, reasoning object format
|
|
7
|
-
* - GPT-5.4-nano: reasoning effort capped at medium
|
|
8
|
-
* - o-series (legacy): reasoning_effort flat string, temperature suppressed
|
|
9
|
-
*/
|
|
10
|
-
/** GPT-5.x models (new generation with unified reasoning). */
|
|
11
|
-
export declare function isGPT5xModel(model: string): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* GPT-5.4-nano models 鈥?reasoning effort capped at medium.
|
|
14
|
-
* openai-ProviderMax 搂3: gpt-5.4-nano only supports none/low/medium effort.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isGPT5NanoModel(model: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* OpenAI o-series reasoning models (legacy, kept for 3rd-party provider compat).
|
|
19
|
-
* These suppress temperature/top_p and use reasoning_effort as flat string.
|
|
20
|
-
* Matches: o1, o1-mini, o1-pro, o3, o3-mini, o3-pro, o4-mini, etc.
|
|
21
|
-
*/
|
|
22
|
-
export declare function isOpenAIReasoningModel(model: string): boolean;
|