aegiscode 3.1.10 → 3.2.0
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-cli-linux-x64 +0 -0
- package/bin/cli.js +68 -0
- package/package.json +11 -48
- package/scripts/download-binary.mjs +155 -0
- 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
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ChatSearch - Ctrl+F inline search within messages
|
|
3
|
-
*
|
|
4
|
-
* Shows a search bar overlay when activated via Ctrl+F.
|
|
5
|
-
* Highlights matching messages and allows cycling through results.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { useState, useCallback, useEffect, useRef, useMemo } from 'react';
|
|
9
|
-
import { Box, Text, useInput } from 'ink';
|
|
10
|
-
import { themeManager } from '../../themes/index.js';
|
|
11
|
-
import { vanillaStore } from '../../../store/vanilla.js';
|
|
12
|
-
import type { FocusId } from '../../focus/index.js';
|
|
13
|
-
|
|
14
|
-
interface ChatSearchProps {
|
|
15
|
-
/** Called when search is dismissed */
|
|
16
|
-
onDismiss: () => void;
|
|
17
|
-
/** Called with indices of matching messages */
|
|
18
|
-
onResults?: (indices: number[], currentIndex: number) => void;
|
|
19
|
-
/** The focus ID for input capture */
|
|
20
|
-
focusId?: FocusId;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const ChatSearch: React.FC<ChatSearchProps> = ({
|
|
24
|
-
onDismiss,
|
|
25
|
-
onResults,
|
|
26
|
-
}) => {
|
|
27
|
-
const theme = themeManager.getTheme();
|
|
28
|
-
const [query, setQuery] = useState('');
|
|
29
|
-
const [cursorPos, setCursorPos] = useState(0);
|
|
30
|
-
const [currentMatch, setCurrentMatch] = useState(0);
|
|
31
|
-
const queryRef = useRef('');
|
|
32
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
33
|
-
|
|
34
|
-
const messages = useMemo(
|
|
35
|
-
() => vanillaStore.getState().session.messages,
|
|
36
|
-
[],
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const matchIndices = useMemo(() => {
|
|
40
|
-
if (!query.trim()) return [];
|
|
41
|
-
const q = query.toLowerCase();
|
|
42
|
-
return messages.reduce<number[]>((acc, msg, idx) => {
|
|
43
|
-
if (msg.content.toLowerCase().includes(q)) acc.push(idx);
|
|
44
|
-
return acc;
|
|
45
|
-
}, []);
|
|
46
|
-
}, [query, messages]);
|
|
47
|
-
|
|
48
|
-
const totalMatches = matchIndices.length;
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
setCurrentMatch(0);
|
|
52
|
-
if (onResults) {
|
|
53
|
-
onResults(matchIndices, 0);
|
|
54
|
-
}
|
|
55
|
-
}, [query]);
|
|
56
|
-
|
|
57
|
-
const handleChange = useCallback((value: string) => {
|
|
58
|
-
queryRef.current = value;
|
|
59
|
-
setQuery(value);
|
|
60
|
-
setCursorPos(value.length);
|
|
61
|
-
}, []);
|
|
62
|
-
|
|
63
|
-
const handlePrev = useCallback(() => {
|
|
64
|
-
if (matchIndices.length === 0) return;
|
|
65
|
-
const next = currentMatch > 0 ? currentMatch - 1 : matchIndices.length - 1;
|
|
66
|
-
setCurrentMatch(next);
|
|
67
|
-
if (onResults) onResults(matchIndices, next);
|
|
68
|
-
}, [currentMatch, matchIndices, onResults]);
|
|
69
|
-
|
|
70
|
-
const handleNext = useCallback(() => {
|
|
71
|
-
if (matchIndices.length === 0) return;
|
|
72
|
-
const next = currentMatch < matchIndices.length - 1 ? currentMatch + 1 : 0;
|
|
73
|
-
setCurrentMatch(next);
|
|
74
|
-
if (onResults) onResults(matchIndices, next);
|
|
75
|
-
}, [currentMatch, matchIndices, onResults]);
|
|
76
|
-
|
|
77
|
-
useInput((input, key) => {
|
|
78
|
-
if (key.escape) {
|
|
79
|
-
onDismiss();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (key.return) {
|
|
83
|
-
handleNext();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (key.backspace || key.delete) {
|
|
87
|
-
handleChange(queryRef.current.slice(0, -1));
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (key.tab) {
|
|
91
|
-
handleNext();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (key.shift && key.tab) {
|
|
95
|
-
handlePrev();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (key.upArrow) {
|
|
99
|
-
handlePrev();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (key.downArrow) {
|
|
103
|
-
handleNext();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (input && !key.ctrl && !key.meta && input.length === 1) {
|
|
107
|
-
handleChange(queryRef.current + input);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<Box
|
|
113
|
-
flexDirection="row"
|
|
114
|
-
paddingX={1}
|
|
115
|
-
paddingY={0}
|
|
116
|
-
borderStyle="round"
|
|
117
|
-
borderColor={theme.colors.accent}
|
|
118
|
-
marginBottom={0}
|
|
119
|
-
>
|
|
120
|
-
<Box marginRight={1}>
|
|
121
|
-
<Text color={theme.colors.info} bold>
|
|
122
|
-
{'\u2315'}
|
|
123
|
-
</Text>
|
|
124
|
-
</Box>
|
|
125
|
-
|
|
126
|
-
<Box flexGrow={1}>
|
|
127
|
-
<Text>
|
|
128
|
-
<Text color={theme.colors.text.primary}>{query}</Text>
|
|
129
|
-
<Text color={theme.colors.text.muted}>{'\u2502'}</Text>
|
|
130
|
-
</Text>
|
|
131
|
-
</Box>
|
|
132
|
-
|
|
133
|
-
<Box marginRight={1}>
|
|
134
|
-
<Text color={theme.colors.text.muted} dimColor>
|
|
135
|
-
{totalMatches > 0
|
|
136
|
-
? `${currentMatch + 1}/${totalMatches}`
|
|
137
|
-
: query.trim()
|
|
138
|
-
? '0/0'
|
|
139
|
-
: ''}
|
|
140
|
-
</Text>
|
|
141
|
-
</Box>
|
|
142
|
-
|
|
143
|
-
<Text color={theme.colors.text.muted} dimColor>
|
|
144
|
-
{'n/N to navigate, Esc to close'}
|
|
145
|
-
</Text>
|
|
146
|
-
</Box>
|
|
147
|
-
);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export default ChatSearch;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ErrorBoundary - React 错误边界组件
|
|
3
|
-
*
|
|
4
|
-
* Enhanced with region name for logging and optional fallback render prop.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { Box, Text } from 'ink';
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
fallback?: React.ReactNode;
|
|
13
|
-
/** Region name for debug logging (e.g. 'MessageList', 'ThinkingPanel') */
|
|
14
|
-
name?: string;
|
|
15
|
-
/** Called when an error is caught, for telemetry */
|
|
16
|
-
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface State {
|
|
20
|
-
hasError: boolean;
|
|
21
|
-
error: Error | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class ErrorBoundary extends React.Component<Props, State> {
|
|
25
|
-
constructor(props: Props) {
|
|
26
|
-
super(props);
|
|
27
|
-
this.state = { hasError: false, error: null };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static getDerivedStateFromError(error: Error): State {
|
|
31
|
-
return { hasError: true, error };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
|
|
35
|
-
const region = this.props.name || 'unknown';
|
|
36
|
-
console.error(`[ErrorBoundary:${region}] Caught error:`, error);
|
|
37
|
-
console.error(`[ErrorBoundary:${region}] Component stack:`, errorInfo.componentStack);
|
|
38
|
-
this.props.onError?.(error, errorInfo);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
render(): React.ReactNode {
|
|
42
|
-
if (this.state.hasError) {
|
|
43
|
-
if (this.props.fallback) {
|
|
44
|
-
return this.props.fallback;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const region = this.props.name || 'application';
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Box flexDirection="column" padding={1}>
|
|
51
|
-
<Text color="red" bold>
|
|
52
|
-
❌ {region} Error
|
|
53
|
-
</Text>
|
|
54
|
-
<Box marginTop={1}>
|
|
55
|
-
<Text color="yellow">
|
|
56
|
-
An unexpected error occurred in {region}. Please restart the application.
|
|
57
|
-
</Text>
|
|
58
|
-
</Box>
|
|
59
|
-
{this.state.error && (
|
|
60
|
-
<Box marginTop={1} flexDirection="column">
|
|
61
|
-
<Text color="gray">Error: {this.state.error.message}</Text>
|
|
62
|
-
{this.state.error.stack && (
|
|
63
|
-
<Box marginTop={1}>
|
|
64
|
-
<Text color="gray" dimColor>
|
|
65
|
-
{this.state.error.stack.split('\n').slice(0, 5).join('\n')}
|
|
66
|
-
</Text>
|
|
67
|
-
</Box>
|
|
68
|
-
)}
|
|
69
|
-
</Box>
|
|
70
|
-
)}
|
|
71
|
-
<Box marginTop={1}>
|
|
72
|
-
<Text color="cyan">Press Ctrl+C to exit</Text>
|
|
73
|
-
</Box>
|
|
74
|
-
</Box>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return this.props.children;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default ErrorBoundary;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ExitMessage - visar session-info och synkar till aegiscloud.org vid exit
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import { Box, Text, useApp } from 'ink';
|
|
7
|
-
import { themeManager } from '../../themes/index.js';
|
|
8
|
-
import { getState } from '../../../store/index.js';
|
|
9
|
-
|
|
10
|
-
interface ExitMessageProps {
|
|
11
|
-
sessionId: string;
|
|
12
|
-
exitDelay?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const ExitMessage: React.FC<ExitMessageProps> = ({
|
|
16
|
-
sessionId,
|
|
17
|
-
exitDelay = 800,
|
|
18
|
-
}) => {
|
|
19
|
-
const { exit } = useApp();
|
|
20
|
-
const theme = themeManager.getTheme();
|
|
21
|
-
const [syncStatus, setSyncStatus] = useState<'syncing' | 'done' | 'skip' | 'error'>('syncing');
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const doExit = async () => {
|
|
25
|
-
const { appendToLocalMemory, syncConversation } = await import('../../../services/CloudSync.js');
|
|
26
|
-
const { sharedMemory } = await import('../../../memory/SharedMemory.js');
|
|
27
|
-
const storeMessages = getState().session.messages;
|
|
28
|
-
|
|
29
|
-
if (storeMessages?.length > 0) {
|
|
30
|
-
const messages = storeMessages.map((m: any) => ({
|
|
31
|
-
role: m.role as string,
|
|
32
|
-
content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
// Local memory + episodic summary
|
|
36
|
-
await appendToLocalMemory(sessionId, messages).catch(() => {});
|
|
37
|
-
let model: string | undefined;
|
|
38
|
-
try {
|
|
39
|
-
const fs = await import('fs');
|
|
40
|
-
const path = await import('path');
|
|
41
|
-
const os = await import('os');
|
|
42
|
-
const cfg = JSON.parse(fs.readFileSync(path.join(os.homedir(), '.aegiscode', 'config.json'), 'utf8'));
|
|
43
|
-
model = cfg?.default?.model || cfg?.models?.find((m: any) => m.id === cfg.currentModelId)?.model;
|
|
44
|
-
if (sharedMemory.isEnabled()) {
|
|
45
|
-
const apiKey = cfg?.default?.apiKey || cfg?.models?.find((m: any) => m.id === cfg.currentModelId)?.apiKey;
|
|
46
|
-
const baseURL = cfg?.default?.baseURL || cfg?.models?.find((m: any) => m.id === cfg.currentModelId)?.baseURL;
|
|
47
|
-
await sharedMemory.summarizeAndStoreSession(sessionId, apiKey, baseURL, model);
|
|
48
|
-
}
|
|
49
|
-
} catch {}
|
|
50
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
51
|
-
try {
|
|
52
|
-
const result = await syncConversation(sessionId, messages, model);
|
|
53
|
-
if (result.reason === 'uploaded') {
|
|
54
|
-
setSyncStatus('done');
|
|
55
|
-
break;
|
|
56
|
-
} else if (result.reason === 'error' && attempt < 2) {
|
|
57
|
-
await new Promise(r => setTimeout(r, 1000 * (attempt + 1)));
|
|
58
|
-
continue;
|
|
59
|
-
} else {
|
|
60
|
-
setSyncStatus(result.reason === 'error' ? 'error' : 'skip');
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
if (attempt < 2) {
|
|
65
|
-
await new Promise(r => setTimeout(r, 1000 * (attempt + 1)));
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
setSyncStatus('error');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
setSyncStatus('skip');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
setTimeout(() => { exit(); setTimeout(() => process.exit(0), 50); }, 300);
|
|
76
|
-
};
|
|
77
|
-
doExit();
|
|
78
|
-
}, [exit, sessionId]);
|
|
79
|
-
|
|
80
|
-
const shortId = sessionId.length > 16
|
|
81
|
-
? `${sessionId.slice(0, 8)}..${sessionId.slice(-6)}`
|
|
82
|
-
: sessionId;
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Box flexDirection="column" paddingY={1}>
|
|
86
|
-
<Box marginBottom={1}>
|
|
87
|
-
<Text color={theme.colors.text.muted}>─ </Text>
|
|
88
|
-
<Text color={theme.colors.warning}>session saved</Text>
|
|
89
|
-
<Text color={theme.colors.text.muted}> [</Text>
|
|
90
|
-
<Text color={theme.colors.info}>{shortId}</Text>
|
|
91
|
-
<Text color={theme.colors.text.muted}>]</Text>
|
|
92
|
-
{syncStatus === 'syncing' && (
|
|
93
|
-
<Text color={theme.colors.text.muted}> · syncing…</Text>
|
|
94
|
-
)}
|
|
95
|
-
{syncStatus === 'done' && (
|
|
96
|
-
<Text color={theme.colors.success}> · synced ↑</Text>
|
|
97
|
-
)}
|
|
98
|
-
{syncStatus === 'error' && (
|
|
99
|
-
<Text color={theme.colors.warning}> · sync failed</Text>
|
|
100
|
-
)}
|
|
101
|
-
{syncStatus === 'skip' && (
|
|
102
|
-
<Text color={theme.colors.text.muted}> · local only</Text>
|
|
103
|
-
)}
|
|
104
|
-
</Box>
|
|
105
|
-
|
|
106
|
-
<Box flexDirection="column" marginLeft={2}>
|
|
107
|
-
<Text color={theme.colors.text.muted}>resume: </Text>
|
|
108
|
-
<Box marginLeft={2}>
|
|
109
|
-
<Text color={theme.colors.success}>aegis --continue</Text>
|
|
110
|
-
</Box>
|
|
111
|
-
<Box marginLeft={2}>
|
|
112
|
-
<Text color={theme.colors.success}>aegis --resume </Text>
|
|
113
|
-
<Text color={theme.colors.info}>{sessionId}</Text>
|
|
114
|
-
</Box>
|
|
115
|
-
</Box>
|
|
116
|
-
</Box>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default ExitMessage;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LoadingIndicator - 加载指示器组件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Box, Text } from 'ink';
|
|
7
|
-
|
|
8
|
-
import { themeManager } from '../../themes/index.js';
|
|
9
|
-
|
|
10
|
-
interface LoadingIndicatorProps {
|
|
11
|
-
/** 是否显示 */
|
|
12
|
-
isVisible?: boolean;
|
|
13
|
-
/** 加载文本 */
|
|
14
|
-
text?: string;
|
|
15
|
-
/** 显示详情 */
|
|
16
|
-
details?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export const LoadingIndicator: React.FC<LoadingIndicatorProps> = React.memo(({
|
|
23
|
-
isVisible = true,
|
|
24
|
-
text = 'Thinking...',
|
|
25
|
-
details,
|
|
26
|
-
}) => {
|
|
27
|
-
const theme = themeManager.getTheme();
|
|
28
|
-
|
|
29
|
-
if (!isVisible) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Box flexDirection="row" paddingX={1} marginY={1}>
|
|
35
|
-
<Box flexDirection="column">
|
|
36
|
-
<Text color={theme.colors.warning}>{text}</Text>
|
|
37
|
-
{details && (
|
|
38
|
-
<Text color={theme.colors.text.muted} dimColor>
|
|
39
|
-
{details}
|
|
40
|
-
</Text>
|
|
41
|
-
)}
|
|
42
|
-
</Box>
|
|
43
|
-
</Box>
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
48
|
-
|
|
49
|
-
export default LoadingIndicator;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ConfirmationPrompt - 权限确认组件
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React, { useState } from 'react';
|
|
8
|
-
import { Box, Text, useInput } from 'ink';
|
|
9
|
-
import { themeManager } from '../../themes/index.js';
|
|
10
|
-
import { FocusId, focusManager, useIsFocused } from '../../focus/index.js';
|
|
11
|
-
import type { ConfirmationDetails, ConfirmationResponse } from '../../../agent/types.js';
|
|
12
|
-
|
|
13
|
-
interface ConfirmationPromptProps {
|
|
14
|
-
details: ConfirmationDetails;
|
|
15
|
-
onResponse: (response: ConfirmationResponse) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const ConfirmationPrompt: React.FC<ConfirmationPromptProps> = ({
|
|
19
|
-
details,
|
|
20
|
-
onResponse,
|
|
21
|
-
}) => {
|
|
22
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
23
|
-
const theme = themeManager.getTheme();
|
|
24
|
-
const isFocused = useIsFocused(FocusId.CONFIRMATION_PROMPT);
|
|
25
|
-
|
|
26
|
-
const options = [
|
|
27
|
-
{ key: 'y', label: 'allow', scope: 'once' as const, approved: true },
|
|
28
|
-
{ key: 'a', label: 'always', scope: 'session' as const, approved: true },
|
|
29
|
-
{ key: 'n', label: 'deny', scope: 'once' as const, approved: false },
|
|
30
|
-
{ key: 'd', label: 'never', scope: 'session' as const, approved: false },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
useInput((input, key) => {
|
|
34
|
-
if (key.upArrow) {
|
|
35
|
-
setSelectedIndex(prev => (prev > 0 ? prev - 1 : options.length - 1));
|
|
36
|
-
} else if (key.downArrow) {
|
|
37
|
-
setSelectedIndex(prev => (prev < options.length - 1 ? prev + 1 : 0));
|
|
38
|
-
} else if (key.return) {
|
|
39
|
-
const sel = options[selectedIndex];
|
|
40
|
-
onResponse({ approved: sel.approved, scope: sel.scope, reason: sel.approved ? undefined : 'denied' });
|
|
41
|
-
} else if (input === 'y' || input === 'Y') {
|
|
42
|
-
onResponse({ approved: true, scope: 'once' });
|
|
43
|
-
} else if (input === 'a' || input === 'A') {
|
|
44
|
-
onResponse({ approved: true, scope: 'session' });
|
|
45
|
-
} else if (input === 'n' || input === 'N') {
|
|
46
|
-
onResponse({ approved: false, scope: 'once', reason: 'denied' });
|
|
47
|
-
} else if (input === 'd' || input === 'D') {
|
|
48
|
-
onResponse({ approved: false, scope: 'session', reason: 'denied for this session' });
|
|
49
|
-
}
|
|
50
|
-
}, { isActive: isFocused });
|
|
51
|
-
|
|
52
|
-
// Extract tool name from title (e.g. "Permission Required: Bash" -> "Bash")
|
|
53
|
-
const toolName = details.title.replace(/^.*:\s*/, '');
|
|
54
|
-
|
|
55
|
-
// Skip showing the tool name header for tools where the label+highlight is self-explanatory
|
|
56
|
-
const hideHeader = ['Bash', 'Shell'].includes(toolName) && details.details?.includes('**Command:**');
|
|
57
|
-
|
|
58
|
-
// Extract the primary content to highlight (command, file path, etc.)
|
|
59
|
-
const { label, highlight, extra } = extractHighlight(details.details);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<Box flexDirection="column" paddingX={1}>
|
|
63
|
-
{/* Header: tool name + reason (skipped for bash/shell when command is shown) */}
|
|
64
|
-
{!hideHeader && (
|
|
65
|
-
<Box>
|
|
66
|
-
<Text color={theme.colors.warning} bold>? </Text>
|
|
67
|
-
<Text bold>{toolName}</Text>
|
|
68
|
-
{details.message && details.message !== details.title && (
|
|
69
|
-
<Text color={theme.colors.text.muted} dimColor> · {details.message}</Text>
|
|
70
|
-
)}
|
|
71
|
-
</Box>
|
|
72
|
-
)}
|
|
73
|
-
|
|
74
|
-
{/* When header is hidden (Bash/Shell), show "? Command: <cmd>" on one line */}
|
|
75
|
-
{hideHeader && highlight && (
|
|
76
|
-
<Box>
|
|
77
|
-
<Text color={theme.colors.warning} bold>? </Text>
|
|
78
|
-
{label && <Text color={theme.colors.text.muted} dimColor>{label} </Text>}
|
|
79
|
-
<Text color={theme.colors.accent} wrap="wrap">{highlight}</Text>
|
|
80
|
-
</Box>
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
{/* Highlighted content (command / file path) — only when header is shown */}
|
|
84
|
-
{!hideHeader && highlight && (
|
|
85
|
-
<Box marginLeft={2}>
|
|
86
|
-
{label && <Text color={theme.colors.text.muted} dimColor>{label} </Text>}
|
|
87
|
-
<Text color={theme.colors.accent} wrap="wrap">{highlight}</Text>
|
|
88
|
-
</Box>
|
|
89
|
-
)}
|
|
90
|
-
|
|
91
|
-
{/* Extra detail lines (e.g. directory, content preview) */}
|
|
92
|
-
{extra.length > 0 && (
|
|
93
|
-
<Box flexDirection="column" marginLeft={2}>
|
|
94
|
-
{extra.map((line, i) => (
|
|
95
|
-
<Text key={i} color={theme.colors.text.muted} dimColor wrap="wrap">
|
|
96
|
-
{line}
|
|
97
|
-
</Text>
|
|
98
|
-
))}
|
|
99
|
-
</Box>
|
|
100
|
-
)}
|
|
101
|
-
|
|
102
|
-
{/* Affected files */}
|
|
103
|
-
{details.affectedFiles && details.affectedFiles.length > 0 && (
|
|
104
|
-
<Box marginLeft={2}>
|
|
105
|
-
<Text color={theme.colors.info} dimColor>
|
|
106
|
-
{details.affectedFiles.join(', ')}
|
|
107
|
-
</Text>
|
|
108
|
-
</Box>
|
|
109
|
-
)}
|
|
110
|
-
|
|
111
|
-
{/* Risks - single line */}
|
|
112
|
-
{details.risks && details.risks.length > 0 && (
|
|
113
|
-
<Box marginLeft={2}>
|
|
114
|
-
<Text color={theme.colors.text.muted} dimColor>
|
|
115
|
-
{details.risks.join(' · ')}
|
|
116
|
-
</Text>
|
|
117
|
-
</Box>
|
|
118
|
-
)}
|
|
119
|
-
|
|
120
|
-
{/* Options - vertical, up/down selection */}
|
|
121
|
-
<Box flexDirection="column" marginLeft={2} marginTop={1}>
|
|
122
|
-
{options.map((opt, i) => {
|
|
123
|
-
const active = i === selectedIndex;
|
|
124
|
-
return (
|
|
125
|
-
<Box key={opt.key}>
|
|
126
|
-
<Text
|
|
127
|
-
color={active ? theme.colors.success : theme.colors.text.muted}
|
|
128
|
-
bold={active}
|
|
129
|
-
dimColor={!active}
|
|
130
|
-
>
|
|
131
|
-
{active ? '> ' : ' '}
|
|
132
|
-
{opt.label}
|
|
133
|
-
</Text>
|
|
134
|
-
<Text color={theme.colors.text.muted} dimColor> ({opt.key})</Text>
|
|
135
|
-
</Box>
|
|
136
|
-
);
|
|
137
|
-
})}
|
|
138
|
-
</Box>
|
|
139
|
-
</Box>
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*/
|
|
147
|
-
function extractHighlight(details?: string): { label: string; highlight: string; extra: string[] } {
|
|
148
|
-
if (!details) return { label: '', highlight: '', extra: [] };
|
|
149
|
-
|
|
150
|
-
const strip = (s: string) =>
|
|
151
|
-
s.replace(/\*\*(.+?)\*\*/g, '$1').replace(/`([^`]+)`/g, '$1').trim();
|
|
152
|
-
|
|
153
|
-
const lines = details.split('\n').filter(l => l.trim());
|
|
154
|
-
let label = '';
|
|
155
|
-
let highlight = '';
|
|
156
|
-
const highlightLines: string[] = [];
|
|
157
|
-
const extra: string[] = [];
|
|
158
|
-
let inHighlight = false;
|
|
159
|
-
|
|
160
|
-
const KNOWN_PREFIX = /^(Command|File|Directory|Content Preview|Before|After):\s*/;
|
|
161
|
-
|
|
162
|
-
for (const raw of lines) {
|
|
163
|
-
const line = strip(raw);
|
|
164
|
-
if (line === '```' || line.startsWith('```')) {
|
|
165
|
-
// skip code fences
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
if (/^Command:\s*/.test(line)) {
|
|
169
|
-
label = 'Command:';
|
|
170
|
-
highlightLines.push(line.replace(/^Command:\s*/, ''));
|
|
171
|
-
inHighlight = true;
|
|
172
|
-
} else if (/^File:\s*/.test(line)) {
|
|
173
|
-
label = 'File:';
|
|
174
|
-
highlightLines.push(line.replace(/^File:\s*/, ''));
|
|
175
|
-
inHighlight = true;
|
|
176
|
-
} else if (/^(Directory|Content Preview|Before|After):\s*/.test(line)) {
|
|
177
|
-
inHighlight = false;
|
|
178
|
-
extra.push(line);
|
|
179
|
-
} else if (inHighlight) {
|
|
180
|
-
// Continuation of a multi-line Command/File value — keep it part of the
|
|
181
|
-
// highlight instead of dropping it into the unrelated "extra" lines, or
|
|
182
|
-
// multi-line bash commands get silently truncated to their first line.
|
|
183
|
-
highlightLines.push(line);
|
|
184
|
-
} else if (line) {
|
|
185
|
-
extra.push(line);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
highlight = highlightLines.join('\n');
|
|
190
|
-
|
|
191
|
-
return { label, highlight, extra };
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*/
|
|
198
|
-
export function createAutoConfirmationHandler(
|
|
199
|
-
mode: 'approve' | 'deny' | 'approve_session' = 'deny'
|
|
200
|
-
): (details: ConfirmationDetails) => Promise<ConfirmationResponse> {
|
|
201
|
-
return async () => ({
|
|
202
|
-
approved: mode.startsWith('approve'),
|
|
203
|
-
scope: mode === 'approve_session' ? 'session' : 'once',
|
|
204
|
-
reason: `Auto-${mode} by non-interactive mode`,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export default ConfirmationPrompt;
|