aegiscode 3.1.10 → 3.4.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/bin/aegis.js +165 -0
- package/package.json +18 -86
- package/LICENSE +0 -21
- package/README.md +0 -394
- package/dist/main.js +0 -2171
- package/gui/run-gui.cjs +0 -13
- package/src/agent/Agent.ts +0 -903
- package/src/agent/SimpleAgent.ts +0 -48
- package/src/agent/index.ts +0 -54
- package/src/agent/orchestrator/AppBuilder.ts +0 -443
- package/src/agent/orchestrator/CouncilAgent.ts +0 -310
- package/src/agent/orchestrator/DiscussionRoom.ts +0 -462
- package/src/agent/orchestrator/OrchestratorAgent.ts +0 -637
- package/src/agent/orchestrator/index.ts +0 -38
- package/src/agent/orchestrator/utils.ts +0 -397
- package/src/agent/pricing.ts +0 -115
- package/src/agent/router.ts +0 -74
- package/src/agent/routerStats.ts +0 -121
- package/src/agent/types.ts +0 -318
- package/src/auth/login.ts +0 -383
- package/src/cli/config.ts +0 -189
- package/src/cli/index.ts +0 -17
- package/src/cli/middleware.ts +0 -119
- package/src/cli/types.ts +0 -75
- package/src/config/ConfigManager.ts +0 -587
- package/src/config/index.ts +0 -7
- package/src/config/types.ts +0 -584
- package/src/context/CompactionService.ts +0 -300
- package/src/context/ContextManager.ts +0 -450
- package/src/context/FileAnalyzer.ts +0 -267
- package/src/context/TokenCounter.ts +0 -265
- package/src/context/index.ts +0 -27
- package/src/context/storage/CacheStore.ts +0 -176
- package/src/context/storage/JSONLStore.ts +0 -201
- package/src/context/storage/MemoryStore.ts +0 -205
- package/src/context/storage/PersistentStore.ts +0 -327
- package/src/context/storage/index.ts +0 -9
- package/src/context/storage/pathUtils.ts +0 -114
- package/src/context/test.ts +0 -309
- package/src/context/types.ts +0 -268
- package/src/hooks/HookExecutor.ts +0 -434
- package/src/hooks/HookManager.ts +0 -596
- package/src/hooks/HookService.ts +0 -269
- package/src/hooks/Matcher.ts +0 -157
- package/src/hooks/index.ts +0 -63
- package/src/hooks/types.ts +0 -424
- package/src/main.tsx +0 -596
- package/src/mcp/HealthMonitor.ts +0 -150
- package/src/mcp/McpClient.ts +0 -491
- package/src/mcp/McpRegistry.ts +0 -321
- package/src/mcp/createMcpTool.ts +0 -251
- package/src/mcp/index.ts +0 -15
- package/src/mcp/server.ts +0 -334
- package/src/mcp/test-server.ts +0 -88
- package/src/mcp/test.ts +0 -372
- package/src/mcp/types.ts +0 -247
- package/src/memory/AgentMemoryBus.ts +0 -432
- package/src/memory/CloudSync.ts +0 -99
- package/src/memory/DriveSync.ts +0 -106
- package/src/memory/SharedMemory.ts +0 -951
- package/src/memory/index.ts +0 -14
- package/src/memory/machineFingerprint.ts +0 -40
- package/src/orchestrator/SubAgentMetadata.ts +0 -136
- package/src/prompts/builder.ts +0 -213
- package/src/prompts/default.ts +0 -144
- package/src/prompts/index.ts +0 -16
- package/src/prompts/plan.ts +0 -64
- package/src/prompts/test.ts +0 -78
- package/src/services/AnthropicChatService.ts +0 -341
- package/src/services/ChatService.ts +0 -347
- package/src/services/ClaudeCliChatService.ts +0 -256
- package/src/services/CloudSync.ts +0 -168
- package/src/services/CostLedger.ts +0 -211
- package/src/services/Heartbeat.ts +0 -135
- package/src/services/LearningCollector.ts +0 -291
- package/src/services/OllamaInstaller.ts +0 -342
- package/src/services/VersionChecker.ts +0 -445
- package/src/services/index.ts +0 -57
- package/src/services/streaming/OpenAIEventAdapter.ts +0 -126
- package/src/services/streaming/RenderingProfile.ts +0 -90
- package/src/services/streaming/StreamEventParser.ts +0 -181
- package/src/services/streaming/ThrottledRenderer.ts +0 -139
- package/src/services/streaming/TranscriptBuffer.ts +0 -574
- package/src/services/streaming/eventStatusMap.ts +0 -52
- package/src/services/streaming/index.ts +0 -46
- package/src/services/streaming/renderFormatting.ts +0 -79
- package/src/services/streaming/types.ts +0 -234
- package/src/skills/SkillLoader.ts +0 -126
- package/src/skills/SkillRegistry.ts +0 -366
- package/src/skills/index.ts +0 -48
- package/src/skills/types.ts +0 -146
- package/src/slash-commands/billing.ts +0 -70
- package/src/slash-commands/build.ts +0 -413
- package/src/slash-commands/builtinCommands.ts +0 -2733
- package/src/slash-commands/clone.ts +0 -242
- package/src/slash-commands/council.ts +0 -125
- package/src/slash-commands/custom/CustomCommandExecutor.ts +0 -143
- package/src/slash-commands/custom/CustomCommandLoader.ts +0 -251
- package/src/slash-commands/custom/CustomCommandRegistry.ts +0 -144
- package/src/slash-commands/custom/index.ts +0 -7
- package/src/slash-commands/debate.ts +0 -254
- package/src/slash-commands/gmail.ts +0 -105
- package/src/slash-commands/index.ts +0 -388
- package/src/slash-commands/mcpCommand.ts +0 -205
- package/src/slash-commands/types.ts +0 -201
- package/src/store/index.ts +0 -76
- package/src/store/selectors.ts +0 -246
- package/src/store/slices/appSlice.ts +0 -205
- package/src/store/slices/commandSlice.ts +0 -115
- package/src/store/slices/configSlice.ts +0 -46
- package/src/store/slices/focusSlice.ts +0 -64
- package/src/store/slices/index.ts +0 -9
- package/src/store/slices/sessionSlice.ts +0 -424
- package/src/store/streaming-buffer.ts +0 -425
- package/src/store/test.ts +0 -296
- package/src/store/types.ts +0 -274
- package/src/store/vanilla.ts +0 -186
- package/src/tools/builtin/bash.ts +0 -236
- package/src/tools/builtin/council.ts +0 -105
- package/src/tools/builtin/edit.ts +0 -213
- package/src/tools/builtin/glob.ts +0 -136
- package/src/tools/builtin/grep.ts +0 -263
- package/src/tools/builtin/index.ts +0 -61
- package/src/tools/builtin/memory.ts +0 -66
- package/src/tools/builtin/read.ts +0 -168
- package/src/tools/builtin/skill.ts +0 -97
- package/src/tools/builtin/snapshot.ts +0 -40
- package/src/tools/builtin/task.ts +0 -106
- package/src/tools/builtin/write.ts +0 -134
- package/src/tools/createTool.ts +0 -221
- package/src/tools/execution/ExecutionPipeline.ts +0 -263
- package/src/tools/execution/index.ts +0 -40
- package/src/tools/execution/stages/CacheStage.ts +0 -131
- package/src/tools/execution/stages/ConfirmationStage.ts +0 -203
- package/src/tools/execution/stages/DiscoveryStage.ts +0 -46
- package/src/tools/execution/stages/ExecutionStage.ts +0 -48
- package/src/tools/execution/stages/FormattingStage.ts +0 -44
- package/src/tools/execution/stages/HookStage.ts +0 -72
- package/src/tools/execution/stages/PermissionStage.ts +0 -287
- package/src/tools/execution/stages/PostHookStage.ts +0 -71
- package/src/tools/execution/stages/index.ts +0 -12
- package/src/tools/execution/test.ts +0 -266
- package/src/tools/execution/types.ts +0 -273
- package/src/tools/index.ts +0 -81
- package/src/tools/registry.ts +0 -304
- package/src/tools/schemas.ts +0 -109
- package/src/tools/test.ts +0 -220
- package/src/tools/types.ts +0 -175
- package/src/tools/validation/PermissionChecker.ts +0 -242
- package/src/tools/validation/SensitiveFileDetector.ts +0 -210
- package/src/tools/validation/index.ts +0 -11
- package/src/ui/App.tsx +0 -166
- package/src/ui/components/AegisInterface.tsx +0 -484
- package/src/ui/components/common/ChatSearch.tsx +0 -150
- package/src/ui/components/common/ErrorBoundary.tsx +0 -82
- package/src/ui/components/common/ExitMessage.tsx +0 -120
- package/src/ui/components/common/LoadingIndicator.tsx +0 -49
- package/src/ui/components/common/index.ts +0 -6
- package/src/ui/components/dialog/ConfirmationPrompt.tsx +0 -208
- package/src/ui/components/dialog/InteractiveSelector.tsx +0 -149
- package/src/ui/components/dialog/SetupWizard.tsx +0 -297
- package/src/ui/components/dialog/UpdatePrompt.tsx +0 -155
- package/src/ui/components/dialog/index.ts +0 -8
- package/src/ui/components/index.ts +0 -28
- package/src/ui/components/input/CommandSuggestions.tsx +0 -139
- package/src/ui/components/input/CustomTextInput.tsx +0 -220
- package/src/ui/components/input/InputArea.tsx +0 -361
- package/src/ui/components/input/PromptSuggestions.tsx +0 -66
- package/src/ui/components/input/index.ts +0 -6
- package/src/ui/components/layout/ChatStatusBar.tsx +0 -90
- package/src/ui/components/layout/ContextBar.tsx +0 -79
- package/src/ui/components/layout/MessageArea.tsx +0 -96
- package/src/ui/components/layout/MessageList.tsx +0 -647
- package/src/ui/components/layout/MessageSeparator.tsx +0 -26
- package/src/ui/components/layout/WelcomeMessage.tsx +0 -93
- package/src/ui/components/layout/index.ts +0 -7
- package/src/ui/components/markdown/CodeHighlighter.tsx +0 -292
- package/src/ui/components/markdown/MessageRenderer.tsx +0 -1211
- package/src/ui/components/markdown/index.ts +0 -8
- package/src/ui/components/markdown/parser.ts +0 -336
- package/src/ui/components/markdown/types.ts +0 -66
- package/src/ui/focus/FocusManager.ts +0 -137
- package/src/ui/focus/index.ts +0 -13
- package/src/ui/focus/types.ts +0 -54
- package/src/ui/focus/useFocus.ts +0 -75
- package/src/ui/hooks/index.ts +0 -11
- package/src/ui/hooks/useAgent.ts +0 -284
- package/src/ui/hooks/useCommandHistory.ts +0 -87
- package/src/ui/hooks/useCommandProcessor.ts +0 -443
- package/src/ui/hooks/useConfirmation.ts +0 -99
- package/src/ui/hooks/useCtrlCHandler.ts +0 -100
- package/src/ui/hooks/useInputBuffer.ts +0 -122
- package/src/ui/hooks/useTerminalSize.ts +0 -68
- package/src/ui/hooks/useTerminalWidth.ts +0 -5
- package/src/ui/hooks/useWindowedList.ts +0 -118
- package/src/ui/render-debugger.ts +0 -621
- package/src/ui/test.ts +0 -189
- package/src/ui/themes/ThemeManager.ts +0 -332
- package/src/ui/themes/aegisTheme.ts +0 -87
- package/src/ui/themes/darkTheme.ts +0 -87
- package/src/ui/themes/defaultTheme.ts +0 -85
- package/src/ui/themes/index.ts +0 -10
- package/src/ui/themes/lightTheme.ts +0 -89
- package/src/ui/themes/popularThemes.ts +0 -187
- package/src/ui/themes/types.ts +0 -130
- package/src/utils/clipboard.ts +0 -48
- package/src/utils/debug.ts +0 -43
- package/src/utils/environment.ts +0 -68
- package/src/utils/index.ts +0 -10
package/src/config/types.ts
DELETED
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* - config.json: 基础配置(API、模型、UI)
|
|
6
|
-
* - settings.json: 行为配置(权限、Hooks、环境变量)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
|
|
11
|
-
// ========== 枚举定
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* LLM API 提供商类型
|
|
15
|
-
*/
|
|
16
|
-
export type ProviderType = 'openai-compatible' | 'anthropic';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export enum PermissionMode {
|
|
22
|
-
DEFAULT = 'default', // 只读自动,写入需确
|
|
23
|
-
AUTO_EDIT = 'autoEdit', // 只读+写入自动,执行需确
|
|
24
|
-
YOLO = 'yolo', // 完全自动(危
|
|
25
|
-
PLAN = 'plan', // 只读自动,其他拦
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// ========== Zod Schemas ==========
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
export const ModelConfigSchema = z.object({
|
|
36
|
-
id: z.string().optional(), // nanoid 自动生
|
|
37
|
-
name: z.string().optional(), // 显示名
|
|
38
|
-
provider: z.enum(['openai-compatible', 'anthropic']).optional(),
|
|
39
|
-
apiKey: z.string().optional(),
|
|
40
|
-
baseURL: z.string().optional(),
|
|
41
|
-
model: z.string().optional(),
|
|
42
|
-
temperature: z.number().min(0).max(2).optional(),
|
|
43
|
-
maxContextTokens: z.number().optional(),
|
|
44
|
-
topP: z.number().optional(),
|
|
45
|
-
topK: z.number().optional(),
|
|
46
|
-
|
|
47
|
-
// 模型级工具过滤:只在当前模型生效
|
|
48
|
-
allowedTools: z.array(z.string()).optional(),
|
|
49
|
-
disallowedTools: z.array(z.string()).optional(),
|
|
50
|
-
|
|
51
|
-
// 是否需要确认提示(默认 true,保持原有行为)
|
|
52
|
-
requireConfirmation: z.boolean().optional(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
*/
|
|
58
|
-
export const PRESET_THEME_IDS = ['default', 'light', 'dark', 'ocean', 'forest', 'sunset'] as const;
|
|
59
|
-
export type PresetThemeId = typeof PRESET_THEME_IDS[number];
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* UI 配置 Schema
|
|
63
|
-
*/
|
|
64
|
-
export const UIConfigSchema = z.object({
|
|
65
|
-
// 支持所有预设主题,也支持自定义主题名
|
|
66
|
-
theme: z.string().optional(),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Auto-router Schema — per-tier model id overrides for simple/medium/complex tasks
|
|
71
|
-
*/
|
|
72
|
-
export const AutoRouterConfigSchema = z.object({
|
|
73
|
-
enabled: z.boolean().optional(),
|
|
74
|
-
tiers: z.object({
|
|
75
|
-
simple: z.string().optional(),
|
|
76
|
-
medium: z.string().optional(),
|
|
77
|
-
complex: z.string().optional(),
|
|
78
|
-
}).optional(),
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Extended-thinking Schema — budget tier sent as `thinking.budget_tokens` to
|
|
83
|
-
* Anthropic models that support it. 'off' omits the thinking param entirely.
|
|
84
|
-
*/
|
|
85
|
-
export const ThinkingConfigSchema = z.object({
|
|
86
|
-
budget: z.enum(['off', 'low', 'medium', 'high', 'max']).optional(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
*/
|
|
92
|
-
export const PermissionConfigSchema = z.object({
|
|
93
|
-
allow: z.array(z.string()).default([]),
|
|
94
|
-
deny: z.array(z.string()).default([]),
|
|
95
|
-
ask: z.array(z.string()).default([]),
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* MCP 服务器配置 Schema
|
|
100
|
-
*/
|
|
101
|
-
export const McpServerConfigSchema = z.object({
|
|
102
|
-
type: z.enum(['stdio', 'sse', 'http']),
|
|
103
|
-
|
|
104
|
-
// stdio 配
|
|
105
|
-
command: z.string().optional(),
|
|
106
|
-
args: z.array(z.string()).optional(),
|
|
107
|
-
env: z.record(z.string()).optional(),
|
|
108
|
-
cwd: z.string().optional(),
|
|
109
|
-
|
|
110
|
-
// sse/http 配置
|
|
111
|
-
url: z.string().optional(),
|
|
112
|
-
headers: z.record(z.string()).optional(),
|
|
113
|
-
|
|
114
|
-
// 其他配
|
|
115
|
-
enabled: z.boolean().optional(),
|
|
116
|
-
timeout: z.number().optional(),
|
|
117
|
-
description: z.string().optional(),
|
|
118
|
-
|
|
119
|
-
// 健康检查配
|
|
120
|
-
healthCheck: z.object({
|
|
121
|
-
enabled: z.boolean(),
|
|
122
|
-
intervalMs: z.number(),
|
|
123
|
-
timeoutMs: z.number(),
|
|
124
|
-
maxFailures: z.number(),
|
|
125
|
-
}).optional(),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Hook 配置 Schema
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
export const HookConfigSchema = z.object({
|
|
135
|
-
enabled: z.boolean().optional(),
|
|
136
|
-
defaultTimeout: z.number().optional(),
|
|
137
|
-
timeoutBehavior: z.enum(['ignore', 'deny', 'ask']).optional(),
|
|
138
|
-
failureBehavior: z.enum(['ignore', 'deny', 'ask']).optional(),
|
|
139
|
-
maxConcurrentHooks: z.number().optional(),
|
|
140
|
-
// 各事件类型的 Hook 列表(使用 passthrough 接受完整结
|
|
141
|
-
PreToolUse: z.array(z.any()).optional(),
|
|
142
|
-
PostToolUse: z.array(z.any()).optional(),
|
|
143
|
-
PostToolUseFailure: z.array(z.any()).optional(),
|
|
144
|
-
PermissionRequest: z.array(z.any()).optional(),
|
|
145
|
-
UserPromptSubmit: z.array(z.any()).optional(),
|
|
146
|
-
SessionStart: z.array(z.any()).optional(),
|
|
147
|
-
SessionEnd: z.array(z.any()).optional(),
|
|
148
|
-
Stop: z.array(z.any()).optional(),
|
|
149
|
-
SubagentStop: z.array(z.any()).optional(),
|
|
150
|
-
Notification: z.array(z.any()).optional(),
|
|
151
|
-
Compaction: z.array(z.any()).optional(),
|
|
152
|
-
}).optional();
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
*
|
|
156
|
-
*/
|
|
157
|
-
export const ConfigSchema = z.object({
|
|
158
|
-
//
|
|
159
|
-
default: ModelConfigSchema.optional(),
|
|
160
|
-
|
|
161
|
-
//
|
|
162
|
-
models: z.array(ModelConfigSchema).optional(),
|
|
163
|
-
currentModelId: z.string().optional(),
|
|
164
|
-
|
|
165
|
-
// UI
|
|
166
|
-
ui: UIConfigSchema.optional(),
|
|
167
|
-
theme: z.string().optional(),
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
permissions: PermissionConfigSchema.optional(),
|
|
171
|
-
|
|
172
|
-
//
|
|
173
|
-
defaultPermissionMode: z.enum(['default', 'autoEdit', 'yolo', 'plan']).optional(),
|
|
174
|
-
|
|
175
|
-
//
|
|
176
|
-
toolWhitelist: z.array(z.string()).optional(),
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
toolBlacklist: z.array(z.string()).optional(),
|
|
180
|
-
|
|
181
|
-
// MCP
|
|
182
|
-
mcpServers: z.record(McpServerConfigSchema).optional(),
|
|
183
|
-
|
|
184
|
-
// MCP
|
|
185
|
-
mcpEnabled: z.boolean().optional(),
|
|
186
|
-
|
|
187
|
-
// Hooks
|
|
188
|
-
hooks: HookConfigSchema,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*/
|
|
195
|
-
export const ClawdConfigSchema = z.object({
|
|
196
|
-
// ===== 基础配
|
|
197
|
-
|
|
198
|
-
// 默认模型配置(向后兼
|
|
199
|
-
default: ModelConfigSchema.optional(),
|
|
200
|
-
|
|
201
|
-
// 多模型配
|
|
202
|
-
currentModelId: z.string().optional(),
|
|
203
|
-
models: z.array(ModelConfigSchema).optional(),
|
|
204
|
-
|
|
205
|
-
// 全局参
|
|
206
|
-
temperature: z.number().min(0).max(2).optional(),
|
|
207
|
-
maxContextTokens: z.number().optional(),
|
|
208
|
-
maxOutputTokens: z.number().optional(),
|
|
209
|
-
stream: z.boolean().optional(),
|
|
210
|
-
timeout: z.number().optional(),
|
|
211
|
-
|
|
212
|
-
// UI
|
|
213
|
-
ui: UIConfigSchema.optional(),
|
|
214
|
-
theme: z.string().optional(),
|
|
215
|
-
language: z.string().optional(),
|
|
216
|
-
|
|
217
|
-
// 调
|
|
218
|
-
debug: z.union([z.string(), z.boolean()]).optional(),
|
|
219
|
-
|
|
220
|
-
// MCP
|
|
221
|
-
mcpEnabled: z.boolean().optional(),
|
|
222
|
-
mcpServers: z.record(McpServerConfigSchema).optional(),
|
|
223
|
-
|
|
224
|
-
// 自动路由:按任务复杂度自动选择模型
|
|
225
|
-
autoRouter: AutoRouterConfigSchema.optional(),
|
|
226
|
-
|
|
227
|
-
// 扩展思考:发送给支持的模型的 thinking budget
|
|
228
|
-
thinking: ThinkingConfigSchema.optional(),
|
|
229
|
-
|
|
230
|
-
// ===== 行为配
|
|
231
|
-
|
|
232
|
-
// 权
|
|
233
|
-
permissions: PermissionConfigSchema.optional(),
|
|
234
|
-
defaultPermissionMode: z.enum(['default', 'autoEdit', 'yolo', 'plan']).optional(),
|
|
235
|
-
|
|
236
|
-
// 工具过
|
|
237
|
-
toolWhitelist: z.array(z.string()).optional(),
|
|
238
|
-
toolBlacklist: z.array(z.string()).optional(),
|
|
239
|
-
|
|
240
|
-
// Hooks
|
|
241
|
-
hooks: HookConfigSchema,
|
|
242
|
-
|
|
243
|
-
// 环境变
|
|
244
|
-
env: z.record(z.string()).optional(),
|
|
245
|
-
|
|
246
|
-
// 其
|
|
247
|
-
maxTurns: z.number().optional(),
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*/
|
|
254
|
-
export const RuntimeConfigSchema = ClawdConfigSchema.extend({
|
|
255
|
-
// 系统提
|
|
256
|
-
systemPrompt: z.string().optional(),
|
|
257
|
-
appendSystemPrompt: z.string().optional(),
|
|
258
|
-
|
|
259
|
-
// 会话管
|
|
260
|
-
initialMessage: z.string().optional(),
|
|
261
|
-
resumeSessionId: z.string().optional(),
|
|
262
|
-
forkSession: z.boolean().optional(),
|
|
263
|
-
|
|
264
|
-
// 工具过滤(CLI 临
|
|
265
|
-
allowedTools: z.array(z.string()).optional(),
|
|
266
|
-
disallowedTools: z.array(z.string()).optional(),
|
|
267
|
-
|
|
268
|
-
// MCP(CLI 临
|
|
269
|
-
mcpConfigPaths: z.array(z.string()).optional(),
|
|
270
|
-
strictMcpConfig: z.boolean().optional(),
|
|
271
|
-
|
|
272
|
-
// 其
|
|
273
|
-
fallbackModel: z.string().optional(),
|
|
274
|
-
addDirs: z.array(z.string()).optional(),
|
|
275
|
-
outputFormat: z.enum(['text', 'json', 'stream-json']).optional(),
|
|
276
|
-
print: z.boolean().optional(),
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// ========== 类型导
|
|
280
|
-
|
|
281
|
-
export type ModelConfig = z.infer<typeof ModelConfigSchema>;
|
|
282
|
-
export type UIConfig = z.infer<typeof UIConfigSchema>;
|
|
283
|
-
export type AutoRouterConfig = z.infer<typeof AutoRouterConfigSchema>;
|
|
284
|
-
export type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
|
|
285
|
-
export type PermissionConfig = z.infer<typeof PermissionConfigSchema>;
|
|
286
|
-
export type McpServerConfig = z.infer<typeof McpServerConfigSchema>;
|
|
287
|
-
export type HookConfig = z.infer<typeof HookConfigSchema>;
|
|
288
|
-
export type ClawdConfig = z.infer<typeof ClawdConfigSchema>;
|
|
289
|
-
export type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
|
|
290
|
-
|
|
291
|
-
// 向后兼
|
|
292
|
-
export type Config = ClawdConfig;
|
|
293
|
-
|
|
294
|
-
// ========== 字段路由
|
|
295
|
-
|
|
296
|
-
export type MergeStrategy = 'replace' | 'append-dedupe' | 'deep-merge';
|
|
297
|
-
export type ConfigTarget = 'config' | 'settings';
|
|
298
|
-
export type ConfigScope = 'local' | 'project' | 'global';
|
|
299
|
-
|
|
300
|
-
export interface FieldRouting {
|
|
301
|
-
target: ConfigTarget;
|
|
302
|
-
defaultScope: ConfigScope;
|
|
303
|
-
mergeStrategy: MergeStrategy;
|
|
304
|
-
persistable: boolean;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
*
|
|
309
|
-
*/
|
|
310
|
-
export const FIELD_ROUTING_TABLE: Record<string, FieldRouting> = {
|
|
311
|
-
// config.json 字
|
|
312
|
-
models: { target: 'config', defaultScope: 'global', mergeStrategy: 'replace', persistable: true },
|
|
313
|
-
currentModelId: { target: 'config', defaultScope: 'global', mergeStrategy: 'replace', persistable: true },
|
|
314
|
-
theme: { target: 'config', defaultScope: 'global', mergeStrategy: 'replace', persistable: true },
|
|
315
|
-
language: { target: 'config', defaultScope: 'global', mergeStrategy: 'replace', persistable: true },
|
|
316
|
-
mcpServers: { target: 'config', defaultScope: 'global', mergeStrategy: 'deep-merge', persistable: true },
|
|
317
|
-
mcpEnabled: { target: 'config', defaultScope: 'global', mergeStrategy: 'replace', persistable: true },
|
|
318
|
-
autoRouter: { target: 'config', defaultScope: 'global', mergeStrategy: 'deep-merge', persistable: true },
|
|
319
|
-
thinking: { target: 'config', defaultScope: 'global', mergeStrategy: 'deep-merge', persistable: true },
|
|
320
|
-
|
|
321
|
-
// settings.json 字
|
|
322
|
-
permissions: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: true },
|
|
323
|
-
defaultPermissionMode: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: true },
|
|
324
|
-
hooks: { target: 'settings', defaultScope: 'local', mergeStrategy: 'deep-merge', persistable: true },
|
|
325
|
-
env: { target: 'settings', defaultScope: 'local', mergeStrategy: 'deep-merge', persistable: true },
|
|
326
|
-
|
|
327
|
-
// 非持久化字段(CLI 临时参
|
|
328
|
-
systemPrompt: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: false },
|
|
329
|
-
appendSystemPrompt: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: false },
|
|
330
|
-
initialMessage: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: false },
|
|
331
|
-
resumeSessionId: { target: 'settings', defaultScope: 'local', mergeStrategy: 'replace', persistable: false },
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
// ========== 默认配
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
*
|
|
338
|
-
*/
|
|
339
|
-
export const DEFAULT_PERMISSIONS: PermissionConfig = {
|
|
340
|
-
allow: [
|
|
341
|
-
// 安全的系统信息命
|
|
342
|
-
'Bash(pwd)',
|
|
343
|
-
'Bash(whoami)',
|
|
344
|
-
'Bash(hostname)',
|
|
345
|
-
'Bash(uname *)',
|
|
346
|
-
'Bash(date)',
|
|
347
|
-
'Bash(echo *)',
|
|
348
|
-
// 目录列
|
|
349
|
-
'Bash(ls *)',
|
|
350
|
-
'Bash(tree *)',
|
|
351
|
-
// Git 只读命
|
|
352
|
-
'Bash(git status)',
|
|
353
|
-
'Bash(git log *)',
|
|
354
|
-
'Bash(git diff *)',
|
|
355
|
-
'Bash(git branch *)',
|
|
356
|
-
// 包管理器只读命
|
|
357
|
-
'Bash(npm list *)',
|
|
358
|
-
'Bash(npm view *)',
|
|
359
|
-
'Bash(bun *)',
|
|
360
|
-
],
|
|
361
|
-
ask: [
|
|
362
|
-
// 高风险命令(需要确
|
|
363
|
-
'Bash(curl *)',
|
|
364
|
-
'Bash(wget *)',
|
|
365
|
-
'Bash(rm -rf *)',
|
|
366
|
-
'Bash(rm -r *)',
|
|
367
|
-
],
|
|
368
|
-
deny: [
|
|
369
|
-
// 敏感文
|
|
370
|
-
'Read(./.env)',
|
|
371
|
-
'Read(./.env.*)',
|
|
372
|
-
// 危险命
|
|
373
|
-
'Bash(rm -rf /)',
|
|
374
|
-
'Bash(sudo *)',
|
|
375
|
-
'Bash(chmod 777 *)',
|
|
376
|
-
// Shell 嵌
|
|
377
|
-
'Bash(bash *)',
|
|
378
|
-
'Bash(sh *)',
|
|
379
|
-
'Bash(eval *)',
|
|
380
|
-
],
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
*
|
|
385
|
-
*/
|
|
386
|
-
export const DEFAULT_MODELS = [
|
|
387
|
-
{
|
|
388
|
-
id: 'claude-fable-5',
|
|
389
|
-
name: 'Claude Fable 5',
|
|
390
|
-
provider: 'anthropic' as const,
|
|
391
|
-
model: 'claude-fable-5',
|
|
392
|
-
baseURL: 'https://api.anthropic.com/v1',
|
|
393
|
-
apiKey: '',
|
|
394
|
-
allowedTools: ['Read', 'Grep', 'Glob', 'Edit', 'Write', 'Bash'],
|
|
395
|
-
requireConfirmation: false,
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
id: 'claude-sonnet-4',
|
|
399
|
-
name: 'Claude Sonnet 4.6',
|
|
400
|
-
provider: 'anthropic' as const,
|
|
401
|
-
model: 'claude-sonnet-4-6',
|
|
402
|
-
baseURL: 'https://api.anthropic.com/v1',
|
|
403
|
-
apiKey: '',
|
|
404
|
-
allowedTools: ['Read', 'Grep', 'Glob', 'Edit', 'Write', 'Bash'],
|
|
405
|
-
requireConfirmation: false,
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
id: 'claude-opus-4',
|
|
409
|
-
name: 'Claude Opus 4.8',
|
|
410
|
-
provider: 'anthropic' as const,
|
|
411
|
-
model: 'claude-opus-4-8',
|
|
412
|
-
baseURL: 'https://api.anthropic.com/v1',
|
|
413
|
-
apiKey: '',
|
|
414
|
-
allowedTools: ['Read', 'Grep', 'Glob', 'Edit', 'Write', 'Bash'],
|
|
415
|
-
requireConfirmation: false,
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
id: 'claude-haiku-4',
|
|
419
|
-
name: 'Claude Haiku 4.5',
|
|
420
|
-
provider: 'anthropic' as const,
|
|
421
|
-
model: 'claude-haiku-4-5-20251001',
|
|
422
|
-
baseURL: 'https://api.anthropic.com/v1',
|
|
423
|
-
apiKey: '',
|
|
424
|
-
allowedTools: ['Read', 'Grep', 'Glob', 'Edit', 'Write', 'Bash'],
|
|
425
|
-
requireConfirmation: false,
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
id: 'deepseek-chat',
|
|
429
|
-
name: 'DeepSeek Chat',
|
|
430
|
-
provider: 'openai-compatible' as const,
|
|
431
|
-
model: 'deepseek-chat',
|
|
432
|
-
baseURL: 'https://api.deepseek.com/v1',
|
|
433
|
-
apiKey: '',
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
id: 'deepseek-reasoner',
|
|
437
|
-
name: 'DeepSeek Reasoner',
|
|
438
|
-
provider: 'openai-compatible' as const,
|
|
439
|
-
model: 'deepseek-reasoner',
|
|
440
|
-
baseURL: 'https://api.deepseek.com/v1',
|
|
441
|
-
apiKey: '',
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
id: 'groq-llama',
|
|
445
|
-
name: 'Groq Llama 3.3 70B',
|
|
446
|
-
provider: 'openai-compatible' as const,
|
|
447
|
-
model: 'llama-3.3-70b-versatile',
|
|
448
|
-
baseURL: 'https://api.groq.com/openai/v1',
|
|
449
|
-
apiKey: '',
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
id: 'groq-deepseek',
|
|
453
|
-
name: 'Groq QwQ-32B',
|
|
454
|
-
provider: 'openai-compatible' as const,
|
|
455
|
-
model: 'qwen-qwq-32b',
|
|
456
|
-
baseURL: 'https://api.groq.com/openai/v1',
|
|
457
|
-
apiKey: '',
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
id: 'openai-gpt-5.5',
|
|
461
|
-
name: 'GPT-5.5',
|
|
462
|
-
provider: 'openai-compatible' as const,
|
|
463
|
-
model: 'gpt-5.5',
|
|
464
|
-
baseURL: 'https://api.openai.com/v1',
|
|
465
|
-
apiKey: '',
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
id: 'chatgpt',
|
|
469
|
-
name: 'ChatGPT',
|
|
470
|
-
provider: 'openai-compatible' as const,
|
|
471
|
-
model: 'chatgpt-4o-latest',
|
|
472
|
-
baseURL: 'https://api.openai.com/v1',
|
|
473
|
-
apiKey: '',
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
id: 'openai-gpt-4o',
|
|
477
|
-
name: 'GPT-4o',
|
|
478
|
-
provider: 'openai-compatible' as const,
|
|
479
|
-
model: 'gpt-4o',
|
|
480
|
-
baseURL: 'https://api.openai.com/v1',
|
|
481
|
-
apiKey: '',
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
id: 'openai-o3',
|
|
485
|
-
name: 'OpenAI o3',
|
|
486
|
-
provider: 'openai-compatible' as const,
|
|
487
|
-
model: 'o3',
|
|
488
|
-
baseURL: 'https://api.openai.com/v1',
|
|
489
|
-
apiKey: '',
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
id: 'gemini-2.5-pro',
|
|
493
|
-
name: 'Gemini 2.5 Pro',
|
|
494
|
-
provider: 'openai-compatible' as const,
|
|
495
|
-
model: 'gemini-2.5-pro',
|
|
496
|
-
baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai/',
|
|
497
|
-
apiKey: '',
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
id: 'gemini-2.5-flash',
|
|
501
|
-
name: 'Gemini 2.5 Flash',
|
|
502
|
-
provider: 'openai-compatible' as const,
|
|
503
|
-
model: 'gemini-2.5-flash',
|
|
504
|
-
baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai/',
|
|
505
|
-
apiKey: '',
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
id: 'ollama-local',
|
|
509
|
-
name: 'Ollama (local)',
|
|
510
|
-
provider: 'openai-compatible' as const,
|
|
511
|
-
model: 'llama3.2',
|
|
512
|
-
baseURL: 'http://localhost:11434/v1',
|
|
513
|
-
apiKey: 'ollama',
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
id: 'sakana-fugu',
|
|
517
|
-
name: 'Sakana Fugu',
|
|
518
|
-
provider: 'openai-compatible' as const,
|
|
519
|
-
model: 'fugu',
|
|
520
|
-
baseURL: 'https://api.sakana.ai/v1',
|
|
521
|
-
apiKey: '',
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
id: 'sakana-fugu-ultra',
|
|
525
|
-
name: 'Sakana Fugu Ultra',
|
|
526
|
-
provider: 'openai-compatible' as const,
|
|
527
|
-
model: 'fugu-ultra',
|
|
528
|
-
baseURL: 'https://api.sakana.ai/v1',
|
|
529
|
-
apiKey: '',
|
|
530
|
-
},
|
|
531
|
-
// Nexus - AEGIS's pooled aegis-key. Auto-routes server-side (smart_router) to the
|
|
532
|
-
// cheapest backend that fits the tier; OpenAI-wire-compatible, billed via token bank.
|
|
533
|
-
{
|
|
534
|
-
id: 'nexus-fast',
|
|
535
|
-
name: 'Nexus (Fast)',
|
|
536
|
-
provider: 'openai-compatible' as const,
|
|
537
|
-
model: 'nexus-fast',
|
|
538
|
-
baseURL: 'https://aegisintel.up.railway.app/api/v1',
|
|
539
|
-
apiKey: '',
|
|
540
|
-
},
|
|
541
|
-
{
|
|
542
|
-
id: 'nexus-smart',
|
|
543
|
-
name: 'Nexus (Smart)',
|
|
544
|
-
provider: 'openai-compatible' as const,
|
|
545
|
-
model: 'nexus-smart',
|
|
546
|
-
baseURL: 'https://aegisintel.up.railway.app/api/v1',
|
|
547
|
-
apiKey: '',
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
id: 'nexus-neo',
|
|
551
|
-
name: 'Nexus (NEO)',
|
|
552
|
-
provider: 'openai-compatible' as const,
|
|
553
|
-
model: 'nexus-neo',
|
|
554
|
-
baseURL: 'https://aegisintel.up.railway.app/api/v1',
|
|
555
|
-
apiKey: '',
|
|
556
|
-
},
|
|
557
|
-
];
|
|
558
|
-
|
|
559
|
-
export const DEFAULT_CONFIG: ClawdConfig = {
|
|
560
|
-
default: {
|
|
561
|
-
model: 'claude-sonnet-4-6',
|
|
562
|
-
baseURL: 'https://api.anthropic.com/v1',
|
|
563
|
-
apiKey: '',
|
|
564
|
-
},
|
|
565
|
-
models: DEFAULT_MODELS,
|
|
566
|
-
currentModelId: 'claude-sonnet-4',
|
|
567
|
-
temperature: 0.7,
|
|
568
|
-
maxContextTokens: 200000,
|
|
569
|
-
maxOutputTokens: 16384,
|
|
570
|
-
stream: true,
|
|
571
|
-
timeout: 900000, // 15 minutes
|
|
572
|
-
ui: {
|
|
573
|
-
theme: 'dark',
|
|
574
|
-
},
|
|
575
|
-
theme: 'dark',
|
|
576
|
-
language: 'en',
|
|
577
|
-
mcpEnabled: true,
|
|
578
|
-
autoRouter: { enabled: false, tiers: {} },
|
|
579
|
-
thinking: { budget: 'off' },
|
|
580
|
-
mcpServers: {},
|
|
581
|
-
permissions: DEFAULT_PERMISSIONS,
|
|
582
|
-
defaultPermissionMode: 'default',
|
|
583
|
-
maxTurns: -1,
|
|
584
|
-
};
|