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.
Files changed (209) hide show
  1. package/bin/aegis.js +165 -0
  2. package/package.json +18 -86
  3. package/LICENSE +0 -21
  4. package/README.md +0 -394
  5. package/dist/main.js +0 -2171
  6. package/gui/run-gui.cjs +0 -13
  7. package/src/agent/Agent.ts +0 -903
  8. package/src/agent/SimpleAgent.ts +0 -48
  9. package/src/agent/index.ts +0 -54
  10. package/src/agent/orchestrator/AppBuilder.ts +0 -443
  11. package/src/agent/orchestrator/CouncilAgent.ts +0 -310
  12. package/src/agent/orchestrator/DiscussionRoom.ts +0 -462
  13. package/src/agent/orchestrator/OrchestratorAgent.ts +0 -637
  14. package/src/agent/orchestrator/index.ts +0 -38
  15. package/src/agent/orchestrator/utils.ts +0 -397
  16. package/src/agent/pricing.ts +0 -115
  17. package/src/agent/router.ts +0 -74
  18. package/src/agent/routerStats.ts +0 -121
  19. package/src/agent/types.ts +0 -318
  20. package/src/auth/login.ts +0 -383
  21. package/src/cli/config.ts +0 -189
  22. package/src/cli/index.ts +0 -17
  23. package/src/cli/middleware.ts +0 -119
  24. package/src/cli/types.ts +0 -75
  25. package/src/config/ConfigManager.ts +0 -587
  26. package/src/config/index.ts +0 -7
  27. package/src/config/types.ts +0 -584
  28. package/src/context/CompactionService.ts +0 -300
  29. package/src/context/ContextManager.ts +0 -450
  30. package/src/context/FileAnalyzer.ts +0 -267
  31. package/src/context/TokenCounter.ts +0 -265
  32. package/src/context/index.ts +0 -27
  33. package/src/context/storage/CacheStore.ts +0 -176
  34. package/src/context/storage/JSONLStore.ts +0 -201
  35. package/src/context/storage/MemoryStore.ts +0 -205
  36. package/src/context/storage/PersistentStore.ts +0 -327
  37. package/src/context/storage/index.ts +0 -9
  38. package/src/context/storage/pathUtils.ts +0 -114
  39. package/src/context/test.ts +0 -309
  40. package/src/context/types.ts +0 -268
  41. package/src/hooks/HookExecutor.ts +0 -434
  42. package/src/hooks/HookManager.ts +0 -596
  43. package/src/hooks/HookService.ts +0 -269
  44. package/src/hooks/Matcher.ts +0 -157
  45. package/src/hooks/index.ts +0 -63
  46. package/src/hooks/types.ts +0 -424
  47. package/src/main.tsx +0 -596
  48. package/src/mcp/HealthMonitor.ts +0 -150
  49. package/src/mcp/McpClient.ts +0 -491
  50. package/src/mcp/McpRegistry.ts +0 -321
  51. package/src/mcp/createMcpTool.ts +0 -251
  52. package/src/mcp/index.ts +0 -15
  53. package/src/mcp/server.ts +0 -334
  54. package/src/mcp/test-server.ts +0 -88
  55. package/src/mcp/test.ts +0 -372
  56. package/src/mcp/types.ts +0 -247
  57. package/src/memory/AgentMemoryBus.ts +0 -432
  58. package/src/memory/CloudSync.ts +0 -99
  59. package/src/memory/DriveSync.ts +0 -106
  60. package/src/memory/SharedMemory.ts +0 -951
  61. package/src/memory/index.ts +0 -14
  62. package/src/memory/machineFingerprint.ts +0 -40
  63. package/src/orchestrator/SubAgentMetadata.ts +0 -136
  64. package/src/prompts/builder.ts +0 -213
  65. package/src/prompts/default.ts +0 -144
  66. package/src/prompts/index.ts +0 -16
  67. package/src/prompts/plan.ts +0 -64
  68. package/src/prompts/test.ts +0 -78
  69. package/src/services/AnthropicChatService.ts +0 -341
  70. package/src/services/ChatService.ts +0 -347
  71. package/src/services/ClaudeCliChatService.ts +0 -256
  72. package/src/services/CloudSync.ts +0 -168
  73. package/src/services/CostLedger.ts +0 -211
  74. package/src/services/Heartbeat.ts +0 -135
  75. package/src/services/LearningCollector.ts +0 -291
  76. package/src/services/OllamaInstaller.ts +0 -342
  77. package/src/services/VersionChecker.ts +0 -445
  78. package/src/services/index.ts +0 -57
  79. package/src/services/streaming/OpenAIEventAdapter.ts +0 -126
  80. package/src/services/streaming/RenderingProfile.ts +0 -90
  81. package/src/services/streaming/StreamEventParser.ts +0 -181
  82. package/src/services/streaming/ThrottledRenderer.ts +0 -139
  83. package/src/services/streaming/TranscriptBuffer.ts +0 -574
  84. package/src/services/streaming/eventStatusMap.ts +0 -52
  85. package/src/services/streaming/index.ts +0 -46
  86. package/src/services/streaming/renderFormatting.ts +0 -79
  87. package/src/services/streaming/types.ts +0 -234
  88. package/src/skills/SkillLoader.ts +0 -126
  89. package/src/skills/SkillRegistry.ts +0 -366
  90. package/src/skills/index.ts +0 -48
  91. package/src/skills/types.ts +0 -146
  92. package/src/slash-commands/billing.ts +0 -70
  93. package/src/slash-commands/build.ts +0 -413
  94. package/src/slash-commands/builtinCommands.ts +0 -2733
  95. package/src/slash-commands/clone.ts +0 -242
  96. package/src/slash-commands/council.ts +0 -125
  97. package/src/slash-commands/custom/CustomCommandExecutor.ts +0 -143
  98. package/src/slash-commands/custom/CustomCommandLoader.ts +0 -251
  99. package/src/slash-commands/custom/CustomCommandRegistry.ts +0 -144
  100. package/src/slash-commands/custom/index.ts +0 -7
  101. package/src/slash-commands/debate.ts +0 -254
  102. package/src/slash-commands/gmail.ts +0 -105
  103. package/src/slash-commands/index.ts +0 -388
  104. package/src/slash-commands/mcpCommand.ts +0 -205
  105. package/src/slash-commands/types.ts +0 -201
  106. package/src/store/index.ts +0 -76
  107. package/src/store/selectors.ts +0 -246
  108. package/src/store/slices/appSlice.ts +0 -205
  109. package/src/store/slices/commandSlice.ts +0 -115
  110. package/src/store/slices/configSlice.ts +0 -46
  111. package/src/store/slices/focusSlice.ts +0 -64
  112. package/src/store/slices/index.ts +0 -9
  113. package/src/store/slices/sessionSlice.ts +0 -424
  114. package/src/store/streaming-buffer.ts +0 -425
  115. package/src/store/test.ts +0 -296
  116. package/src/store/types.ts +0 -274
  117. package/src/store/vanilla.ts +0 -186
  118. package/src/tools/builtin/bash.ts +0 -236
  119. package/src/tools/builtin/council.ts +0 -105
  120. package/src/tools/builtin/edit.ts +0 -213
  121. package/src/tools/builtin/glob.ts +0 -136
  122. package/src/tools/builtin/grep.ts +0 -263
  123. package/src/tools/builtin/index.ts +0 -61
  124. package/src/tools/builtin/memory.ts +0 -66
  125. package/src/tools/builtin/read.ts +0 -168
  126. package/src/tools/builtin/skill.ts +0 -97
  127. package/src/tools/builtin/snapshot.ts +0 -40
  128. package/src/tools/builtin/task.ts +0 -106
  129. package/src/tools/builtin/write.ts +0 -134
  130. package/src/tools/createTool.ts +0 -221
  131. package/src/tools/execution/ExecutionPipeline.ts +0 -263
  132. package/src/tools/execution/index.ts +0 -40
  133. package/src/tools/execution/stages/CacheStage.ts +0 -131
  134. package/src/tools/execution/stages/ConfirmationStage.ts +0 -203
  135. package/src/tools/execution/stages/DiscoveryStage.ts +0 -46
  136. package/src/tools/execution/stages/ExecutionStage.ts +0 -48
  137. package/src/tools/execution/stages/FormattingStage.ts +0 -44
  138. package/src/tools/execution/stages/HookStage.ts +0 -72
  139. package/src/tools/execution/stages/PermissionStage.ts +0 -287
  140. package/src/tools/execution/stages/PostHookStage.ts +0 -71
  141. package/src/tools/execution/stages/index.ts +0 -12
  142. package/src/tools/execution/test.ts +0 -266
  143. package/src/tools/execution/types.ts +0 -273
  144. package/src/tools/index.ts +0 -81
  145. package/src/tools/registry.ts +0 -304
  146. package/src/tools/schemas.ts +0 -109
  147. package/src/tools/test.ts +0 -220
  148. package/src/tools/types.ts +0 -175
  149. package/src/tools/validation/PermissionChecker.ts +0 -242
  150. package/src/tools/validation/SensitiveFileDetector.ts +0 -210
  151. package/src/tools/validation/index.ts +0 -11
  152. package/src/ui/App.tsx +0 -166
  153. package/src/ui/components/AegisInterface.tsx +0 -484
  154. package/src/ui/components/common/ChatSearch.tsx +0 -150
  155. package/src/ui/components/common/ErrorBoundary.tsx +0 -82
  156. package/src/ui/components/common/ExitMessage.tsx +0 -120
  157. package/src/ui/components/common/LoadingIndicator.tsx +0 -49
  158. package/src/ui/components/common/index.ts +0 -6
  159. package/src/ui/components/dialog/ConfirmationPrompt.tsx +0 -208
  160. package/src/ui/components/dialog/InteractiveSelector.tsx +0 -149
  161. package/src/ui/components/dialog/SetupWizard.tsx +0 -297
  162. package/src/ui/components/dialog/UpdatePrompt.tsx +0 -155
  163. package/src/ui/components/dialog/index.ts +0 -8
  164. package/src/ui/components/index.ts +0 -28
  165. package/src/ui/components/input/CommandSuggestions.tsx +0 -139
  166. package/src/ui/components/input/CustomTextInput.tsx +0 -220
  167. package/src/ui/components/input/InputArea.tsx +0 -361
  168. package/src/ui/components/input/PromptSuggestions.tsx +0 -66
  169. package/src/ui/components/input/index.ts +0 -6
  170. package/src/ui/components/layout/ChatStatusBar.tsx +0 -90
  171. package/src/ui/components/layout/ContextBar.tsx +0 -79
  172. package/src/ui/components/layout/MessageArea.tsx +0 -96
  173. package/src/ui/components/layout/MessageList.tsx +0 -647
  174. package/src/ui/components/layout/MessageSeparator.tsx +0 -26
  175. package/src/ui/components/layout/WelcomeMessage.tsx +0 -93
  176. package/src/ui/components/layout/index.ts +0 -7
  177. package/src/ui/components/markdown/CodeHighlighter.tsx +0 -292
  178. package/src/ui/components/markdown/MessageRenderer.tsx +0 -1211
  179. package/src/ui/components/markdown/index.ts +0 -8
  180. package/src/ui/components/markdown/parser.ts +0 -336
  181. package/src/ui/components/markdown/types.ts +0 -66
  182. package/src/ui/focus/FocusManager.ts +0 -137
  183. package/src/ui/focus/index.ts +0 -13
  184. package/src/ui/focus/types.ts +0 -54
  185. package/src/ui/focus/useFocus.ts +0 -75
  186. package/src/ui/hooks/index.ts +0 -11
  187. package/src/ui/hooks/useAgent.ts +0 -284
  188. package/src/ui/hooks/useCommandHistory.ts +0 -87
  189. package/src/ui/hooks/useCommandProcessor.ts +0 -443
  190. package/src/ui/hooks/useConfirmation.ts +0 -99
  191. package/src/ui/hooks/useCtrlCHandler.ts +0 -100
  192. package/src/ui/hooks/useInputBuffer.ts +0 -122
  193. package/src/ui/hooks/useTerminalSize.ts +0 -68
  194. package/src/ui/hooks/useTerminalWidth.ts +0 -5
  195. package/src/ui/hooks/useWindowedList.ts +0 -118
  196. package/src/ui/render-debugger.ts +0 -621
  197. package/src/ui/test.ts +0 -189
  198. package/src/ui/themes/ThemeManager.ts +0 -332
  199. package/src/ui/themes/aegisTheme.ts +0 -87
  200. package/src/ui/themes/darkTheme.ts +0 -87
  201. package/src/ui/themes/defaultTheme.ts +0 -85
  202. package/src/ui/themes/index.ts +0 -10
  203. package/src/ui/themes/lightTheme.ts +0 -89
  204. package/src/ui/themes/popularThemes.ts +0 -187
  205. package/src/ui/themes/types.ts +0 -130
  206. package/src/utils/clipboard.ts +0 -48
  207. package/src/utils/debug.ts +0 -43
  208. package/src/utils/environment.ts +0 -68
  209. package/src/utils/index.ts +0 -10
@@ -1,121 +0,0 @@
1
- /**
2
- * Auto-router learning loop — v1.
3
- *
4
- * The only outcome signal available without new UI is whether the user
5
- * aborted (Escape/Ctrl+C) an auto-routed response. That's a noisy proxy for
6
- * "this model didn't deliver" (people also abort for unrelated reasons —
7
- * wrong question, impatience), but it's real, already-wired data instead of
8
- * a guessed-at shape. Tracked as a Beta(success, failure) per tier+model and
9
- * sampled via Thompson sampling, so the fallback list self-corrects toward
10
- * whichever configured model actually finishes tasks for that tier, instead
11
- * of always picking the same hardcoded first candidate.
12
- */
13
-
14
- import * as fs from 'node:fs';
15
- import * as path from 'node:path';
16
- import * as os from 'node:os';
17
- import type { ComplexityTier } from './router.js';
18
-
19
- type ModelStats = { success: number; failure: number };
20
- type RouterStats = Partial<Record<ComplexityTier, Record<string, ModelStats>>>;
21
-
22
- const STATS_PATH = path.join(os.homedir(), '.aegiscode', 'router-stats.json');
23
-
24
- let cache: RouterStats | null = null;
25
-
26
- function load(): RouterStats {
27
- if (cache) return cache;
28
- try {
29
- cache = JSON.parse(fs.readFileSync(STATS_PATH, 'utf8'));
30
- } catch {
31
- cache = {};
32
- }
33
- return cache!;
34
- }
35
-
36
- function save(stats: RouterStats): void {
37
- cache = stats;
38
- try {
39
- fs.mkdirSync(path.dirname(STATS_PATH), { recursive: true });
40
- fs.writeFileSync(STATS_PATH, JSON.stringify(stats, null, 2));
41
- } catch { /* non-fatal — learning is best-effort */ }
42
- }
43
-
44
- /** Record whether an auto-routed turn completed normally or was aborted/errored. */
45
- export function recordRouterOutcome(tier: ComplexityTier, modelId: string, success: boolean): void {
46
- const stats = load();
47
- const tierStats = stats[tier] || (stats[tier] = {});
48
- const modelStats = tierStats[modelId] || (tierStats[modelId] = { success: 0, failure: 0 });
49
- if (success) modelStats.success += 1;
50
- else modelStats.failure += 1;
51
- save(stats);
52
- }
53
-
54
- export function getRouterStats(): RouterStats {
55
- return load();
56
- }
57
-
58
- /** Marsaglia-Tsang gamma sampler — shape > 0, scale 1. */
59
- function sampleGamma(shape: number): number {
60
- if (shape < 1) {
61
- // Boost via Johnk's trick: Gamma(shape) = Gamma(shape+1) * U^(1/shape)
62
- const u = Math.random();
63
- return sampleGamma(shape + 1) * Math.pow(u, 1 / shape);
64
- }
65
- const d = shape - 1 / 3;
66
- const c = 1 / Math.sqrt(9 * d);
67
- for (;;) {
68
- let x: number;
69
- let v: number;
70
- do {
71
- // Box-Muller for a standard normal sample
72
- const u1 = Math.random() || Number.EPSILON;
73
- const u2 = Math.random();
74
- x = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
75
- v = 1 + c * x;
76
- } while (v <= 0);
77
- v = v * v * v;
78
- const u = Math.random();
79
- if (u < 1 - 0.0331 * (x * x) * (x * x)) return d * v;
80
- if (Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) return d * v;
81
- }
82
- }
83
-
84
- function sampleBeta(alpha: number, beta: number): number {
85
- const ga = sampleGamma(alpha);
86
- const gb = sampleGamma(beta);
87
- return ga / (ga + gb);
88
- }
89
-
90
- /**
91
- * Thompson sampling pick among candidate model ids for this tier, in
92
- * cost-ascending order (cheapest first). A flat Beta(1,1) prior would make
93
- * brand-new, zero-data routing an even coin flip across candidates —
94
- * defeating the point of a cost-ordered fallback list before any evidence
95
- * exists. Instead each candidate's prior is biased by its cost rank (a
96
- * "virtual success" head start that shrinks toward the back of the list),
97
- * so with no data it deterministically prefers the cheapest candidate, and
98
- * only drifts toward a pricier one once real failures (aborted responses)
99
- * accumulate enough to outweigh that head start.
100
- */
101
- export function pickByOutcomes(tier: ComplexityTier, candidateIdsCostOrder: string[]): string | undefined {
102
- const n = candidateIdsCostOrder.length;
103
- if (n === 0) return undefined;
104
- if (n === 1) return candidateIdsCostOrder[0];
105
-
106
- const stats = load();
107
- const tierStats = stats[tier] || {};
108
-
109
- let best: string | undefined;
110
- let bestScore = -Infinity;
111
- candidateIdsCostOrder.forEach((id, i) => {
112
- const priorBonus = (n - 1 - i) * 3; // cheapest gets the biggest head start
113
- const s = tierStats[id];
114
- const score = sampleBeta(1 + priorBonus + (s?.success ?? 0), 1 + (s?.failure ?? 0));
115
- if (score > bestScore) {
116
- bestScore = score;
117
- best = id;
118
- }
119
- });
120
- return best;
121
- }
@@ -1,318 +0,0 @@
1
- /**
2
- * Agent 类型定义
3
- *
4
- *
5
- */
6
-
7
- // ========== 消息类
8
-
9
- /**
10
- *
11
- */
12
- export type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
13
-
14
- /**
15
- *
16
- */
17
- export interface ToolCall {
18
- id: string;
19
- type: 'function';
20
- function: {
21
- name: string;
22
- arguments: string; // JSON 字符
23
- };
24
- }
25
-
26
- /**
27
- *
28
- *
29
- */
30
- export interface Message {
31
- role: MessageRole;
32
- content: string;
33
-
34
- /** DeepSeek R1 等推理模型产生的思维链内容 */
35
- reasoning_content?: string;
36
-
37
- /** assistant 消息专用:发起的工具调用列表 */
38
- tool_calls?: ToolCall[];
39
-
40
- /** tool 消息专用:关联的调用 ID */
41
- tool_call_id?: string;
42
-
43
- /** tool 消息专用:工具名称 */
44
- name?: string;
45
- }
46
-
47
- // ========== 上下文类
48
-
49
- /**
50
- *
51
- */
52
- export type PermissionMode = 'default' | 'autoEdit' | 'yolo' | 'plan';
53
-
54
- /**
55
- *
56
- */
57
- export interface ConfirmationDetails {
58
- title: string;
59
- message: string;
60
- details?: string;
61
- risks?: string[];
62
- affectedFiles?: string[];
63
- }
64
-
65
- /**
66
- *
67
- */
68
- export interface ConfirmationResponse {
69
- approved: boolean;
70
- reason?: string;
71
- scope?: 'once' | 'session';
72
- }
73
-
74
- /**
75
- *
76
- */
77
- export interface ConfirmationHandler {
78
- requestConfirmation(details: ConfirmationDetails): Promise<ConfirmationResponse>;
79
- }
80
-
81
- /**
82
- *
83
- *
84
- * Agent 是无状态的,所有状态通过 context 传入
85
- */
86
- export interface ChatContext {
87
- /** 会话 ID */
88
- sessionId: string;
89
-
90
- /** 消息历史 */
91
- messages: Message[];
92
-
93
- /** 权限模式 */
94
- permissionMode?: PermissionMode;
95
-
96
- /** 中断信号 */
97
- signal?: AbortSignal;
98
-
99
- /** 确认处理器 */
100
- confirmationHandler?: ConfirmationHandler;
101
- }
102
-
103
- // ========== 循环选项与结
104
-
105
- /**
106
- *
107
- */
108
- export interface LoopOptions {
109
- /** 最大轮次 */
110
- maxTurns?: number;
111
-
112
- /** 中断信号 */
113
- signal?: AbortSignal;
114
-
115
- /** 轮次开始回调 */
116
- onTurnStart?: (info: { turn: number; maxTurns: number }) => void;
117
-
118
- /** 内容回调(完整内容,用于非流式场景) */
119
- onContent?: (content: string) => void;
120
-
121
- /** Unified Anthropic-format stream event (preferred over individual delta callbacks) */
122
- onStreamEvent?: (event: import('../services/streaming/types.js').AnthropicStreamEvent) => void;
123
-
124
- /** 内容增量回调(流式) */
125
- onContentDelta?: (delta: string) => void;
126
-
127
- /** 思考内容回调(完整内容) */
128
- onThinking?: (content: string) => void;
129
-
130
- /** 思考内容增量回调(流式) */
131
- onThinkingDelta?: (delta: string) => void;
132
-
133
- /** 工具调用开始回调 */
134
- onToolCallStart?: (toolCall: Partial<ToolCall>) => void;
135
-
136
- /** 工具调用参数增量回调(流式) */
137
- onToolCallDelta?: (toolCallId: string, argumentsDelta: string) => void;
138
-
139
- /** 工具结果回调 */
140
- onToolResult?: (toolCall: ToolCall, result: ToolResult) => void;
141
-
142
- /** 轮次上限回调 */
143
- onTurnLimitReached?: (info: { turnsCount: number }) => Promise<{ continue: boolean }>;
144
- }
145
-
146
- /**
147
- *
148
- */
149
- export type LoopErrorType =
150
- | 'aborted'
151
- | 'max_turns_exceeded'
152
- | 'chat_disabled'
153
- | 'initialization_failed'
154
- | 'llm_error'
155
- | 'tool_error';
156
-
157
- /**
158
- *
159
- */
160
- export interface LoopError {
161
- type: LoopErrorType;
162
- message?: string;
163
- cause?: Error;
164
- }
165
-
166
- /**
167
- *
168
- */
169
- export interface LoopResult {
170
- success: boolean;
171
- finalMessage?: string;
172
- error?: LoopError;
173
- metadata?: {
174
- turnsCount: number;
175
- toolCallsCount: number;
176
- totalTokens?: number;
177
- };
178
- }
179
-
180
- // ========== 工具类
181
-
182
- /**
183
- *
184
- */
185
- export interface ToolResult {
186
- success: boolean;
187
-
188
- /** 显示给用户的内容 */
189
- displayContent?: string;
190
-
191
- /** 发送给 LLM 的内容 */
192
- llmContent?: string;
193
-
194
- /** 错误信息 */
195
- error?: string;
196
-
197
- /** 元数据 */
198
- metadata?: Record<string, unknown>;
199
- }
200
-
201
- /**
202
- *
203
- */
204
- export interface ToolDefinition {
205
- type: 'function';
206
- function: {
207
- name: string;
208
- description: string;
209
- parameters: {
210
- type: 'object';
211
- properties: Record<string, {
212
- type: string;
213
- description: string;
214
- enum?: string[];
215
- }>;
216
- required?: string[];
217
- };
218
- };
219
- }
220
-
221
- // ========== Agent 配
222
-
223
- /**
224
- * Agent 配置
225
- */
226
- export interface AgentConfig {
227
- /** API Key */
228
- apiKey: string;
229
-
230
- /** API Base URL */
231
- baseURL?: string;
232
-
233
- /** 模型名称 */
234
- model?: string;
235
-
236
- /** 最大轮次 (-1 表示无限) */
237
- maxTurns?: number;
238
-
239
- /** 最大上下文 Token */
240
- maxContextTokens?: number;
241
-
242
- /** 最大输出 Token */
243
- maxOutputTokens?: number;
244
-
245
- /** 系统提示词 */
246
- systemPrompt?: string;
247
-
248
- /** Request timeout in ms (default 60000) */
249
- timeout?: number;
250
-
251
- /** Show confirmation prompts before sensitive tool calls (default true) */
252
- requireConfirmation?: boolean;
253
-
254
- /** aegiscode's own permission mode; only consulted for OAuth (claude CLI) transport. */
255
- permissionMode?: string;
256
- }
257
-
258
- /**
259
- * Agent 创建选项
260
- */
261
- export interface AgentOptions {
262
- /** 最大轮次 */
263
- maxTurns?: number;
264
-
265
- /** 工具白名单 */
266
- toolWhitelist?: string[];
267
-
268
- /** 工具黑名单 */
269
- toolBlacklist?: string[];
270
- }
271
-
272
- // ========== ChatService 类
273
-
274
- /**
275
- * ChatService 响应
276
- */
277
- export interface ChatResponse {
278
- content: string;
279
- reasoningContent?: string;
280
- toolCalls?: ToolCall[];
281
- usage?: {
282
- promptTokens: number;
283
- completionTokens: number;
284
- totalTokens: number;
285
- /** Tokens served from the prompt cache (~0.1x cost) — native Anthropic transport only. */
286
- cacheReadTokens?: number;
287
- /** Tokens written to the prompt cache this request (~1.25x cost) — native Anthropic transport only. */
288
- cacheCreationTokens?: number;
289
- };
290
- }
291
-
292
- /**
293
- *
294
- */
295
- export interface StreamCallbacks {
296
- /** Unified Anthropic-format stream event (preferred over the individual callbacks below) */
297
- onStreamEvent?: (event: import('../services/streaming/types.js').AnthropicStreamEvent) => void;
298
- /** 内容增量回调 */
299
- onContentDelta?: (delta: string) => void;
300
- /** 思考内容增量回调 */
301
- onThinkingDelta?: (delta: string) => void;
302
- /** 工具调用开始回调 */
303
- onToolCallStart?: (toolCall: Partial<ToolCall>) => void;
304
- /** 工具调用参数增量回调 */
305
- onToolCallDelta?: (toolCallId: string, argumentsDelta: string) => void;
306
- }
307
-
308
- /**
309
- * ChatService 接口
310
- */
311
- export interface IChatService {
312
- chat(
313
- messages: Message[],
314
- tools?: ToolDefinition[],
315
- signal?: AbortSignal,
316
- streamCallbacks?: StreamCallbacks
317
- ): Promise<ChatResponse>;
318
- }