@huyooo/ai-chat-core 0.2.45 → 0.3.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/adapter/index.d.ts +11 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/model-adapter.d.ts +25 -0
- package/dist/adapter/model-adapter.d.ts.map +1 -0
- package/dist/adapter/model-options.d.ts +53 -0
- package/dist/adapter/model-options.d.ts.map +1 -0
- package/dist/adapter/types.d.ts +28 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/chat-runtime.d.ts +96 -0
- package/dist/chat-runtime.d.ts.map +1 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/events.d.ts +605 -1
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +1 -1
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.d.ts.map +1 -0
- package/dist/extension/types.d.ts +46 -0
- package/dist/extension/types.d.ts.map +1 -0
- package/dist/families/index.d.ts +11 -0
- package/dist/families/index.d.ts.map +1 -0
- package/dist/families/presets.d.ts +31 -0
- package/dist/families/presets.d.ts.map +1 -0
- package/dist/families/resolver.d.ts +11 -0
- package/dist/families/resolver.d.ts.map +1 -0
- package/dist/families/types.d.ts +29 -0
- package/dist/families/types.d.ts.map +1 -0
- package/dist/governance/command-safety.d.ts +34 -0
- package/dist/governance/command-safety.d.ts.map +1 -0
- package/dist/governance/governance.d.ts +19 -0
- package/dist/governance/governance.d.ts.map +1 -0
- package/dist/governance/index.d.ts +12 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/types.d.ts +29 -0
- package/dist/governance/types.d.ts.map +1 -0
- package/dist/index.d.ts +72 -804
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -1
- package/dist/internal/management-args.d.ts +13 -0
- package/dist/internal/management-args.d.ts.map +1 -0
- package/dist/internal/management-results.d.ts +21 -0
- package/dist/internal/management-results.d.ts.map +1 -0
- package/dist/llm-config.d.ts +108 -0
- package/dist/llm-config.d.ts.map +1 -0
- package/dist/logger/core.d.ts +31 -0
- package/dist/logger/core.d.ts.map +1 -0
- package/dist/logger/index.d.ts +9 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/orchestrator/compression-handler.d.ts +29 -0
- package/dist/orchestrator/compression-handler.d.ts.map +1 -0
- package/dist/orchestrator/context-compressor.d.ts +51 -0
- package/dist/orchestrator/context-compressor.d.ts.map +1 -0
- package/dist/orchestrator/context-summarizer.d.ts +41 -0
- package/dist/orchestrator/context-summarizer.d.ts.map +1 -0
- package/dist/orchestrator/index.d.ts +12 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +46 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/types.d.ts +58 -0
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/parts/index.d.ts +13 -0
- package/dist/parts/index.d.ts.map +1 -0
- package/dist/parts/registry.d.ts +11 -0
- package/dist/parts/registry.d.ts.map +1 -0
- package/dist/parts/summaries.d.ts +9 -0
- package/dist/parts/summaries.d.ts.map +1 -0
- package/dist/parts/types.d.ts +61 -0
- package/dist/parts/types.d.ts.map +1 -0
- package/dist/platform.d.ts +17 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +1 -0
- package/dist/protocols/anthropic.d.ts +20 -0
- package/dist/protocols/anthropic.d.ts.map +1 -0
- package/dist/protocols/ark.d.ts +36 -0
- package/dist/protocols/ark.d.ts.map +1 -0
- package/dist/protocols/deepseek.d.ts +24 -0
- package/dist/protocols/deepseek.d.ts.map +1 -0
- package/dist/protocols/error-utils.d.ts +14 -0
- package/dist/protocols/error-utils.d.ts.map +1 -0
- package/dist/protocols/gemini.d.ts +24 -0
- package/dist/protocols/gemini.d.ts.map +1 -0
- package/dist/protocols/glm.d.ts +20 -0
- package/dist/protocols/glm.d.ts.map +1 -0
- package/dist/protocols/grok.d.ts +20 -0
- package/dist/protocols/grok.d.ts.map +1 -0
- package/dist/protocols/index.d.ts +31 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/minimax.d.ts +38 -0
- package/dist/protocols/minimax.d.ts.map +1 -0
- package/dist/protocols/moonshot.d.ts +20 -0
- package/dist/protocols/moonshot.d.ts.map +1 -0
- package/dist/protocols/openai-sse.d.ts +33 -0
- package/dist/protocols/openai-sse.d.ts.map +1 -0
- package/dist/protocols/openai.d.ts +19 -0
- package/dist/protocols/openai.d.ts.map +1 -0
- package/dist/protocols/qwen.d.ts +26 -0
- package/dist/protocols/qwen.d.ts.map +1 -0
- package/dist/protocols/responses-sse.d.ts +30 -0
- package/dist/protocols/responses-sse.d.ts.map +1 -0
- package/dist/protocols/sse-reader.d.ts +23 -0
- package/dist/protocols/sse-reader.d.ts.map +1 -0
- package/dist/protocols/tool-arguments.d.ts +8 -0
- package/dist/protocols/tool-arguments.d.ts.map +1 -0
- package/dist/protocols/types.d.ts +148 -0
- package/dist/protocols/types.d.ts.map +1 -0
- package/dist/protocols/vercel-gateway.d.ts +15 -0
- package/dist/protocols/vercel-gateway.d.ts.map +1 -0
- package/dist/runtime.d.ts +151 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/skills/index.d.ts +14 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/management/admin.d.ts +10 -0
- package/dist/skills/management/admin.d.ts.map +1 -0
- package/dist/skills/management/index.d.ts +11 -0
- package/dist/skills/management/index.d.ts.map +1 -0
- package/dist/skills/management/inputs.d.ts +44 -0
- package/dist/skills/management/inputs.d.ts.map +1 -0
- package/dist/skills/management/operations.d.ts +78 -0
- package/dist/skills/management/operations.d.ts.map +1 -0
- package/dist/skills/management/types.d.ts +70 -0
- package/dist/skills/management/types.d.ts.map +1 -0
- package/dist/skills/registry.d.ts +37 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/summaries.d.ts +9 -0
- package/dist/skills/summaries.d.ts.map +1 -0
- package/dist/skills/types.d.ts +61 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/test-utils/mock-sse.d.ts +13 -0
- package/dist/test-utils/mock-sse.d.ts.map +1 -0
- package/dist/tool-manager/define-tool.d.ts +35 -0
- package/dist/tool-manager/define-tool.d.ts.map +1 -0
- package/dist/tool-manager/formats.d.ts +46 -0
- package/dist/tool-manager/formats.d.ts.map +1 -0
- package/dist/tool-manager/identity.d.ts +18 -0
- package/dist/tool-manager/identity.d.ts.map +1 -0
- package/dist/tool-manager/in-process-provider.d.ts +15 -0
- package/dist/tool-manager/in-process-provider.d.ts.map +1 -0
- package/dist/tool-manager/index.d.ts +18 -0
- package/dist/tool-manager/index.d.ts.map +1 -0
- package/dist/tool-manager/manager.d.ts +18 -0
- package/dist/tool-manager/manager.d.ts.map +1 -0
- package/dist/tool-manager/mcp-provider.d.ts +21 -0
- package/dist/tool-manager/mcp-provider.d.ts.map +1 -0
- package/dist/tool-manager/summaries.d.ts +39 -0
- package/dist/tool-manager/summaries.d.ts.map +1 -0
- package/dist/tool-manager/types.d.ts +314 -0
- package/dist/tool-manager/types.d.ts.map +1 -0
- package/dist/types.d.ts +663 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +26 -15
- package/src/adapter/index.ts +25 -0
- package/src/adapter/model-adapter.ts +196 -0
- package/src/adapter/model-options.ts +143 -0
- package/src/adapter/types.ts +41 -0
- package/src/chat-runtime.ts +515 -0
- package/src/constants.ts +9 -102
- package/src/events.ts +364 -150
- package/src/extension/index.ts +24 -0
- package/src/extension/types.ts +49 -0
- package/src/families/index.ts +28 -0
- package/src/families/presets.ts +124 -0
- package/src/families/resolver.ts +22 -0
- package/src/families/types.ts +55 -0
- package/src/governance/command-safety.ts +224 -0
- package/src/governance/governance.ts +125 -0
- package/src/governance/index.ts +38 -0
- package/src/governance/types.ts +44 -0
- package/src/index.ts +250 -145
- package/src/internal/management-args.ts +39 -0
- package/src/internal/management-results.ts +60 -0
- package/src/llm-config.ts +137 -0
- package/src/logger/core.ts +96 -0
- package/src/logger/index.ts +8 -0
- package/src/orchestrator/compression-handler.ts +137 -0
- package/src/{providers → orchestrator}/context-compressor.ts +79 -47
- package/src/orchestrator/context-summarizer.ts +123 -0
- package/src/orchestrator/index.ts +20 -0
- package/src/orchestrator/orchestrator.ts +1002 -0
- package/src/orchestrator/types.ts +70 -0
- package/src/parts/index.ts +20 -0
- package/src/parts/registry.ts +95 -0
- package/src/parts/summaries.ts +40 -0
- package/src/parts/types.ts +63 -0
- package/src/platform.ts +73 -0
- package/src/protocols/anthropic.ts +377 -0
- package/src/protocols/ark.ts +300 -0
- package/src/protocols/deepseek.ts +192 -0
- package/src/{providers/protocols → protocols}/error-utils.ts +17 -20
- package/src/protocols/gemini.ts +352 -0
- package/src/protocols/glm.ts +212 -0
- package/src/protocols/grok.ts +98 -0
- package/src/protocols/index.ts +48 -0
- package/src/protocols/minimax.ts +308 -0
- package/src/protocols/moonshot.ts +186 -0
- package/src/protocols/openai-sse.ts +156 -0
- package/src/protocols/openai.ts +97 -0
- package/src/protocols/qwen.ts +358 -0
- package/src/protocols/responses-sse.ts +224 -0
- package/src/protocols/sse-reader.ts +54 -0
- package/src/protocols/tool-arguments.ts +32 -0
- package/src/{providers/protocols → protocols}/types.ts +46 -37
- package/src/protocols/vercel-gateway.ts +391 -0
- package/src/runtime.ts +167 -0
- package/src/skills/index.ts +29 -0
- package/src/skills/management/admin.ts +170 -0
- package/src/skills/management/index.ts +27 -0
- package/src/skills/management/inputs.ts +79 -0
- package/src/skills/management/operations.ts +256 -0
- package/src/skills/management/types.ts +57 -0
- package/src/skills/registry.ts +120 -0
- package/src/skills/summaries.ts +48 -0
- package/src/skills/types.ts +65 -0
- package/src/test-utils/mock-sse.ts +3 -3
- package/src/tool-manager/define-tool.ts +201 -0
- package/src/tool-manager/formats.ts +146 -0
- package/src/tool-manager/identity.ts +80 -0
- package/src/tool-manager/in-process-provider.ts +164 -0
- package/src/tool-manager/index.ts +63 -0
- package/src/tool-manager/manager.ts +562 -0
- package/src/tool-manager/mcp-provider.ts +509 -0
- package/src/tool-manager/summaries.ts +136 -0
- package/src/tool-manager/types.ts +389 -0
- package/src/types.ts +750 -191
- package/dist/events-CU5D5ray.d.ts +0 -1128
- package/src/agent.ts +0 -409
- package/src/internal/update-plan.ts +0 -2
- package/src/internal/web-search.ts +0 -77
- package/src/mcp/client-manager.ts +0 -302
- package/src/mcp/index.ts +0 -2
- package/src/mcp/types.ts +0 -43
- package/src/providers/context-summarizer.ts +0 -70
- package/src/providers/index.ts +0 -125
- package/src/providers/model-registry.ts +0 -466
- package/src/providers/orchestrator.ts +0 -839
- package/src/providers/protocols/anthropic.ts +0 -406
- package/src/providers/protocols/ark.ts +0 -362
- package/src/providers/protocols/deepseek.ts +0 -344
- package/src/providers/protocols/gemini.ts +0 -350
- package/src/providers/protocols/index.ts +0 -36
- package/src/providers/protocols/openai.ts +0 -420
- package/src/providers/protocols/qwen.ts +0 -315
- package/src/providers/types.ts +0 -264
- package/src/providers/unified-adapter.ts +0 -367
- package/src/router.ts +0 -72
- package/src/tools.ts +0 -162
- package/src/utils.ts +0 -86
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 治理域类型定义
|
|
3
|
+
*
|
|
4
|
+
* - 统一描述本地/市场/系统资产的来源、作用域、运行时形态
|
|
5
|
+
* - 为工具、Part、Skill、MCP 提供共享的管理与审批元模型
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type AssetKind = 'tool' | 'part' | 'skill' | 'mcp-server';
|
|
9
|
+
|
|
10
|
+
/** 资产分发来源(所有资产类型统一) */
|
|
11
|
+
export type AssetSource = 'system' | 'bundled' | 'market' | 'user';
|
|
12
|
+
|
|
13
|
+
export type AssetScope = 'core' | 'local' | 'external';
|
|
14
|
+
|
|
15
|
+
export type AssetRuntime = 'in-process' | 'part-render' | 'prompt-injection' | 'mcp-provider';
|
|
16
|
+
|
|
17
|
+
export type AssetSideEffectLevel = 'read' | 'write' | 'destructive';
|
|
18
|
+
|
|
19
|
+
export type AssetApprovalPolicy = 'auto' | 'manual' | 'destructive-only';
|
|
20
|
+
|
|
21
|
+
export type AssetExecutionIsolation =
|
|
22
|
+
| 'in-process'
|
|
23
|
+
| 'subprocess'
|
|
24
|
+
| 'mcp'
|
|
25
|
+
| 'part-render'
|
|
26
|
+
| 'prompt-injection';
|
|
27
|
+
|
|
28
|
+
export type AssetHostDependency = 'none' | 'local-app' | 'os-service' | 'remote-service';
|
|
29
|
+
|
|
30
|
+
export interface AssetGovernance {
|
|
31
|
+
sideEffectLevel: AssetSideEffectLevel;
|
|
32
|
+
approvalPolicy: AssetApprovalPolicy;
|
|
33
|
+
executionIsolation: AssetExecutionIsolation;
|
|
34
|
+
hostDependency: AssetHostDependency;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type AssetGovernanceOverrides = Partial<Omit<AssetGovernance, 'executionIsolation'>>;
|
|
38
|
+
|
|
39
|
+
export interface ManagedAssetSummaryBase {
|
|
40
|
+
kind: AssetKind;
|
|
41
|
+
scope: AssetScope;
|
|
42
|
+
runtime: AssetRuntime;
|
|
43
|
+
governance?: AssetGovernance;
|
|
44
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @huyooo/ai-chat-core
|
|
3
|
-
*
|
|
4
|
-
* AI Chat 核心包
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* AI Chat 核心包 — 环境无关,浏览器安全
|
|
5
|
+
*
|
|
6
|
+
* 分层架构:
|
|
7
|
+
* ┌─────────────────────────────────────────────────┐
|
|
8
|
+
* │ families/ 模型行为差异(thinking/工具格式) │
|
|
9
|
+
* │ protocols/ HTTP/SSE 通信 + 协议标识 │
|
|
10
|
+
* ├─────────────────────────────────────────────────┤
|
|
11
|
+
* │ adapter/ 协议路由 + 模型列表构建 │
|
|
12
|
+
* │ orchestrator/ 工具调用循环 + 上下文压缩 + 类型 │
|
|
13
|
+
* ├─────────────────────────────────────────────────┤
|
|
14
|
+
* │ tool-manager/ 统一工具管理(Provider + Manager) │
|
|
15
|
+
* │ skills/ 技能注册表 + 管理 API │
|
|
16
|
+
* │ parts/ UI 组件注册表 + 管理 API │
|
|
17
|
+
* ├─────────────────────────────────────────────────┤
|
|
18
|
+
* │ governance/ 资产治理策略(审批/副作用/命令安全)│
|
|
19
|
+
* │ extension/ 扩展元数据类型 + 构建常量 │
|
|
20
|
+
* └─────────────────────────────────────────────────┘
|
|
21
|
+
*
|
|
22
|
+
* Node.js 宿主能力(文件操作 / 工具执行器 / LLM 配置加载)
|
|
23
|
+
* 均在 @huyooo/ai-chat-host-node 中提供。
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
26
|
// ==================== Agent ====================
|
|
26
27
|
|
|
27
|
-
export {
|
|
28
|
+
export { ChatRuntime, type RuntimeConfig } from './chat-runtime';
|
|
28
29
|
|
|
29
|
-
// ====================
|
|
30
|
+
// ==================== Family 层 ====================
|
|
30
31
|
|
|
31
32
|
export {
|
|
32
|
-
// 家族配置
|
|
33
33
|
MODEL_FAMILIES,
|
|
34
34
|
DOUBAO_FAMILY,
|
|
35
35
|
DEEPSEEK_FAMILY,
|
|
@@ -37,39 +37,54 @@ export {
|
|
|
37
37
|
GEMINI_FAMILY,
|
|
38
38
|
GPT_FAMILY,
|
|
39
39
|
CLAUDE_FAMILY,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
MODEL_REGISTRY,
|
|
43
|
-
|
|
44
|
-
// 查询函数
|
|
45
|
-
getModelEntry,
|
|
46
|
-
getModelFamily,
|
|
47
|
-
getModelProtocol,
|
|
48
|
-
getVisibleModels,
|
|
49
|
-
getModelsByFamily,
|
|
50
|
-
getModelsByProtocol,
|
|
51
|
-
modelSupportsThinking,
|
|
52
|
-
modelSupportsNativeSearch,
|
|
53
|
-
getModelSearchStrategy,
|
|
54
|
-
} from './providers/model-registry';
|
|
40
|
+
resolveModelFamilyConfig,
|
|
41
|
+
} from './families';
|
|
55
42
|
|
|
56
43
|
export type {
|
|
57
44
|
ModelFamilyId,
|
|
58
|
-
ProtocolId,
|
|
59
45
|
ThinkingFormat,
|
|
60
|
-
SearchStrategy,
|
|
61
46
|
ToolCallFormat,
|
|
62
47
|
ModelFamilyConfig,
|
|
63
|
-
|
|
64
|
-
} from './providers/model-registry';
|
|
48
|
+
} from './families';
|
|
65
49
|
|
|
66
|
-
// ====================
|
|
50
|
+
// ==================== 协议标识 ====================
|
|
67
51
|
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
|
|
52
|
+
export type { ProtocolId } from './protocols';
|
|
53
|
+
export { getBaseProtocol } from './protocols';
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// ==================== Adapter ====================
|
|
57
|
+
|
|
58
|
+
export { ModelAdapter } from './adapter';
|
|
59
|
+
export {
|
|
60
|
+
buildModelOptions,
|
|
61
|
+
getModelContextConfigFromLLM,
|
|
62
|
+
formatContextWindow,
|
|
63
|
+
formatPricing,
|
|
64
|
+
} from './adapter';
|
|
65
|
+
|
|
66
|
+
export type {
|
|
67
|
+
ModelOption,
|
|
68
|
+
ModelContextConfig,
|
|
69
|
+
} from './adapter';
|
|
70
|
+
|
|
71
|
+
export type {
|
|
72
|
+
ProviderAdapter,
|
|
73
|
+
AdapterConfig,
|
|
74
|
+
StreamOnceOptions,
|
|
75
|
+
} from './adapter';
|
|
76
|
+
|
|
77
|
+
export type {
|
|
78
|
+
OrchestratorConfig,
|
|
79
|
+
OrchestratorContext,
|
|
80
|
+
OrchestratorOptions,
|
|
81
|
+
OrchestratorToolExecutor,
|
|
82
|
+
ToolExecutionHooks,
|
|
83
|
+
GetAutoRunConfigCallback,
|
|
84
|
+
} from './orchestrator';
|
|
85
|
+
|
|
86
|
+
// ==================== Protocol Layer ====================
|
|
71
87
|
|
|
72
|
-
// Protocol Layer
|
|
73
88
|
export {
|
|
74
89
|
ArkProtocol,
|
|
75
90
|
createArkProtocol,
|
|
@@ -77,47 +92,27 @@ export {
|
|
|
77
92
|
createDeepSeekProtocol,
|
|
78
93
|
QwenProtocol,
|
|
79
94
|
createQwenProtocol,
|
|
80
|
-
|
|
81
|
-
createGeminiProtocol,
|
|
82
|
-
OpenAIProtocol,
|
|
83
|
-
createOpenAIProtocol,
|
|
95
|
+
createVercelGatewayProtocol,
|
|
84
96
|
AnthropicProtocol,
|
|
85
97
|
createAnthropicProtocol,
|
|
86
|
-
} from './
|
|
98
|
+
} from './protocols';
|
|
87
99
|
|
|
88
100
|
export type {
|
|
89
101
|
Protocol,
|
|
90
102
|
ProtocolConfig,
|
|
103
|
+
ProtocolAttachment,
|
|
91
104
|
ProtocolMessage,
|
|
92
105
|
ProtocolToolDefinition,
|
|
93
|
-
ProtocolToolCall,
|
|
94
106
|
RawEvent,
|
|
95
107
|
RawEventType,
|
|
108
|
+
RawOutputPart,
|
|
96
109
|
RawToolCall,
|
|
97
|
-
|
|
98
|
-
} from './
|
|
99
|
-
|
|
100
|
-
// Orchestrator - 统一的工具调用处理
|
|
101
|
-
export { ChatOrchestrator, createOrchestrator } from './providers/orchestrator';
|
|
110
|
+
RawTokenUsage,
|
|
111
|
+
} from './protocols';
|
|
102
112
|
|
|
103
|
-
//
|
|
104
|
-
export type {
|
|
105
|
-
StreamChunk,
|
|
106
|
-
StreamChunkType,
|
|
107
|
-
ToolCallRequest,
|
|
108
|
-
SearchResultItem,
|
|
109
|
-
StandardMessage,
|
|
110
|
-
ProviderAdapter,
|
|
111
|
-
AdapterConfig,
|
|
112
|
-
StreamOnceOptions,
|
|
113
|
-
OrchestratorConfig,
|
|
114
|
-
OrchestratorContext,
|
|
115
|
-
OrchestratorOptions,
|
|
116
|
-
SimpleToolDefinition,
|
|
117
|
-
ToolExecutor as OrchestratorToolExecutor,
|
|
118
|
-
} from './providers/types';
|
|
113
|
+
// ==================== Orchestrator ====================
|
|
119
114
|
|
|
120
|
-
|
|
115
|
+
export { ChatOrchestrator, createOrchestrator } from './orchestrator';
|
|
121
116
|
|
|
122
117
|
// ==================== 配置与类型 ====================
|
|
123
118
|
|
|
@@ -132,38 +127,43 @@ export type {
|
|
|
132
127
|
ToolDefinition,
|
|
133
128
|
ChatMessage,
|
|
134
129
|
ResponsesApiTool,
|
|
135
|
-
// 模型类型
|
|
136
|
-
ModelOption,
|
|
137
|
-
ProviderType,
|
|
138
|
-
// 工具接口
|
|
139
130
|
Tool,
|
|
140
131
|
ToolContext,
|
|
132
|
+
DataEngineContext,
|
|
141
133
|
ToolUI,
|
|
142
134
|
RenderType,
|
|
143
135
|
ActionType,
|
|
144
136
|
ExecResult,
|
|
137
|
+
ExecOptions,
|
|
138
|
+
ToolResult,
|
|
139
|
+
ToolSuccess,
|
|
140
|
+
ToolExecuteResult,
|
|
145
141
|
ToolError,
|
|
146
142
|
ToolErrorCode,
|
|
147
|
-
|
|
143
|
+
ToolErrorCategory,
|
|
148
144
|
ToolPlugin,
|
|
149
145
|
ToolConfigItem,
|
|
150
|
-
|
|
146
|
+
ToolExecutionAuditHooks,
|
|
151
147
|
UserToolDefinition,
|
|
148
|
+
JsonSchemaObject,
|
|
152
149
|
} from './types';
|
|
153
150
|
|
|
154
151
|
export {
|
|
155
|
-
// 模型列表
|
|
156
|
-
MODELS,
|
|
157
|
-
getModelByModelId,
|
|
158
|
-
// 工具解析和辅助函数
|
|
159
152
|
resolveTools,
|
|
160
153
|
tool,
|
|
161
154
|
tools,
|
|
162
|
-
|
|
155
|
+
ToolException,
|
|
156
|
+
normalizeToolResult,
|
|
157
|
+
serializeToolResult,
|
|
158
|
+
isToolResult,
|
|
159
|
+
toolOk,
|
|
160
|
+
createResolvedOutputSchema,
|
|
161
|
+
STANDARD_TOOL_ERROR_SCHEMA,
|
|
162
|
+
resolveToolResultUi,
|
|
163
|
+
mergeToolGovernance,
|
|
164
|
+
resolveToolGovernanceSnapshot,
|
|
163
165
|
throwToolError,
|
|
164
|
-
rethrowToolError,
|
|
165
166
|
isToolError,
|
|
166
|
-
getArg,
|
|
167
167
|
} from './types';
|
|
168
168
|
|
|
169
169
|
// 常量
|
|
@@ -171,21 +171,16 @@ export { DEFAULT_MODEL } from './constants';
|
|
|
171
171
|
|
|
172
172
|
// ==================== 事件系统 ====================
|
|
173
173
|
|
|
174
|
-
// 基础类型
|
|
175
174
|
export type {
|
|
176
|
-
SearchResult,
|
|
177
175
|
ToolCallStatus,
|
|
178
176
|
ToolCallInfo,
|
|
179
177
|
TokenUsage,
|
|
180
178
|
ErrorCategory,
|
|
181
179
|
ErrorDetails,
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
FinishReason,
|
|
181
|
+
ToolFailureReason,
|
|
184
182
|
} from './events';
|
|
185
183
|
|
|
186
|
-
export { isThrowableToolError } from './events';
|
|
187
|
-
|
|
188
|
-
// 思考事件
|
|
189
184
|
export type {
|
|
190
185
|
ThinkingStartEvent,
|
|
191
186
|
ThinkingDeltaEvent,
|
|
@@ -193,15 +188,6 @@ export type {
|
|
|
193
188
|
ThinkingEvent
|
|
194
189
|
} from './events';
|
|
195
190
|
|
|
196
|
-
// 搜索事件
|
|
197
|
-
export type {
|
|
198
|
-
SearchStartEvent,
|
|
199
|
-
SearchResultEvent,
|
|
200
|
-
SearchEndEvent,
|
|
201
|
-
SearchEvent
|
|
202
|
-
} from './events';
|
|
203
|
-
|
|
204
|
-
// 工具事件
|
|
205
191
|
export type {
|
|
206
192
|
ToolCallStartEvent,
|
|
207
193
|
ToolCallResultEvent,
|
|
@@ -211,19 +197,22 @@ export type {
|
|
|
211
197
|
ToolEvent
|
|
212
198
|
} from './events';
|
|
213
199
|
|
|
214
|
-
// 文本事件
|
|
215
200
|
export type {
|
|
201
|
+
TextStartEvent,
|
|
216
202
|
TextDeltaEvent,
|
|
203
|
+
TextEndEvent,
|
|
217
204
|
TextEvent
|
|
218
205
|
} from './events';
|
|
219
206
|
|
|
220
|
-
|
|
207
|
+
export type {
|
|
208
|
+
DataEvent,
|
|
209
|
+
} from './events';
|
|
210
|
+
|
|
221
211
|
export type {
|
|
222
212
|
PlanStep,
|
|
223
213
|
PlanStepStatus,
|
|
224
214
|
} from './events';
|
|
225
215
|
|
|
226
|
-
// 状态事件
|
|
227
216
|
export type {
|
|
228
217
|
DoneEvent,
|
|
229
218
|
ErrorEvent,
|
|
@@ -231,34 +220,30 @@ export type {
|
|
|
231
220
|
StatusEvent
|
|
232
221
|
} from './events';
|
|
233
222
|
|
|
234
|
-
// 步骤事件
|
|
235
223
|
export type {
|
|
236
224
|
StepStartEvent,
|
|
237
225
|
StepEndEvent,
|
|
238
226
|
StepEvent
|
|
239
227
|
} from './events';
|
|
240
228
|
|
|
241
|
-
// 聚合类型
|
|
242
229
|
export type {
|
|
243
230
|
ChatEvent,
|
|
244
|
-
ChatEventType
|
|
231
|
+
ChatEventType,
|
|
232
|
+
AssistantSegmentReason,
|
|
233
|
+
AssistantSegmentStartEvent,
|
|
234
|
+
AssistantSegmentEvent,
|
|
245
235
|
} from './events';
|
|
246
236
|
|
|
247
|
-
// 事件创建函数
|
|
248
237
|
export {
|
|
249
238
|
createThinkingStart,
|
|
250
239
|
createThinkingDelta,
|
|
251
240
|
createThinkingEnd,
|
|
252
|
-
createSearchStart,
|
|
253
|
-
createSearchResult,
|
|
254
|
-
createSearchEnd,
|
|
255
241
|
createToolCallStart,
|
|
256
242
|
createToolCallResult,
|
|
257
243
|
createToolCallOutput,
|
|
258
244
|
createToolCallRequest,
|
|
259
245
|
createTextDelta,
|
|
260
246
|
createDone,
|
|
261
|
-
// 错误创建函数
|
|
262
247
|
createError,
|
|
263
248
|
createApiError,
|
|
264
249
|
createRateLimitError,
|
|
@@ -266,56 +251,176 @@ export {
|
|
|
266
251
|
createTimeoutError,
|
|
267
252
|
createParseError,
|
|
268
253
|
createAbort,
|
|
269
|
-
// 步骤事件
|
|
270
254
|
createStepStart,
|
|
271
255
|
createStepEnd,
|
|
272
|
-
|
|
256
|
+
createAssistantSegmentStart,
|
|
273
257
|
isThinkingEvent,
|
|
274
|
-
isSearchEvent,
|
|
275
258
|
isToolEvent,
|
|
276
259
|
isTextEvent,
|
|
277
260
|
isStatusEvent,
|
|
278
261
|
isErrorEvent,
|
|
279
262
|
isAbortEvent,
|
|
280
263
|
isStepEvent,
|
|
264
|
+
isAssistantSegmentEvent,
|
|
281
265
|
isRetryableError,
|
|
282
266
|
CHAT_EVENT_TYPES
|
|
283
267
|
} from './events';
|
|
284
268
|
|
|
285
|
-
// ====================
|
|
269
|
+
// ==================== 统一工具管理 ====================
|
|
286
270
|
|
|
287
|
-
export {
|
|
271
|
+
export { Type } from '@sinclair/typebox';
|
|
272
|
+
export type { Static, TSchema, TObject } from '@sinclair/typebox';
|
|
288
273
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
274
|
+
export {
|
|
275
|
+
createToolRuntimeManager,
|
|
276
|
+
createInProcessProvider,
|
|
277
|
+
createMcpProvider,
|
|
278
|
+
createManagedToolSummary,
|
|
279
|
+
createManagedToolDetail,
|
|
280
|
+
createManagedMcpServerSummary,
|
|
281
|
+
createManagedMcpServerDetail,
|
|
282
|
+
defineTool,
|
|
283
|
+
TOOL_FORMATS,
|
|
284
|
+
validateJsonSchemaArgs,
|
|
285
|
+
validateTypeBoxArgs,
|
|
286
|
+
registerToolFormats,
|
|
287
|
+
registerToolFormat,
|
|
288
|
+
hasToolFormat,
|
|
289
|
+
} from './tool-manager';
|
|
300
290
|
|
|
301
|
-
|
|
291
|
+
export type {
|
|
292
|
+
ToolDescriptor,
|
|
293
|
+
ToolChangeEvent,
|
|
294
|
+
ToolChangeListener,
|
|
295
|
+
SessionToolsChangeEvent,
|
|
296
|
+
SessionToolsChangeListener,
|
|
297
|
+
ToolProvider,
|
|
298
|
+
InProcessProvider,
|
|
299
|
+
McpProviderExtended,
|
|
300
|
+
McpServerConfig,
|
|
301
|
+
McpConnectionStatus,
|
|
302
|
+
McpConnectionInfo,
|
|
303
|
+
ManagedToolSummary,
|
|
304
|
+
ManagedToolDetail,
|
|
305
|
+
ManagedMcpServerSummary,
|
|
306
|
+
ManagedMcpServerDetail,
|
|
307
|
+
ToolSearchQuery,
|
|
308
|
+
CategorySummary,
|
|
309
|
+
ProviderInfo,
|
|
310
|
+
ToolRuntimeManager,
|
|
311
|
+
TypeBoxToolConfig,
|
|
312
|
+
ToolFormat,
|
|
313
|
+
} from './tool-manager';
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
// ==================== 技能 ====================
|
|
317
|
+
|
|
318
|
+
export { skillRegistry } from './skills';
|
|
319
|
+
export type { SkillRegistry } from './skills';
|
|
320
|
+
export type {
|
|
321
|
+
SkillMeta,
|
|
322
|
+
SkillSearchQuery,
|
|
323
|
+
ManagedSkillSummary,
|
|
324
|
+
ManagedSkillDetail,
|
|
325
|
+
} from './skills';
|
|
326
|
+
|
|
327
|
+
export { skillManagementPlugin } from './skills';
|
|
328
|
+
export { createManagedSkillSummary, createManagedSkillDetail } from './skills';
|
|
329
|
+
export type {
|
|
330
|
+
SkillManagementOptions,
|
|
331
|
+
OnSkillCreate,
|
|
332
|
+
OnSkillUpdate,
|
|
333
|
+
OnSkillDelete,
|
|
334
|
+
OnSkillSetEnabled,
|
|
335
|
+
OnSkillLoadContent,
|
|
336
|
+
OnSkillLoadReference,
|
|
337
|
+
} from './skills';
|
|
302
338
|
|
|
303
|
-
|
|
339
|
+
// ==================== LLM 配置(Model 中心)====================
|
|
304
340
|
|
|
305
341
|
export {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
342
|
+
getRouteChain,
|
|
343
|
+
resolveRouteUrl,
|
|
344
|
+
findRouteByProtocol,
|
|
345
|
+
} from './llm-config';
|
|
346
|
+
export type {
|
|
347
|
+
LLMConfig,
|
|
348
|
+
ModelRoute,
|
|
349
|
+
ModelConfig,
|
|
350
|
+
ModelPricing,
|
|
351
|
+
CompressionConfig,
|
|
352
|
+
} from './llm-config';
|
|
311
353
|
|
|
312
|
-
// ====================
|
|
313
|
-
// McpClientManager 只在内部使用(agent.ts 直接 import),不从主入口导出
|
|
314
|
-
// 避免在 renderer 中因 barrel file 加载整个模块图而引入 Node.js-only 的 MCP SDK
|
|
315
|
-
// 如需外部使用,请通过 @huyooo/ai-chat-core/mcp 子路径导入
|
|
354
|
+
// ==================== UI 组件 ====================
|
|
316
355
|
|
|
317
|
-
export
|
|
356
|
+
export { partRegistry } from './parts';
|
|
357
|
+
export type {
|
|
358
|
+
PartMeta,
|
|
359
|
+
PartSearchQuery,
|
|
360
|
+
PartRegistry,
|
|
361
|
+
ManagedPartSummary,
|
|
362
|
+
ManagedPartDetail,
|
|
363
|
+
} from './parts';
|
|
364
|
+
|
|
365
|
+
export { createManagedPartSummary, createManagedPartDetail } from './parts';
|
|
366
|
+
|
|
367
|
+
// ==================== 治理策略 ====================
|
|
368
|
+
|
|
369
|
+
export {
|
|
370
|
+
analyzeCommandRisk,
|
|
371
|
+
createAssetSummaryBase,
|
|
372
|
+
createCommandGovernanceSnapshot,
|
|
373
|
+
createCommandToolMetadata,
|
|
374
|
+
createLocalMcpServerGovernance,
|
|
375
|
+
createLocalToolGovernance,
|
|
376
|
+
createPartAssetGovernance,
|
|
377
|
+
readAssetGovernanceOverrides,
|
|
378
|
+
toAssetGovernanceOverrides,
|
|
379
|
+
} from './governance';
|
|
380
|
+
export type {
|
|
381
|
+
AssetApprovalPolicy,
|
|
382
|
+
AssetExecutionIsolation,
|
|
383
|
+
AssetGovernance,
|
|
384
|
+
AssetGovernanceOverrides,
|
|
385
|
+
AssetHostDependency,
|
|
386
|
+
AssetKind,
|
|
387
|
+
AssetRuntime,
|
|
388
|
+
AssetScope,
|
|
389
|
+
AssetSideEffectLevel,
|
|
390
|
+
AssetSource,
|
|
391
|
+
CommandRiskAssessment,
|
|
392
|
+
CommandRiskTag,
|
|
393
|
+
CommandSafetyPolicy,
|
|
394
|
+
CommandToolMetadata,
|
|
395
|
+
ManagedAssetSummaryBase,
|
|
396
|
+
} from './governance';
|
|
397
|
+
|
|
398
|
+
// ==================== 扩展元数据 ====================
|
|
399
|
+
|
|
400
|
+
export type {
|
|
401
|
+
AssetType,
|
|
402
|
+
AssetMeta,
|
|
403
|
+
AssetToolMeta,
|
|
404
|
+
} from './extension';
|
|
405
|
+
|
|
406
|
+
// ==================== 管理工具辅助(参数解析 / 结果格式化) ====================
|
|
407
|
+
|
|
408
|
+
export {
|
|
409
|
+
getRequiredString,
|
|
410
|
+
getOptionalString,
|
|
411
|
+
getBooleanWithDefault,
|
|
412
|
+
getStringArray,
|
|
413
|
+
getStringRecord,
|
|
414
|
+
splitCommaSeparatedStrings,
|
|
415
|
+
} from './internal/management-args';
|
|
416
|
+
export {
|
|
417
|
+
createCollectionResult,
|
|
418
|
+
createInspectResult,
|
|
419
|
+
createActionResult,
|
|
420
|
+
createToggleResult,
|
|
421
|
+
} from './internal/management-results';
|
|
318
422
|
|
|
319
|
-
// ====================
|
|
423
|
+
// ==================== 日志 ====================
|
|
320
424
|
|
|
321
|
-
export {
|
|
425
|
+
export { initLogger, getLogger, createModuleLogger } from './logger';
|
|
426
|
+
export type { LogLevel, LoggerConfig } from './logger';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 管理工具参数解析辅助(未知 → 强类型)
|
|
3
|
+
*
|
|
4
|
+
* - 供 skill/tool/mcp 管理插件从 args 提取 string、boolean、数组
|
|
5
|
+
* - 避免各处重复 typeof 判空逻辑
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function getRequiredString(value: unknown): string {
|
|
9
|
+
return typeof value === 'string' ? value : '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getOptionalString(value: unknown): string | undefined {
|
|
13
|
+
return typeof value === 'string' ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getBooleanWithDefault(value: unknown, fallback: boolean): boolean {
|
|
17
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getStringArray(value: unknown): string[] | undefined {
|
|
21
|
+
if (!Array.isArray(value)) return undefined;
|
|
22
|
+
return value.filter((item): item is string => typeof item === 'string');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getStringRecord(value: unknown): Record<string, string> | undefined {
|
|
26
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
|
|
27
|
+
|
|
28
|
+
const entries = Object.entries(value).filter(
|
|
29
|
+
(entry): entry is [string, string] => typeof entry[0] === 'string' && typeof entry[1] === 'string',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return Object.fromEntries(entries);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function splitCommaSeparatedStrings(value: unknown): string[] | undefined {
|
|
36
|
+
const raw = getOptionalString(value);
|
|
37
|
+
if (!raw) return undefined;
|
|
38
|
+
return raw.split(',').map(item => item.trim()).filter(Boolean);
|
|
39
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 管理 API 统一返回结构构造器
|
|
3
|
+
*
|
|
4
|
+
* - list 类结果:`count` + 命名数组字段 + 可选 extra
|
|
5
|
+
* - 与各 management 插件的 JSON 形状保持一致
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type ResultExtra = Record<string, unknown>;
|
|
9
|
+
|
|
10
|
+
export function createCollectionResult<TKey extends string, TItem>(
|
|
11
|
+
key: TKey,
|
|
12
|
+
items: TItem[],
|
|
13
|
+
extra: ResultExtra = {},
|
|
14
|
+
): Record<TKey | 'count', unknown> & ResultExtra {
|
|
15
|
+
return {
|
|
16
|
+
count: items.length,
|
|
17
|
+
[key]: items,
|
|
18
|
+
...extra,
|
|
19
|
+
} as Record<TKey | 'count', unknown> & ResultExtra;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createInspectResult<TKey extends string, TItem>(
|
|
23
|
+
key: TKey,
|
|
24
|
+
item: TItem,
|
|
25
|
+
extra: ResultExtra = {},
|
|
26
|
+
): Record<TKey, unknown> & ResultExtra {
|
|
27
|
+
return {
|
|
28
|
+
[key]: item,
|
|
29
|
+
...extra,
|
|
30
|
+
} as Record<TKey, unknown> & ResultExtra;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createActionResult<TAction extends string, TKey extends string, TItem>(
|
|
34
|
+
action: TAction,
|
|
35
|
+
key: TKey,
|
|
36
|
+
item: TItem,
|
|
37
|
+
extra: ResultExtra = {},
|
|
38
|
+
): Record<'action' | TKey, unknown> & ResultExtra {
|
|
39
|
+
return {
|
|
40
|
+
action,
|
|
41
|
+
[key]: item,
|
|
42
|
+
...extra,
|
|
43
|
+
} as Record<'action' | TKey, unknown> & ResultExtra;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function createToggleResult<TResult extends { enabled: boolean; error?: string }>(
|
|
47
|
+
results: TResult[],
|
|
48
|
+
extra: ResultExtra = {},
|
|
49
|
+
) {
|
|
50
|
+
const enabledCount = results.filter(item => item.enabled && !item.error).length;
|
|
51
|
+
const disabledCount = results.filter(item => !item.enabled && !item.error).length;
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
action: 'enabled',
|
|
55
|
+
results,
|
|
56
|
+
enabledCount,
|
|
57
|
+
disabledCount,
|
|
58
|
+
...extra,
|
|
59
|
+
};
|
|
60
|
+
}
|