tabby-ai-assistant 1.0.9 → 1.0.11
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/index.js +1 -1
- package/package.json +3 -3
- package/src/components/chat/ai-sidebar.component.scss +43 -0
- package/src/components/chat/ai-sidebar.component.ts +43 -1
- package/src/components/settings/ai-settings-tab.component.html +13 -5
- package/src/components/settings/ai-settings-tab.component.scss +164 -33
- package/src/components/settings/ai-settings-tab.component.ts +1 -0
- package/src/components/settings/context-settings.component.html +87 -0
- package/src/components/settings/context-settings.component.scss +133 -0
- package/src/components/settings/context-settings.component.ts +91 -0
- package/src/components/settings/provider-config.component.html +46 -12
- package/src/components/settings/provider-config.component.scss +59 -0
- package/src/components/settings/provider-config.component.ts +112 -15
- package/src/i18n/translations/en-US.ts +27 -1
- package/src/i18n/translations/ja-JP.ts +27 -1
- package/src/i18n/translations/zh-CN.ts +27 -1
- package/src/i18n/types.ts +28 -0
- package/src/index.ts +6 -0
- package/src/services/chat/chat-session.service.ts +91 -2
- package/src/services/context/manager.ts +33 -2
- package/src/services/core/ai-assistant.service.ts +35 -11
- package/src/services/core/config-provider.service.ts +66 -0
- package/src/services/core/toast.service.ts +36 -0
- package/src/services/providers/anthropic-provider.service.ts +12 -4
- package/src/services/providers/glm-provider.service.ts +12 -4
- package/src/services/providers/minimax-provider.service.ts +12 -4
- package/src/types/ai.types.ts +3 -3
- package/src/types/provider.types.ts +1 -0
- package/dist/components/chat/ai-sidebar.component.d.ts +0 -160
- package/dist/components/chat/chat-input.component.d.ts +0 -69
- package/dist/components/chat/chat-interface.component.d.ts +0 -124
- package/dist/components/chat/chat-message.component.d.ts +0 -53
- package/dist/components/chat/chat-settings.component.d.ts +0 -72
- package/dist/components/common/error-message.component.d.ts +0 -11
- package/dist/components/common/loading-spinner.component.d.ts +0 -4
- package/dist/components/security/consent-dialog.component.d.ts +0 -11
- package/dist/components/security/password-prompt.component.d.ts +0 -10
- package/dist/components/security/risk-confirm-dialog.component.d.ts +0 -36
- package/dist/components/settings/ai-settings-tab.component.d.ts +0 -82
- package/dist/components/settings/general-settings.component.d.ts +0 -94
- package/dist/components/settings/provider-config.component.d.ts +0 -273
- package/dist/components/settings/security-settings.component.d.ts +0 -33
- package/dist/components/terminal/ai-toolbar-button.component.d.ts +0 -10
- package/dist/components/terminal/command-preview.component.d.ts +0 -53
- package/dist/components/terminal/command-suggestion.component.d.ts +0 -16
- package/dist/i18n/index.d.ts +0 -48
- package/dist/i18n/translations/en-US.d.ts +0 -5
- package/dist/i18n/translations/ja-JP.d.ts +0 -5
- package/dist/i18n/translations/zh-CN.d.ts +0 -5
- package/dist/i18n/types.d.ts +0 -198
- package/dist/index-full.d.ts +0 -8
- package/dist/index-minimal.d.ts +0 -3
- package/dist/index.d.ts +0 -12
- package/dist/main.d.ts +0 -8
- package/dist/providers/tabby/ai-config.provider.d.ts +0 -70
- package/dist/providers/tabby/ai-hotkey.provider.d.ts +0 -15
- package/dist/providers/tabby/ai-settings-tab.provider.d.ts +0 -11
- package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +0 -16
- package/dist/services/chat/ai-sidebar.service.d.ts +0 -111
- package/dist/services/chat/chat-history.service.d.ts +0 -145
- package/dist/services/chat/chat-session.service.d.ts +0 -113
- package/dist/services/chat/command-generator.service.d.ts +0 -49
- package/dist/services/context/compaction.d.ts +0 -90
- package/dist/services/context/manager.d.ts +0 -69
- package/dist/services/context/memory.d.ts +0 -116
- package/dist/services/context/token-budget.d.ts +0 -105
- package/dist/services/core/ai-assistant.service.d.ts +0 -127
- package/dist/services/core/ai-provider-manager.service.d.ts +0 -119
- package/dist/services/core/checkpoint.service.d.ts +0 -130
- package/dist/services/core/config-provider.service.d.ts +0 -137
- package/dist/services/core/logger.service.d.ts +0 -21
- package/dist/services/core/theme.service.d.ts +0 -53
- package/dist/services/platform/escape-sequence.service.d.ts +0 -132
- package/dist/services/platform/platform-detection.service.d.ts +0 -146
- package/dist/services/providers/anthropic-provider.service.d.ts +0 -44
- package/dist/services/providers/base-provider.service.d.ts +0 -142
- package/dist/services/providers/glm-provider.service.d.ts +0 -96
- package/dist/services/providers/minimax-provider.service.d.ts +0 -102
- package/dist/services/providers/ollama-provider.service.d.ts +0 -76
- package/dist/services/providers/openai-compatible.service.d.ts +0 -44
- package/dist/services/providers/openai-provider.service.d.ts +0 -43
- package/dist/services/providers/vllm-provider.service.d.ts +0 -82
- package/dist/services/security/consent-manager.service.d.ts +0 -65
- package/dist/services/security/password-manager.service.d.ts +0 -67
- package/dist/services/security/risk-assessment.service.d.ts +0 -65
- package/dist/services/security/security-validator.service.d.ts +0 -36
- package/dist/services/terminal/buffer-analyzer.service.d.ts +0 -128
- package/dist/services/terminal/command-analyzer.service.d.ts +0 -20
- package/dist/services/terminal/context-menu.service.d.ts +0 -24
- package/dist/services/terminal/hotkey.service.d.ts +0 -28
- package/dist/services/terminal/terminal-context.service.d.ts +0 -100
- package/dist/services/terminal/terminal-manager.service.d.ts +0 -185
- package/dist/services/terminal/terminal-tools.service.d.ts +0 -79
- package/dist/types/ai.types.d.ts +0 -199
- package/dist/types/provider.types.d.ts +0 -105
- package/dist/types/security.types.d.ts +0 -85
- package/dist/types/terminal.types.d.ts +0 -150
- package/dist/utils/encryption.utils.d.ts +0 -83
- package/dist/utils/formatting.utils.d.ts +0 -106
- package/dist/utils/validation.utils.d.ts +0 -83
- package/jest.config.js +0 -47
- package/webpack-docker.config.js +0 -42
- package/webpack.config.js +0 -81
package/dist/i18n/types.d.ts
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 翻译键类型定义
|
|
3
|
-
*/
|
|
4
|
-
export interface CommonTranslations {
|
|
5
|
-
save: string;
|
|
6
|
-
cancel: string;
|
|
7
|
-
delete: string;
|
|
8
|
-
confirm: string;
|
|
9
|
-
enabled: string;
|
|
10
|
-
disabled: string;
|
|
11
|
-
online: string;
|
|
12
|
-
offline: string;
|
|
13
|
-
testing: string;
|
|
14
|
-
error: string;
|
|
15
|
-
success: string;
|
|
16
|
-
notConfigured: string;
|
|
17
|
-
add: string;
|
|
18
|
-
remove: string;
|
|
19
|
-
close: string;
|
|
20
|
-
yes: string;
|
|
21
|
-
no: string;
|
|
22
|
-
reset: string;
|
|
23
|
-
default: string;
|
|
24
|
-
today: string;
|
|
25
|
-
}
|
|
26
|
-
export interface SettingsTranslations {
|
|
27
|
-
title: string;
|
|
28
|
-
generalTab: string;
|
|
29
|
-
providersTab: string;
|
|
30
|
-
securityTab: string;
|
|
31
|
-
chatTab: string;
|
|
32
|
-
advancedTab: string;
|
|
33
|
-
}
|
|
34
|
-
export interface GeneralTranslations {
|
|
35
|
-
title: string;
|
|
36
|
-
enableAssistant: string;
|
|
37
|
-
enableAssistantDesc: string;
|
|
38
|
-
defaultProvider: string;
|
|
39
|
-
providerCount: string;
|
|
40
|
-
language: string;
|
|
41
|
-
theme: string;
|
|
42
|
-
themeAuto: string;
|
|
43
|
-
themeLight: string;
|
|
44
|
-
themeDark: string;
|
|
45
|
-
themePixel: string;
|
|
46
|
-
themeTech: string;
|
|
47
|
-
shortcuts: string;
|
|
48
|
-
shortcutOpenChat: string;
|
|
49
|
-
shortcutOpenChatDesc: string;
|
|
50
|
-
shortcutGenerate: string;
|
|
51
|
-
shortcutGenerateDesc: string;
|
|
52
|
-
shortcutExplain: string;
|
|
53
|
-
shortcutExplainDesc: string;
|
|
54
|
-
shortcutTip: string;
|
|
55
|
-
}
|
|
56
|
-
export interface ChatSettingsTranslations {
|
|
57
|
-
title: string;
|
|
58
|
-
appearance: string;
|
|
59
|
-
theme: string;
|
|
60
|
-
fontSize: string;
|
|
61
|
-
compactMode: string;
|
|
62
|
-
compactModeDesc: string;
|
|
63
|
-
behavior: string;
|
|
64
|
-
enterToSend: string;
|
|
65
|
-
enterToSendDesc: string;
|
|
66
|
-
showTimestamps: string;
|
|
67
|
-
showTimestampsDesc: string;
|
|
68
|
-
showAvatars: string;
|
|
69
|
-
showAvatarsDesc: string;
|
|
70
|
-
soundEnabled: string;
|
|
71
|
-
soundEnabledDesc: string;
|
|
72
|
-
history: string;
|
|
73
|
-
enableHistory: string;
|
|
74
|
-
enableHistoryDesc: string;
|
|
75
|
-
maxHistory: string;
|
|
76
|
-
maxHistoryUnit: string;
|
|
77
|
-
autoSave: string;
|
|
78
|
-
autoSaveDesc: string;
|
|
79
|
-
exportSettings: string;
|
|
80
|
-
clearHistory: string;
|
|
81
|
-
resetDefaults: string;
|
|
82
|
-
clearHistoryConfirm: string;
|
|
83
|
-
resetConfirm: string;
|
|
84
|
-
}
|
|
85
|
-
export interface SecurityTranslations {
|
|
86
|
-
title: string;
|
|
87
|
-
accessControl: string;
|
|
88
|
-
passwordProtection: string;
|
|
89
|
-
passwordProtectionDesc: string;
|
|
90
|
-
setPassword: string;
|
|
91
|
-
passwordPlaceholder: string;
|
|
92
|
-
riskAssessment: string;
|
|
93
|
-
riskAssessmentDesc: string;
|
|
94
|
-
defaultRiskLevel: string;
|
|
95
|
-
riskLow: string;
|
|
96
|
-
riskMedium: string;
|
|
97
|
-
riskHigh: string;
|
|
98
|
-
userConsent: string;
|
|
99
|
-
rememberConsent: string;
|
|
100
|
-
rememberConsentDesc: string;
|
|
101
|
-
consentExpiryDays: string;
|
|
102
|
-
dangerousPatterns: string;
|
|
103
|
-
addPattern: string;
|
|
104
|
-
patternPlaceholder: string;
|
|
105
|
-
saveSettings: string;
|
|
106
|
-
resetDefaults: string;
|
|
107
|
-
resetConfirm: string;
|
|
108
|
-
}
|
|
109
|
-
export interface ProvidersTranslations {
|
|
110
|
-
title: string;
|
|
111
|
-
cloudProviders: string;
|
|
112
|
-
cloudProvidersDesc: string;
|
|
113
|
-
localProviders: string;
|
|
114
|
-
localProvidersDesc: string;
|
|
115
|
-
configured: string;
|
|
116
|
-
displayName: string;
|
|
117
|
-
status: string;
|
|
118
|
-
apiKey: string;
|
|
119
|
-
baseURL: string;
|
|
120
|
-
model: string;
|
|
121
|
-
saveConfig: string;
|
|
122
|
-
testConnection: string;
|
|
123
|
-
detectService: string;
|
|
124
|
-
delete: string;
|
|
125
|
-
deleteConfirm: string;
|
|
126
|
-
testSuccess: string;
|
|
127
|
-
testFail: string;
|
|
128
|
-
testError: string;
|
|
129
|
-
configSaved: string;
|
|
130
|
-
configDeleted: string;
|
|
131
|
-
}
|
|
132
|
-
export interface ProviderNamesTranslations {
|
|
133
|
-
openai: string;
|
|
134
|
-
anthropic: string;
|
|
135
|
-
minimax: string;
|
|
136
|
-
glm: string;
|
|
137
|
-
openaiCompatible: string;
|
|
138
|
-
ollama: string;
|
|
139
|
-
vllm: string;
|
|
140
|
-
}
|
|
141
|
-
export interface ChatInterfaceTranslations {
|
|
142
|
-
title: string;
|
|
143
|
-
welcomeMessage: string;
|
|
144
|
-
inputPlaceholder: string;
|
|
145
|
-
thinking: string;
|
|
146
|
-
executingTool: string;
|
|
147
|
-
toolComplete: string;
|
|
148
|
-
errorPrefix: string;
|
|
149
|
-
tipCommand: string;
|
|
150
|
-
tipShortcut: string;
|
|
151
|
-
clearChat: string;
|
|
152
|
-
clearChatConfirm: string;
|
|
153
|
-
exportChat: string;
|
|
154
|
-
switchProvider: string;
|
|
155
|
-
providerBadge: string;
|
|
156
|
-
}
|
|
157
|
-
export interface RiskLevelTranslations {
|
|
158
|
-
low: string;
|
|
159
|
-
medium: string;
|
|
160
|
-
high: string;
|
|
161
|
-
unknown: string;
|
|
162
|
-
}
|
|
163
|
-
export interface AdvancedSettingsTranslations {
|
|
164
|
-
title: string;
|
|
165
|
-
configManagement: string;
|
|
166
|
-
validateConfig: string;
|
|
167
|
-
resetDefaults: string;
|
|
168
|
-
logSettings: string;
|
|
169
|
-
logLevel: string;
|
|
170
|
-
logLevels: {
|
|
171
|
-
debug: string;
|
|
172
|
-
info: string;
|
|
173
|
-
warn: string;
|
|
174
|
-
error: string;
|
|
175
|
-
};
|
|
176
|
-
systemInfo: string;
|
|
177
|
-
pluginVersion: string;
|
|
178
|
-
supportedProviders: string;
|
|
179
|
-
currentProvider: string;
|
|
180
|
-
}
|
|
181
|
-
export interface TranslationKeys {
|
|
182
|
-
common: CommonTranslations;
|
|
183
|
-
settings: SettingsTranslations;
|
|
184
|
-
general: GeneralTranslations;
|
|
185
|
-
chatSettings: ChatSettingsTranslations;
|
|
186
|
-
security: SecurityTranslations;
|
|
187
|
-
providers: ProvidersTranslations;
|
|
188
|
-
providerNames: ProviderNamesTranslations;
|
|
189
|
-
chatInterface: ChatInterfaceTranslations;
|
|
190
|
-
riskLevel: RiskLevelTranslations;
|
|
191
|
-
advancedSettings: AdvancedSettingsTranslations;
|
|
192
|
-
}
|
|
193
|
-
export type SupportedLanguage = 'zh-CN' | 'en-US' | 'ja-JP';
|
|
194
|
-
export interface LanguageConfig {
|
|
195
|
-
code: SupportedLanguage;
|
|
196
|
-
label: string;
|
|
197
|
-
flag: string;
|
|
198
|
-
}
|
package/dist/index-full.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AiAssistantService } from './services/core/ai-assistant.service';
|
|
2
|
-
import { ConfigProviderService } from './services/core/config-provider.service';
|
|
3
|
-
export default class AiAssistantModule {
|
|
4
|
-
private app;
|
|
5
|
-
private aiService;
|
|
6
|
-
private config;
|
|
7
|
-
constructor(app: any, aiService: AiAssistantService, config: ConfigProviderService);
|
|
8
|
-
}
|
package/dist/index-minimal.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import './styles/ai-assistant.scss';
|
|
2
|
-
import { AppService, ConfigService, HotkeysService } from 'tabby-core';
|
|
3
|
-
import { AiAssistantService } from './services/core/ai-assistant.service';
|
|
4
|
-
import { AiSidebarService } from './services/chat/ai-sidebar.service';
|
|
5
|
-
export default class AiAssistantModule {
|
|
6
|
-
private app;
|
|
7
|
-
private config;
|
|
8
|
-
private aiService;
|
|
9
|
-
private sidebarService;
|
|
10
|
-
constructor(app: AppService, config: ConfigService, aiService: AiAssistantService, sidebarService: AiSidebarService, hotkeys: HotkeysService);
|
|
11
|
-
}
|
|
12
|
-
export declare const forRoot: () => typeof AiAssistantModule;
|
package/dist/main.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tabby AI Assistant Plugin - Main Entry Point
|
|
3
|
-
*
|
|
4
|
-
* This file serves as the main entry point for the Tabby AI Assistant plugin.
|
|
5
|
-
* It initializes the Angular module and integrates with Tabby's plugin system.
|
|
6
|
-
*/
|
|
7
|
-
import AiAssistantModule from './index';
|
|
8
|
-
export default AiAssistantModule;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ConfigProvider } from 'tabby-core';
|
|
2
|
-
import { ConfigProviderService } from '../../services/core/config-provider.service';
|
|
3
|
-
/**
|
|
4
|
-
* Tabby配置提供者
|
|
5
|
-
* 为Tabby提供AI助手配置管理
|
|
6
|
-
*/
|
|
7
|
-
export declare class AiConfigProvider extends ConfigProvider {
|
|
8
|
-
private configService;
|
|
9
|
-
/**
|
|
10
|
-
* 默认配置
|
|
11
|
-
*/
|
|
12
|
-
defaults: {
|
|
13
|
-
hotkeys: {
|
|
14
|
-
'ai-assistant-toggle': string[];
|
|
15
|
-
'ai-command-generation': string[];
|
|
16
|
-
'ai-explain-command': string[];
|
|
17
|
-
};
|
|
18
|
-
aiAssistant: {
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
defaultProvider: string;
|
|
21
|
-
autoSuggestCommands: boolean;
|
|
22
|
-
enableSecurityChecks: boolean;
|
|
23
|
-
providers: {
|
|
24
|
-
openai: {
|
|
25
|
-
apiKey: string;
|
|
26
|
-
model: string;
|
|
27
|
-
baseURL: string;
|
|
28
|
-
};
|
|
29
|
-
anthropic: {
|
|
30
|
-
apiKey: string;
|
|
31
|
-
model: string;
|
|
32
|
-
baseURL: string;
|
|
33
|
-
};
|
|
34
|
-
minimax: {
|
|
35
|
-
apiKey: string;
|
|
36
|
-
model: string;
|
|
37
|
-
baseURL: string;
|
|
38
|
-
};
|
|
39
|
-
glm: {
|
|
40
|
-
apiKey: string;
|
|
41
|
-
model: string;
|
|
42
|
-
baseURL: string;
|
|
43
|
-
};
|
|
44
|
-
openaiCompatible: {
|
|
45
|
-
apiKey: string;
|
|
46
|
-
model: string;
|
|
47
|
-
baseURL: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
security: {
|
|
51
|
-
passwordProtection: boolean;
|
|
52
|
-
riskAssessmentLevel: string;
|
|
53
|
-
consentPersistenceDays: number;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* 平台特定默认配置
|
|
59
|
-
*/
|
|
60
|
-
platformDefaults: {
|
|
61
|
-
macOS: {
|
|
62
|
-
hotkeys: {
|
|
63
|
-
'ai-assistant-toggle': string[];
|
|
64
|
-
'ai-command-generation': string[];
|
|
65
|
-
'ai-explain-command': string[];
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
constructor(configService: ConfigProviderService);
|
|
70
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { HotkeyProvider, HotkeyDescription, TranslateService } from 'tabby-core';
|
|
2
|
-
import { AiSidebarService } from '../../services/chat/ai-sidebar.service';
|
|
3
|
-
/**
|
|
4
|
-
* Tabby热键提供者
|
|
5
|
-
* 为Tabby添加AI助手热键支持
|
|
6
|
-
*
|
|
7
|
-
* 注意:热键 ID 必须与 AiConfigProvider.defaults.hotkeys 中定义的一致
|
|
8
|
-
*/
|
|
9
|
-
export declare class AiHotkeyProvider extends HotkeyProvider {
|
|
10
|
-
private sidebarService;
|
|
11
|
-
private translate;
|
|
12
|
-
hotkeys: HotkeyDescription[];
|
|
13
|
-
constructor(sidebarService: AiSidebarService, translate: TranslateService);
|
|
14
|
-
provide(): Promise<HotkeyDescription[]>;
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ToolbarButtonProvider, ToolbarButton, AppService } from 'tabby-core';
|
|
2
|
-
import { AiSidebarService } from '../../services/chat/ai-sidebar.service';
|
|
3
|
-
/**
|
|
4
|
-
* Tabby工具栏按钮提供者
|
|
5
|
-
* 为Tabby工具栏添加AI助手按钮,使用侧边栏方式
|
|
6
|
-
*/
|
|
7
|
-
export declare class AiToolbarButtonProvider extends ToolbarButtonProvider {
|
|
8
|
-
private app;
|
|
9
|
-
private sidebarService;
|
|
10
|
-
constructor(app: AppService, sidebarService: AiSidebarService);
|
|
11
|
-
provide(): ToolbarButton[];
|
|
12
|
-
/**
|
|
13
|
-
* 打开设置页面
|
|
14
|
-
*/
|
|
15
|
-
private openSettings;
|
|
16
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { ComponentFactoryResolver, ApplicationRef, Injector } from '@angular/core';
|
|
2
|
-
import { ConfigService } from 'tabby-core';
|
|
3
|
-
/**
|
|
4
|
-
* AI Sidebar 配置接口
|
|
5
|
-
*/
|
|
6
|
-
export interface AiSidebarConfig {
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
position?: 'left' | 'right';
|
|
9
|
-
showInToolbar?: boolean;
|
|
10
|
-
sidebarVisible?: boolean;
|
|
11
|
-
sidebarCollapsed?: boolean;
|
|
12
|
-
sidebarWidth?: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* AI Sidebar 服务 - 管理 AI 聊天侧边栏的生命周期
|
|
16
|
-
*
|
|
17
|
-
* 采用 Flexbox 布局方式,将 sidebar 插入到 app-root 作为第一个子元素,
|
|
18
|
-
* app-root 变为水平 flex 容器,sidebar 在左侧
|
|
19
|
-
*/
|
|
20
|
-
export declare class AiSidebarService {
|
|
21
|
-
private componentFactoryResolver;
|
|
22
|
-
private appRef;
|
|
23
|
-
private injector;
|
|
24
|
-
private config;
|
|
25
|
-
private sidebarComponentRef;
|
|
26
|
-
private sidebarElement;
|
|
27
|
-
private styleElement;
|
|
28
|
-
private resizeHandle;
|
|
29
|
-
private _isVisible;
|
|
30
|
-
private readonly MIN_WIDTH;
|
|
31
|
-
private readonly MAX_WIDTH;
|
|
32
|
-
private readonly DEFAULT_WIDTH;
|
|
33
|
-
private currentWidth;
|
|
34
|
-
private isResizing;
|
|
35
|
-
/**
|
|
36
|
-
* 侧边栏是否可见
|
|
37
|
-
*/
|
|
38
|
-
get sidebarVisible(): boolean;
|
|
39
|
-
constructor(componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, injector: Injector, config: ConfigService);
|
|
40
|
-
/**
|
|
41
|
-
* 显示 sidebar
|
|
42
|
-
*/
|
|
43
|
-
show(): void;
|
|
44
|
-
/**
|
|
45
|
-
* 隐藏 sidebar
|
|
46
|
-
*/
|
|
47
|
-
hide(): void;
|
|
48
|
-
/**
|
|
49
|
-
* 切换 sidebar 显示状态
|
|
50
|
-
*/
|
|
51
|
-
toggle(): void;
|
|
52
|
-
/**
|
|
53
|
-
* 获取当前显示状态
|
|
54
|
-
*/
|
|
55
|
-
get visible(): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* 初始化 - 应用启动时调用
|
|
58
|
-
*/
|
|
59
|
-
initialize(): void;
|
|
60
|
-
/**
|
|
61
|
-
* 创建 sidebar 组件
|
|
62
|
-
*
|
|
63
|
-
* 使用固定定位方案:
|
|
64
|
-
* 1. 侧边栏 position: fixed,固定在左侧
|
|
65
|
-
* 2. 主内容区通过 margin-left 推开
|
|
66
|
-
* 这样不改变任何现有元素的 flex 布局
|
|
67
|
-
*/
|
|
68
|
-
private createSidebar;
|
|
69
|
-
/**
|
|
70
|
-
* 销毁 sidebar 组件
|
|
71
|
-
*/
|
|
72
|
-
private destroySidebar;
|
|
73
|
-
/**
|
|
74
|
-
* 调整 .content 元素样式 - 只处理第二个(更深层的).content
|
|
75
|
-
*/
|
|
76
|
-
private adjustContentStyles;
|
|
77
|
-
/**
|
|
78
|
-
* 注入布局 CSS - 使用 margin-left 把主内容推开
|
|
79
|
-
*
|
|
80
|
-
* 固定定位方案:侧边栏 fixed,主内容区 margin-left
|
|
81
|
-
*/
|
|
82
|
-
private injectLayoutCSS;
|
|
83
|
-
/**
|
|
84
|
-
* 移除布局 CSS
|
|
85
|
-
*/
|
|
86
|
-
private removeLayoutCSS;
|
|
87
|
-
/**
|
|
88
|
-
* 设置 resize handle 拖动逻辑
|
|
89
|
-
*/
|
|
90
|
-
private setupResizeHandler;
|
|
91
|
-
/**
|
|
92
|
-
* 更新布局 CSS(resize 时调用)
|
|
93
|
-
*/
|
|
94
|
-
private updateLayoutCSS;
|
|
95
|
-
/**
|
|
96
|
-
* 加载保存的侧边栏宽度
|
|
97
|
-
*/
|
|
98
|
-
private loadSidebarWidth;
|
|
99
|
-
/**
|
|
100
|
-
* 保存侧边栏宽度到配置
|
|
101
|
-
*/
|
|
102
|
-
private saveSidebarWidth;
|
|
103
|
-
/**
|
|
104
|
-
* 获取插件配置
|
|
105
|
-
*/
|
|
106
|
-
private getPluginConfig;
|
|
107
|
-
/**
|
|
108
|
-
* 保存插件配置
|
|
109
|
-
*/
|
|
110
|
-
private savePluginConfig;
|
|
111
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { ChatMessage } from '../../types/ai.types';
|
|
3
|
-
import { LoggerService } from '../core/logger.service';
|
|
4
|
-
export interface SavedSession {
|
|
5
|
-
sessionId: string;
|
|
6
|
-
title: string;
|
|
7
|
-
messages: ChatMessage[];
|
|
8
|
-
createdAt: Date;
|
|
9
|
-
updatedAt: Date;
|
|
10
|
-
messageCount: number;
|
|
11
|
-
contextInfo?: {
|
|
12
|
-
tokenUsage?: {
|
|
13
|
-
input: number;
|
|
14
|
-
output: number;
|
|
15
|
-
cacheRead: number;
|
|
16
|
-
cacheWrite: number;
|
|
17
|
-
};
|
|
18
|
-
compactionHistory?: Array<{
|
|
19
|
-
timestamp: Date;
|
|
20
|
-
type: 'prune' | 'compact' | 'truncate';
|
|
21
|
-
tokensSaved: number;
|
|
22
|
-
condenseId?: string;
|
|
23
|
-
}>;
|
|
24
|
-
hasCompression?: boolean;
|
|
25
|
-
lastCompactionAt?: Date;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 聊天历史服务
|
|
30
|
-
* 持久化存储和管理聊天会话历史
|
|
31
|
-
*/
|
|
32
|
-
export declare class ChatHistoryService {
|
|
33
|
-
private logger;
|
|
34
|
-
private sessionsSubject;
|
|
35
|
-
sessions$: Observable<SavedSession[]>;
|
|
36
|
-
constructor(logger: LoggerService);
|
|
37
|
-
/**
|
|
38
|
-
* 保存会话
|
|
39
|
-
*/
|
|
40
|
-
saveSession(sessionId: string, messages: ChatMessage[], title?: string): void;
|
|
41
|
-
/**
|
|
42
|
-
* 加载会话
|
|
43
|
-
*/
|
|
44
|
-
loadSession(sessionId: string): SavedSession | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* 删除会话
|
|
47
|
-
*/
|
|
48
|
-
deleteSession(sessionId: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* 清空所有历史
|
|
51
|
-
*/
|
|
52
|
-
clearAllHistory(): void;
|
|
53
|
-
/**
|
|
54
|
-
* 搜索会话
|
|
55
|
-
*/
|
|
56
|
-
searchSessions(query: string): SavedSession[];
|
|
57
|
-
/**
|
|
58
|
-
* 获取最近的会话
|
|
59
|
-
*/
|
|
60
|
-
getRecentSessions(count?: number): SavedSession[];
|
|
61
|
-
/**
|
|
62
|
-
* 获取会话统计
|
|
63
|
-
*/
|
|
64
|
-
getStatistics(): {
|
|
65
|
-
totalSessions: number;
|
|
66
|
-
totalMessages: number;
|
|
67
|
-
averageMessagesPerSession: number;
|
|
68
|
-
oldestSession?: Date;
|
|
69
|
-
newestSession?: Date;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* 导出所有历史
|
|
73
|
-
*/
|
|
74
|
-
exportAllHistory(): string;
|
|
75
|
-
/**
|
|
76
|
-
* 导入历史
|
|
77
|
-
*/
|
|
78
|
-
importHistory(data: string): void;
|
|
79
|
-
private loadSessions;
|
|
80
|
-
private saveToStorage;
|
|
81
|
-
private generateSessionTitle;
|
|
82
|
-
private trimMessages;
|
|
83
|
-
/**
|
|
84
|
-
* 更新会话的上下文信息(压缩标记支持)
|
|
85
|
-
*/
|
|
86
|
-
updateContextInfo(sessionId: string, contextInfo: SavedSession['contextInfo']): void;
|
|
87
|
-
/**
|
|
88
|
-
* 导出会话(包含压缩状态)
|
|
89
|
-
*/
|
|
90
|
-
exportSessionWithContext(sessionId: string): string | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* 导出会话历史(包含所有压缩状态)
|
|
93
|
-
*/
|
|
94
|
-
exportAllHistoryWithContext(): string;
|
|
95
|
-
/**
|
|
96
|
-
* 导入会话(包含压缩状态)
|
|
97
|
-
*/
|
|
98
|
-
importSessionWithContext(data: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* 清理压缩数据
|
|
101
|
-
*/
|
|
102
|
-
cleanupCompressedData(sessionId?: string): void;
|
|
103
|
-
/**
|
|
104
|
-
* 获取压缩统计信息
|
|
105
|
-
*/
|
|
106
|
-
getCompressionStatistics(): {
|
|
107
|
-
totalSessions: number;
|
|
108
|
-
sessionsWithCompression: number;
|
|
109
|
-
totalTokensSaved: number;
|
|
110
|
-
averageTokensSaved: number;
|
|
111
|
-
lastCompactionAt?: Date;
|
|
112
|
-
compactionHistory: Array<{
|
|
113
|
-
sessionId: string;
|
|
114
|
-
type: 'prune' | 'compact' | 'truncate';
|
|
115
|
-
timestamp: Date;
|
|
116
|
-
tokensSaved: number;
|
|
117
|
-
}>;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* 记录压缩事件
|
|
121
|
-
*/
|
|
122
|
-
recordCompactionEvent(sessionId: string, type: 'prune' | 'compact' | 'truncate', tokensSaved: number, condenseId?: string): void;
|
|
123
|
-
/**
|
|
124
|
-
* 检查会话是否有压缩标记
|
|
125
|
-
*/
|
|
126
|
-
hasCompressionMarkers(sessionId: string): boolean;
|
|
127
|
-
/**
|
|
128
|
-
* 获取会话的压缩历史
|
|
129
|
-
*/
|
|
130
|
-
getCompactionHistory(sessionId: string): Array<{
|
|
131
|
-
timestamp: Date;
|
|
132
|
-
type: 'prune' | 'compact' | 'truncate';
|
|
133
|
-
tokensSaved: number;
|
|
134
|
-
condenseId?: string;
|
|
135
|
-
}>;
|
|
136
|
-
/**
|
|
137
|
-
* 更新Token使用统计
|
|
138
|
-
*/
|
|
139
|
-
updateTokenUsage(sessionId: string, tokenUsage?: {
|
|
140
|
-
input: number;
|
|
141
|
-
output: number;
|
|
142
|
-
cacheRead: number;
|
|
143
|
-
cacheWrite: number;
|
|
144
|
-
}): void;
|
|
145
|
-
}
|