@cuijy/free-api 0.1.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/LICENSE +21 -0
- package/README.md +299 -0
- package/bin/freeapi +8 -0
- package/dist/cli/commands/chat.d.ts +3 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +39 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +289 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +114 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +3 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +109 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +3 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +51 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/start.d.ts +3 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +34 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +45 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +3 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +54 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +79 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/services/base/index.d.ts +112 -0
- package/dist/services/base/index.d.ts.map +1 -0
- package/dist/services/base/index.js +51 -0
- package/dist/services/base/index.js.map +1 -0
- package/dist/services/base/types.d.ts +114 -0
- package/dist/services/base/types.d.ts.map +1 -0
- package/dist/services/base/types.js +7 -0
- package/dist/services/base/types.js.map +1 -0
- package/dist/services/chatgpt/api-client.d.ts +81 -0
- package/dist/services/chatgpt/api-client.d.ts.map +1 -0
- package/dist/services/chatgpt/api-client.js +325 -0
- package/dist/services/chatgpt/api-client.js.map +1 -0
- package/dist/services/chatgpt/cli-adapter.d.ts +108 -0
- package/dist/services/chatgpt/cli-adapter.d.ts.map +1 -0
- package/dist/services/chatgpt/cli-adapter.js +315 -0
- package/dist/services/chatgpt/cli-adapter.js.map +1 -0
- package/dist/services/chatgpt/config-manager.d.ts +87 -0
- package/dist/services/chatgpt/config-manager.d.ts.map +1 -0
- package/dist/services/chatgpt/config-manager.js +344 -0
- package/dist/services/chatgpt/config-manager.js.map +1 -0
- package/dist/services/chatgpt/config-wizard.d.ts +35 -0
- package/dist/services/chatgpt/config-wizard.d.ts.map +1 -0
- package/dist/services/chatgpt/config-wizard.js +524 -0
- package/dist/services/chatgpt/config-wizard.js.map +1 -0
- package/dist/services/chatgpt/error-handler.d.ts +94 -0
- package/dist/services/chatgpt/error-handler.d.ts.map +1 -0
- package/dist/services/chatgpt/error-handler.js +409 -0
- package/dist/services/chatgpt/error-handler.js.map +1 -0
- package/dist/services/chatgpt/exports.d.ts +71 -0
- package/dist/services/chatgpt/exports.d.ts.map +1 -0
- package/dist/services/chatgpt/exports.js +81 -0
- package/dist/services/chatgpt/exports.js.map +1 -0
- package/dist/services/chatgpt/index.d.ts +125 -0
- package/dist/services/chatgpt/index.d.ts.map +1 -0
- package/dist/services/chatgpt/index.js +394 -0
- package/dist/services/chatgpt/index.js.map +1 -0
- package/dist/services/chatgpt/service-adapter.d.ts +152 -0
- package/dist/services/chatgpt/service-adapter.d.ts.map +1 -0
- package/dist/services/chatgpt/service-adapter.js +430 -0
- package/dist/services/chatgpt/service-adapter.js.map +1 -0
- package/dist/services/chatgpt/session-manager.d.ts +113 -0
- package/dist/services/chatgpt/session-manager.d.ts.map +1 -0
- package/dist/services/chatgpt/session-manager.js +396 -0
- package/dist/services/chatgpt/session-manager.js.map +1 -0
- package/dist/services/chatgpt/types.d.ts +130 -0
- package/dist/services/chatgpt/types.d.ts.map +1 -0
- package/dist/services/chatgpt/types.js +19 -0
- package/dist/services/chatgpt/types.js.map +1 -0
- package/dist/utils/config.d.ts +61 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +215 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatGPT Service Adapter
|
|
3
|
+
* Main adapter that implements the FreeAPI service interface for ChatGPT
|
|
4
|
+
*/
|
|
5
|
+
import { ChatOptions, ChatResponse } from './index';
|
|
6
|
+
import { ChatGPTError, RecoveryAction } from './error-handler';
|
|
7
|
+
import { ChatGPTConfig, ChatGPTMode, Conversation, AuthenticationResponse, UsageStats } from './types';
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
export interface ServiceStatus {
|
|
10
|
+
initialized: boolean;
|
|
11
|
+
mode: ChatGPTMode;
|
|
12
|
+
authenticated: boolean;
|
|
13
|
+
hasActiveSession: boolean;
|
|
14
|
+
totalConversations: number;
|
|
15
|
+
totalTokens: number;
|
|
16
|
+
rateLimited: boolean;
|
|
17
|
+
errorCount: number;
|
|
18
|
+
lastError?: ChatGPTError;
|
|
19
|
+
}
|
|
20
|
+
export interface ServiceInfo {
|
|
21
|
+
name: string;
|
|
22
|
+
version: string;
|
|
23
|
+
description: string;
|
|
24
|
+
capabilities: string[];
|
|
25
|
+
limitations: string[];
|
|
26
|
+
configuration: {
|
|
27
|
+
base_url: string;
|
|
28
|
+
mode: ChatGPTMode;
|
|
29
|
+
model: string;
|
|
30
|
+
max_tokens: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare class ChatGPTServiceAdapter extends EventEmitter {
|
|
34
|
+
private service;
|
|
35
|
+
private configManager;
|
|
36
|
+
private errorHandler;
|
|
37
|
+
private config;
|
|
38
|
+
private isInitialized;
|
|
39
|
+
private encryptionKey;
|
|
40
|
+
constructor(encryptionKey?: string);
|
|
41
|
+
/**
|
|
42
|
+
* Set up event forwarding
|
|
43
|
+
*/
|
|
44
|
+
private setupEventForwarding;
|
|
45
|
+
/**
|
|
46
|
+
* Initialize the service adapter
|
|
47
|
+
*/
|
|
48
|
+
initialize(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Load configuration from file
|
|
51
|
+
*/
|
|
52
|
+
private loadConfiguration;
|
|
53
|
+
/**
|
|
54
|
+
* Save configuration to file
|
|
55
|
+
*/
|
|
56
|
+
saveConfiguration(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Send a chat message
|
|
59
|
+
*/
|
|
60
|
+
sendMessage(message: string, options?: ChatOptions): Promise<ChatResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Authenticate user
|
|
63
|
+
*/
|
|
64
|
+
authenticate(email: string, password: string): Promise<AuthenticationResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Update configuration
|
|
67
|
+
*/
|
|
68
|
+
updateConfiguration(newConfig: Partial<ChatGPTConfig>): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Get conversation by ID
|
|
71
|
+
*/
|
|
72
|
+
getConversation(conversationId: string): Conversation | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Get all conversations
|
|
75
|
+
*/
|
|
76
|
+
getAllConversations(): Conversation[];
|
|
77
|
+
/**
|
|
78
|
+
* Delete conversation
|
|
79
|
+
*/
|
|
80
|
+
deleteConversation(conversationId: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get service status
|
|
83
|
+
*/
|
|
84
|
+
getStatus(): ServiceStatus;
|
|
85
|
+
/**
|
|
86
|
+
* Get service information
|
|
87
|
+
*/
|
|
88
|
+
getServiceInfo(): ServiceInfo;
|
|
89
|
+
/**
|
|
90
|
+
* Get usage statistics
|
|
91
|
+
*/
|
|
92
|
+
getUsageStats(): UsageStats;
|
|
93
|
+
/**
|
|
94
|
+
* Get error statistics
|
|
95
|
+
*/
|
|
96
|
+
getErrorStatistics(): {
|
|
97
|
+
totalErrors: number;
|
|
98
|
+
errorCounts: Record<import("./error-handler").ChatGPTErrorCode, number>;
|
|
99
|
+
retryableErrors: number;
|
|
100
|
+
lastErrorTime?: number;
|
|
101
|
+
mostCommonError?: import("./error-handler").ChatGPTErrorCode;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Get recent errors
|
|
105
|
+
*/
|
|
106
|
+
getRecentErrors(limit?: number): ChatGPTError[];
|
|
107
|
+
/**
|
|
108
|
+
* Get recovery actions for last error
|
|
109
|
+
*/
|
|
110
|
+
getRecoveryActions(): RecoveryAction[];
|
|
111
|
+
/**
|
|
112
|
+
* Clear error history
|
|
113
|
+
*/
|
|
114
|
+
clearErrorHistory(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get configuration
|
|
117
|
+
*/
|
|
118
|
+
getConfiguration(): ChatGPTConfig;
|
|
119
|
+
/**
|
|
120
|
+
* Get configuration file path
|
|
121
|
+
*/
|
|
122
|
+
getConfigFilePath(): string;
|
|
123
|
+
/**
|
|
124
|
+
* Backup configuration
|
|
125
|
+
*/
|
|
126
|
+
backupConfiguration(backupDir?: string): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Restore configuration from backup
|
|
129
|
+
*/
|
|
130
|
+
restoreConfiguration(backupFile: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* List available backups
|
|
133
|
+
*/
|
|
134
|
+
listBackups(backupDir?: string): Promise<string[]>;
|
|
135
|
+
/**
|
|
136
|
+
* Reset configuration to defaults
|
|
137
|
+
*/
|
|
138
|
+
resetConfiguration(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Test service connection
|
|
141
|
+
*/
|
|
142
|
+
testConnection(): Promise<boolean>;
|
|
143
|
+
/**
|
|
144
|
+
* Clean up resources
|
|
145
|
+
*/
|
|
146
|
+
destroy(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Utility function for delays
|
|
149
|
+
*/
|
|
150
|
+
private delay;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=service-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/chatgpt/service-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAkB,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAuB,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE;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;IACH,eAAe,CAAC,KAAK,SAAK,GAAG,YAAY,EAAE;IAI3C;;OAEG;IACH,kBAAkB,IAAI,cAAc,EAAE;IAQtC;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAIzB;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;OAEG;IACG,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAW9D;;OAEG;IACG,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB7D;;OAEG;IACG,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIxD;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAazC;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IA0DxC;;OAEG;IACH,OAAO,IAAI,IAAI;IAOf;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ChatGPT Service Adapter
|
|
4
|
+
* Main adapter that implements the FreeAPI service interface for ChatGPT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ChatGPTServiceAdapter = void 0;
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
const config_manager_1 = require("./config-manager");
|
|
10
|
+
const error_handler_1 = require("./error-handler");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const events_1 = require("events");
|
|
13
|
+
class ChatGPTServiceAdapter extends events_1.EventEmitter {
|
|
14
|
+
service;
|
|
15
|
+
configManager;
|
|
16
|
+
errorHandler;
|
|
17
|
+
config;
|
|
18
|
+
isInitialized = false;
|
|
19
|
+
encryptionKey;
|
|
20
|
+
constructor(encryptionKey) {
|
|
21
|
+
super();
|
|
22
|
+
this.encryptionKey = encryptionKey || 'default-encryption-key-change-in-production';
|
|
23
|
+
this.configManager = new config_manager_1.ChatGPTConfigManager();
|
|
24
|
+
this.errorHandler = new error_handler_1.ChatGPTErrorHandler();
|
|
25
|
+
// Load configuration
|
|
26
|
+
this.config = this.configManager.getDefaultConfig();
|
|
27
|
+
this.service = new index_1.ChatGPTService(this.config);
|
|
28
|
+
// Set up event forwarding
|
|
29
|
+
this.setupEventForwarding();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Set up event forwarding
|
|
33
|
+
*/
|
|
34
|
+
setupEventForwarding() {
|
|
35
|
+
// Forward service events
|
|
36
|
+
this.service.on('service:initializing', () => this.emit('service:initializing'));
|
|
37
|
+
this.service.on('service:initialized', () => this.emit('service:initialized'));
|
|
38
|
+
this.service.on('service:init:error', (error) => this.emit('service:init:error', error));
|
|
39
|
+
this.service.on('service:auth:attempt', (data) => this.emit('service:auth:attempt', data));
|
|
40
|
+
this.service.on('service:auth:success', (data) => this.emit('service:auth:success', data));
|
|
41
|
+
this.service.on('service:auth:failed', (data) => this.emit('service:auth:failed', data));
|
|
42
|
+
this.service.on('service:auth:error', (data) => this.emit('service:auth:error', data));
|
|
43
|
+
this.service.on('service:config:updated', (config) => this.emit('service:config:updated', config));
|
|
44
|
+
this.service.on('service:destroyed', () => this.emit('service:destroyed'));
|
|
45
|
+
// Forward chat events
|
|
46
|
+
this.service.on('chat:start', (data) => this.emit('chat:start', data));
|
|
47
|
+
this.service.on('chat:request', (data) => this.emit('chat:request', data));
|
|
48
|
+
this.service.on('chat:success', (data) => this.emit('chat:success', data));
|
|
49
|
+
this.service.on('chat:error', (data) => this.emit('chat:error', data));
|
|
50
|
+
// Forward error handler events
|
|
51
|
+
this.errorHandler.on('error', (error) => this.emit('error:handled', error));
|
|
52
|
+
this.errorHandler.on('log', (logEntry) => this.emit('log', logEntry));
|
|
53
|
+
this.errorHandler.on('history:cleared', () => this.emit('error:history:cleared'));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize the service adapter
|
|
57
|
+
*/
|
|
58
|
+
async initialize() {
|
|
59
|
+
if (this.isInitialized) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
this.emit('adapter:initializing');
|
|
64
|
+
// Load configuration
|
|
65
|
+
await this.loadConfiguration();
|
|
66
|
+
// Initialize service
|
|
67
|
+
await this.service.initialize();
|
|
68
|
+
this.isInitialized = true;
|
|
69
|
+
this.emit('adapter:initialized');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const chatGPTError = this.errorHandler.handleError(error, 'initialize');
|
|
73
|
+
this.emit('adapter:init:error', chatGPTError);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Load configuration from file
|
|
79
|
+
*/
|
|
80
|
+
async loadConfiguration() {
|
|
81
|
+
try {
|
|
82
|
+
const loadedConfig = await this.configManager.loadConfig();
|
|
83
|
+
// Decrypt sensitive data if encrypted
|
|
84
|
+
if (this.encryptionKey) {
|
|
85
|
+
this.config = this.configManager.decryptSensitiveData(loadedConfig, this.encryptionKey);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.config = loadedConfig;
|
|
89
|
+
}
|
|
90
|
+
// Update service with loaded configuration
|
|
91
|
+
this.service.updateConfig(this.config);
|
|
92
|
+
this.emit('config:loaded', this.config);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const chatGPTError = this.errorHandler.handleError(error, 'loadConfiguration');
|
|
96
|
+
throw new Error(`Failed to load configuration: ${chatGPTError.message}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Save configuration to file
|
|
101
|
+
*/
|
|
102
|
+
async saveConfiguration() {
|
|
103
|
+
try {
|
|
104
|
+
// Encrypt sensitive data before saving
|
|
105
|
+
const configToSave = this.encryptionKey
|
|
106
|
+
? this.configManager.encryptSensitiveData(this.config, this.encryptionKey)
|
|
107
|
+
: this.config;
|
|
108
|
+
await this.configManager.saveConfig(configToSave);
|
|
109
|
+
this.emit('config:saved', this.config);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const chatGPTError = this.errorHandler.handleError(error, 'saveConfiguration');
|
|
113
|
+
throw new Error(`Failed to save configuration: ${chatGPTError.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Send a chat message
|
|
118
|
+
*/
|
|
119
|
+
async sendMessage(message, options = {}) {
|
|
120
|
+
if (!this.isInitialized) {
|
|
121
|
+
await this.initialize();
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const response = await this.service.chat(message, options);
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
const chatGPTError = this.errorHandler.handleError(error, 'sendMessage');
|
|
129
|
+
// Get recovery actions
|
|
130
|
+
const recoveryActions = this.errorHandler.getRecoveryActions(chatGPTError);
|
|
131
|
+
// Try automatic recovery if available
|
|
132
|
+
if (this.errorHandler.shouldAutoRecover(chatGPTError)) {
|
|
133
|
+
this.emit('recovery:attempt', { error: chatGPTError, actions: recoveryActions });
|
|
134
|
+
// For now, just retry once for retryable errors
|
|
135
|
+
if (chatGPTError.retryable) {
|
|
136
|
+
await this.delay(1000); // Wait 1 second
|
|
137
|
+
return this.sendMessage(message, options);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
throw new Error(this.errorHandler.getUserFriendlyMessage(chatGPTError));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Authenticate user
|
|
145
|
+
*/
|
|
146
|
+
async authenticate(email, password) {
|
|
147
|
+
if (!this.isInitialized) {
|
|
148
|
+
await this.initialize();
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const response = await this.service.authenticate(email, password);
|
|
152
|
+
// Update configuration with new credentials
|
|
153
|
+
this.config.mode = types_1.ChatGPTMode.AUTHENTICATED;
|
|
154
|
+
this.config.credentials = {
|
|
155
|
+
email,
|
|
156
|
+
password,
|
|
157
|
+
access_token: response.access_token,
|
|
158
|
+
refresh_token: response.refresh_token,
|
|
159
|
+
session_token: response.session_token
|
|
160
|
+
};
|
|
161
|
+
// Save updated configuration
|
|
162
|
+
await this.saveConfiguration();
|
|
163
|
+
return response;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const chatGPTError = this.errorHandler.handleError(error, 'authenticate');
|
|
167
|
+
throw new Error(this.errorHandler.getUserFriendlyMessage(chatGPTError));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Update configuration
|
|
172
|
+
*/
|
|
173
|
+
async updateConfiguration(newConfig) {
|
|
174
|
+
try {
|
|
175
|
+
// Merge with current config
|
|
176
|
+
this.config = { ...this.config, ...newConfig };
|
|
177
|
+
// Update service
|
|
178
|
+
this.service.updateConfig(this.config);
|
|
179
|
+
// Save to file
|
|
180
|
+
await this.saveConfiguration();
|
|
181
|
+
this.emit('config:updated', this.config);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const chatGPTError = this.errorHandler.handleError(error, 'updateConfiguration');
|
|
185
|
+
throw new Error(`Failed to update configuration: ${chatGPTError.message}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get conversation by ID
|
|
190
|
+
*/
|
|
191
|
+
getConversation(conversationId) {
|
|
192
|
+
return this.service.getConversation(conversationId);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get all conversations
|
|
196
|
+
*/
|
|
197
|
+
getAllConversations() {
|
|
198
|
+
return this.service.getAllConversations();
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Delete conversation
|
|
202
|
+
*/
|
|
203
|
+
deleteConversation(conversationId) {
|
|
204
|
+
const success = this.service.deleteConversation(conversationId);
|
|
205
|
+
if (success) {
|
|
206
|
+
this.emit('conversation:deleted', conversationId);
|
|
207
|
+
}
|
|
208
|
+
return success;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get service status
|
|
212
|
+
*/
|
|
213
|
+
getStatus() {
|
|
214
|
+
const serviceStatus = this.service.getStatus();
|
|
215
|
+
const errorStats = this.errorHandler.getErrorStatistics();
|
|
216
|
+
const recentErrors = this.errorHandler.getRecentErrors(1);
|
|
217
|
+
return {
|
|
218
|
+
...serviceStatus,
|
|
219
|
+
errorCount: errorStats.totalErrors,
|
|
220
|
+
lastError: recentErrors[0]
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get service information
|
|
225
|
+
*/
|
|
226
|
+
getServiceInfo() {
|
|
227
|
+
return {
|
|
228
|
+
name: 'ChatGPT',
|
|
229
|
+
version: '1.0.0',
|
|
230
|
+
description: 'OpenAI ChatGPT service with public and authenticated modes',
|
|
231
|
+
capabilities: [
|
|
232
|
+
'Text generation',
|
|
233
|
+
'Conversation management',
|
|
234
|
+
'Multiple model support',
|
|
235
|
+
'Session management',
|
|
236
|
+
'Rate limiting',
|
|
237
|
+
'Error recovery'
|
|
238
|
+
],
|
|
239
|
+
limitations: [
|
|
240
|
+
'Token limits apply',
|
|
241
|
+
'Rate limits may restrict usage',
|
|
242
|
+
'Some features require authentication'
|
|
243
|
+
],
|
|
244
|
+
configuration: {
|
|
245
|
+
base_url: this.config.base_url,
|
|
246
|
+
mode: this.config.mode,
|
|
247
|
+
model: this.config.model,
|
|
248
|
+
max_tokens: this.config.max_tokens
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get usage statistics
|
|
254
|
+
*/
|
|
255
|
+
getUsageStats() {
|
|
256
|
+
return this.service.getUsageStats();
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get error statistics
|
|
260
|
+
*/
|
|
261
|
+
getErrorStatistics() {
|
|
262
|
+
return this.errorHandler.getErrorStatistics();
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get recent errors
|
|
266
|
+
*/
|
|
267
|
+
getRecentErrors(limit = 10) {
|
|
268
|
+
return this.errorHandler.getRecentErrors(limit);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get recovery actions for last error
|
|
272
|
+
*/
|
|
273
|
+
getRecoveryActions() {
|
|
274
|
+
const recentErrors = this.getRecentErrors(1);
|
|
275
|
+
if (recentErrors.length === 0) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
return this.errorHandler.getRecoveryActions(recentErrors[0]);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Clear error history
|
|
282
|
+
*/
|
|
283
|
+
clearErrorHistory() {
|
|
284
|
+
this.errorHandler.clearHistory();
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get configuration
|
|
288
|
+
*/
|
|
289
|
+
getConfiguration() {
|
|
290
|
+
return { ...this.config };
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get configuration file path
|
|
294
|
+
*/
|
|
295
|
+
getConfigFilePath() {
|
|
296
|
+
return this.configManager.getConfigFilePath();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Backup configuration
|
|
300
|
+
*/
|
|
301
|
+
async backupConfiguration(backupDir) {
|
|
302
|
+
try {
|
|
303
|
+
const backupFile = await this.configManager.backupConfig(backupDir);
|
|
304
|
+
this.emit('config:backup:created', backupFile);
|
|
305
|
+
return backupFile;
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
const chatGPTError = this.errorHandler.handleError(error, 'backupConfiguration');
|
|
309
|
+
throw new Error(`Failed to backup configuration: ${chatGPTError.message}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Restore configuration from backup
|
|
314
|
+
*/
|
|
315
|
+
async restoreConfiguration(backupFile) {
|
|
316
|
+
try {
|
|
317
|
+
const restoredConfig = await this.configManager.restoreConfig(backupFile);
|
|
318
|
+
// Decrypt if needed
|
|
319
|
+
if (this.encryptionKey) {
|
|
320
|
+
this.config = this.configManager.decryptSensitiveData(restoredConfig, this.encryptionKey);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
this.config = restoredConfig;
|
|
324
|
+
}
|
|
325
|
+
// Update service
|
|
326
|
+
this.service.updateConfig(this.config);
|
|
327
|
+
this.emit('config:restored', this.config);
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
const chatGPTError = this.errorHandler.handleError(error, 'restoreConfiguration');
|
|
331
|
+
throw new Error(`Failed to restore configuration: ${chatGPTError.message}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* List available backups
|
|
336
|
+
*/
|
|
337
|
+
async listBackups(backupDir) {
|
|
338
|
+
return this.configManager.listBackups(backupDir);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Reset configuration to defaults
|
|
342
|
+
*/
|
|
343
|
+
async resetConfiguration() {
|
|
344
|
+
try {
|
|
345
|
+
this.config = this.configManager.getDefaultConfig();
|
|
346
|
+
this.service.updateConfig(this.config);
|
|
347
|
+
await this.saveConfiguration();
|
|
348
|
+
this.emit('config:reset', this.config);
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
const chatGPTError = this.errorHandler.handleError(error, 'resetConfiguration');
|
|
352
|
+
throw new Error(`Failed to reset configuration: ${chatGPTError.message}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Test service connection
|
|
357
|
+
*/
|
|
358
|
+
async testConnection() {
|
|
359
|
+
try {
|
|
360
|
+
this.emit('connection:test:start');
|
|
361
|
+
// Check if we have API key for authenticated mode
|
|
362
|
+
if (this.config.mode === 'authenticated' && !this.config.api_key) {
|
|
363
|
+
this.emit('connection:test:failed', {
|
|
364
|
+
reason: 'API key required for authenticated mode'
|
|
365
|
+
});
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
// For public mode without API key, just check basic connectivity
|
|
369
|
+
if (this.config.mode === 'public' && !this.config.api_key) {
|
|
370
|
+
// Just validate configuration without making API call
|
|
371
|
+
const isValid = this.config.base_url && this.config.model;
|
|
372
|
+
if (isValid) {
|
|
373
|
+
this.emit('connection:test:success', {
|
|
374
|
+
mode: 'public',
|
|
375
|
+
message: 'Configuration valid (no API key for actual test)'
|
|
376
|
+
});
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
this.emit('connection:test:failed', {
|
|
381
|
+
reason: 'Invalid configuration'
|
|
382
|
+
});
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// For authenticated mode with API key, test actual API connection
|
|
387
|
+
try {
|
|
388
|
+
const response = await this.sendMessage('Hello', {
|
|
389
|
+
maxTokens: 10,
|
|
390
|
+
systemPrompt: 'You are a helpful assistant.'
|
|
391
|
+
});
|
|
392
|
+
const success = !!response && !!response.message.content;
|
|
393
|
+
if (success) {
|
|
394
|
+
this.emit('connection:test:success', response);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
this.emit('connection:test:failed', { reason: 'Empty response' });
|
|
398
|
+
}
|
|
399
|
+
return success;
|
|
400
|
+
}
|
|
401
|
+
catch (apiError) {
|
|
402
|
+
const chatGPTError = this.errorHandler.handleError(apiError, 'testConnection');
|
|
403
|
+
this.emit('connection:test:failed', { error: chatGPTError });
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
const chatGPTError = this.errorHandler.handleError(error, 'testConnection');
|
|
409
|
+
this.emit('connection:test:failed', { error: chatGPTError });
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Clean up resources
|
|
415
|
+
*/
|
|
416
|
+
destroy() {
|
|
417
|
+
this.service.destroy();
|
|
418
|
+
this.errorHandler.removeAllListeners();
|
|
419
|
+
this.removeAllListeners();
|
|
420
|
+
this.emit('adapter:destroyed');
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Utility function for delays
|
|
424
|
+
*/
|
|
425
|
+
delay(ms) {
|
|
426
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.ChatGPTServiceAdapter = ChatGPTServiceAdapter;
|
|
430
|
+
//# sourceMappingURL=service-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-adapter.js","sourceRoot":"","sources":["../../../src/services/chatgpt/service-adapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAoE;AACpE,qDAAwD;AACxD,mDAAoF;AACpF,mCAAuG;AACvG,mCAAsC;AA4BtC,MAAa,qBAAsB,SAAQ,qBAAY;IAC7C,OAAO,CAAiB;IACxB,aAAa,CAAuB;IACpC,YAAY,CAAsB;IAClC,MAAM,CAAgB;IACtB,aAAa,GAAG,KAAK,CAAC;IACtB,aAAa,CAAS;IAE9B,YAAY,aAAsB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,6CAA6C,CAAC;QACpF,IAAI,CAAC,aAAa,GAAG,IAAI,qCAAoB,EAAE,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,mCAAmB,EAAE,CAAC;QAE9C,qBAAqB;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE/C,0BAA0B;QAC1B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;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