qlogicagent 2.10.1 → 2.10.2
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/cli.js +2 -2
- package/dist/index.js +2 -2
- 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/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/provider-core/adapters/aliyun-oss-file-upload-adapter.d.ts +44 -0
- package/dist/types/provider-core/adapters/gemini-file-upload-adapter.d.ts +26 -0
- package/dist/types/provider-core/adapters/hub-oss-file-upload-adapter.d.ts +29 -0
- package/dist/types/provider-core/adapters/index.d.ts +10 -0
- package/dist/types/provider-core/adapters/openai-file-upload-adapter.d.ts +38 -0
- package/dist/types/provider-core/adapters/volcengine-file-upload-adapter.d.ts +24 -0
- package/dist/types/provider-core/builtin-providers.d.ts +10 -0
- package/dist/types/provider-core/constants.d.ts +1 -0
- package/dist/types/provider-core/credentials.d.ts +1 -0
- package/dist/types/provider-core/debug-transport.d.ts +12 -0
- package/dist/types/provider-core/errors.d.ts +11 -0
- package/dist/types/provider-core/events.d.ts +48 -0
- package/dist/types/provider-core/file-upload-service.d.ts +68 -0
- package/dist/types/provider-core/gemini-schema-utils.d.ts +17 -0
- package/dist/types/provider-core/index.d.ts +37 -0
- package/dist/types/provider-core/llm-client.d.ts +43 -0
- package/dist/types/provider-core/media-client.d.ts +42 -0
- package/dist/types/provider-core/media-transport.d.ts +176 -0
- package/dist/types/provider-core/media.d.ts +2 -0
- package/dist/types/provider-core/model-catalog.d.ts +82 -0
- package/dist/types/provider-core/model-detection.d.ts +22 -0
- package/dist/types/provider-core/paths.d.ts +2 -0
- package/dist/types/provider-core/provider-def.d.ts +214 -0
- package/dist/types/provider-core/provider-registry.d.ts +59 -0
- package/dist/types/provider-core/provider-tool-api.d.ts +44 -0
- package/dist/types/provider-core/retry.d.ts +37 -0
- package/dist/types/provider-core/transport.d.ts +281 -0
- package/dist/types/provider-core/transports/anthropic-messages.d.ts +65 -0
- package/dist/types/provider-core/transports/gemini-cache-api.d.ts +86 -0
- package/dist/types/provider-core/transports/gemini-file-api.d.ts +90 -0
- package/dist/types/provider-core/transports/gemini-generatecontent.d.ts +56 -0
- package/dist/types/provider-core/transports/gemini-lyria-realtime.d.ts +117 -0
- package/dist/types/provider-core/transports/gemini-media.d.ts +53 -0
- package/dist/types/provider-core/transports/media-resolve.d.ts +50 -0
- package/dist/types/provider-core/transports/minimax-media.d.ts +55 -0
- package/dist/types/provider-core/transports/openai-chat.d.ts +81 -0
- package/dist/types/provider-core/transports/openai-media.d.ts +24 -0
- package/dist/types/provider-core/transports/openai-responses.d.ts +63 -0
- package/dist/types/provider-core/transports/qwen-media.d.ts +50 -0
- package/dist/types/provider-core/transports/realtime-transport.d.ts +183 -0
- package/dist/types/provider-core/transports/volcengine-grounding.d.ts +58 -0
- package/dist/types/provider-core/transports/volcengine-media.d.ts +93 -0
- package/dist/types/provider-core/transports/volcengine-responses.d.ts +64 -0
- package/dist/types/provider-core/transports/zhipu-media.d.ts +82 -0
- package/dist/types/provider-core/transports/zhipu-tool-api.d.ts +35 -0
- package/dist/types/provider-core/wire-types.d.ts +51 -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 +2 -2
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Zero imports from express/pg/ioredis/ws.
|
|
14
14
|
*/
|
|
15
15
|
import type { AgentLogger, ToolInvoker, TurnEvent, TurnRequest, HookRegistry } from "./types.js";
|
|
16
|
-
import type { LLMTransport } from "
|
|
16
|
+
import type { LLMTransport } from "../provider-core/index.js";
|
|
17
17
|
export interface AgentConfig {
|
|
18
18
|
llmTransport: LLMTransport;
|
|
19
19
|
apiKey: string;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* Zero imports from express/pg/ioredis/ws.
|
|
20
20
|
*/
|
|
21
21
|
import type { AgentLogger, ChatMessage, ToolDefinition, ToolInvoker, TurnEvent, HookRegistry } from "./types.js";
|
|
22
|
-
import type { LLMTransport } from "
|
|
22
|
+
import type { LLMTransport } from "../provider-core/index.js";
|
|
23
23
|
export interface ToolLoopParams {
|
|
24
24
|
turnId: string;
|
|
25
25
|
sessionId: string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { SkillInstruction } from "../orchestration/index.js";
|
|
9
9
|
import type { HookRegistry } from "../contracts/hooks.js";
|
|
10
|
-
import type { MediaCapability } from "
|
|
10
|
+
import type { MediaCapability } from "../provider-core/index.js";
|
|
11
11
|
import type { ChatMessage as WireChatMessage, ChatMessageRole as WireChatMessageRole, ThinkingBlock as WireThinkingBlock, ToolCallMessage as WireToolCallMessage, ToolDefinition as WireToolDefinition, WireTokenUsage } from "../protocol/wire/index.js";
|
|
12
12
|
export type ChatMessageRole = WireChatMessageRole;
|
|
13
13
|
export type ThinkingBlock = WireThinkingBlock;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ChatMessage } from "../../agent/types.js";
|
|
6
6
|
import type { AgentRpcRequest } from "../../protocol/wire/agent-rpc.js";
|
|
7
|
-
import type { LLMTransport } from "
|
|
7
|
+
import type { LLMTransport } from "../../provider-core/index.js";
|
|
8
8
|
export declare function handleAbort(this: any, msg: AgentRpcRequest): void;
|
|
9
9
|
export declare function handleApprovalResponse(this: any, msg: AgentRpcRequest): void;
|
|
10
10
|
export declare function handleUserResponse(this: any, msg: AgentRpcRequest): void;
|
|
@@ -3,9 +3,9 @@ import { type TaskToolHooks } from "../skills/tools/task-tool.js";
|
|
|
3
3
|
import { type ExecProgress } from "../skills/tools/exec-tool.js";
|
|
4
4
|
import type { AgentLogger } from "../agent/types.js";
|
|
5
5
|
import { type AskUserQuestion } from "../skills/tools/ask-user-tool.js";
|
|
6
|
-
import type { MediaClient } from "
|
|
7
|
-
import type { MediaCapability } from "
|
|
8
|
-
import type { ProviderToolAPI } from "
|
|
6
|
+
import type { MediaClient } from "../provider-core/index.js";
|
|
7
|
+
import type { MediaCapability } from "../provider-core/index.js";
|
|
8
|
+
import type { ProviderToolAPI } from "../provider-core/index.js";
|
|
9
9
|
/** Enable or disable group security mode (blocks sensitive file access). */
|
|
10
10
|
export declare function setGroupSecurityMode(enabled: boolean): void;
|
|
11
11
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { AgentConfig } from "./config/config.js";
|
|
|
10
10
|
export type { Transport } from "./cli/transport.js";
|
|
11
11
|
export { StdioTransport } from "./cli/transport.js";
|
|
12
12
|
export { StdioServer, type StdioServerConfig } from "./cli/stdio-server.js";
|
|
13
|
-
export { ProviderRegistry, createLLMClient, } from "
|
|
14
|
-
export type { LLMTransport, LLMRequest, LLMChunk } from "
|
|
13
|
+
export { ProviderRegistry, createLLMClient, } from "./provider-core/index.js";
|
|
14
|
+
export type { LLMTransport, LLMRequest, LLMChunk } from "./provider-core/index.js";
|
|
15
15
|
export { createHookRegistry } from "./runtime/hooks/hook-registry.js";
|
|
16
16
|
export { buildSkillInstruction, } from "./orchestration/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../provider-core/index.js";
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
*
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { cascadeWebSearch } from "./tool-cascade.js";
|
|
26
|
-
* import { ZhipuToolAPI } from "
|
|
26
|
+
* import { ZhipuToolAPI } from "../provider-core/transports/zhipu-tool-api.js";
|
|
27
27
|
*
|
|
28
28
|
* const providerApi = new ZhipuToolAPI({ baseUrl, apiKey });
|
|
29
29
|
* const cascadedSearch = cascadeWebSearch(providerApi, fallbackSearchFn);
|
|
30
30
|
* const tool = createWebSearchTool({ search: cascadedSearch });
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
import type { ProviderToolAPI } from "
|
|
33
|
+
import type { ProviderToolAPI } from "../provider-core/index.js";
|
|
34
34
|
import type { WebSearchToolDeps } from "../skills/tools/web-search-tool.js";
|
|
35
35
|
/**
|
|
36
36
|
* Cascade web search: provider-native search → host fallback.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aliyun OSS File Upload Adapter 鈥?direct upload to Alibaba Cloud OSS.
|
|
3
|
+
*
|
|
4
|
+
* Uploads files directly to OSS bucket using V1 signature (HMAC-SHA1).
|
|
5
|
+
* No external dependencies 鈥?uses Node.js crypto + fetch.
|
|
6
|
+
*
|
|
7
|
+
* This is the **universal fallback adapter** for providers without a native
|
|
8
|
+
* File Upload API (e.g. Anthropic). Ensures ALL file handling goes through
|
|
9
|
+
* upload 鈥?never base64 inline.
|
|
10
|
+
*
|
|
11
|
+
* Environment variables:
|
|
12
|
+
* OSS_ACCESS_KEY_ID 鈥?Aliyun AccessKey ID
|
|
13
|
+
* OSS_ACCESS_KEY_SECRET 鈥?Aliyun AccessKey Secret
|
|
14
|
+
* OSS_BUCKET 鈥?Bucket name (default: "qlogicagent")
|
|
15
|
+
* OSS_REGION 鈥?Region (default: "cn-beijing")
|
|
16
|
+
* OSS_ENDPOINT 鈥?Custom endpoint (default: derived from region)
|
|
17
|
+
*/
|
|
18
|
+
import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
|
|
19
|
+
export interface AliyunOSSFileUploadConfig {
|
|
20
|
+
/** Aliyun AccessKey ID. Required. */
|
|
21
|
+
accessKeyId: string;
|
|
22
|
+
/** Aliyun AccessKey Secret. Required. */
|
|
23
|
+
accessKeySecret: string;
|
|
24
|
+
/** OSS Bucket name. Default: "qlogicagent". */
|
|
25
|
+
bucket?: string;
|
|
26
|
+
/** OSS Region. Default: "cn-beijing". */
|
|
27
|
+
region?: string;
|
|
28
|
+
/** Custom OSS endpoint. Default: "{bucket}.oss-{region}.aliyuncs.com". */
|
|
29
|
+
endpoint?: string;
|
|
30
|
+
/** Upload path prefix. Default: "media". */
|
|
31
|
+
pathPrefix?: string;
|
|
32
|
+
/** Timeout ms. Default: 120_000. */
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create an AliyunOSSFileUploadAdapter from environment variables.
|
|
37
|
+
* Returns undefined if required env vars (OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET) are missing.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createAliyunOSSAdapterFromEnv(): AliyunOSSFileUploadAdapter | undefined;
|
|
40
|
+
export declare class AliyunOSSFileUploadAdapter implements FileUploadAdapter {
|
|
41
|
+
private readonly config;
|
|
42
|
+
constructor(config: AliyunOSSFileUploadConfig);
|
|
43
|
+
uploadFile(buffer: Buffer, filename: string, mimeType: string, _apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini File Upload Adapter.
|
|
3
|
+
*
|
|
4
|
+
* Implements the Google Gemini 2-step resumable upload protocol
|
|
5
|
+
* into the unified FileUploadAdapter interface.
|
|
6
|
+
*
|
|
7
|
+
* Protocol:
|
|
8
|
+
* 1. POST /upload/v1beta/files 鈥?initiate, get upload URL
|
|
9
|
+
* 2. PUT {uploadUrl} 鈥?send bytes, finalize
|
|
10
|
+
*
|
|
11
|
+
* Returns a file URI (e.g. "files/abc123") that can be used in
|
|
12
|
+
* generateContent requests as a file reference.
|
|
13
|
+
*/
|
|
14
|
+
import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
|
|
15
|
+
export interface GeminiFileUploadConfig {
|
|
16
|
+
/** Base URL (e.g. "https://generativelanguage.googleapis.com/v1beta") */
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/** Timeout ms. Default: 180_000. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class GeminiFileUploadAdapter implements FileUploadAdapter {
|
|
22
|
+
private readonly config;
|
|
23
|
+
constructor(config: GeminiFileUploadConfig);
|
|
24
|
+
uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
25
|
+
private waitForProcessing;
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hub OSS File Upload Adapter 鈥?for providers without native File API (e.g. Anthropic).
|
|
3
|
+
*
|
|
4
|
+
* Uploads local files to the Hub's OSS relay endpoint, which stores them in
|
|
5
|
+
* cloud object storage (Aliyun OSS / Tencent COS) and returns a public URL.
|
|
6
|
+
* The LLM provider can then access the file via this public URL.
|
|
7
|
+
*
|
|
8
|
+
* This enables Anthropic (which only supports base64 inline or public URL)
|
|
9
|
+
* to handle large files that exceed the base64 size limit (20MB).
|
|
10
|
+
*
|
|
11
|
+
* Endpoint: POST {hubBaseUrl}/api/v1/files/upload
|
|
12
|
+
* Returns: { url: "https://oss-bucket.oss-cn-xxx.aliyuncs.com/..." }
|
|
13
|
+
*/
|
|
14
|
+
import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
|
|
15
|
+
export interface HubOSSFileUploadConfig {
|
|
16
|
+
/** Hub API base URL (e.g. "https://hub.xiaozhiclaw.com" or from env). */
|
|
17
|
+
hubBaseUrl: string;
|
|
18
|
+
/** Hub API key for authentication. */
|
|
19
|
+
hubApiKey?: string;
|
|
20
|
+
/** Timeout ms. Default: 120_000. */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
/** Provider name for result metadata. Default: "hub-oss". */
|
|
23
|
+
provider?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class HubOSSFileUploadAdapter implements FileUploadAdapter {
|
|
26
|
+
private readonly config;
|
|
27
|
+
constructor(config: HubOSSFileUploadConfig);
|
|
28
|
+
uploadFile(buffer: Buffer, filename: string, mimeType: string, _apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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";
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builtin provider definitions 鈥?hardcoded fallback list (~30 providers).
|
|
3
|
+
*
|
|
4
|
+
* This is Layer 1 (lowest priority) of the three-layer merge strategy.
|
|
5
|
+
* Used when remote model catalog is unavailable.
|
|
6
|
+
*
|
|
7
|
+
* Aligned with Hermes hermes_cli/models.py hardcoded fallback.
|
|
8
|
+
*/
|
|
9
|
+
import type { ProviderDef } from "./provider-def.js";
|
|
10
|
+
export declare const BUILTIN_PROVIDERS: ProviderDef[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MEDIA_MAX_UPLOAD_SIZE: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveApiKey(envVarNames: string[], env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
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[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 } 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 { ModelCatalog } from "./model-catalog.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";
|
|
@@ -0,0 +1,43 @@
|
|
|
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;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|