@h-ai/ai 0.1.0-alpha.36 → 0.1.0-alpha.37

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.
@@ -426,7 +426,8 @@ interface AIVectorBackend {
426
426
  * AI 存储 Provider 接口
427
427
  *
428
428
  * 负责创建 AIRelStore / AIVectorStore 实例,并管理存储层生命周期。
429
- * 默认实现基于 reldb + vecdb;也可对接 SaaS API 或其他后端。
429
+ * reldb + vecdb 已初始化时默认使用持久化 DB 实现,否则使用进程内临时实现;
430
+ * 也可对接 SaaS API 或其他后端。
430
431
  *
431
432
  * @example
432
433
  * ```ts
@@ -818,7 +819,67 @@ interface StreamOperations {
818
819
  encodeSSE: (event: SSEEvent) => string;
819
820
  }
820
821
  /** 工具错误类型枚举 */
821
- type ToolErrorType = 'TOOL_NOT_FOUND' | 'VALIDATION_FAILED' | 'EXECUTION_FAILED' | 'TIMEOUT';
822
+ type ToolErrorType = 'TOOL_NOT_FOUND' | 'TOOL_ALREADY_REGISTERED' | 'VALIDATION_FAILED' | 'EXECUTION_FAILED' | 'FORBIDDEN' | 'TIMEOUT';
823
+ /**
824
+ * 工具执行上下文(传给 handler)
825
+ *
826
+ * 由框架在 `execute` / `executeAll` 时构造并透传给工具 handler,使工具能够:
827
+ * - 响应取消(主持人打断、上层 AbortSignal)提前中止耗时操作(DB 查询 / HTTP 请求);
828
+ * - 感知超时截止时间;
829
+ * - 获知当前交互主体 / 会话,做数据隔离或审计。
830
+ *
831
+ * `signal` 始终存在:即便调用方未传入信号,框架也会依据默认超时构造一个。
832
+ */
833
+ interface ToolExecutionContext {
834
+ /** 取消信号(始终存在;结合调用方信号与超时截止) */
835
+ signal: AbortSignal;
836
+ /** 交互主体 ID(透传自 Context / Reasoning 作用域) */
837
+ objectId?: string;
838
+ /** 会话 ID(透传自 Context / Reasoning 作用域) */
839
+ sessionId?: string;
840
+ /** 截止时间(Unix 毫秒;到期自动取消) */
841
+ deadline?: number;
842
+ }
843
+ /**
844
+ * 工具授权请求
845
+ *
846
+ * `input` 已通过工具的 Zod schema 校验;授权函数在 handler 执行前调用。
847
+ */
848
+ interface ToolAuthorizationRequest<TInput = unknown> {
849
+ /** 工具名称 */
850
+ toolName: string;
851
+ /** 已校验的工具输入 */
852
+ input: TInput;
853
+ /** 本次执行上下文 */
854
+ context: ToolExecutionContext;
855
+ }
856
+ /** 工具授权函数;返回 `false` 或抛出异常时均拒绝执行(fail-closed) */
857
+ type ToolAuthorizer = (request: ToolAuthorizationRequest) => Promise<boolean> | boolean;
858
+ /**
859
+ * 工具执行入参(调用方传给 `execute` / `executeAll`)
860
+ *
861
+ * 所有字段可选。框架据此解析出传给 handler 的 {@link ToolExecutionContext}:
862
+ * 组合调用方 `signal` 与超时信号,超时优先级 `deadline` > `timeoutMs` > 工具默认 > 全局默认。
863
+ */
864
+ interface ToolExecutionOptions {
865
+ /** 调用方取消信号(与超时信号组合) */
866
+ signal?: AbortSignal;
867
+ /** 交互主体 ID */
868
+ objectId?: string;
869
+ /** 会话 ID */
870
+ sessionId?: string;
871
+ /** 截止时间(Unix 毫秒;优先级高于 timeoutMs) */
872
+ deadline?: number;
873
+ /** 本次执行超时(毫秒;覆盖工具默认超时) */
874
+ timeoutMs?: number;
875
+ /**
876
+ * 本次执行授权函数
877
+ *
878
+ * 与 Registry 级授权同时存在时必须全部通过。授权异常不会进入 handler,统一返回
879
+ * `TOOL_FORBIDDEN`,避免因授权服务故障而放行高风险操作。
880
+ */
881
+ authorize?: ToolAuthorizer;
882
+ }
822
883
  /**
823
884
  * 工具定义选项(传给 `ai.tools.define()`)
824
885
  *
@@ -832,8 +893,15 @@ interface DefineToolOptions<TInput, TOutput> {
832
893
  description: string;
833
894
  /** Zod schema,用于参数校验和 JSON Schema 转换 */
834
895
  parameters: ZodType<TInput>;
835
- /** 执行函数,接收校验后的参数,支持同步/异步 */
836
- handler: (input: TInput) => Promise<TOutput> | TOutput;
896
+ /**
897
+ * 执行函数,接收校验后的参数与执行上下文,支持同步/异步
898
+ *
899
+ * `context.signal` 用于响应取消:长耗时操作应把它透传给 DB / HTTP 客户端,
900
+ * 以便打断或超时时提前中止。
901
+ */
902
+ handler: (input: TInput, context: ToolExecutionContext) => Promise<TOutput> | TOutput;
903
+ /** 本工具默认执行超时(毫秒;execute 未指定 deadline/timeoutMs 时生效) */
904
+ timeoutMs?: number;
837
905
  }
838
906
  /**
839
907
  * 工具实例(由 `ai.tools.define()` 创建)
@@ -848,21 +916,24 @@ interface Tool<TInput = unknown, TOutput = unknown> {
848
916
  description: string;
849
917
  /** Zod 参数 schema */
850
918
  parameters: ZodType<TInput>;
851
- /** 执行工具(自动校验参数),失败返回 ToolError */
852
- execute: (input: TInput) => Promise<HaiResult<TOutput>>;
919
+ /** 执行工具(自动校验参数),失败返回 ToolError;超时 / 取消返回 TOOL_TIMEOUT */
920
+ execute: (input: TInput, options?: ToolExecutionOptions) => Promise<HaiResult<TOutput>>;
853
921
  /** 转换为 OpenAI function calling 定义格式($schema 字段已移除) */
854
922
  toDefinition: () => ToolDefinition;
855
923
  }
856
924
  /**
857
925
  * 工具注册表接口(由 `ai.tools.createRegistry()` 创建)
858
926
  *
859
- * 管理一组工具的注册、查询与批量执行,支持链式调用。
927
+ * 管理一组工具的注册、查询与批量执行。注册方法返回 `HaiResult<void>`,
928
+ * 调用方应显式处理重名等配置错误。
860
929
  */
861
930
  interface ToolRegistryOperations {
862
- /** 注册工具(同名覆盖),返回 registry 自身以支持链式调用 */
863
- register: <TInput, TOutput>(tool: Tool<TInput, TOutput>) => ToolRegistryOperations;
864
- /** 批量注册工具,返回 registry 自身 */
865
- registerMany: (tools: Tool<unknown, unknown>[]) => ToolRegistryOperations;
931
+ /** 注册工具;同名工具已存在时返回 `TOOL_ALREADY_REGISTERED` */
932
+ register: <TInput, TOutput>(tool: Tool<TInput, TOutput>) => HaiResult<void>;
933
+ /** 原子批量注册;列表内或注册表内存在重名时不写入任何工具 */
934
+ registerMany: (tools: Tool<unknown, unknown>[]) => HaiResult<void>;
935
+ /** 显式替换已注册工具;目标不存在时返回 `TOOL_NOT_FOUND` */
936
+ replace: <TInput, TOutput>(tool: Tool<TInput, TOutput>) => HaiResult<void>;
866
937
  /** 注销指定名称的工具,成功返回 `true`,不存在返回 `false` */
867
938
  unregister: (name: string) => boolean;
868
939
  /** 按名称获取工具实例,不存在返回 `undefined` */
@@ -873,10 +944,10 @@ interface ToolRegistryOperations {
873
944
  getNames: () => string[];
874
945
  /** 获取所有工具的 OpenAI function calling 定义(用于传入 ChatCompletionRequest.tools) */
875
946
  getDefinitions: () => ToolDefinition[];
876
- /** 执行单个工具调用,自动解析 JSON 参数并校验;失败返回 ToolError */
877
- execute: (toolCall: ToolCall) => Promise<HaiResult<ToolMessage>>;
878
- /** 批量执行工具调用(默认并行),任一失败立即返回错误 */
879
- executeAll: (toolCalls: ToolCall[], options?: {
947
+ /** 执行单个工具调用,自动解析 JSON 参数并校验;失败返回 ToolError,超时 / 取消返回 TOOL_TIMEOUT */
948
+ execute: (toolCall: ToolCall, options?: ToolExecutionOptions) => Promise<HaiResult<ToolMessage>>;
949
+ /** 批量执行工具调用(默认串行),任一失败立即返回错误;仅显式 `parallel: true` 时并行 */
950
+ executeAll: (toolCalls: ToolCall[], options?: ToolExecutionOptions & {
880
951
  parallel?: boolean;
881
952
  }) => Promise<HaiResult<ToolMessage[]>>;
882
953
  /** 清空所有已注册的工具 */
@@ -884,12 +955,22 @@ interface ToolRegistryOperations {
884
955
  /** 当前已注册的工具数量 */
885
956
  readonly size: number;
886
957
  }
958
+ /** 工具注册表创建选项 */
959
+ interface ToolRegistryOptions {
960
+ /**
961
+ * Registry 级授权函数
962
+ *
963
+ * 适合统一执行租户、角色、资源归属和高风险操作确认。它不能替代 handler 内针对最终资源的
964
+ * 业务校验;两层校验应共同采用最小权限原则。
965
+ */
966
+ authorize?: ToolAuthorizer;
967
+ }
887
968
  /** 工具操作接口(通过 `ai.tools` 访问,纯函数,无需初始化) */
888
969
  interface ToolsOperations {
889
970
  /** 定义工具(Zod schema 类型推断 + 自动参数校验) */
890
971
  define: <TInput, TOutput>(options: DefineToolOptions<TInput, TOutput>) => Tool<TInput, TOutput>;
891
- /** 创建新的工具注册表实例 */
892
- createRegistry: () => ToolRegistryOperations;
972
+ /** 创建新的工具注册表实例,可注入统一授权函数 */
973
+ createRegistry: (options?: ToolRegistryOptions) => ToolRegistryOperations;
893
974
  }
894
975
  /** 对话记录查询选项 */
895
976
  interface ChatHistoryOptions {
@@ -1935,7 +2016,49 @@ interface MemoryAccessScope {
1935
2016
  /** 业务作用域(entry.scope 必须包含这些 key-value) */
1936
2017
  scope?: Record<string, unknown>;
1937
2018
  }
1938
- interface MemoryOperations {
2019
+ /**
2020
+ * 记忆作用域绑定(`ai.memory.scoped()` 使用)
2021
+ *
2022
+ * 绑定后,所有操作自动携带 `objectId` 与 `scope`,无需每次手动传入,
2023
+ * 从根本上避免「忘记传 objectId 导致跨租户越权」的安全隐患。
2024
+ */
2025
+ interface ScopedMemoryBinding {
2026
+ /** 归属主体 ID(所有操作自动绑定) */
2027
+ objectId: string;
2028
+ /** 业务作用域(所有操作自动绑定并作为归属校验的一部分,如 `{ topicId, personaId }`) */
2029
+ scope?: Record<string, unknown>;
2030
+ }
2031
+ /**
2032
+ * 全局清空选项(`ai.memory.admin.clearAll()` 使用)
2033
+ *
2034
+ * 危险操作:清空整个记忆后端的全部数据。必须显式传入 `confirm: true`,
2035
+ * 防止误调用;普通 `clear()` 不再支持通过省略参数隐式清空全局。
2036
+ */
2037
+ interface MemoryClearAllOptions {
2038
+ /** 必须显式为 `true`,否则拒绝执行 */
2039
+ confirm: true;
2040
+ }
2041
+ /**
2042
+ * 记忆管理接口(`ai.memory.admin`)
2043
+ *
2044
+ * 承载危险的全局操作,与业务作用域操作明确分离。
2045
+ */
2046
+ interface MemoryAdminOperations {
2047
+ /**
2048
+ * 清空整个记忆后端的全部数据(跨所有主体 / 作用域)
2049
+ *
2050
+ * @param options - 必须传入 `{ confirm: true }`
2051
+ * @returns 成功返回 ok(undefined);未确认返回 MEMORY_STORE_FAILED
2052
+ */
2053
+ clearAll: (options: MemoryClearAllOptions) => Promise<HaiResult<void>>;
2054
+ }
2055
+ /**
2056
+ * 记忆核心操作(Provider 实现层)
2057
+ *
2058
+ * 各 Provider(native / mem0)实现这一组操作。公共入口 `ai.memory` 在其基础上
2059
+ * 叠加作用域绑定(`scoped`)与管理接口(`admin`),并对 `clear` 施加空过滤保护。
2060
+ */
2061
+ interface MemoryCoreOperations {
1939
2062
  /**
1940
2063
  * 从对话消息中自动提取记忆条目
1941
2064
  *
@@ -2033,6 +2156,54 @@ interface MemoryOperations {
2033
2156
  */
2034
2157
  clear: (options?: MemoryClearOptions) => Promise<HaiResult<void>>;
2035
2158
  }
2159
+ /**
2160
+ * 作用域绑定的记忆操作(`ai.memory.scoped()` 返回)
2161
+ *
2162
+ * 所有操作自动携带绑定的 `objectId` 与 `scope`,无需重复传入;`get` / `update` / `remove`
2163
+ * 自动施加归属校验(跨租户访问返回 `MEMORY_NOT_FOUND`);`clear` 仅清空绑定作用域内的记忆,
2164
+ * 永远不会误清全局。
2165
+ */
2166
+ interface ScopedMemoryOperations {
2167
+ /** 从对话中提取记忆(自动绑定 objectId / scope) */
2168
+ extract: (messages: ChatMessage[], options?: Omit<MemoryExtractOptions, 'objectId' | 'scope'>) => Promise<HaiResult<MemoryEntry[]>>;
2169
+ /** 检索相关记忆(自动绑定 objectId / scope) */
2170
+ recall: (query: string, options?: Omit<MemoryRecallOptions, 'objectId' | 'scope'>) => Promise<HaiResult<MemoryEntry[]>>;
2171
+ /** 注入相关记忆(自动绑定 objectId / scope) */
2172
+ injectMemories: (messages: ChatMessage[], options?: Omit<MemoryInjectionOptions, 'objectId' | 'scope'>) => Promise<HaiResult<ChatMessage[]>>;
2173
+ /** 添加记忆(自动绑定 objectId / scope) */
2174
+ add: (entry: Omit<MemoryEntryInput, 'objectId' | 'scope'>) => Promise<HaiResult<MemoryEntry>>;
2175
+ /** 更新记忆(自动施加归属校验) */
2176
+ update: (memoryId: string, updates: MemoryUpdateInput) => Promise<HaiResult<MemoryEntry>>;
2177
+ /** 按 ID 获取记忆(自动施加归属校验) */
2178
+ get: (memoryId: string) => Promise<HaiResult<MemoryEntry>>;
2179
+ /** 删除记忆(自动施加归属校验) */
2180
+ remove: (memoryId: string) => Promise<HaiResult<void>>;
2181
+ /** 列出记忆(自动绑定 objectId / scope) */
2182
+ list: (options?: Omit<MemoryListOptions, 'objectId' | 'scope'>) => Promise<HaiResult<MemoryEntry[]>>;
2183
+ /** 分页列出记忆(自动绑定 objectId / scope) */
2184
+ listPage: (options?: Omit<MemoryListPageOptions, 'objectId' | 'scope'>) => Promise<HaiResult<StorePage<MemoryEntry>>>;
2185
+ /** 清空绑定作用域内的记忆(自动绑定 objectId / scope,不会误清全局) */
2186
+ clear: (options?: Omit<MemoryClearOptions, 'objectId' | 'scope'>) => Promise<HaiResult<void>>;
2187
+ }
2188
+ /**
2189
+ * 公共记忆操作接口(通过 `ai.memory` 访问)
2190
+ *
2191
+ * 在核心操作基础上增加:
2192
+ * - `scoped(binding)`:返回自动绑定 objectId / scope 的安全实例(多租户推荐入口);
2193
+ * - `admin`:承载危险的全局操作(如 `clearAll`);
2194
+ * - `clear`:拒绝空过滤调用(无 objectId / types / scope 时返回错误),防止误清全局。
2195
+ */
2196
+ interface MemoryOperations extends MemoryCoreOperations {
2197
+ /**
2198
+ * 创建绑定作用域的记忆实例
2199
+ *
2200
+ * @param binding - 作用域绑定(objectId + 可选 scope)
2201
+ * @returns 所有操作自动携带该作用域的记忆实例
2202
+ */
2203
+ scoped: (binding: ScopedMemoryBinding) => ScopedMemoryOperations;
2204
+ /** 管理接口(危险的全局操作,需显式确认) */
2205
+ admin: MemoryAdminOperations;
2206
+ }
2036
2207
 
2037
2208
  /**
2038
2209
  * @h-ai/ai — 错误码 + 配置 Schema
@@ -2396,6 +2567,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
2396
2567
  native: "native";
2397
2568
  mem0: "mem0";
2398
2569
  }>>;
2570
+ allowEphemeralFallback: z.ZodDefault<z.ZodBoolean>;
2399
2571
  maxEntriesPerObject: z.ZodDefault<z.ZodNumber>;
2400
2572
  maxEntriesGlobal: z.ZodDefault<z.ZodNumber>;
2401
2573
  systemPrompt: z.ZodOptional<z.ZodString>;
@@ -2846,6 +3018,7 @@ declare const AIConfigSchema: z.ZodObject<{
2846
3018
  native: "native";
2847
3019
  mem0: "mem0";
2848
3020
  }>>;
3021
+ allowEphemeralFallback: z.ZodDefault<z.ZodBoolean>;
2849
3022
  maxEntriesPerObject: z.ZodDefault<z.ZodNumber>;
2850
3023
  maxEntriesGlobal: z.ZodDefault<z.ZodNumber>;
2851
3024
  systemPrompt: z.ZodOptional<z.ZodString>;
@@ -3102,11 +3275,17 @@ interface SynthesisResult extends AudioContent {
3102
3275
  *
3103
3276
  * 每个文本段严格按 `segment_started → audio* → segment_done` 顺序产出,调用方可在
3104
3277
  * 对应音频真正播放完成后提交该段文本,不需要按字节数反推文本边界。
3278
+ *
3279
+ * `segment_started` 携带服务端解析 Provider 后的**真实输出音频参数**(format / sampleRate / channels),
3280
+ * 调用方据此正确解码、设置 PCM 播放参数、选择保存扩展名,而非根据请求参数猜测。
3105
3281
  */
3106
3282
  type SynthesisEvent = {
3107
3283
  type: 'segment_started';
3108
3284
  segmentId: string;
3109
3285
  text: string;
3286
+ format: AudioFormat;
3287
+ sampleRate?: number;
3288
+ channels?: 1 | 2;
3110
3289
  } | {
3111
3290
  type: 'audio';
3112
3291
  segmentId: string;
@@ -3462,4 +3641,4 @@ interface ReasoningOperations {
3462
3641
  runStream: (query: string, options?: ReasoningOptions) => AsyncIterable<ReasoningStreamEvent>;
3463
3642
  }
3464
3643
 
3465
- export { type SummaryConfig as $, type A2AConfig as A, MCPConfigSchema as B, type CompressConfig as C, type MCPServerCapabilities as D, type EmbeddingConfig as E, type FileConfig as F, MCPServerCapabilitiesSchema as G, type MCPServerConfig as H, MCPServerConfigSchema as I, type MemoryConfig as J, type KnowledgeConfig as K, type LLMConfig as L, type MCPConfig as M, MemoryConfigSchema as N, type MemoryType as O, MemoryTypeSchema as P, type ModelEntry as Q, ModelEntrySchema as R, type ModelScenario as S, ModelScenarioSchema as T, type ResolveRequiredModelEntryOptions as U, type ResolvedAudioModel as V, type ResolvedModelConfig as W, type RetrievalConfig as X, RetrievalConfigSchema as Y, type RetrievalSourceConfig as Z, RetrievalSourceSchema as _, A2AConfigSchema as a, type KnowledgeIngestResult as a$, SummaryConfigSchema as a0, type SynthesisEvent as a1, type SynthesisRequest as a2, type SynthesisResult as a3, type SynthesisStreamRequest as a4, type SynthesisTextSegment as a5, type TokenConfig as a6, TokenConfigSchema as a7, type TranscriptionEvent as a8, type TranscriptionRequest as a9, 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 GenerateObjectRequest as aO, type ImageContent as aP, type InteractionScope as aQ, type KnowledgeAskOptions as aR, type KnowledgeAskResult as aS, type KnowledgeDocumentInfo as aT, type KnowledgeDocumentListOptions as aU, type KnowledgeDocumentRemoveOptions as aV, type KnowledgeEntity as aW, type KnowledgeIngestBatchProgress as aX, type KnowledgeIngestBatchResult as aY, type KnowledgeIngestFileInput as aZ, type KnowledgeIngestInput as a_, type TranscriptionResult as aa, type TranscriptionStreamRequest as ab, resolveAudioModel as ac, resolveModelApi as ad, resolveModelEntry as ae, type A2AAgentCardConfig as af, type A2AApiKeySecurity as ag, type A2AAuthenticator as ah, type A2ACallOptions as ai, type A2ACallResult as aj, type A2ACallerIdentity as ak, type A2AContextInfo as al, type A2AHandleResult as am, type A2AMessageRecord as an, type A2AOperations as ao, type A2ASecurityConfig as ap, type A2ATaskFilter as aq, type AILLMFunctionsDeps as ar, type AIRelStore as as, type AIRelStoreOptions as at, type AIStoreProvider as au, type AIVectorBackend as av, type AIVectorStore as aw, type AskOptions as ax, type AssistantMessage as ay, type ChatCompletionChoice as az, A2ASkillConfigSchema as b, type KnowledgeOperations as b0, type KnowledgeRetrieveItem as b1, type KnowledgeRetrieveOptions as b2, type KnowledgeRetrieveResult as b3, type KnowledgeSetupOptions as b4, type KnowledgeStore as b5, type LLMOperations as b6, type LLMProvider as b7, type MemoryAccessScope as b8, type MemoryClearOptions as b9, type RetrievalResult as bA, type RetrievalResultItem as bB, type RetrievalSource as bC, type SSEDecoder as bD, type SSEEvent as bE, type SessionInfo as bF, type StoreFilter as bG, type StorePage as bH, type StoreScope as bI, type StreamOperations as bJ, type StreamProcessor as bK, type StreamResult as bL, type SystemMessage as bM, type TempModelConfig as bN, type TextContent as bO, type TokenUsage as bP, type Tool as bQ, type ToolCall as bR, type ToolDefinition as bS, type ToolErrorType as bT, type ToolMessage as bU, type ToolRegistryOperations as bV, type ToolsOperations as bW, type UserMessage as bX, type WhereClause as bY, type WhereOperator as bZ, type WhereValue as b_, type MemoryEntry as ba, type MemoryEntryInput as bb, type MemoryExtractOptions as bc, type MemoryInjectionOptions as bd, type MemoryListOptions as be, type MemoryListPageOptions as bf, type MemoryOperations as bg, type MemoryRecallOptions as bh, type MemoryUpdateInput as bi, type MessageContent as bj, type MessageRole as bk, type ObjectRef as bl, type RagContextItem as bm, type RagOperations as bn, type RagOptions as bo, type RagResult as bp, type RagStreamEvent as bq, type ReasoningOperations as br, type ReasoningOptions as bs, type ReasoningResult as bt, type ReasoningStep as bu, type ReasoningStepType as bv, type ReasoningStrategy as bw, type ReasoningStreamEvent as bx, type RetrievalOperations as by, type RetrievalRequest as bz, type AIConfig as c, type AIConfigInput as d, AIConfigSchema as e, type ApiType as f, ApiTypeSchema as g, type AudioCapabilitiesRequest as h, type AudioConfig as i, AudioConfigSchema as j, type AudioContent as k, type AudioFormat as l, type AudioInputStream as m, type AudioModelCapabilities as n, type AudioModelEntry as o, AudioModelEntrySchema as p, type AudioOperations as q, type AudioProviderName as r, AudioProviderSchema as s, CompressConfigSchema as t, EmbeddingConfigSchema as u, type EntityType as v, EntityTypeSchema as w, FileConfigSchema as x, KnowledgeConfigSchema as y, LLMConfigSchema as z };
3644
+ export { type SummaryConfig as $, type A2AConfig as A, MCPConfigSchema as B, type CompressConfig as C, type MCPServerCapabilities as D, type EmbeddingConfig as E, type FileConfig as F, MCPServerCapabilitiesSchema as G, type MCPServerConfig as H, MCPServerConfigSchema as I, type MemoryConfig as J, type KnowledgeConfig as K, type LLMConfig as L, type MCPConfig as M, MemoryConfigSchema as N, type MemoryType as O, MemoryTypeSchema as P, type ModelEntry as Q, ModelEntrySchema as R, type ModelScenario as S, ModelScenarioSchema as T, type ResolveRequiredModelEntryOptions as U, type ResolvedAudioModel as V, type ResolvedModelConfig as W, type RetrievalConfig as X, RetrievalConfigSchema as Y, type RetrievalSourceConfig as Z, RetrievalSourceSchema as _, A2AConfigSchema as a, type KnowledgeIngestResult as a$, SummaryConfigSchema as a0, type SynthesisEvent as a1, type SynthesisRequest as a2, type SynthesisResult as a3, type SynthesisStreamRequest as a4, type SynthesisTextSegment as a5, type TokenConfig as a6, TokenConfigSchema as a7, type TranscriptionEvent as a8, type TranscriptionRequest as a9, type ChatCompletionChoice as aA, type ChatCompletionChunk as aB, type ChatCompletionDelta as aC, type ChatCompletionRequest as aD, type ChatCompletionResponse as aE, type ChatHistoryOptions as aF, type ChatMessage as aG, type ChatRecord as aH, type Citation as aI, type DefineToolOptions as aJ, type DeveloperMessage as aK, type EntityDocumentRelation as aL, type EntityDocumentResult as aM, type EntityListOptions as aN, type EntityQueryOptions as aO, type GenerateObjectRequest as aP, type ImageContent as aQ, type KnowledgeAskOptions as aR, type KnowledgeAskResult as aS, type KnowledgeDocumentInfo as aT, type KnowledgeDocumentListOptions as aU, type KnowledgeDocumentRemoveOptions as aV, type KnowledgeEntity as aW, type KnowledgeIngestBatchProgress as aX, type KnowledgeIngestBatchResult as aY, type KnowledgeIngestFileInput as aZ, type KnowledgeIngestInput as a_, type TranscriptionResult as aa, type TranscriptionStreamRequest as ab, resolveAudioModel as ac, resolveModelApi as ad, resolveModelEntry as ae, type InteractionScope as af, type A2AAgentCardConfig as ag, type A2AApiKeySecurity as ah, type A2AAuthenticator as ai, type A2ACallOptions as aj, type A2ACallResult as ak, type A2ACallerIdentity as al, type A2AContextInfo as am, type A2AHandleResult as an, type A2AMessageRecord as ao, type A2AOperations as ap, type A2ASecurityConfig as aq, type A2ATaskFilter as ar, type AILLMFunctionsDeps as as, type AIRelStore as at, type AIRelStoreOptions as au, type AIStoreProvider as av, type AIVectorBackend as aw, type AIVectorStore as ax, type AskOptions as ay, type AssistantMessage as az, A2ASkillConfigSchema as b, type ToolExecutionContext as b$, type KnowledgeOperations as b0, type KnowledgeRetrieveItem as b1, type KnowledgeRetrieveOptions as b2, type KnowledgeRetrieveResult as b3, type KnowledgeSetupOptions as b4, type KnowledgeStore as b5, type LLMOperations as b6, type LLMProvider as b7, type MemoryAccessScope as b8, type MemoryAdminOperations as b9, type ReasoningStreamEvent as bA, type RetrievalOperations as bB, type RetrievalRequest as bC, type RetrievalResult as bD, type RetrievalResultItem as bE, type RetrievalSource as bF, type SSEDecoder as bG, type SSEEvent as bH, type ScopedMemoryBinding as bI, type ScopedMemoryOperations as bJ, type SessionInfo as bK, type StoreFilter as bL, type StorePage as bM, type StoreScope as bN, type StreamOperations as bO, type StreamProcessor as bP, type StreamResult as bQ, type SystemMessage as bR, type TempModelConfig as bS, type TextContent as bT, type TokenUsage as bU, type Tool as bV, type ToolAuthorizationRequest as bW, type ToolAuthorizer as bX, type ToolCall as bY, type ToolDefinition as bZ, type ToolErrorType as b_, type MemoryClearAllOptions as ba, type MemoryClearOptions as bb, type MemoryCoreOperations as bc, type MemoryEntry as bd, type MemoryEntryInput as be, type MemoryExtractOptions as bf, type MemoryInjectionOptions as bg, type MemoryListOptions as bh, type MemoryListPageOptions as bi, type MemoryOperations as bj, type MemoryRecallOptions as bk, type MemoryUpdateInput as bl, type MessageContent as bm, type MessageRole as bn, type ObjectRef as bo, type RagContextItem as bp, type RagOperations as bq, type RagOptions as br, type RagResult as bs, type RagStreamEvent as bt, type ReasoningOperations as bu, type ReasoningOptions as bv, type ReasoningResult as bw, type ReasoningStep as bx, type ReasoningStepType as by, type ReasoningStrategy as bz, type AIConfig as c, type ToolExecutionOptions as c0, type ToolMessage as c1, type ToolRegistryOperations as c2, type ToolRegistryOptions as c3, type ToolsOperations as c4, type UserMessage as c5, type WhereClause as c6, type WhereOperator as c7, type WhereValue as c8, type AIConfigInput as d, AIConfigSchema as e, type ApiType as f, ApiTypeSchema as g, type AudioCapabilitiesRequest as h, type AudioConfig as i, AudioConfigSchema as j, type AudioContent as k, type AudioFormat as l, type AudioInputStream as m, type AudioModelCapabilities as n, type AudioModelEntry as o, AudioModelEntrySchema as p, type AudioOperations as q, type AudioProviderName as r, AudioProviderSchema as s, CompressConfigSchema as t, EmbeddingConfigSchema as u, type EntityType as v, EntityTypeSchema as w, FileConfigSchema as x, KnowledgeConfigSchema as y, LLMConfigSchema as z };
package/dist/browser.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, f as ApiType, g as ApiTypeSchema, h as AudioCapabilitiesRequest, i as AudioConfig, j as AudioConfigSchema, k as AudioContent, l as AudioFormat, m as AudioInputStream, n as AudioModelCapabilities, o as AudioModelEntry, p as AudioModelEntrySchema, q as AudioOperations, r as AudioProviderName, s as AudioProviderSchema, C as CompressConfig, t as CompressConfigSchema, E as EmbeddingConfig, u as EmbeddingConfigSchema, v as EntityType, w as EntityTypeSchema, F as FileConfig, x as FileConfigSchema, K as KnowledgeConfig, y as KnowledgeConfigSchema, L as LLMConfig, z as LLMConfigSchema, M as MCPConfig, B as MCPConfigSchema, D as MCPServerCapabilities, G as MCPServerCapabilitiesSchema, H as MCPServerConfig, I as MCPServerConfigSchema, J as MemoryConfig, N as MemoryConfigSchema, O as MemoryType, P as MemoryTypeSchema, Q as ModelEntry, R as ModelEntrySchema, S as ModelScenario, T as ModelScenarioSchema, U as ResolveRequiredModelEntryOptions, V as ResolvedAudioModel, W as ResolvedModelConfig, X as RetrievalConfig, Y as RetrievalConfigSchema, Z as RetrievalSourceConfig, _ as RetrievalSourceSchema, $ as SummaryConfig, a0 as SummaryConfigSchema, a1 as SynthesisEvent, a2 as SynthesisRequest, a3 as SynthesisResult, a4 as SynthesisStreamRequest, a5 as SynthesisTextSegment, a6 as TokenConfig, a7 as TokenConfigSchema, a8 as TranscriptionEvent, a9 as TranscriptionRequest, aa as TranscriptionResult, ab as TranscriptionStreamRequest, ac as resolveAudioModel, ad as resolveModelApi, ae as resolveModelEntry } from './ai-reasoning-types-DLLzpn6T.js';
2
- export { A as AIFunctions, a as AIInitOptions, b as AUDIO_WS_PATH, c as AudioWsClientMessage, d as AudioWsDoneMessage, e as AudioWsEndMessage, f as AudioWsErrorMessage, g as AudioWsSegmentDoneMessage, h as AudioWsSegmentStartedMessage, i as AudioWsServerMessage, j as AudioWsSpeechMessage, k as AudioWsStartMessage, l as AudioWsTextMessage, m as AudioWsTranscriptMessage, C as CompressionStrategy, n as CompressionStrategySchema, H as HaiAIError } from './ai-audio-ws-protocol-CsmuWetO.js';
3
- export { A2AClientOperations, AIApiAdapter, AIClient, AIClientConfig, AudioClientConfig, AudioClientOperations, StreamOptions, StreamProgress, collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './client/index.js';
1
+ export { A as A2AConfig, a as A2AConfigSchema, b as A2ASkillConfigSchema, c as AIConfig, d as AIConfigInput, e as AIConfigSchema, f as ApiType, g as ApiTypeSchema, h as AudioCapabilitiesRequest, i as AudioConfig, j as AudioConfigSchema, k as AudioContent, l as AudioFormat, m as AudioInputStream, n as AudioModelCapabilities, o as AudioModelEntry, p as AudioModelEntrySchema, q as AudioOperations, r as AudioProviderName, s as AudioProviderSchema, C as CompressConfig, t as CompressConfigSchema, E as EmbeddingConfig, u as EmbeddingConfigSchema, v as EntityType, w as EntityTypeSchema, F as FileConfig, x as FileConfigSchema, K as KnowledgeConfig, y as KnowledgeConfigSchema, L as LLMConfig, z as LLMConfigSchema, M as MCPConfig, B as MCPConfigSchema, D as MCPServerCapabilities, G as MCPServerCapabilitiesSchema, H as MCPServerConfig, I as MCPServerConfigSchema, J as MemoryConfig, N as MemoryConfigSchema, O as MemoryType, P as MemoryTypeSchema, Q as ModelEntry, R as ModelEntrySchema, S as ModelScenario, T as ModelScenarioSchema, U as ResolveRequiredModelEntryOptions, V as ResolvedAudioModel, W as ResolvedModelConfig, X as RetrievalConfig, Y as RetrievalConfigSchema, Z as RetrievalSourceConfig, _ as RetrievalSourceSchema, $ as SummaryConfig, a0 as SummaryConfigSchema, a1 as SynthesisEvent, a2 as SynthesisRequest, a3 as SynthesisResult, a4 as SynthesisStreamRequest, a5 as SynthesisTextSegment, a6 as TokenConfig, a7 as TokenConfigSchema, a8 as TranscriptionEvent, a9 as TranscriptionRequest, aa as TranscriptionResult, ab as TranscriptionStreamRequest, ac as resolveAudioModel, ad as resolveModelApi, ae as resolveModelEntry } from './ai-reasoning-types-CslaY4xX.js';
2
+ export { A as AIFunctions, a as AIInitOptions, b as AUDIO_WS_PATH, c as AudioFormatSchema, d as AudioWsClientMessage, e as AudioWsClientMessageSchema, f as AudioWsDoneMessage, g as AudioWsDoneMessageSchema, h as AudioWsEndMessage, i as AudioWsErrorMessage, j as AudioWsSegmentDoneMessage, k as AudioWsSegmentStartedMessage, l as AudioWsServerMessage, m as AudioWsSpeechMessage, n as AudioWsStartMessage, o as AudioWsStartMessageSchema, p as AudioWsTextMessage, q as AudioWsTextMessageSchema, r as AudioWsTranscriptMessage, C as CompressionStrategy, s as CompressionStrategySchema, H as HaiAIError } from './ai-audio-ws-protocol-BK5753o1.js';
3
+ export { A2AClientOperations, AIApiAdapter, AIClient, AIClientConfig, AudioClientConfig, AudioClientOperations, AudioTicketRequest, StreamOptions, StreamProgress, collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './client/index.js';
4
4
  import '@a2a-js/sdk/server';
5
5
  import '@h-ai/core';
6
6
  import '@h-ai/datapipe';
7
7
  import 'zod';
8
8
  import 'openai';
9
9
  import 'node:buffer';
10
+ import 'zod/v4/core';
package/dist/browser.js CHANGED
@@ -1,4 +1,5 @@
1
- export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioModelEntrySchema, AudioProviderSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, HaiAIError, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, resolveAudioModel, resolveModelApi, resolveModelEntry } from './chunk-UROBPUCF.js';
2
- export { collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './chunk-535CQURK.js';
1
+ export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, resolveAudioModel, resolveModelApi, resolveModelEntry } from './chunk-5XL4QDIJ.js';
2
+ export { collectStreamContent, createA2AClient, createAIClient, createAudioClient, createUnconfiguredAudioClient, parseSSE } from './chunk-ELH2IPOE.js';
3
+ export { HaiAIError } from './chunk-P3GND76X.js';
3
4
  //# sourceMappingURL=browser.js.map
4
5
  //# sourceMappingURL=browser.js.map
@@ -1,106 +1,10 @@
1
- import { core, err, ok } from '@h-ai/core';
1
+ import { HaiAIError } from './chunk-P3GND76X.js';
2
2
  import { z } from 'zod';
3
3
  import process from 'process';
4
+ import { core, err, ok } from '@h-ai/core';
4
5
  import { ChunkOptionsSchema, CleanOptionsSchema } from '@h-ai/datapipe';
6
+ import { AUDIO_WS_PATH as AUDIO_WS_PATH$1, AudioFormatSchema as AudioFormatSchema$1, AudioWsClientMessageSchema as AudioWsClientMessageSchema$1, AudioWsDoneMessageSchema as AudioWsDoneMessageSchema$1, AudioWsStartMessageSchema as AudioWsStartMessageSchema$1, AudioWsTextMessageSchema as AudioWsTextMessageSchema$1 } from '@h-ai/api-contract';
5
7
 
6
- // src/ai-types.ts
7
- var AIErrorInfo = {
8
- // 通用 (000-009)
9
- INTERNAL_ERROR: "000:500",
10
- // 初始化 (010-019)
11
- NOT_INITIALIZED: "010:500",
12
- CONFIGURATION_ERROR: "011:500",
13
- INIT_IN_PROGRESS: "012:500",
14
- RERANK_API_ERROR: "020:502",
15
- RERANK_INVALID_REQUEST: "021:400",
16
- // LLM (100-199)
17
- API_ERROR: "100:502",
18
- INVALID_REQUEST: "101:400",
19
- RATE_LIMITED: "102:429",
20
- TIMEOUT: "103:504",
21
- MODEL_NOT_FOUND: "104:404",
22
- CONTEXT_LENGTH_EXCEEDED: "105:400",
23
- LLM_RECORD_FAILED: "106:500",
24
- LLM_HISTORY_FAILED: "107:500",
25
- // MCP (200-299)
26
- MCP_CONNECTION_ERROR: "200:502",
27
- MCP_PROTOCOL_ERROR: "201:502",
28
- MCP_TOOL_ERROR: "202:500",
29
- MCP_RESOURCE_ERROR: "203:500",
30
- MCP_SERVER_ERROR: "204:502",
31
- // Embedding (300-399)
32
- EMBEDDING_API_ERROR: "300:502",
33
- EMBEDDING_MODEL_NOT_FOUND: "301:404",
34
- EMBEDDING_INPUT_TOO_LONG: "302:400",
35
- // 工具 (400-499)
36
- TOOL_NOT_FOUND: "400:404",
37
- TOOL_VALIDATION_FAILED: "401:400",
38
- TOOL_EXECUTION_FAILED: "402:500",
39
- TOOL_TIMEOUT: "403:504",
40
- // Reasoning (500-599)
41
- REASONING_FAILED: "500:500",
42
- REASONING_MAX_ROUNDS: "501:400",
43
- REASONING_STRATEGY_NOT_FOUND: "502:404",
44
- // Retrieval (600-699)
45
- RETRIEVAL_FAILED: "600:500",
46
- RETRIEVAL_SOURCE_NOT_FOUND: "601:404",
47
- // RAG (700-799)
48
- RAG_FAILED: "700:500",
49
- RAG_CONTEXT_BUILD_FAILED: "701:500",
50
- // Knowledge (800-899)
51
- KNOWLEDGE_SETUP_FAILED: "800:500",
52
- KNOWLEDGE_INGEST_FAILED: "801:500",
53
- KNOWLEDGE_RETRIEVE_FAILED: "802:500",
54
- KNOWLEDGE_ENTITY_EXTRACT_FAILED: "803:500",
55
- KNOWLEDGE_NOT_SETUP: "804:500",
56
- KNOWLEDGE_COLLECTION_NOT_FOUND: "805:404",
57
- // Memory (900-949)
58
- MEMORY_EXTRACT_FAILED: "900:500",
59
- MEMORY_STORE_FAILED: "901:500",
60
- MEMORY_RECALL_FAILED: "902:500",
61
- MEMORY_NOT_FOUND: "903:404",
62
- MEMORY_ENRICH_FAILED: "904:500",
63
- MEMORY_PROMOTE_FAILED: "905:500",
64
- // Persona (910-919)
65
- PERSONA_NOT_FOUND: "910:404",
66
- PERSONA_SAVE_FAILED: "911:500",
67
- // File (030-049)
68
- FILE_PARSE_FAILED: "030:500",
69
- FILE_UNSUPPORTED_FORMAT: "031:400",
70
- FILE_OCR_FAILED: "032:500",
71
- FILE_INVALID_CONTENT: "033:400",
72
- // Audio (050-059)
73
- AUDIO_INVALID_REQUEST: "050:400",
74
- AUDIO_MODEL_NOT_FOUND: "051:404",
75
- AUDIO_PROVIDER_NOT_FOUND: "052:404",
76
- AUDIO_UNSUPPORTED_INPUT: "053:400",
77
- AUDIO_UPSTREAM_ERROR: "054:502",
78
- AUDIO_PROTOCOL_ERROR: "055:502",
79
- AUDIO_CONNECTION_FAILED: "056:502",
80
- AUDIO_TIMEOUT: "057:504",
81
- AUDIO_INPUT_TOO_LARGE: "058:413",
82
- AUDIO_CANCELLED: "059:499",
83
- // Context (950-999)
84
- CONTEXT_COMPRESS_FAILED: "950:500",
85
- CONTEXT_SUMMARIZE_FAILED: "951:500",
86
- CONTEXT_TOKEN_ESTIMATE_FAILED: "952:500",
87
- CONTEXT_BUDGET_EXCEEDED: "953:400",
88
- CONTEXT_TURN_NOT_FOUND: "954:404",
89
- CONTEXT_TURN_INVALID_STATE: "955:409",
90
- // Store (960-969)
91
- STORE_FAILED: "960:500",
92
- STORE_NOT_AVAILABLE: "961:503",
93
- // Session (970-979)
94
- SESSION_NOT_FOUND: "970:404",
95
- SESSION_FAILED: "971:500",
96
- // A2A (980-999)
97
- A2A_NOT_CONFIGURED: "980:500",
98
- A2A_HANDLE_FAILED: "981:500",
99
- A2A_REMOTE_CALL_FAILED: "982:502",
100
- A2A_AUTH_FAILED: "983:401",
101
- A2A_LIST_MESSAGES_FAILED: "984:500"
102
- };
103
- var HaiAIError = core.error.buildHaiErrorsDef("ai", AIErrorInfo);
104
8
  var CompressionStrategySchema = z.enum(["summary", "sliding-window", "hybrid"]);
105
9
  var EntityTypeSchema = z.enum(["person", "project", "concept", "organization", "location", "event", "other"]);
106
10
  var MemoryTypeSchema = z.enum(["fact", "preference", "event", "entity", "instruction"]);
@@ -122,6 +26,9 @@ var en_US_default = {
122
26
  ai_mcpPromptFailed: "MCP prompt '{name}' execution failed: {error}",
123
27
  ai_toolNotFound: "Tool '{name}' not found",
124
28
  ai_toolInvalidJson: "Invalid JSON in tool call arguments",
29
+ ai_toolTimeout: "Tool '{name}' timed out or was cancelled after {ms}ms",
30
+ ai_toolAlreadyRegistered: "Tool '{name}' is already registered; use replace() to replace it explicitly",
31
+ ai_toolForbidden: "Tool '{name}' execution is not authorized",
125
32
  ai_configError: "AI config validation failed: {error}",
126
33
  ai_llmRecordFailed: "Chat record save failed: {error}",
127
34
  ai_llmHistoryFailed: "Chat history query failed: {error}",
@@ -147,6 +54,9 @@ var en_US_default = {
147
54
  ai_memoryStoreFailed: "Memory storage failed: {error}",
148
55
  ai_memoryRecallFailed: "Memory recall failed: {error}",
149
56
  ai_memoryNotFound: "Memory entry '{id}' not found",
57
+ ai_memoryEphemeralFallbackDenied: "Memory provider 'mem0' cannot map vector backend '{backend}' to a persistent store; refusing silent in-memory fallback. Set memory.allowEphemeralFallback=true to allow ephemeral storage, or use a qdrant/pgvector backend.",
58
+ ai_memoryClearRequiresFilter: "clear() requires at least one filter (objectId / types / scope); to wipe all memories use ai.memory.admin.clearAll({ confirm: true })",
59
+ ai_memoryClearAllUnconfirmed: "admin.clearAll() requires explicit confirmation: pass { confirm: true }",
150
60
  ai_memoryEnrichFailed: "Memory enrichment failed: {error}",
151
61
  ai_memoryPromoteFailed: "Memory promotion (long-term consolidation) failed: {error}",
152
62
  ai_personaNotFound: "Persona '{id}' not found",
@@ -156,6 +66,7 @@ var en_US_default = {
156
66
  ai_contextTokenEstimateFailed: "Token estimation failed: {error}",
157
67
  ai_turnNotFound: "Conversation turn '{turnId}' not found",
158
68
  ai_turnInvalidState: "Conversation turn '{turnId}' is already committed",
69
+ ai_contextBusy: "Context manager is busy: a generation is already in progress (concurrency='reject')",
159
70
  ai_storeFailed: "Store operation failed: {error}",
160
71
  ai_storeNotAvailable: "Store backend not available, degraded to memory mode",
161
72
  ai_sessionNotFound: "Session '{id}' not found",
@@ -202,6 +113,9 @@ var zh_CN_default = {
202
113
  ai_mcpPromptFailed: "MCP \u63D0\u793A\u8BCD '{name}' \u6267\u884C\u5931\u8D25\uFF1A{error}",
203
114
  ai_toolNotFound: "\u5DE5\u5177 '{name}' \u672A\u627E\u5230",
204
115
  ai_toolInvalidJson: "\u5DE5\u5177\u8C03\u7528\u53C2\u6570 JSON \u683C\u5F0F\u65E0\u6548",
116
+ ai_toolTimeout: "\u5DE5\u5177 '{name}' \u5728 {ms}ms \u540E\u8D85\u65F6\u6216\u88AB\u53D6\u6D88",
117
+ ai_toolAlreadyRegistered: "\u5DE5\u5177 '{name}' \u5DF2\u6CE8\u518C\uFF1B\u5982\u9700\u66FF\u6362\u8BF7\u663E\u5F0F\u8C03\u7528 replace()",
118
+ ai_toolForbidden: "\u5DE5\u5177 '{name}' \u672A\u83B7\u6267\u884C\u6388\u6743",
205
119
  ai_configError: "AI \u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF1A{error}",
206
120
  ai_llmRecordFailed: "\u5BF9\u8BDD\u8BB0\u5F55\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",
207
121
  ai_llmHistoryFailed: "\u5BF9\u8BDD\u5386\u53F2\u67E5\u8BE2\u5931\u8D25\uFF1A{error}",
@@ -227,6 +141,9 @@ var zh_CN_default = {
227
141
  ai_memoryStoreFailed: "\u8BB0\u5FC6\u5B58\u50A8\u5931\u8D25\uFF1A{error}",
228
142
  ai_memoryRecallFailed: "\u8BB0\u5FC6\u53EC\u56DE\u5931\u8D25\uFF1A{error}",
229
143
  ai_memoryNotFound: "\u8BB0\u5FC6\u6761\u76EE '{id}' \u4E0D\u5B58\u5728",
144
+ ai_memoryEphemeralFallbackDenied: "\u8BB0\u5FC6 provider 'mem0' \u65E0\u6CD5\u5C06\u5411\u91CF\u540E\u7AEF '{backend}' \u6620\u5C04\u4E3A\u6301\u4E45\u5316\u5B58\u50A8\uFF0C\u62D2\u7EDD\u9759\u9ED8\u9000\u56DE\u5185\u5B58\u5B58\u50A8\u3002\u8BF7\u8BBE\u7F6E memory.allowEphemeralFallback=true \u5141\u8BB8\u4E34\u65F6\u5B58\u50A8\uFF0C\u6216\u6539\u7528 qdrant/pgvector \u540E\u7AEF\u3002",
145
+ ai_memoryClearRequiresFilter: "clear() \u81F3\u5C11\u9700\u4F20\u5165\u4E00\u4E2A\u8FC7\u6EE4\u6761\u4EF6\uFF08objectId / types / scope\uFF09\uFF1B\u8981\u6E05\u7A7A\u5168\u90E8\u8BB0\u5FC6\u8BF7\u4F7F\u7528 ai.memory.admin.clearAll({ confirm: true })",
146
+ ai_memoryClearAllUnconfirmed: "admin.clearAll() \u9700\u8981\u663E\u5F0F\u786E\u8BA4\uFF1A\u8BF7\u4F20\u5165 { confirm: true }",
230
147
  ai_memoryEnrichFailed: "\u8BB0\u5FC6\u6CE8\u5165\u5931\u8D25\uFF1A{error}",
231
148
  ai_memoryPromoteFailed: "\u8BB0\u5FC6\u56FA\u5316\uFF08\u957F\u671F\u5316\uFF09\u5931\u8D25\uFF1A{error}",
232
149
  ai_personaNotFound: "\u89D2\u8272 '{id}' \u4E0D\u5B58\u5728",
@@ -236,6 +153,7 @@ var zh_CN_default = {
236
153
  ai_contextTokenEstimateFailed: "Token \u4F30\u7B97\u5931\u8D25\uFF1A{error}",
237
154
  ai_turnNotFound: "\u5BF9\u8BDD\u8F6E\u6B21 '{turnId}' \u4E0D\u5B58\u5728",
238
155
  ai_turnInvalidState: "\u5BF9\u8BDD\u8F6E\u6B21 '{turnId}' \u5DF2\u63D0\u4EA4\uFF0C\u65E0\u6CD5\u91CD\u590D\u63D0\u4EA4",
156
+ ai_contextBusy: "\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u6B63\u5FD9\uFF1A\u5DF2\u6709\u4E00\u4E2A\u751F\u6210\u6B63\u5728\u8FDB\u884C\uFF08concurrency='reject'\uFF09",
239
157
  ai_storeFailed: "\u5B58\u50A8\u64CD\u4F5C\u5931\u8D25\uFF1A{error}",
240
158
  ai_storeNotAvailable: "\u5B58\u50A8\u540E\u7AEF\u4E0D\u53EF\u7528\uFF0C\u5DF2\u964D\u7EA7\u4E3A\u5185\u5B58\u6A21\u5F0F",
241
159
  ai_sessionNotFound: "\u4F1A\u8BDD '{id}' \u4E0D\u5B58\u5728",
@@ -410,6 +328,14 @@ var KnowledgeConfigSchema = z.object({
410
328
  var MemoryConfigSchema = z.object({
411
329
  /** 记忆后端:native = 逐条写回;mem0 = 批量 ADD/UPDATE/DELETE 合并(均为嵌入式,复用 HAI 组件) */
412
330
  provider: z.enum(["native", "mem0"]).default("native"),
331
+ /**
332
+ * 是否允许在配置了持久化向量后端但 mem0 无法映射时退回内存存储(默认 false)
333
+ *
334
+ * 仅影响 `provider='mem0'`:mem0 TS 仅支持 qdrant / pgvector。当底层 vecdb 是
335
+ * lancedb / chroma / 未知后端时,默认 fail-fast(初始化失败),避免服务重启后记忆静默丢失;
336
+ * 仅当显式设为 true 时才退回 mem0 自带 in-memory 存储(数据不持久)。
337
+ */
338
+ allowEphemeralFallback: z.boolean().default(false),
413
339
  /**
414
340
  * 单个主体(objectId)的最大记忆条数(默认 1000)
415
341
  *
@@ -646,10 +572,13 @@ var AIConfigSchema = z.object({
646
572
  /** Audio 配置(语音识别 / 语音合成) */
647
573
  audio: AudioConfigSchema.optional()
648
574
  });
575
+ var AUDIO_WS_PATH = AUDIO_WS_PATH$1;
576
+ var AudioFormatSchema = AudioFormatSchema$1;
577
+ var AudioWsStartMessageSchema = AudioWsStartMessageSchema$1;
578
+ var AudioWsTextMessageSchema = AudioWsTextMessageSchema$1;
579
+ var AudioWsDoneMessageSchema = AudioWsDoneMessageSchema$1;
580
+ var AudioWsClientMessageSchema = AudioWsClientMessageSchema$1;
649
581
 
650
- // src/audio/ai-audio-ws-protocol.ts
651
- var AUDIO_WS_PATH = "/ai/audio";
652
-
653
- export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioModelEntrySchema, AudioProviderSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, HaiAIError, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, aiM, resolveAudioModel, resolveModelApi, resolveModelEntry };
654
- //# sourceMappingURL=chunk-UROBPUCF.js.map
655
- //# sourceMappingURL=chunk-UROBPUCF.js.map
582
+ export { A2AConfigSchema, A2ASkillConfigSchema, AIConfigSchema, AUDIO_WS_PATH, ApiTypeSchema, AudioConfigSchema, AudioFormatSchema, AudioModelEntrySchema, AudioProviderSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, CompressConfigSchema, CompressionStrategySchema, EmbeddingConfigSchema, EntityTypeSchema, FileConfigSchema, KnowledgeConfigSchema, LLMConfigSchema, MCPConfigSchema, MCPServerCapabilitiesSchema, MCPServerConfigSchema, MemoryConfigSchema, MemoryTypeSchema, ModelEntrySchema, ModelScenarioSchema, RetrievalConfigSchema, RetrievalSourceSchema, SummaryConfigSchema, TokenConfigSchema, aiM, resolveAudioModel, resolveModelApi, resolveModelEntry };
583
+ //# sourceMappingURL=chunk-5XL4QDIJ.js.map
584
+ //# sourceMappingURL=chunk-5XL4QDIJ.js.map