Skip to content

Commit 98ba7b8

Browse files
tensorboyclaude
andcommitted
Refactor Hawkeye core and improve resource cleanup
- Optimize imports and property organization in Hawkeye class - Add OpenAI to supported AI providers configuration - Implement proper MCP server shutdown in stop method - Reorder class properties for better readability Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e52b753 commit 98ba7b8

1 file changed

Lines changed: 27 additions & 26 deletions

File tree

packages/core/src/hawkeye.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,35 @@ import {
2222
createSelfReflection,
2323
type SelfReflectionConfig,
2424
} from './autonomous/self-reflection';
25-
26-
// ...
27-
28-
export class Hawkeye extends EventEmitter {
29-
// ...
30-
private selfReflection: SelfReflection | null = null;
31-
32-
constructor(config: HawkeyeConfig) {
33-
super();
34-
// ...
35-
// 初始化核心模块(非 async 部分)
36-
this.perception = new PerceptionEngine(config.perception);
37-
// ...
38-
this.database = new HawkeyeDatabase(config.storage?.database);
39-
this.vectorStore = new VectorStore(config.storage?.vectorStore);
40-
41-
// 初始化 SelfReflection (含 SEPO)
42-
this.selfReflection = createSelfReflection({}, this.vectorStore);
43-
44-
// ...
45-
}
46-
}
25+
import {
26+
AutonomousManager,
27+
createAutonomousManager,
28+
type AutonomousConfig,
29+
type SuggestedAction,
30+
type AutonomousAnalysisResult,
31+
} from './autonomous';
32+
import { PermissionManager, AuditLogger } from './security';
33+
import {
34+
ToolRegistry,
35+
getToolRegistry,
36+
MCPServer,
37+
} from './mcp';
38+
import {
39+
SkillManager,
40+
} from './skills';
41+
import { EventCollector } from './debug';
4742
import type {
4843
UserIntent,
4944
ExecutionPlan,
5045
AIMessage,
5146
} from './ai/types';
47+
import type { ExecutionResult } from './types';
5248

5349
export interface HawkeyeConfig {
5450
/** AI Provider 配置 */
5551
ai: {
5652
providers: AIProviderConfig[];
57-
preferredProvider?: 'ollama' | 'gemini';
53+
preferredProvider?: 'ollama' | 'gemini' | 'openai';
5854
enableFailover?: boolean;
5955
};
6056

@@ -147,13 +143,13 @@ export class Hawkeye extends EventEmitter {
147143
private dashboardManager: DashboardManager | null = null;
148144
private workflowManager: WorkflowManager | null = null;
149145
private pluginManager: PluginManager | null = null;
150-
private toolRegistry: ToolRegistry;
151-
private skillManager: SkillManager;
152-
private mcpServer: MCPServer | null = null;
153146
private autonomousManager: AutonomousManager | null = null;
154147
private selfReflection: SelfReflection | null = null;
155148
private permissionManager: PermissionManager;
156149
private auditLogger: AuditLogger;
150+
private toolRegistry: ToolRegistry;
151+
private skillManager: SkillManager;
152+
private mcpServer: MCPServer | null = null;
157153

158154
// 调试事件收集器
159155
private eventCollector: EventCollector;
@@ -959,6 +955,11 @@ export class Hawkeye extends EventEmitter {
959955
this.autonomousManager.stop();
960956
}
961957

958+
// 停止 MCP Server
959+
if (this.mcpServer) {
960+
await this.mcpServer.stop();
961+
}
962+
962963
if (this.syncServer) {
963964
this.syncServer.stop();
964965
this._syncRunning = false;

0 commit comments

Comments
 (0)