@h-ai/ai 0.1.0-alpha.12 → 0.1.0-alpha.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/{ai-reasoning-types-DvnIDR7a.d.ts → ai-reasoning-types-C1uvQosU.d.ts} +23 -6
- package/dist/{ai-types-B8jZlb4E.d.ts → ai-types-GOmowSTF.d.ts} +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -631,8 +631,8 @@ interface A2ACallResult {
|
|
|
631
631
|
* @module ai-llm-types
|
|
632
632
|
*/
|
|
633
633
|
|
|
634
|
-
/** 消息角色枚举:`'system'` | `'user'` | `'assistant'` | `'tool'` */
|
|
635
|
-
type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
634
|
+
/** 消息角色枚举:`'system'` | `'developer'` | `'user'` | `'assistant'` | `'tool'` */
|
|
635
|
+
type MessageRole = 'system' | 'developer' | 'user' | 'assistant' | 'tool';
|
|
636
636
|
/** 文本内容块(多模态消息中的纯文本部分) */
|
|
637
637
|
type TextContent = OpenAI.Chat.Completions.ChatCompletionContentPartText;
|
|
638
638
|
/** 图片内容块(多模态消息中的图片部分) */
|
|
@@ -641,16 +641,29 @@ type ImageContent = OpenAI.Chat.Completions.ChatCompletionContentPartImage;
|
|
|
641
641
|
type MessageContent = string | OpenAI.Chat.Completions.ChatCompletionContentPart[];
|
|
642
642
|
/** 系统消息,用于设定对话的行为规则 */
|
|
643
643
|
type SystemMessage = OpenAI.Chat.Completions.ChatCompletionSystemMessageParam;
|
|
644
|
+
/** 开发者消息(高优先级运行时约束) */
|
|
645
|
+
interface DeveloperMessage {
|
|
646
|
+
role: 'developer';
|
|
647
|
+
content: string | TextContent[];
|
|
648
|
+
name?: string;
|
|
649
|
+
}
|
|
644
650
|
/** 用户消息 */
|
|
645
651
|
type UserMessage = OpenAI.Chat.Completions.ChatCompletionUserMessageParam;
|
|
646
652
|
/** 工具调用描述,由助手消息中的 `tool_calls` 字段携带 */
|
|
647
653
|
type ToolCall = OpenAI.Chat.Completions.ChatCompletionMessageToolCall;
|
|
648
654
|
/** 助手消息(模型生成的回复,或传入对话上下文的助手轮次) */
|
|
649
|
-
type AssistantMessage = OpenAI.Chat.Completions.ChatCompletionAssistantMessageParam
|
|
655
|
+
type AssistantMessage = OpenAI.Chat.Completions.ChatCompletionAssistantMessageParam & {
|
|
656
|
+
/**
|
|
657
|
+
* 推理模型额外返回的思维链内容。
|
|
658
|
+
*
|
|
659
|
+
* DeepSeek thinking mode 在 function calling 多轮续写时要求回传该字段。
|
|
660
|
+
*/
|
|
661
|
+
reasoning_content?: string | null;
|
|
662
|
+
};
|
|
650
663
|
/** 工具消息(工具执行结果,用于回传给模型) */
|
|
651
664
|
type ToolMessage = OpenAI.Chat.Completions.ChatCompletionToolMessageParam;
|
|
652
665
|
/** 聊天消息联合类型,涵盖对话中所有角色的消息 */
|
|
653
|
-
type ChatMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
|
666
|
+
type ChatMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam | DeveloperMessage;
|
|
654
667
|
/** OpenAI function calling 工具定义格式 */
|
|
655
668
|
type ToolDefinition = OpenAI.Chat.Completions.ChatCompletionTool;
|
|
656
669
|
/**
|
|
@@ -660,7 +673,9 @@ type ToolDefinition = OpenAI.Chat.Completions.ChatCompletionTool;
|
|
|
660
673
|
* `model` 改为可选(未指定时使用配置中的默认模型)。
|
|
661
674
|
* `stream` 字段由框架内部控制,不对外暴露。
|
|
662
675
|
*/
|
|
663
|
-
type ChatCompletionRequest = Omit<OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, 'model' | 'stream'> & {
|
|
676
|
+
type ChatCompletionRequest = Omit<OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, 'model' | 'stream' | 'messages'> & {
|
|
677
|
+
/** 对话消息列表 */
|
|
678
|
+
messages: ChatMessage[];
|
|
664
679
|
/** 模型名称(可选,未指定时使用配置中的默认模型) */
|
|
665
680
|
model?: string;
|
|
666
681
|
/** 交互主体 ID(传入后 LLM 会自动关联到该主体) */
|
|
@@ -684,6 +699,8 @@ type ChatCompletionChunk = OpenAI.Chat.ChatCompletionChunk;
|
|
|
684
699
|
interface StreamResult {
|
|
685
700
|
/** 累积的完整文本内容 */
|
|
686
701
|
content: string;
|
|
702
|
+
/** 累积的完整 reasoning 内容 */
|
|
703
|
+
reasoningContent: string;
|
|
687
704
|
/** 累积的完整工具调用列表 */
|
|
688
705
|
toolCalls: ToolCall[];
|
|
689
706
|
/** 完成原因(流未结束时为 `null`) */
|
|
@@ -2822,4 +2839,4 @@ interface ReasoningOperations {
|
|
|
2822
2839
|
runStream: (query: string, options?: ReasoningOptions) => AsyncIterable<ReasoningStreamEvent>;
|
|
2823
2840
|
}
|
|
2824
2841
|
|
|
2825
|
-
export { type A2AOperations as $, type A2AConfig as A, type RetrievalConfig as B, type CompressConfig as C, RetrievalConfigSchema as D, type EmbeddingConfig as E, type FileConfig as F, type RetrievalSourceConfig as G, RetrievalSourceSchema as H, SummaryConfigSchema as I, TokenConfigSchema as J, type KnowledgeConfig as K, type LLMConfig as L, type MCPConfig as M, resolveModelEntry as N, type A2AAgentCardConfig as O, type A2AApiKeySecurity as P, type A2AAuthenticator as Q, type ResolveRequiredModelEntryOptions as R, type SummaryConfig as S, type TokenConfig as T, type A2ACallOptions as U, type A2ACallResult as V, type A2ACallerIdentity as W, type A2AClientCallRecord as X, type A2AContextInfo as Y, type A2AHandleResult as Z, type A2AMessageRecord as _, A2AConfigSchema as a, type
|
|
2842
|
+
export { type A2AOperations as $, type A2AConfig as A, type RetrievalConfig as B, type CompressConfig as C, RetrievalConfigSchema as D, type EmbeddingConfig as E, type FileConfig as F, type RetrievalSourceConfig as G, RetrievalSourceSchema as H, SummaryConfigSchema as I, TokenConfigSchema as J, type KnowledgeConfig as K, type LLMConfig as L, type MCPConfig as M, resolveModelEntry as N, type A2AAgentCardConfig as O, type A2AApiKeySecurity as P, type A2AAuthenticator as Q, type ResolveRequiredModelEntryOptions as R, type SummaryConfig as S, type TokenConfig as T, type A2ACallOptions as U, type A2ACallResult as V, type A2ACallerIdentity as W, type A2AClientCallRecord as X, type A2AContextInfo as Y, type A2AHandleResult as Z, type A2AMessageRecord as _, A2AConfigSchema as a, type ReasoningOperations as a$, type A2ASecurityConfig as a0, type A2ATaskFilter as a1, type AILLMFunctionsDeps as a2, type AIRelStore as a3, type AIRelStoreOptions as a4, type AIStoreProvider as a5, type AIVectorStore as a6, type AskOptions as a7, type AssistantMessage as a8, type ChatCompletionChoice as a9, type KnowledgeIngestResult as aA, type KnowledgeOperations as aB, type KnowledgeRetrieveItem as aC, type KnowledgeRetrieveOptions as aD, type KnowledgeRetrieveResult as aE, type KnowledgeSetupOptions as aF, type KnowledgeStore as aG, type LLMOperations as aH, type LLMProvider as aI, type MemoryClearOptions as aJ, type MemoryEntry as aK, type MemoryEntryInput as aL, type MemoryExtractOptions as aM, type MemoryInjectionOptions as aN, type MemoryListOptions as aO, type MemoryListPageOptions as aP, type MemoryOperations as aQ, type MemoryRecallOptions as aR, type MemoryUpdateInput as aS, type MessageContent as aT, type MessageRole as aU, type ObjectRef as aV, type RagContextItem as aW, type RagOperations as aX, type RagOptions as aY, type RagResult as aZ, type RagStreamEvent as a_, type ChatCompletionChunk as aa, type ChatCompletionDelta as ab, type ChatCompletionRequest as ac, type ChatCompletionResponse as ad, type ChatHistoryOptions as ae, type ChatMessage as af, type ChatRecord as ag, type Citation as ah, type DefineToolOptions as ai, type DeveloperMessage as aj, type EntityDocumentRelation as ak, type EntityDocumentResult as al, type EntityListOptions as am, type EntityQueryOptions as an, type ImageContent as ao, type InteractionScope as ap, type KnowledgeAskOptions as aq, type KnowledgeAskResult as ar, type KnowledgeDocumentInfo as as, type KnowledgeDocumentListOptions as at, type KnowledgeDocumentRemoveOptions as au, type KnowledgeEntity as av, type KnowledgeIngestBatchProgress as aw, type KnowledgeIngestBatchResult as ax, type KnowledgeIngestFileInput as ay, type KnowledgeIngestInput as az, A2ASkillConfigSchema as b, type ReasoningOptions as b0, type ReasoningResult as b1, type ReasoningStep as b2, type ReasoningStepType as b3, type ReasoningStrategy as b4, type ReasoningStreamEvent as b5, type RetrievalOperations as b6, type RetrievalRequest as b7, type RetrievalResult as b8, type RetrievalResultItem as b9, type RetrievalSource as ba, type SSEDecoder as bb, type SSEEvent as bc, type SessionInfo as bd, type StoreFilter as be, type StorePage as bf, type StoreScope as bg, type StreamOperations as bh, type StreamProcessor as bi, type StreamResult as bj, type SystemMessage as bk, type TextContent as bl, type TokenUsage as bm, type Tool as bn, type ToolCall as bo, type ToolDefinition as bp, type ToolErrorType as bq, type ToolMessage as br, type ToolRegistryOperations as bs, type ToolsOperations as bt, type UserMessage as bu, type WhereClause as bv, type WhereOperator as bw, type WhereValue as bx, type AIConfig as c, type AIConfigInput as d, AIConfigSchema as e, CompressConfigSchema as f, EmbeddingConfigSchema as g, type EntityType as h, EntityTypeSchema as i, FileConfigSchema as j, KnowledgeConfigSchema as k, LLMConfigSchema as l, MCPConfigSchema as m, type MCPServerCapabilities as n, MCPServerCapabilitiesSchema as o, type MCPServerConfig as p, MCPServerConfigSchema as q, type MemoryConfig as r, MemoryConfigSchema as s, type MemoryType as t, MemoryTypeSchema as u, type ModelEntry as v, ModelEntrySchema as w, type ModelScenario as x, ModelScenarioSchema as y, type ResolvedModelConfig as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _h_ai_core from '@h-ai/core';
|
|
2
2
|
import { HaiResult } from '@h-ai/core';
|
|
3
|
-
import { af as ChatMessage,
|
|
3
|
+
import { af as ChatMessage, ap as InteractionScope, aN as MemoryInjectionOptions, aY as RagOptions, b0 as ReasoningOptions, bs as ToolRegistryOperations, bd as SessionInfo, aH as LLMOperations, aQ as MemoryOperations, aX as RagOperations, a$ as ReasoningOperations, c as AIConfig, d as AIConfigInput, a5 as AIStoreProvider, bt as ToolsOperations, bh as StreamOperations, b6 as RetrievalOperations, aB as KnowledgeOperations, $ as A2AOperations } from './ai-reasoning-types-C1uvQosU.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { Buffer } from 'node:buffer';
|
|
6
6
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, C as CompressConfig, f as CompressConfigSchema, E as EmbeddingConfig, g as EmbeddingConfigSchema, h as EntityType, i as EntityTypeSchema, F as FileConfig, j as FileConfigSchema, K as KnowledgeConfig, k as KnowledgeConfigSchema, L as LLMConfig, l as LLMConfigSchema, M as MCPConfig, m as MCPConfigSchema, n as MCPServerCapabilities, o as MCPServerCapabilitiesSchema, p as MCPServerConfig, q as MCPServerConfigSchema, r as MemoryConfig, s as MemoryConfigSchema, t as MemoryType, u as MemoryTypeSchema, v as ModelEntry, w as ModelEntrySchema, x as ModelScenario, y as ModelScenarioSchema, R as ResolveRequiredModelEntryOptions, z as ResolvedModelConfig, B as RetrievalConfig, D as RetrievalConfigSchema, G as RetrievalSourceConfig, H as RetrievalSourceSchema, S as SummaryConfig, I as SummaryConfigSchema, T as TokenConfig, J as TokenConfigSchema, N as resolveModelEntry } from './ai-reasoning-types-
|
|
2
|
-
export { A as AIFunctions, a as AIInitOptions, C as CompressionStrategy, b as CompressionStrategySchema, H as HaiAIError } from './ai-types-
|
|
1
|
+
export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, C as CompressConfig, f as CompressConfigSchema, E as EmbeddingConfig, g as EmbeddingConfigSchema, h as EntityType, i as EntityTypeSchema, F as FileConfig, j as FileConfigSchema, K as KnowledgeConfig, k as KnowledgeConfigSchema, L as LLMConfig, l as LLMConfigSchema, M as MCPConfig, m as MCPConfigSchema, n as MCPServerCapabilities, o as MCPServerCapabilitiesSchema, p as MCPServerConfig, q as MCPServerConfigSchema, r as MemoryConfig, s as MemoryConfigSchema, t as MemoryType, u as MemoryTypeSchema, v as ModelEntry, w as ModelEntrySchema, x as ModelScenario, y as ModelScenarioSchema, R as ResolveRequiredModelEntryOptions, z as ResolvedModelConfig, B as RetrievalConfig, D as RetrievalConfigSchema, G as RetrievalSourceConfig, H as RetrievalSourceSchema, S as SummaryConfig, I as SummaryConfigSchema, T as TokenConfig, J as TokenConfigSchema, N as resolveModelEntry } from './ai-reasoning-types-C1uvQosU.js';
|
|
2
|
+
export { A as AIFunctions, a as AIInitOptions, C as CompressionStrategy, b as CompressionStrategySchema, H as HaiAIError } from './ai-types-GOmowSTF.js';
|
|
3
3
|
export { A2AClientOperations, AIApiAdapter, AIClient, AIClientConfig, StreamOptions, StreamProgress, collectStreamContent, createA2AClient, createAIClient, parseSSE } from './client/index.js';
|
|
4
4
|
import '@a2a-js/sdk/server';
|
|
5
5
|
import '@h-ai/core';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ac as ChatCompletionRequest, ad as ChatCompletionResponse, aa as ChatCompletionChunk,
|
|
1
|
+
import { ac as ChatCompletionRequest, ad as ChatCompletionResponse, aa as ChatCompletionChunk, aE as KnowledgeRetrieveResult, ar as KnowledgeAskResult, aA as KnowledgeIngestResult, as as KnowledgeDocumentInfo, aK as MemoryEntry, bf as StorePage, aL as MemoryEntryInput, aS as MemoryUpdateInput, bd as SessionInfo, ag as ChatRecord, aZ as RagResult, b1 as ReasoningResult, O as A2AAgentCardConfig, _ as A2AMessageRecord, V as A2ACallResult } from '../ai-reasoning-types-C1uvQosU.js';
|
|
2
2
|
import { HaiResult } from '@h-ai/core';
|
|
3
3
|
import '@a2a-js/sdk/server';
|
|
4
4
|
import '@h-ai/datapipe';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { O as A2AAgentCardConfig, P as A2AApiKeySecurity, Q as A2AAuthenticator, U as A2ACallOptions, V as A2ACallResult, W as A2ACallerIdentity, X as A2AClientCallRecord, A as A2AConfig, a as A2AConfigSchema, Y as A2AContextInfo, Z as A2AHandleResult, _ as A2AMessageRecord, $ as A2AOperations, a0 as A2ASecurityConfig, b as A2ASkillConfigSchema, a1 as A2ATaskFilter, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, a2 as AILLMFunctionsDeps, a3 as AIRelStore, a4 as AIRelStoreOptions, a5 as AIStoreProvider, a6 as AIVectorStore, a7 as AskOptions, a8 as AssistantMessage, a9 as ChatCompletionChoice, aa as ChatCompletionChunk, ab as ChatCompletionDelta, ac as ChatCompletionRequest, ad as ChatCompletionResponse, ae as ChatHistoryOptions, af as ChatMessage, ag as ChatRecord, ah as Citation, C as CompressConfig, f as CompressConfigSchema, ai as DefineToolOptions, E as EmbeddingConfig, g as EmbeddingConfigSchema,
|
|
2
|
-
import { A as AIFunctions } from './ai-types-
|
|
3
|
-
export { a as AIInitOptions, c as AIMCPFunctionsDeps, d as CompressOperations, e as CompressOptions, f as CompressResult, C as CompressionStrategy, b as CompressionStrategySchema, g as ContextChatOptions, h as ContextChatResult, i as ContextDeps, j as ContextManager, k as ContextManagerOptions, l as ContextOperations, m as ContextStreamEvent, E as EmbeddingItem, n as EmbeddingOperations, o as EmbeddingProvider, p as EmbeddingRequest, q as EmbeddingResponse, F as FileOperations, r as FileParseMethod, s as FileParseOptions, t as FileParseRequest, u as FileParseResult, H as HaiAIError, M as MCPContext, v as MCPOperations, w as MCPPrompt, x as MCPPromptArgument, y as MCPPromptContent, z as MCPPromptMessage, B as MCPProvider, D as MCPResource, G as MCPResourceContent, I as MCPToolDefinition, J as MCPToolHandler, K as McpServerOptions, O as OutputFormat, R as RerankDocument, L as RerankItem, N as RerankOperations, P as RerankRequest, Q as RerankResponse, S as SummaryOperations, T as SummaryOptions, U as SummaryResult, V as TokenOperations } from './ai-types-
|
|
1
|
+
export { O as A2AAgentCardConfig, P as A2AApiKeySecurity, Q as A2AAuthenticator, U as A2ACallOptions, V as A2ACallResult, W as A2ACallerIdentity, X as A2AClientCallRecord, A as A2AConfig, a as A2AConfigSchema, Y as A2AContextInfo, Z as A2AHandleResult, _ as A2AMessageRecord, $ as A2AOperations, a0 as A2ASecurityConfig, b as A2ASkillConfigSchema, a1 as A2ATaskFilter, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, a2 as AILLMFunctionsDeps, a3 as AIRelStore, a4 as AIRelStoreOptions, a5 as AIStoreProvider, a6 as AIVectorStore, a7 as AskOptions, a8 as AssistantMessage, a9 as ChatCompletionChoice, aa as ChatCompletionChunk, ab as ChatCompletionDelta, ac as ChatCompletionRequest, ad as ChatCompletionResponse, ae as ChatHistoryOptions, af as ChatMessage, ag as ChatRecord, ah as Citation, C as CompressConfig, f as CompressConfigSchema, ai as DefineToolOptions, aj as DeveloperMessage, E as EmbeddingConfig, g as EmbeddingConfigSchema, ak as EntityDocumentRelation, al as EntityDocumentResult, am as EntityListOptions, an as EntityQueryOptions, h as EntityType, i as EntityTypeSchema, F as FileConfig, j as FileConfigSchema, ao as ImageContent, ap as InteractionScope, aq as KnowledgeAskOptions, ar as KnowledgeAskResult, K as KnowledgeConfig, k as KnowledgeConfigSchema, as as KnowledgeDocumentInfo, at as KnowledgeDocumentListOptions, au as KnowledgeDocumentRemoveOptions, av as KnowledgeEntity, aw as KnowledgeIngestBatchProgress, ax as KnowledgeIngestBatchResult, ay as KnowledgeIngestFileInput, az as KnowledgeIngestInput, aA as KnowledgeIngestResult, aB as KnowledgeOperations, aC as KnowledgeRetrieveItem, aD as KnowledgeRetrieveOptions, aE as KnowledgeRetrieveResult, aF as KnowledgeSetupOptions, aG as KnowledgeStore, L as LLMConfig, l as LLMConfigSchema, aH as LLMOperations, aI as LLMProvider, M as MCPConfig, m as MCPConfigSchema, n as MCPServerCapabilities, o as MCPServerCapabilitiesSchema, p as MCPServerConfig, q as MCPServerConfigSchema, aJ as MemoryClearOptions, r as MemoryConfig, s as MemoryConfigSchema, aK as MemoryEntry, aL as MemoryEntryInput, aM as MemoryExtractOptions, aN as MemoryInjectionOptions, aO as MemoryListOptions, aP as MemoryListPageOptions, aQ as MemoryOperations, aR as MemoryRecallOptions, t as MemoryType, u as MemoryTypeSchema, aS as MemoryUpdateInput, aT as MessageContent, aU as MessageRole, v as ModelEntry, w as ModelEntrySchema, x as ModelScenario, y as ModelScenarioSchema, aV as ObjectRef, aW as RagContextItem, aX as RagOperations, aY as RagOptions, aZ as RagResult, a_ as RagStreamEvent, a$ as ReasoningOperations, b0 as ReasoningOptions, b1 as ReasoningResult, b2 as ReasoningStep, b3 as ReasoningStepType, b4 as ReasoningStrategy, b5 as ReasoningStreamEvent, R as ResolveRequiredModelEntryOptions, z as ResolvedModelConfig, B as RetrievalConfig, D as RetrievalConfigSchema, b6 as RetrievalOperations, b7 as RetrievalRequest, b8 as RetrievalResult, b9 as RetrievalResultItem, ba as RetrievalSource, G as RetrievalSourceConfig, H as RetrievalSourceSchema, bb as SSEDecoder, bc as SSEEvent, bd as SessionInfo, be as StoreFilter, bf as StorePage, bg as StoreScope, bh as StreamOperations, bi as StreamProcessor, bj as StreamResult, S as SummaryConfig, I as SummaryConfigSchema, bk as SystemMessage, bl as TextContent, T as TokenConfig, J as TokenConfigSchema, bm as TokenUsage, bn as Tool, bo as ToolCall, bp as ToolDefinition, bq as ToolErrorType, br as ToolMessage, bs as ToolRegistryOperations, bt as ToolsOperations, bu as UserMessage, bv as WhereClause, bw as WhereOperator, bx as WhereValue, N as resolveModelEntry } from './ai-reasoning-types-C1uvQosU.js';
|
|
2
|
+
import { A as AIFunctions } from './ai-types-GOmowSTF.js';
|
|
3
|
+
export { a as AIInitOptions, c as AIMCPFunctionsDeps, d as CompressOperations, e as CompressOptions, f as CompressResult, C as CompressionStrategy, b as CompressionStrategySchema, g as ContextChatOptions, h as ContextChatResult, i as ContextDeps, j as ContextManager, k as ContextManagerOptions, l as ContextOperations, m as ContextStreamEvent, E as EmbeddingItem, n as EmbeddingOperations, o as EmbeddingProvider, p as EmbeddingRequest, q as EmbeddingResponse, F as FileOperations, r as FileParseMethod, s as FileParseOptions, t as FileParseRequest, u as FileParseResult, H as HaiAIError, M as MCPContext, v as MCPOperations, w as MCPPrompt, x as MCPPromptArgument, y as MCPPromptContent, z as MCPPromptMessage, B as MCPProvider, D as MCPResource, G as MCPResourceContent, I as MCPToolDefinition, J as MCPToolHandler, K as McpServerOptions, O as OutputFormat, R as RerankDocument, L as RerankItem, N as RerankOperations, P as RerankRequest, Q as RerankResponse, S as SummaryOperations, T as SummaryOptions, U as SummaryResult, V as TokenOperations } from './ai-types-GOmowSTF.js';
|
|
4
4
|
export { TaskStore as A2ATaskStore, AgentExecutor, ExecutionEventBus, RequestContext, ServerCallContext } from '@a2a-js/sdk/server';
|
|
5
5
|
export { AgentCapabilities, AgentCard, AgentProvider, AgentSkill, Artifact, DataPart, FilePart, FileWithBytes, FileWithUri, Message, MessageSendParams, Part, PushNotificationConfig, Task, TaskArtifactUpdateEvent, TaskIdParams, TaskQueryParams, TaskState, TaskStatus, TaskStatusUpdateEvent, TextPart } from '@a2a-js/sdk';
|
|
6
6
|
import '@h-ai/core';
|
package/dist/index.js
CHANGED
|
@@ -437,6 +437,7 @@ ${summaryText}`
|
|
|
437
437
|
// src/llm/ai-llm-stream.ts
|
|
438
438
|
function createStreamProcessor() {
|
|
439
439
|
let content = "";
|
|
440
|
+
let reasoningContent = "";
|
|
440
441
|
let toolCalls = /* @__PURE__ */ new Map();
|
|
441
442
|
let finishReason = null;
|
|
442
443
|
return {
|
|
@@ -449,6 +450,10 @@ function createStreamProcessor() {
|
|
|
449
450
|
if (delta.content) {
|
|
450
451
|
content += delta.content;
|
|
451
452
|
}
|
|
453
|
+
const reasoningDelta = "reasoning_content" in delta && typeof delta.reasoning_content === "string" ? delta.reasoning_content : "";
|
|
454
|
+
if (reasoningDelta) {
|
|
455
|
+
reasoningContent += reasoningDelta;
|
|
456
|
+
}
|
|
452
457
|
if (delta.tool_calls) {
|
|
453
458
|
for (const tc of delta.tool_calls) {
|
|
454
459
|
const existing = toolCalls.get(tc.index);
|
|
@@ -477,6 +482,7 @@ function createStreamProcessor() {
|
|
|
477
482
|
getResult() {
|
|
478
483
|
return {
|
|
479
484
|
content,
|
|
485
|
+
reasoningContent,
|
|
480
486
|
toolCalls: Array.from(toolCalls.values()).map((tc) => ({
|
|
481
487
|
id: tc.id,
|
|
482
488
|
type: "function",
|
|
@@ -495,6 +501,9 @@ function createStreamProcessor() {
|
|
|
495
501
|
role: "assistant",
|
|
496
502
|
content: result.toolCalls.length > 0 ? null : result.content
|
|
497
503
|
};
|
|
504
|
+
if (result.reasoningContent) {
|
|
505
|
+
message.reasoning_content = result.reasoningContent;
|
|
506
|
+
}
|
|
498
507
|
if (result.toolCalls.length > 0) {
|
|
499
508
|
message.tool_calls = result.toolCalls;
|
|
500
509
|
}
|
|
@@ -503,6 +512,7 @@ function createStreamProcessor() {
|
|
|
503
512
|
/** 重置所有状态,可复用处理器处理下一次流 */
|
|
504
513
|
reset() {
|
|
505
514
|
content = "";
|
|
515
|
+
reasoningContent = "";
|
|
506
516
|
toolCalls = /* @__PURE__ */ new Map();
|
|
507
517
|
finishReason = null;
|
|
508
518
|
}
|
|
@@ -2353,6 +2363,17 @@ function toAIError(error) {
|
|
|
2353
2363
|
cause: sanitizeErrorCause(error)
|
|
2354
2364
|
};
|
|
2355
2365
|
}
|
|
2366
|
+
function toOpenAIMessage(message) {
|
|
2367
|
+
if (message.role === "developer") {
|
|
2368
|
+
const developerMessage = {
|
|
2369
|
+
role: "developer",
|
|
2370
|
+
content: message.content,
|
|
2371
|
+
...message.name ? { name: message.name } : {}
|
|
2372
|
+
};
|
|
2373
|
+
return developerMessage;
|
|
2374
|
+
}
|
|
2375
|
+
return message;
|
|
2376
|
+
}
|
|
2356
2377
|
function createOpenAIProvider(deps) {
|
|
2357
2378
|
const { config } = deps;
|
|
2358
2379
|
const clientCache = /* @__PURE__ */ new Map();
|
|
@@ -2381,9 +2402,11 @@ function createOpenAIProvider(deps) {
|
|
|
2381
2402
|
return clientResult;
|
|
2382
2403
|
const { client, model } = clientResult.data;
|
|
2383
2404
|
const { objectId: _objectId, sessionId: _sessionId, ...openaiRequest } = request;
|
|
2405
|
+
const openaiMessages = request.messages.map(toOpenAIMessage);
|
|
2384
2406
|
try {
|
|
2385
2407
|
const response = await client.chat.completions.create({
|
|
2386
2408
|
...openaiRequest,
|
|
2409
|
+
messages: openaiMessages,
|
|
2387
2410
|
model,
|
|
2388
2411
|
stream: false
|
|
2389
2412
|
});
|
|
@@ -2399,8 +2422,10 @@ function createOpenAIProvider(deps) {
|
|
|
2399
2422
|
throw new Error(clientResult.error.message);
|
|
2400
2423
|
const { client, model } = clientResult.data;
|
|
2401
2424
|
const { objectId: _objectId, sessionId: _sessionId, ...openaiRequest } = request;
|
|
2425
|
+
const openaiMessages = request.messages.map(toOpenAIMessage);
|
|
2402
2426
|
const stream = await client.chat.completions.create({
|
|
2403
2427
|
...openaiRequest,
|
|
2428
|
+
messages: openaiMessages,
|
|
2404
2429
|
model,
|
|
2405
2430
|
stream: true
|
|
2406
2431
|
});
|