@huyooo/ai-chat-core 0.3.22 → 0.3.23
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/adapter/model-adapter.d.ts +3 -3
- package/dist/build-chat-integration-export.d.ts +39 -0
- package/dist/chat-catalog-constants.d.ts +23 -0
- package/dist/chat-catalog-types.d.ts +45 -0
- package/dist/chat-runtime-protocol-options.d.ts +5 -0
- package/dist/chat-runtime.d.ts +2 -1
- package/dist/chat-supplier-constants.d.ts +11 -0
- package/dist/compile-chat-model-config.d.ts +25 -0
- package/dist/index.d.ts +16 -5
- package/dist/index.js +9 -21
- package/dist/llm-config.d.ts +22 -18
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/protocol-ids.d.ts +3 -0
- package/dist/protocols/registry.d.ts +38 -0
- package/dist/protocols/types.d.ts +5 -5
- package/dist/server-chat-endpoint.d.ts +22 -0
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
- package/dist/constants.d.ts +0 -11
- package/dist/model-catalog/adapters.d.ts +0 -2
- package/dist/model-catalog/constants.d.ts +0 -5
- package/dist/model-catalog/providers.d.ts +0 -2
- package/dist/model-catalog/service-entries.d.ts +0 -3
- package/dist/model-catalog/services/huyooo-official.d.ts +0 -2
- package/dist/model-catalog/services/model-proxy.d.ts +0 -3
- package/dist/model-catalog/services/volcengine-coding-plan.d.ts +0 -2
- package/dist/model-catalog.d.ts +0 -69
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ModelAdapter - 模型适配器(Model 中心)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 每个模型仅一条出站端点(ModelConfig.endpoint),与目录 offering 1:1。
|
|
5
5
|
*/
|
|
6
6
|
import type { ProtocolMessage, ProtocolToolDefinition, RawEvent } from '../protocols/types';
|
|
7
7
|
import { type ModelFamilyConfig } from '../families';
|
|
@@ -17,10 +17,10 @@ export declare class ModelAdapter implements ProviderAdapter {
|
|
|
17
17
|
private validateModels;
|
|
18
18
|
private resolveRuntimeValue;
|
|
19
19
|
private resolveHeaders;
|
|
20
|
-
private
|
|
20
|
+
private createProtocolForEndpoint;
|
|
21
21
|
get supportedModels(): string[];
|
|
22
22
|
supportsModel(model: string): boolean;
|
|
23
23
|
getModelFamilyConfig(model: string): ModelFamilyConfig | undefined;
|
|
24
24
|
streamOnce(messages: ProtocolMessage[], tools: ProtocolToolDefinition[], options: StreamOnceOptions): AsyncGenerator<RawEvent>;
|
|
25
|
-
private
|
|
25
|
+
private streamModelEndpoint;
|
|
26
26
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 Mongo 编译后的 ChatModelCatalogItem 生成 ai-chat 接入说明(供 ai-server / Ones 导出)
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatModelCatalogItem } from './chat-catalog-types';
|
|
5
|
+
import type { LLMConfig } from './llm-config';
|
|
6
|
+
export interface ChatModelIntegrationExport {
|
|
7
|
+
catalogItem: ChatModelCatalogItem;
|
|
8
|
+
/** BYOK:直连 protocolBaseUrl */
|
|
9
|
+
llmConfigByok: Pick<LLMConfig, 'models' | 'defaultModel'>;
|
|
10
|
+
/** 原厂可走 Huyooo 官方代理时提供 */
|
|
11
|
+
llmConfigOfficial?: Pick<LLMConfig, 'models' | 'defaultModel'>;
|
|
12
|
+
downstreamApis: {
|
|
13
|
+
modelOptions: {
|
|
14
|
+
method: 'POST';
|
|
15
|
+
path: string;
|
|
16
|
+
body?: {
|
|
17
|
+
supplierIds?: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
supplierOptions: {
|
|
21
|
+
method: 'POST';
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
integrationExport: {
|
|
25
|
+
method: 'POST';
|
|
26
|
+
path: string;
|
|
27
|
+
body: {
|
|
28
|
+
offeringModelId: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
reloadRuntime: {
|
|
32
|
+
method: 'POST';
|
|
33
|
+
path: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
compileHints: string[];
|
|
37
|
+
}
|
|
38
|
+
/** 生成可复制/下发的接入导出包 */
|
|
39
|
+
export declare function buildChatModelIntegrationExport(item: ChatModelCatalogItem): ChatModelIntegrationExport;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型目录与 ChatRuntime 编译共用常量(llmProxy path 模板 + Mongo 字段读取)
|
|
3
|
+
* 目录事实(chatRuntimeProtocol / supplier 出站)一律来自 Mongo,runtime 不做常量兜底。
|
|
4
|
+
*/
|
|
5
|
+
import type { ProtocolId } from './protocols/types';
|
|
6
|
+
/** 校验 Mongo chatRuntimeProtocol 是否为已注册 ProtocolId */
|
|
7
|
+
export declare function isChatRuntimeProtocolId(value: string): value is ProtocolId;
|
|
8
|
+
export type ChatServerUpstream = 'direct' | 'llm_proxy';
|
|
9
|
+
export interface ChatServerSupplierPolicy {
|
|
10
|
+
serverUpstream: ChatServerUpstream;
|
|
11
|
+
proxyPathPrefix: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** llmProxy 出站时按 protocolId 拼完整 path(编译规则,非 Mongo 兜底) */
|
|
14
|
+
export declare const SERVER_LLM_PROXY_PATH_BY_PROTOCOL: Record<string, string>;
|
|
15
|
+
/** 读取 Mongo modelAccessProtocol.chatRuntimeProtocol;缺失或无效 → null */
|
|
16
|
+
export declare function resolveChatRuntimeProtocol(stored?: string | null): ProtocolId | null;
|
|
17
|
+
/** 读取 Mongo aiSupplier.officialProxyBaseUrl;缺失 → null */
|
|
18
|
+
export declare function resolveOfficialProxyBaseUrl(stored?: string | null): string | null;
|
|
19
|
+
/** 读取 Mongo aiSupplier 出站策略;不完整 → null */
|
|
20
|
+
export declare function resolveServerSupplierPolicy(stored?: {
|
|
21
|
+
serverUpstream?: ChatServerUpstream | null;
|
|
22
|
+
proxyPathPrefix?: string | null;
|
|
23
|
+
}): ChatServerSupplierPolicy | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对话模型目录 DTO(Mongo offering 编译结果,ai-server / SuperX / 下游共用)
|
|
3
|
+
*/
|
|
4
|
+
import type { ModelFamilyId } from './families';
|
|
5
|
+
import type { ProtocolId } from './protocols/types';
|
|
6
|
+
import type { CatalogSupplierKind } from './chat-supplier-constants';
|
|
7
|
+
import type { ChatServerUpstream } from './chat-catalog-constants';
|
|
8
|
+
export type { ChatServerUpstream };
|
|
9
|
+
export interface ChatSupplierOption {
|
|
10
|
+
key: string;
|
|
11
|
+
label: string;
|
|
12
|
+
supplierKind: CatalogSupplierKind;
|
|
13
|
+
/** 是否可走 Huyooo 官方 AI 代理(原厂供应商) */
|
|
14
|
+
officialEligible: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ChatModelCatalogItem {
|
|
17
|
+
offeringModelId: string;
|
|
18
|
+
profileId: string;
|
|
19
|
+
supplierId: string;
|
|
20
|
+
supplierName: string;
|
|
21
|
+
supplierKind: CatalogSupplierKind;
|
|
22
|
+
officialEligible: boolean;
|
|
23
|
+
/** 是否开放给平台对话(Mongo platformChat) */
|
|
24
|
+
platformChat: boolean;
|
|
25
|
+
displayName: string;
|
|
26
|
+
providerModelId: string;
|
|
27
|
+
protocolId: string;
|
|
28
|
+
chatRuntimeProtocol: ProtocolId;
|
|
29
|
+
protocolBaseUrl: string;
|
|
30
|
+
protocolPath: string;
|
|
31
|
+
family: ModelFamilyId;
|
|
32
|
+
supportsThinking: boolean;
|
|
33
|
+
supportsVision: boolean;
|
|
34
|
+
contextWindowTokens: number;
|
|
35
|
+
maxOutputTokens: number;
|
|
36
|
+
status: 'active' | 'deprecated';
|
|
37
|
+
tags?: string[];
|
|
38
|
+
/** 来自 aiSupplier:Huyooo 官方代理 baseUrl */
|
|
39
|
+
officialProxyBaseUrl?: string;
|
|
40
|
+
/** 来自 aiSupplier:ai-server 平台对话出站 */
|
|
41
|
+
serverUpstream?: 'direct' | 'llm_proxy';
|
|
42
|
+
proxyPathPrefix?: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** 平台 / SuperX 默认对话 profileId(编译时解析为 offeringModelId) */
|
|
45
|
+
export declare const DEFAULT_CHAT_PROFILE_ID = "doubao-seed-2-0-pro-260215";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CHAT_RUNTIME_PROTOCOL_OPTIONS: {
|
|
2
|
+
value: "ark_v1" | "deepseek_v1" | "qwen_v1" | "qwen_text_v1" | "glm_v1" | "moonshot_v1" | "minimax_v1" | "vercel_gateway_v1" | "anthropic_v1" | "gemini_v1" | "openai_v1" | "openai_chat_v1" | "grok_v1";
|
|
3
|
+
label: string;
|
|
4
|
+
}[];
|
|
5
|
+
export declare function formatChatRuntimeProtocolLabel(value?: string | null): string;
|
package/dist/chat-runtime.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { ToolExecutionHooks } from './orchestrator/types';
|
|
|
17
17
|
/** 运行时配置 */
|
|
18
18
|
export interface RuntimeConfig {
|
|
19
19
|
llmConfig: LLMConfig;
|
|
20
|
+
systemPrompt: string;
|
|
20
21
|
cwd: string;
|
|
21
22
|
maxIterations?: number;
|
|
22
23
|
maxDurationMs?: number;
|
|
@@ -47,7 +48,7 @@ export declare class ChatRuntime {
|
|
|
47
48
|
/** 异步初始化工具(懒加载,允许桥接层显式触发) */
|
|
48
49
|
private asyncInit;
|
|
49
50
|
getModelFamilyConfig(model: string): ModelFamilyConfig | undefined;
|
|
50
|
-
|
|
51
|
+
getModelEndpointInfo(model: string): {
|
|
51
52
|
available: boolean;
|
|
52
53
|
familyConfig?: ModelFamilyConfig;
|
|
53
54
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型目录供应商分类(ai-server / Ones 共用,与 Mongo supplierKind 一致)
|
|
3
|
+
*/
|
|
4
|
+
export type CatalogSupplierKind = 'agent_vendor' | 'agent_proxy';
|
|
5
|
+
/** 固定为代理的接入方(非原厂 API) */
|
|
6
|
+
export declare const PROXY_SUPPLIER_IDS: readonly ["openrouter", "volcengine-ark-coding-plan", "volcengine-ark-agent-plan"];
|
|
7
|
+
export declare function isProxySupplierId(supplierId: string): boolean;
|
|
8
|
+
/** 未写入库的历史数据视为原厂 */
|
|
9
|
+
export declare function normalizeCatalogSupplierKind(kind?: CatalogSupplierKind): CatalogSupplierKind;
|
|
10
|
+
/** 按 supplierId 解析类型:OpenRouter / 方舟套餐等始终为代理 */
|
|
11
|
+
export declare function resolveCatalogSupplierKind(supplierId: string, kind?: CatalogSupplierKind): CatalogSupplierKind;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatModelCatalogItem → ModelConfig 统一编译(SuperX / ai-server 共用)
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatModelCatalogItem } from './chat-catalog-types';
|
|
5
|
+
import type { LLMConfig, ModelConfig, ModelEndpoint, RuntimeConfigValue } from './llm-config';
|
|
6
|
+
import { type ServerChatEnv } from './server-chat-endpoint';
|
|
7
|
+
export type ChatModelCompileAccess = {
|
|
8
|
+
mode: 'official';
|
|
9
|
+
accessKey: RuntimeConfigValue;
|
|
10
|
+
headers?: ModelEndpoint['headers'];
|
|
11
|
+
} | {
|
|
12
|
+
mode: 'byok';
|
|
13
|
+
accessKey: RuntimeConfigValue;
|
|
14
|
+
} | {
|
|
15
|
+
mode: 'server';
|
|
16
|
+
env: ServerChatEnv;
|
|
17
|
+
};
|
|
18
|
+
/** 将目录项编译为 ChatRuntime ModelConfig;server 模式在无法出站时返回 null */
|
|
19
|
+
export declare function compileChatModelConfig(item: ChatModelCatalogItem, access: ChatModelCompileAccess): ModelConfig | null;
|
|
20
|
+
export interface ResolveDefaultChatOfferingOptions {
|
|
21
|
+
preferredOfferingModelId?: string;
|
|
22
|
+
preferredProfileId?: string;
|
|
23
|
+
}
|
|
24
|
+
/** 从已编译 models 与 catalog 解析默认 offeringModelId */
|
|
25
|
+
export declare function resolveDefaultChatOfferingModelId(catalog: ChatModelCatalogItem[], models: LLMConfig['models'], options?: ResolveDefaultChatOfferingOptions): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export type { Protocol, ProtocolConfig, ProtocolAttachment, ProtocolMessage, Pro
|
|
|
37
37
|
export { ChatOrchestrator, createOrchestrator } from './orchestrator';
|
|
38
38
|
export type { AgentConfig, ChatOptions, ChatMode, ThinkingMode, AutoRunMode, AutoRunConfig, ToolExecutor, ToolDefinition, ChatMessage, ResponsesApiTool, Tool, ToolContext, DataEngineContext, ToolUI, RenderType, ActionType, ExecResult, ExecOptions, ToolResult, ToolSuccess, ToolExecuteResult, ToolError, ToolErrorCode, ToolErrorCategory, ToolPlugin, ToolConfigItem, ToolExecutionAuditHooks, UserToolDefinition, JsonSchemaObject, } from './types';
|
|
39
39
|
export { resolveTools, tool, tools, ToolException, normalizeToolResult, serializeToolResult, isToolResult, toolOk, createResolvedOutputSchema, STANDARD_TOOL_ERROR_SCHEMA, resolveToolResultUi, mergeToolGovernance, resolveToolGovernanceSnapshot, throwToolError, isToolError, } from './types';
|
|
40
|
-
export { DEFAULT_MODEL } from './constants';
|
|
41
40
|
export type { ToolCallStatus, ToolCallInfo, TokenUsage, ErrorCategory, ErrorDetails, FinishReason, ToolFailureReason, } from './events';
|
|
42
41
|
export type { ThinkingStartEvent, ThinkingDeltaEvent, ThinkingEndEvent, ThinkingEvent } from './events';
|
|
43
42
|
export type { ToolCallStartEvent, ToolCallResultEvent, ToolCallOutputEvent, ToolApprovalRequestEvent, ToolCallRequestEvent, ToolEvent } from './events';
|
|
@@ -58,10 +57,22 @@ export type { SkillMeta, SkillSearchQuery, ManagedSkillSummary, ManagedSkillDeta
|
|
|
58
57
|
export { skillManagementPlugin } from './skills';
|
|
59
58
|
export { createManagedSkillSummary, createManagedSkillDetail } from './skills';
|
|
60
59
|
export type { SkillManagementOptions, OnSkillCreate, OnSkillUpdate, OnSkillDelete, OnSkillSetEnabled, OnSkillLoadContent, OnSkillLoadReference, } from './skills';
|
|
61
|
-
export {
|
|
62
|
-
export type { LLMConfig,
|
|
63
|
-
export {
|
|
64
|
-
export
|
|
60
|
+
export { getModelEndpoint, resolveEndpointUrl, resolveChatModel, findEndpointByProtocol, } from './llm-config';
|
|
61
|
+
export type { LLMConfig, ModelEndpoint, ModelConfig, CompressionConfig, } from './llm-config';
|
|
62
|
+
export type { ChatModelIntegrationExport } from './build-chat-integration-export';
|
|
63
|
+
export { buildChatModelIntegrationExport } from './build-chat-integration-export';
|
|
64
|
+
export { BUILTIN_PROTOCOL_IDS, BUILTIN_PROTOCOL_FACTORIES, getBuiltinProtocolFactories, isRegisteredProtocolId, } from './protocols/registry';
|
|
65
|
+
export { isChatRuntimeProtocolId, resolveChatRuntimeProtocol, resolveOfficialProxyBaseUrl, resolveServerSupplierPolicy, SERVER_LLM_PROXY_PATH_BY_PROTOCOL, } from './chat-catalog-constants';
|
|
66
|
+
export type { ChatServerSupplierPolicy, ChatServerUpstream, } from './chat-catalog-constants';
|
|
67
|
+
export type { CatalogSupplierKind } from './chat-supplier-constants';
|
|
68
|
+
export { PROXY_SUPPLIER_IDS, isProxySupplierId, normalizeCatalogSupplierKind, resolveCatalogSupplierKind, } from './chat-supplier-constants';
|
|
69
|
+
export { CHAT_RUNTIME_PROTOCOL_OPTIONS, formatChatRuntimeProtocolLabel, } from './chat-runtime-protocol-options';
|
|
70
|
+
export type { ChatModelCatalogItem, ChatSupplierOption, } from './chat-catalog-types';
|
|
71
|
+
export { DEFAULT_CHAT_PROFILE_ID } from './chat-catalog-types';
|
|
72
|
+
export type { ChatModelCompileAccess, ResolveDefaultChatOfferingOptions, } from './compile-chat-model-config';
|
|
73
|
+
export { compileChatModelConfig, resolveDefaultChatOfferingModelId, } from './compile-chat-model-config';
|
|
74
|
+
export type { ServerChatEnv } from './server-chat-endpoint';
|
|
75
|
+
export { getServerChatUpstream, resolveServerChatEndpoint, } from './server-chat-endpoint';
|
|
65
76
|
export { partRegistry } from './parts';
|
|
66
77
|
export type { PartMeta, PartSearchQuery, PartRegistry, ManagedPartSummary, ManagedPartDetail, } from './parts';
|
|
67
78
|
export { createManagedPartSummary, createManagedPartDetail } from './parts';
|