@huyooo/ai-chat-core 0.3.6 → 0.3.8
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 +0 -1
- package/dist/adapter/model-adapter.d.ts +0 -1
- package/dist/adapter/model-options.d.ts +0 -1
- package/dist/adapter/types.d.ts +0 -1
- package/dist/chat-runtime.d.ts +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/events.d.ts +0 -1
- package/dist/extension/index.d.ts +0 -1
- package/dist/extension/types.d.ts +0 -1
- package/dist/families/index.d.ts +0 -1
- package/dist/families/presets.d.ts +0 -1
- package/dist/families/resolver.d.ts +0 -1
- package/dist/families/types.d.ts +0 -1
- package/dist/governance/command-safety.d.ts +0 -1
- package/dist/governance/governance.d.ts +0 -1
- package/dist/governance/index.d.ts +0 -1
- package/dist/governance/types.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/internal/management-args.d.ts +0 -1
- package/dist/internal/management-results.d.ts +0 -1
- package/dist/llm-config.d.ts +0 -1
- package/dist/logger/core.d.ts +0 -1
- package/dist/logger/index.d.ts +0 -1
- package/dist/orchestrator/compression-handler.d.ts +0 -1
- package/dist/orchestrator/context-compressor.d.ts +0 -1
- package/dist/orchestrator/context-summarizer.d.ts +0 -1
- package/dist/orchestrator/index.d.ts +0 -1
- package/dist/orchestrator/orchestrator.d.ts +0 -1
- package/dist/orchestrator/types.d.ts +0 -1
- package/dist/parts/index.d.ts +0 -1
- package/dist/parts/registry.d.ts +0 -1
- package/dist/parts/summaries.d.ts +0 -1
- package/dist/parts/types.d.ts +0 -1
- package/dist/platform.d.ts +0 -1
- package/dist/protocols/anthropic.d.ts +0 -1
- package/dist/protocols/ark.d.ts +0 -1
- package/dist/protocols/deepseek.d.ts +0 -1
- package/dist/protocols/error-utils.d.ts +0 -1
- package/dist/protocols/gemini.d.ts +0 -1
- package/dist/protocols/glm.d.ts +0 -1
- package/dist/protocols/grok.d.ts +0 -1
- package/dist/protocols/index.d.ts +0 -1
- package/dist/protocols/minimax.d.ts +0 -1
- package/dist/protocols/moonshot.d.ts +0 -1
- package/dist/protocols/openai-sse.d.ts +0 -1
- package/dist/protocols/openai.d.ts +0 -1
- package/dist/protocols/qwen.d.ts +0 -1
- package/dist/protocols/responses-sse.d.ts +0 -1
- package/dist/protocols/sse-reader.d.ts +0 -1
- package/dist/protocols/tool-arguments.d.ts +0 -1
- package/dist/protocols/types.d.ts +0 -1
- package/dist/protocols/vercel-gateway.d.ts +0 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/skills/index.d.ts +0 -1
- package/dist/skills/management/admin.d.ts +0 -1
- package/dist/skills/management/index.d.ts +0 -1
- package/dist/skills/management/inputs.d.ts +0 -1
- package/dist/skills/management/operations.d.ts +0 -1
- package/dist/skills/management/types.d.ts +0 -1
- package/dist/skills/registry.d.ts +0 -1
- package/dist/skills/summaries.d.ts +0 -1
- package/dist/skills/types.d.ts +0 -1
- package/dist/test-utils/mock-sse.d.ts +0 -1
- package/dist/tool-manager/define-tool.d.ts +0 -1
- package/dist/tool-manager/formats.d.ts +0 -1
- package/dist/tool-manager/identity.d.ts +0 -1
- package/dist/tool-manager/in-process-provider.d.ts +0 -1
- package/dist/tool-manager/index.d.ts +0 -1
- package/dist/tool-manager/manager.d.ts +0 -1
- package/dist/tool-manager/mcp-provider.d.ts +0 -1
- package/dist/tool-manager/summaries.d.ts +0 -1
- package/dist/tool-manager/types.d.ts +0 -1
- package/dist/types.d.ts +0 -1
- package/package.json +2 -3
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/model-adapter.d.ts.map +0 -1
- package/dist/adapter/model-options.d.ts.map +0 -1
- package/dist/adapter/types.d.ts.map +0 -1
- package/dist/chat-runtime.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/extension/index.d.ts.map +0 -1
- package/dist/extension/types.d.ts.map +0 -1
- package/dist/families/index.d.ts.map +0 -1
- package/dist/families/presets.d.ts.map +0 -1
- package/dist/families/resolver.d.ts.map +0 -1
- package/dist/families/types.d.ts.map +0 -1
- package/dist/governance/command-safety.d.ts.map +0 -1
- package/dist/governance/governance.d.ts.map +0 -1
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/types.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/management-args.d.ts.map +0 -1
- package/dist/internal/management-results.d.ts.map +0 -1
- package/dist/llm-config.d.ts.map +0 -1
- package/dist/logger/core.d.ts.map +0 -1
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/orchestrator/compression-handler.d.ts.map +0 -1
- package/dist/orchestrator/context-compressor.d.ts.map +0 -1
- package/dist/orchestrator/context-summarizer.d.ts.map +0 -1
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/orchestrator.d.ts.map +0 -1
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/parts/index.d.ts.map +0 -1
- package/dist/parts/registry.d.ts.map +0 -1
- package/dist/parts/summaries.d.ts.map +0 -1
- package/dist/parts/types.d.ts.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/protocols/anthropic.d.ts.map +0 -1
- package/dist/protocols/ark.d.ts.map +0 -1
- package/dist/protocols/deepseek.d.ts.map +0 -1
- package/dist/protocols/error-utils.d.ts.map +0 -1
- package/dist/protocols/gemini.d.ts.map +0 -1
- package/dist/protocols/glm.d.ts.map +0 -1
- package/dist/protocols/grok.d.ts.map +0 -1
- package/dist/protocols/index.d.ts.map +0 -1
- package/dist/protocols/minimax.d.ts.map +0 -1
- package/dist/protocols/moonshot.d.ts.map +0 -1
- package/dist/protocols/openai-sse.d.ts.map +0 -1
- package/dist/protocols/openai.d.ts.map +0 -1
- package/dist/protocols/qwen.d.ts.map +0 -1
- package/dist/protocols/responses-sse.d.ts.map +0 -1
- package/dist/protocols/sse-reader.d.ts.map +0 -1
- package/dist/protocols/tool-arguments.d.ts.map +0 -1
- package/dist/protocols/types.d.ts.map +0 -1
- package/dist/protocols/vercel-gateway.d.ts.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/management/admin.d.ts.map +0 -1
- package/dist/skills/management/index.d.ts.map +0 -1
- package/dist/skills/management/inputs.d.ts.map +0 -1
- package/dist/skills/management/operations.d.ts.map +0 -1
- package/dist/skills/management/types.d.ts.map +0 -1
- package/dist/skills/registry.d.ts.map +0 -1
- package/dist/skills/summaries.d.ts.map +0 -1
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/test-utils/mock-sse.d.ts.map +0 -1
- package/dist/tool-manager/define-tool.d.ts.map +0 -1
- package/dist/tool-manager/formats.d.ts.map +0 -1
- package/dist/tool-manager/identity.d.ts.map +0 -1
- package/dist/tool-manager/in-process-provider.d.ts.map +0 -1
- package/dist/tool-manager/index.d.ts.map +0 -1
- package/dist/tool-manager/manager.d.ts.map +0 -1
- package/dist/tool-manager/mcp-provider.d.ts.map +0 -1
- package/dist/tool-manager/summaries.d.ts.map +0 -1
- package/dist/tool-manager/types.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/src/adapter/index.ts +0 -25
- package/src/adapter/model-adapter.ts +0 -196
- package/src/adapter/model-options.ts +0 -143
- package/src/adapter/types.ts +0 -41
- package/src/chat-runtime.ts +0 -515
- package/src/constants.ts +0 -32
- package/src/events.ts +0 -1084
- package/src/extension/index.ts +0 -24
- package/src/extension/types.ts +0 -49
- package/src/families/index.ts +0 -28
- package/src/families/presets.ts +0 -124
- package/src/families/resolver.ts +0 -22
- package/src/families/types.ts +0 -55
- package/src/governance/command-safety.ts +0 -224
- package/src/governance/governance.ts +0 -125
- package/src/governance/index.ts +0 -38
- package/src/governance/types.ts +0 -44
- package/src/index.ts +0 -426
- package/src/internal/management-args.ts +0 -39
- package/src/internal/management-results.ts +0 -60
- package/src/llm-config.ts +0 -137
- package/src/logger/core.ts +0 -96
- package/src/logger/index.ts +0 -8
- package/src/orchestrator/compression-handler.ts +0 -137
- package/src/orchestrator/context-compressor.ts +0 -249
- package/src/orchestrator/context-summarizer.ts +0 -123
- package/src/orchestrator/index.ts +0 -20
- package/src/orchestrator/orchestrator.ts +0 -1002
- package/src/orchestrator/types.ts +0 -70
- package/src/parts/index.ts +0 -20
- package/src/parts/registry.ts +0 -95
- package/src/parts/summaries.ts +0 -40
- package/src/parts/types.ts +0 -63
- package/src/platform.ts +0 -73
- package/src/protocols/anthropic.ts +0 -377
- package/src/protocols/ark.ts +0 -300
- package/src/protocols/deepseek.ts +0 -192
- package/src/protocols/error-utils.ts +0 -71
- package/src/protocols/gemini.ts +0 -352
- package/src/protocols/glm.ts +0 -212
- package/src/protocols/grok.ts +0 -98
- package/src/protocols/index.ts +0 -48
- package/src/protocols/minimax.ts +0 -308
- package/src/protocols/moonshot.ts +0 -186
- package/src/protocols/openai-sse.ts +0 -156
- package/src/protocols/openai.ts +0 -97
- package/src/protocols/qwen.ts +0 -358
- package/src/protocols/responses-sse.ts +0 -224
- package/src/protocols/sse-reader.ts +0 -54
- package/src/protocols/tool-arguments.ts +0 -32
- package/src/protocols/types.ts +0 -198
- package/src/protocols/vercel-gateway.ts +0 -391
- package/src/runtime.ts +0 -167
- package/src/skills/index.ts +0 -29
- package/src/skills/management/admin.ts +0 -170
- package/src/skills/management/index.ts +0 -27
- package/src/skills/management/inputs.ts +0 -79
- package/src/skills/management/operations.ts +0 -256
- package/src/skills/management/types.ts +0 -57
- package/src/skills/registry.ts +0 -120
- package/src/skills/summaries.ts +0 -48
- package/src/skills/types.ts +0 -65
- package/src/test-utils/mock-sse.ts +0 -32
- package/src/tool-manager/define-tool.ts +0 -201
- package/src/tool-manager/formats.ts +0 -146
- package/src/tool-manager/identity.ts +0 -80
- package/src/tool-manager/in-process-provider.ts +0 -164
- package/src/tool-manager/index.ts +0 -63
- package/src/tool-manager/manager.ts +0 -562
- package/src/tool-manager/mcp-provider.ts +0 -509
- package/src/tool-manager/summaries.ts +0 -136
- package/src/tool-manager/types.ts +0 -389
- package/src/types.ts +0 -1142
package/src/governance/types.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @huyooo/ai-chat-core
|
|
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 中提供。
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
// ==================== Agent ====================
|
|
27
|
-
|
|
28
|
-
export { ChatRuntime, type RuntimeConfig } from './chat-runtime';
|
|
29
|
-
|
|
30
|
-
// ==================== Family 层 ====================
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
MODEL_FAMILIES,
|
|
34
|
-
DOUBAO_FAMILY,
|
|
35
|
-
DEEPSEEK_FAMILY,
|
|
36
|
-
QWEN_FAMILY,
|
|
37
|
-
GEMINI_FAMILY,
|
|
38
|
-
GPT_FAMILY,
|
|
39
|
-
CLAUDE_FAMILY,
|
|
40
|
-
resolveModelFamilyConfig,
|
|
41
|
-
} from './families';
|
|
42
|
-
|
|
43
|
-
export type {
|
|
44
|
-
ModelFamilyId,
|
|
45
|
-
ThinkingFormat,
|
|
46
|
-
ToolCallFormat,
|
|
47
|
-
ModelFamilyConfig,
|
|
48
|
-
} from './families';
|
|
49
|
-
|
|
50
|
-
// ==================== 协议标识 ====================
|
|
51
|
-
|
|
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 ====================
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
ArkProtocol,
|
|
90
|
-
createArkProtocol,
|
|
91
|
-
DeepSeekProtocol,
|
|
92
|
-
createDeepSeekProtocol,
|
|
93
|
-
QwenProtocol,
|
|
94
|
-
createQwenProtocol,
|
|
95
|
-
createVercelGatewayProtocol,
|
|
96
|
-
AnthropicProtocol,
|
|
97
|
-
createAnthropicProtocol,
|
|
98
|
-
} from './protocols';
|
|
99
|
-
|
|
100
|
-
export type {
|
|
101
|
-
Protocol,
|
|
102
|
-
ProtocolConfig,
|
|
103
|
-
ProtocolAttachment,
|
|
104
|
-
ProtocolMessage,
|
|
105
|
-
ProtocolToolDefinition,
|
|
106
|
-
RawEvent,
|
|
107
|
-
RawEventType,
|
|
108
|
-
RawOutputPart,
|
|
109
|
-
RawToolCall,
|
|
110
|
-
RawTokenUsage,
|
|
111
|
-
} from './protocols';
|
|
112
|
-
|
|
113
|
-
// ==================== Orchestrator ====================
|
|
114
|
-
|
|
115
|
-
export { ChatOrchestrator, createOrchestrator } from './orchestrator';
|
|
116
|
-
|
|
117
|
-
// ==================== 配置与类型 ====================
|
|
118
|
-
|
|
119
|
-
export type {
|
|
120
|
-
AgentConfig,
|
|
121
|
-
ChatOptions,
|
|
122
|
-
ChatMode,
|
|
123
|
-
ThinkingMode,
|
|
124
|
-
AutoRunMode,
|
|
125
|
-
AutoRunConfig,
|
|
126
|
-
ToolExecutor,
|
|
127
|
-
ToolDefinition,
|
|
128
|
-
ChatMessage,
|
|
129
|
-
ResponsesApiTool,
|
|
130
|
-
Tool,
|
|
131
|
-
ToolContext,
|
|
132
|
-
DataEngineContext,
|
|
133
|
-
ToolUI,
|
|
134
|
-
RenderType,
|
|
135
|
-
ActionType,
|
|
136
|
-
ExecResult,
|
|
137
|
-
ExecOptions,
|
|
138
|
-
ToolResult,
|
|
139
|
-
ToolSuccess,
|
|
140
|
-
ToolExecuteResult,
|
|
141
|
-
ToolError,
|
|
142
|
-
ToolErrorCode,
|
|
143
|
-
ToolErrorCategory,
|
|
144
|
-
ToolPlugin,
|
|
145
|
-
ToolConfigItem,
|
|
146
|
-
ToolExecutionAuditHooks,
|
|
147
|
-
UserToolDefinition,
|
|
148
|
-
JsonSchemaObject,
|
|
149
|
-
} from './types';
|
|
150
|
-
|
|
151
|
-
export {
|
|
152
|
-
resolveTools,
|
|
153
|
-
tool,
|
|
154
|
-
tools,
|
|
155
|
-
ToolException,
|
|
156
|
-
normalizeToolResult,
|
|
157
|
-
serializeToolResult,
|
|
158
|
-
isToolResult,
|
|
159
|
-
toolOk,
|
|
160
|
-
createResolvedOutputSchema,
|
|
161
|
-
STANDARD_TOOL_ERROR_SCHEMA,
|
|
162
|
-
resolveToolResultUi,
|
|
163
|
-
mergeToolGovernance,
|
|
164
|
-
resolveToolGovernanceSnapshot,
|
|
165
|
-
throwToolError,
|
|
166
|
-
isToolError,
|
|
167
|
-
} from './types';
|
|
168
|
-
|
|
169
|
-
// 常量
|
|
170
|
-
export { DEFAULT_MODEL } from './constants';
|
|
171
|
-
|
|
172
|
-
// ==================== 事件系统 ====================
|
|
173
|
-
|
|
174
|
-
export type {
|
|
175
|
-
ToolCallStatus,
|
|
176
|
-
ToolCallInfo,
|
|
177
|
-
TokenUsage,
|
|
178
|
-
ErrorCategory,
|
|
179
|
-
ErrorDetails,
|
|
180
|
-
FinishReason,
|
|
181
|
-
ToolFailureReason,
|
|
182
|
-
} from './events';
|
|
183
|
-
|
|
184
|
-
export type {
|
|
185
|
-
ThinkingStartEvent,
|
|
186
|
-
ThinkingDeltaEvent,
|
|
187
|
-
ThinkingEndEvent,
|
|
188
|
-
ThinkingEvent
|
|
189
|
-
} from './events';
|
|
190
|
-
|
|
191
|
-
export type {
|
|
192
|
-
ToolCallStartEvent,
|
|
193
|
-
ToolCallResultEvent,
|
|
194
|
-
ToolCallOutputEvent,
|
|
195
|
-
ToolApprovalRequestEvent,
|
|
196
|
-
ToolCallRequestEvent,
|
|
197
|
-
ToolEvent
|
|
198
|
-
} from './events';
|
|
199
|
-
|
|
200
|
-
export type {
|
|
201
|
-
TextStartEvent,
|
|
202
|
-
TextDeltaEvent,
|
|
203
|
-
TextEndEvent,
|
|
204
|
-
TextEvent
|
|
205
|
-
} from './events';
|
|
206
|
-
|
|
207
|
-
export type {
|
|
208
|
-
DataEvent,
|
|
209
|
-
} from './events';
|
|
210
|
-
|
|
211
|
-
export type {
|
|
212
|
-
PlanStep,
|
|
213
|
-
PlanStepStatus,
|
|
214
|
-
} from './events';
|
|
215
|
-
|
|
216
|
-
export type {
|
|
217
|
-
DoneEvent,
|
|
218
|
-
ErrorEvent,
|
|
219
|
-
AbortEvent,
|
|
220
|
-
StatusEvent
|
|
221
|
-
} from './events';
|
|
222
|
-
|
|
223
|
-
export type {
|
|
224
|
-
StepStartEvent,
|
|
225
|
-
StepEndEvent,
|
|
226
|
-
StepEvent
|
|
227
|
-
} from './events';
|
|
228
|
-
|
|
229
|
-
export type {
|
|
230
|
-
ChatEvent,
|
|
231
|
-
ChatEventType,
|
|
232
|
-
AssistantSegmentReason,
|
|
233
|
-
AssistantSegmentStartEvent,
|
|
234
|
-
AssistantSegmentEvent,
|
|
235
|
-
} from './events';
|
|
236
|
-
|
|
237
|
-
export {
|
|
238
|
-
createThinkingStart,
|
|
239
|
-
createThinkingDelta,
|
|
240
|
-
createThinkingEnd,
|
|
241
|
-
createToolCallStart,
|
|
242
|
-
createToolCallResult,
|
|
243
|
-
createToolCallOutput,
|
|
244
|
-
createToolCallRequest,
|
|
245
|
-
createTextDelta,
|
|
246
|
-
createDone,
|
|
247
|
-
createError,
|
|
248
|
-
createApiError,
|
|
249
|
-
createRateLimitError,
|
|
250
|
-
createToolError,
|
|
251
|
-
createTimeoutError,
|
|
252
|
-
createParseError,
|
|
253
|
-
createAbort,
|
|
254
|
-
createStepStart,
|
|
255
|
-
createStepEnd,
|
|
256
|
-
createAssistantSegmentStart,
|
|
257
|
-
isThinkingEvent,
|
|
258
|
-
isToolEvent,
|
|
259
|
-
isTextEvent,
|
|
260
|
-
isStatusEvent,
|
|
261
|
-
isErrorEvent,
|
|
262
|
-
isAbortEvent,
|
|
263
|
-
isStepEvent,
|
|
264
|
-
isAssistantSegmentEvent,
|
|
265
|
-
isRetryableError,
|
|
266
|
-
CHAT_EVENT_TYPES
|
|
267
|
-
} from './events';
|
|
268
|
-
|
|
269
|
-
// ==================== 统一工具管理 ====================
|
|
270
|
-
|
|
271
|
-
export { Type } from '@sinclair/typebox';
|
|
272
|
-
export type { Static, TSchema, TObject } from '@sinclair/typebox';
|
|
273
|
-
|
|
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';
|
|
290
|
-
|
|
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';
|
|
338
|
-
|
|
339
|
-
// ==================== LLM 配置(Model 中心)====================
|
|
340
|
-
|
|
341
|
-
export {
|
|
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';
|
|
353
|
-
|
|
354
|
-
// ==================== UI 组件 ====================
|
|
355
|
-
|
|
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';
|
|
422
|
-
|
|
423
|
-
// ==================== 日志 ====================
|
|
424
|
-
|
|
425
|
-
export { initLogger, getLogger, createModuleLogger } from './logger';
|
|
426
|
-
export type { LogLevel, LoggerConfig } from './logger';
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
}
|
package/src/llm-config.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM 配置(Model 中心)
|
|
3
|
-
*
|
|
4
|
-
* LLMConfig.models 是模型的唯一真相源:
|
|
5
|
-
* - key = 模型 ID(自定义字符串)
|
|
6
|
-
* - value = ModelConfig(路由 + 元数据)
|
|
7
|
-
* - 前端只展示这里配置的模型
|
|
8
|
-
* - 每个模型必须显式指定 family,不做任何隐式推导
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { ProtocolFactory, Protocol, ProtocolConfig } from './protocols';
|
|
12
|
-
import type { ModelFamilyConfig, ModelFamilyId } from './families';
|
|
13
|
-
|
|
14
|
-
/** 模型定价(每百万 tokens) */
|
|
15
|
-
export interface ModelPricing {
|
|
16
|
-
currency: 'CNY' | 'USD';
|
|
17
|
-
/** 输入价格(每百万 tokens) */
|
|
18
|
-
input: number;
|
|
19
|
-
/** 输出价格,单值或 [最低, 最高] 区间(如思考/非思考差价) */
|
|
20
|
-
output: number | [number, number];
|
|
21
|
-
/** 缓存命中价格(每百万 tokens,部分模型支持) */
|
|
22
|
-
cached?: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** 单条模型访问路径 */
|
|
26
|
-
export interface ModelRoute {
|
|
27
|
-
/** 基础 URL */
|
|
28
|
-
baseUrl: string;
|
|
29
|
-
/** 访问 key(代理 token 或厂商 key) */
|
|
30
|
-
accessKey: string;
|
|
31
|
-
/** 可选,透传给厂商的 key(BYOK,优先于 accessKey) */
|
|
32
|
-
vendorKey?: string;
|
|
33
|
-
/** 协议类型(内置或自定义 protocolId) */
|
|
34
|
-
protocol: string;
|
|
35
|
-
/** 该供应商 API 要求的 model 名 */
|
|
36
|
-
providerModelId: string;
|
|
37
|
-
/** 协议子路径,直连 '',代理 '/openai' 等 */
|
|
38
|
-
path?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** 模型配置(路由 + 元数据) */
|
|
42
|
-
export interface ModelConfig {
|
|
43
|
-
/** 路由链(数组顺序 = 降级优先级) */
|
|
44
|
-
routes: ModelRoute[];
|
|
45
|
-
/** 显示名称(不传则从预设库补全,再 fallback 到 modelId) */
|
|
46
|
-
displayName?: string;
|
|
47
|
-
/**
|
|
48
|
-
* 所属家族(决定 thinking/toolCall 行为)——必填,不做任何隐式推导
|
|
49
|
-
* - 字符串:引用内置 ModelFamilyId 或 LLMConfig.families 中的自定义 familyId
|
|
50
|
-
* - 对象:内联自定义家族配置
|
|
51
|
-
*/
|
|
52
|
-
family: ModelFamilyId | ModelFamilyConfig;
|
|
53
|
-
/** 是否在前端模型选择器中显示(默认 true) */
|
|
54
|
-
visible?: boolean;
|
|
55
|
-
/** 是否支持深度思考(必填,不做隐式推导) */
|
|
56
|
-
supportsThinking: boolean;
|
|
57
|
-
/** 是否支持图片理解(必填,不做隐式推导) */
|
|
58
|
-
supportsVision: boolean;
|
|
59
|
-
/** 上下文窗口 token 数(必填,压缩器依赖此值计算预算,前端展示自动推导为 "256K" 格式) */
|
|
60
|
-
contextWindowTokens: number;
|
|
61
|
-
/** 定价信息(结构化,展示时自动格式化) */
|
|
62
|
-
pricing?: ModelPricing;
|
|
63
|
-
/** 最大输出 token(必填,每个模型限制不同,不做隐式推导) */
|
|
64
|
-
maxOutputTokens: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 压缩模型配置(可选,不配则用默认值)
|
|
69
|
-
*
|
|
70
|
-
* 历史压缩直接复用当前对话模型,零配置。
|
|
71
|
-
* 仅单条超长消息(如用户粘贴巨量文本)需要长上下文模型。
|
|
72
|
-
*/
|
|
73
|
-
export interface CompressionConfig {
|
|
74
|
-
/** 超长内容压缩模型(默认 qwen-long) */
|
|
75
|
-
longModel?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** 完整 LLM 配置 */
|
|
79
|
-
export interface LLMConfig {
|
|
80
|
-
/**
|
|
81
|
-
* 模型配置(唯一真相源)
|
|
82
|
-
*
|
|
83
|
-
* key = 模型 ID,value = 路由 + 元数据。
|
|
84
|
-
* 前端模型选择器只展示这里 visible !== false 的模型。
|
|
85
|
-
*/
|
|
86
|
-
models: Record<string, ModelConfig>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 自定义协议工厂(可插拔)
|
|
90
|
-
*
|
|
91
|
-
* key = 自定义 protocolId,value = Protocol 工厂函数。
|
|
92
|
-
* ModelRoute.protocol 引用此处的 key 或内置 protocolId。
|
|
93
|
-
*/
|
|
94
|
-
protocols?: Record<string, ProtocolFactory>;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 自定义家族配置(可插拔)
|
|
98
|
-
*
|
|
99
|
-
* key = 自定义 familyId,value = ModelFamilyConfig。
|
|
100
|
-
* ModelConfig.family 引用此处的 key 或内置 familyId。
|
|
101
|
-
*/
|
|
102
|
-
families?: Record<string, ModelFamilyConfig>;
|
|
103
|
-
|
|
104
|
-
/** 压缩模型配置(可选) */
|
|
105
|
-
compression?: CompressionConfig;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** 解析 route 的完整 API URL */
|
|
109
|
-
export function resolveRouteUrl(route: ModelRoute): string {
|
|
110
|
-
const p = route.path ?? '';
|
|
111
|
-
return p ? `${route.baseUrl.replace(/\/$/, '')}${p}` : route.baseUrl;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 获取模型的 route 链(按优先级)
|
|
116
|
-
*/
|
|
117
|
-
export function getRouteChain(
|
|
118
|
-
config: LLMConfig,
|
|
119
|
-
modelId: string,
|
|
120
|
-
): ModelRoute[] {
|
|
121
|
-
return config.models?.[modelId]?.routes ?? [];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* 查找第一个支持指定 protocol 的 route
|
|
126
|
-
*/
|
|
127
|
-
export function findRouteByProtocol(
|
|
128
|
-
config: LLMConfig,
|
|
129
|
-
protocolId: string,
|
|
130
|
-
): ModelRoute | undefined {
|
|
131
|
-
for (const modelConfig of Object.values(config.models)) {
|
|
132
|
-
if (!modelConfig?.routes) continue;
|
|
133
|
-
const found = modelConfig.routes.find(r => r.protocol === protocolId);
|
|
134
|
-
if (found) return found;
|
|
135
|
-
}
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|