@acip/cli 1.5.4 → 1.6.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ACIP Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AASA,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFnF"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AASA,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA8FnF"}
@@ -49,7 +49,15 @@ export async function createProjectStructure(options) {
49
49
  author: '',
50
50
  license: 'MIT',
51
51
  dependencies: {
52
+ ...(template === 'basic' || template === 'advanced'
53
+ ? { '@acip/core': '^1.5.0' } : {}),
52
54
  '@acip/model-invocation': '^1.5.0',
55
+ ...(template === 'advanced' ? {
56
+ '@acip/context-management': '^1.5.0',
57
+ '@acip/data-access': '^1.5.0',
58
+ '@acip/blockchain': '^1.5.0',
59
+ '@acip/security-authentication': '^1.5.0'
60
+ } : {}),
53
61
  'dotenv': '^16.3.1'
54
62
  },
55
63
  devDependencies: devDeps
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAUtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAAuB;IAClE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,aA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AAK,UAAU,EAAE,CAAC;QAC5B,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,OAAO,WAAW,CAAC,CAAC;QAC3G,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAC/C,MAAM,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,OAAO,EAAE,CAAC,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,aAAsB;IAC9C,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpE,OAAO;wBACe,cAAc;;;;;;;;;0BASZ,cAAc;;;;;;;;;;;;6BAYX,cAAc;;;;;;;CAO1C,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acip/cli",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Command Line Interface for ACIP",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,17 +24,6 @@
24
24
  "access": "public",
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  },
27
- "scripts": {
28
- "build": "tsc",
29
- "dev": "tsc -w",
30
- "clean": "rimraf dist",
31
- "test": "NODE_OPTIONS='--experimental-vm-modules' jest",
32
- "test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
33
- "test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
34
- "lint": "eslint src --ext .ts",
35
- "lint:fix": "eslint src --ext .ts --fix",
36
- "prepublishOnly": "npm run build"
37
- },
38
27
  "keywords": [
39
28
  "acip",
40
29
  "cli",
@@ -84,5 +73,15 @@
84
73
  },
85
74
  "engines": {
86
75
  "node": ">=18.0.0"
76
+ },
77
+ "scripts": {
78
+ "build": "tsc",
79
+ "dev": "tsc -w",
80
+ "clean": "rimraf dist",
81
+ "test": "NODE_OPTIONS='--experimental-vm-modules' jest",
82
+ "test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
83
+ "test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
84
+ "lint": "eslint src --ext .ts",
85
+ "lint:fix": "eslint src --ext .ts --fix"
87
86
  }
88
- }
87
+ }
@@ -10,3 +10,7 @@ DEFAULT_MODEL_ID=gpt-5.2
10
10
  # 应用配置
11
11
  APP_PORT=3000
12
12
  NODE_ENV=development
13
+
14
+ # 安全认证(advanced 模板使用)
15
+ JWT_SECRET=your_jwt_secret_here
16
+ ADMIN_PASSWORD=Demo@1234
@@ -1,20 +1,29 @@
1
- /**
2
- * 创建AI助手实例
3
- */
4
- export function createAssistant(modelInvocation, options) {
1
+ import * as readline from 'readline';
2
+
3
+ const SYSTEM_PROMPT = `You are ACIP Assistant, an AI powered by the Adaptive Contextual Intelligence Protocol (ACIP).
4
+ ACIP is a distributed AI communication protocol providing semantic routing, resource-aware scheduling, QoS management, blockchain integration, and edge computing support.
5
+ You have access to context management, data access, blockchain audit, and security modules.
6
+ Help users understand and build with ACIP. Be concise and helpful.`;
7
+
8
+ export function createAssistant(modules) {
9
+ const {
10
+ modelInvocation,
11
+ modelId,
12
+ provider,
13
+ contextManager,
14
+ contextId,
15
+ blockchain,
16
+ auditService,
17
+ dataAccess,
18
+ authManager
19
+ } = modules;
20
+
5
21
  const history = [];
6
- const provider = options.provider || 'openai';
7
- const modelId = options.modelId;
8
- const systemPrompt = options.systemPrompt || `
9
- You are ACIP Guide, an AI assistant specializing in the Adaptive Contextual Intelligence Protocol.
10
- Provide helpful, accurate, and concise information about ACIP's features, architecture, and usage.
11
- When asked about technical details, include code examples when appropriate.
12
- If you don't know something, admit it rather than making up information.
13
- `;
14
-
15
- async function sendMessage(content, invokeOptions = {}) {
22
+ let requestCount = 0;
23
+
24
+ async function sendMessage(content) {
16
25
  const messages = [
17
- { role: 'system', content: systemPrompt.trim() },
26
+ { role: 'system', content: SYSTEM_PROMPT },
18
27
  ...history,
19
28
  { role: 'user', content }
20
29
  ];
@@ -22,27 +31,187 @@ If you don't know something, admit it rather than making up information.
22
31
  const response = await modelInvocation.invoke({
23
32
  model: modelId,
24
33
  provider,
25
- messages,
26
- ...invokeOptions
34
+ messages
27
35
  });
28
36
 
29
37
  history.push({ role: 'user', content });
30
38
  history.push({ role: 'assistant', content: response.content });
39
+ requestCount++;
40
+
41
+ // 自动保存到上下文管理
42
+ if (contextManager && contextId) {
43
+ try {
44
+ await contextManager.addToContext(contextId, {
45
+ type: 'text',
46
+ text: `User: ${content}\nAssistant: ${response.content}`,
47
+ timestamp: Date.now()
48
+ });
49
+ } catch { /* 静默降级 */ }
50
+ }
51
+
52
+ // 自动审计到区块链
53
+ if (blockchain) {
54
+ try {
55
+ const tx = blockchain.createTransaction('user', 'ai-assistant', 1);
56
+ tx.type = 'CONTRIBUTION';
57
+ blockchain.addTransaction(tx);
58
+ } catch { /* 静默降级 */ }
59
+ }
31
60
 
32
- return response;
61
+ return response.content;
33
62
  }
34
63
 
35
- function getHistory() {
36
- return [...history];
64
+ async function handleCommand(cmd) {
65
+ const parts = cmd.split(/\s+/);
66
+ const command = parts[0];
67
+
68
+ switch (command) {
69
+ case '/help':
70
+ console.log('\nCommands:');
71
+ console.log(' /help - Show this help');
72
+ console.log(' /clear - Clear conversation history');
73
+ console.log(' /history - Show conversation history');
74
+ console.log(' /status - Show module status');
75
+ console.log(' /audit - Show blockchain audit trail');
76
+ console.log(' /data list - List registered data sources');
77
+ console.log(' /exit - Exit the application\n');
78
+ return true;
79
+
80
+ case '/clear':
81
+ history.length = 0;
82
+ requestCount = 0;
83
+ console.log('Conversation history cleared.\n');
84
+ return true;
85
+
86
+ case '/history':
87
+ if (history.length === 0) {
88
+ console.log('No conversation history yet.\n');
89
+ } else {
90
+ console.log(`\n--- Conversation History (${history.length} messages) ---`);
91
+ for (const msg of history) {
92
+ const prefix = msg.role === 'user' ? 'You' : 'Assistant';
93
+ const text = msg.content.length > 120
94
+ ? msg.content.substring(0, 120) + '...'
95
+ : msg.content;
96
+ console.log(` [${prefix}] ${text}`);
97
+ }
98
+ console.log('---\n');
99
+ }
100
+ return true;
101
+
102
+ case '/status': {
103
+ console.log('\n--- Module Status ---');
104
+ console.log(` Core: active`);
105
+ console.log(` Model Invocation: active (model: ${modelId})`);
106
+ console.log(` Context Mgmt: ${contextManager ? 'active' : 'unavailable'}`);
107
+ console.log(` Data Access: ${dataAccess ? 'active' : 'unavailable'}`);
108
+ console.log(` Blockchain: ${blockchain ? 'active' : 'unavailable'}`);
109
+ console.log(` Security/Auth: ${authManager ? 'active' : 'unavailable'}`);
110
+ console.log(` Requests: ${requestCount}`);
111
+ console.log(` History: ${history.length} messages`);
112
+ if (authManager) {
113
+ try {
114
+ const stats = authManager.getStats();
115
+ console.log(` Users: ${stats.userCount}`);
116
+ console.log(` Sessions: ${stats.sessionCount}`);
117
+ } catch { /* ignore */ }
118
+ }
119
+ console.log('---\n');
120
+ return true;
121
+ }
122
+
123
+ case '/audit':
124
+ if (!auditService) {
125
+ console.log('Blockchain audit is not available.\n');
126
+ } else {
127
+ try {
128
+ const trail = auditService.getAuditTrailForAddress('user');
129
+ if (trail.length === 0) {
130
+ console.log('No audit records yet.\n');
131
+ } else {
132
+ console.log(`\n--- Audit Trail (${trail.length} records) ---`);
133
+ for (const tx of trail.slice(-10)) {
134
+ const time = new Date(tx.timestamp).toLocaleTimeString();
135
+ console.log(` [${time}] ${tx.from} -> ${tx.to} (${tx.type}, amount: ${tx.amount})`);
136
+ }
137
+ console.log('---\n');
138
+ }
139
+ } catch (err) {
140
+ console.log(`Audit error: ${err.message}\n`);
141
+ }
142
+ }
143
+ return true;
144
+
145
+ case '/data':
146
+ if (!dataAccess) {
147
+ console.log('Data Access module is not available.\n');
148
+ } else if (parts[1] === 'list') {
149
+ try {
150
+ const sources = dataAccess.listSources();
151
+ if (sources.length === 0) {
152
+ console.log('No data sources registered.\n');
153
+ } else {
154
+ console.log(`\n--- Data Sources (${sources.length}) ---`);
155
+ for (const src of sources) {
156
+ console.log(` - ${src.name || src}`);
157
+ }
158
+ console.log('---\n');
159
+ }
160
+ } catch (err) {
161
+ console.log(`Data access error: ${err.message}\n`);
162
+ }
163
+ } else {
164
+ console.log('Usage: /data list\n');
165
+ }
166
+ return true;
167
+
168
+ case '/exit':
169
+ case '/quit':
170
+ console.log('Goodbye!');
171
+ process.exit(0);
172
+
173
+ default:
174
+ return false;
175
+ }
37
176
  }
38
177
 
39
- function clearHistory() {
40
- history.length = 0;
178
+ function startREPL() {
179
+ const rl = readline.createInterface({
180
+ input: process.stdin,
181
+ output: process.stdout
182
+ });
183
+
184
+ console.log('\n=== ACIP Advanced Assistant ===');
185
+ console.log('All modules integrated. Type /help for commands.\n');
186
+
187
+ const prompt = () => {
188
+ rl.question('You> ', async (input) => {
189
+ const trimmed = input.trim();
190
+ if (!trimmed) { prompt(); return; }
191
+
192
+ if (trimmed.startsWith('/')) {
193
+ const handled = await handleCommand(trimmed);
194
+ if (handled) { prompt(); return; }
195
+ }
196
+
197
+ try {
198
+ const reply = await sendMessage(trimmed);
199
+ console.log(`\nAssistant> ${reply}\n`);
200
+ } catch (error) {
201
+ console.error(`\nError: ${error.message}\n`);
202
+ }
203
+
204
+ prompt();
205
+ });
206
+ };
207
+
208
+ prompt();
41
209
  }
42
210
 
43
211
  return {
212
+ startREPL,
44
213
  sendMessage,
45
- getHistory,
46
- clearHistory
214
+ getHistory: () => [...history],
215
+ clearHistory: () => { history.length = 0; }
47
216
  };
48
217
  }
@@ -1,37 +1,44 @@
1
- import type { ModelInvocationModule, InvocationResponse, InvocationOptions } from '@acip/model-invocation';
1
+ import * as readline from 'readline';
2
+ import type { ModelInvocationModule } from '@acip/model-invocation';
2
3
 
3
- type AssistantOptions = {
4
+ type Message = { role: 'system' | 'user' | 'assistant'; content: string };
5
+
6
+ export interface AssistantModules {
7
+ modelInvocation: ModelInvocationModule;
4
8
  modelId: string;
5
- provider?: string;
6
- systemPrompt?: string;
7
- };
9
+ provider: string;
10
+ contextManager?: any;
11
+ contextId?: string | null;
12
+ blockchain?: any;
13
+ auditService?: any;
14
+ dataAccess?: any;
15
+ authManager?: any;
16
+ }
8
17
 
9
- type Message = { role: 'system' | 'user' | 'assistant'; content: string };
18
+ const SYSTEM_PROMPT = `You are ACIP Assistant, an AI powered by the Adaptive Contextual Intelligence Protocol (ACIP).
19
+ ACIP is a distributed AI communication protocol providing semantic routing, resource-aware scheduling, QoS management, blockchain integration, and edge computing support.
20
+ You have access to context management, data access, blockchain audit, and security modules.
21
+ Help users understand and build with ACIP. Be concise and helpful.`;
22
+
23
+ export function createAssistant(modules: AssistantModules) {
24
+ const {
25
+ modelInvocation,
26
+ modelId,
27
+ provider,
28
+ contextManager,
29
+ contextId,
30
+ blockchain,
31
+ auditService,
32
+ dataAccess,
33
+ authManager
34
+ } = modules;
10
35
 
11
- /**
12
- * 创建AI助手实例
13
- */
14
- export function createAssistant(
15
- modelInvocation: ModelInvocationModule,
16
- options: AssistantOptions
17
- ) {
18
36
  const history: Message[] = [];
19
- const provider = options.provider || 'openai';
20
- const modelId = options.modelId;
21
- const systemPrompt = options.systemPrompt || `
22
- You are ACIP Guide, an AI assistant specializing in the Adaptive Contextual Intelligence Protocol.
23
- Provide helpful, accurate, and concise information about ACIP's features, architecture, and usage.
24
- When asked about technical details, include code examples when appropriate.
25
- If you don't know something, admit it rather than making up information.
26
- `;
27
-
28
- // 发送消息并返回响应
29
- async function sendMessage(
30
- content: string,
31
- invokeOptions: Omit<InvocationOptions, 'model' | 'provider' | 'messages'> = {}
32
- ): Promise<InvocationResponse> {
37
+ let requestCount = 0;
38
+
39
+ async function sendMessage(content: string): Promise<string> {
33
40
  const messages: Message[] = [
34
- { role: 'system', content: systemPrompt.trim() },
41
+ { role: 'system', content: SYSTEM_PROMPT },
35
42
  ...history,
36
43
  { role: 'user', content }
37
44
  ];
@@ -39,27 +46,187 @@ If you don't know something, admit it rather than making up information.
39
46
  const response = await modelInvocation.invoke({
40
47
  model: modelId,
41
48
  provider,
42
- messages,
43
- ...invokeOptions
49
+ messages
44
50
  });
45
51
 
46
52
  history.push({ role: 'user', content });
47
53
  history.push({ role: 'assistant', content: response.content });
54
+ requestCount++;
48
55
 
49
- return response;
56
+ // 自动保存到上下文管理
57
+ if (contextManager && contextId) {
58
+ try {
59
+ await contextManager.addToContext(contextId, {
60
+ type: 'text',
61
+ text: `User: ${content}\nAssistant: ${response.content}`,
62
+ timestamp: Date.now()
63
+ });
64
+ } catch { /* 静默降级 */ }
65
+ }
66
+
67
+ // 自动审计到区块链
68
+ if (blockchain) {
69
+ try {
70
+ const tx = blockchain.createTransaction('user', 'ai-assistant', 1);
71
+ tx.type = 'CONTRIBUTION';
72
+ blockchain.addTransaction(tx);
73
+ } catch { /* 静默降级 */ }
74
+ }
75
+
76
+ return response.content;
50
77
  }
51
78
 
52
- function getHistory(): Message[] {
53
- return [...history];
79
+ async function handleCommand(cmd: string): Promise<boolean> {
80
+ const parts = cmd.split(/\s+/);
81
+ const command = parts[0];
82
+
83
+ switch (command) {
84
+ case '/help':
85
+ console.log('\nCommands:');
86
+ console.log(' /help - Show this help');
87
+ console.log(' /clear - Clear conversation history');
88
+ console.log(' /history - Show conversation history');
89
+ console.log(' /status - Show module status');
90
+ console.log(' /audit - Show blockchain audit trail');
91
+ console.log(' /data list - List registered data sources');
92
+ console.log(' /exit - Exit the application\n');
93
+ return true;
94
+
95
+ case '/clear':
96
+ history.length = 0;
97
+ requestCount = 0;
98
+ console.log('Conversation history cleared.\n');
99
+ return true;
100
+
101
+ case '/history':
102
+ if (history.length === 0) {
103
+ console.log('No conversation history yet.\n');
104
+ } else {
105
+ console.log(`\n--- Conversation History (${history.length} messages) ---`);
106
+ for (const msg of history) {
107
+ const prefix = msg.role === 'user' ? 'You' : 'Assistant';
108
+ const text = msg.content.length > 120
109
+ ? msg.content.substring(0, 120) + '...'
110
+ : msg.content;
111
+ console.log(` [${prefix}] ${text}`);
112
+ }
113
+ console.log('---\n');
114
+ }
115
+ return true;
116
+
117
+ case '/status': {
118
+ console.log('\n--- Module Status ---');
119
+ console.log(` Core: active`);
120
+ console.log(` Model Invocation: active (model: ${modelId})`);
121
+ console.log(` Context Mgmt: ${contextManager ? 'active' : 'unavailable'}`);
122
+ console.log(` Data Access: ${dataAccess ? 'active' : 'unavailable'}`);
123
+ console.log(` Blockchain: ${blockchain ? 'active' : 'unavailable'}`);
124
+ console.log(` Security/Auth: ${authManager ? 'active' : 'unavailable'}`);
125
+ console.log(` Requests: ${requestCount}`);
126
+ console.log(` History: ${history.length} messages`);
127
+ if (authManager) {
128
+ try {
129
+ const stats = authManager.getStats();
130
+ console.log(` Users: ${stats.userCount}`);
131
+ console.log(` Sessions: ${stats.sessionCount}`);
132
+ } catch { /* ignore */ }
133
+ }
134
+ console.log('---\n');
135
+ return true;
136
+ }
137
+
138
+ case '/audit':
139
+ if (!auditService) {
140
+ console.log('Blockchain audit is not available.\n');
141
+ } else {
142
+ try {
143
+ const trail = auditService.getAuditTrailForAddress('user');
144
+ if (trail.length === 0) {
145
+ console.log('No audit records yet.\n');
146
+ } else {
147
+ console.log(`\n--- Audit Trail (${trail.length} records) ---`);
148
+ for (const tx of trail.slice(-10)) {
149
+ const time = new Date(tx.timestamp).toLocaleTimeString();
150
+ console.log(` [${time}] ${tx.from} -> ${tx.to} (${tx.type}, amount: ${tx.amount})`);
151
+ }
152
+ console.log('---\n');
153
+ }
154
+ } catch (err: any) {
155
+ console.log(`Audit error: ${err.message}\n`);
156
+ }
157
+ }
158
+ return true;
159
+
160
+ case '/data':
161
+ if (!dataAccess) {
162
+ console.log('Data Access module is not available.\n');
163
+ } else if (parts[1] === 'list') {
164
+ try {
165
+ const sources = dataAccess.listSources();
166
+ if (sources.length === 0) {
167
+ console.log('No data sources registered.\n');
168
+ } else {
169
+ console.log(`\n--- Data Sources (${sources.length}) ---`);
170
+ for (const src of sources) {
171
+ console.log(` - ${src.name || src}`);
172
+ }
173
+ console.log('---\n');
174
+ }
175
+ } catch (err: any) {
176
+ console.log(`Data access error: ${err.message}\n`);
177
+ }
178
+ } else {
179
+ console.log('Usage: /data list\n');
180
+ }
181
+ return true;
182
+
183
+ case '/exit':
184
+ case '/quit':
185
+ console.log('Goodbye!');
186
+ process.exit(0);
187
+
188
+ default:
189
+ return false;
190
+ }
54
191
  }
55
192
 
56
- function clearHistory(): void {
57
- history.length = 0;
193
+ function startREPL(): void {
194
+ const rl = readline.createInterface({
195
+ input: process.stdin,
196
+ output: process.stdout
197
+ });
198
+
199
+ console.log('\n=== ACIP Advanced Assistant ===');
200
+ console.log('All modules integrated. Type /help for commands.\n');
201
+
202
+ const prompt = (): void => {
203
+ rl.question('You> ', async (input) => {
204
+ const trimmed = input.trim();
205
+ if (!trimmed) { prompt(); return; }
206
+
207
+ if (trimmed.startsWith('/')) {
208
+ const handled = await handleCommand(trimmed);
209
+ if (handled) { prompt(); return; }
210
+ }
211
+
212
+ try {
213
+ const reply = await sendMessage(trimmed);
214
+ console.log(`\nAssistant> ${reply}\n`);
215
+ } catch (error: any) {
216
+ console.error(`\nError: ${error.message}\n`);
217
+ }
218
+
219
+ prompt();
220
+ });
221
+ };
222
+
223
+ prompt();
58
224
  }
59
225
 
60
226
  return {
227
+ startREPL,
61
228
  sendMessage,
62
- getHistory,
63
- clearHistory
229
+ getHistory: (): Message[] => [...history],
230
+ clearHistory: (): void => { history.length = 0; }
64
231
  };
65
232
  }
@@ -1,4 +1,5 @@
1
1
  import 'dotenv/config';
2
+ import { createCore } from '@acip/core';
2
3
  import { ModelInvocationModule } from '@acip/model-invocation';
3
4
  import { createAssistant } from './components/assistant.js';
4
5
 
@@ -8,60 +9,141 @@ async function main() {
8
9
  const modelId = process.env.DEFAULT_MODEL_ID || 'gpt-5.2';
9
10
 
10
11
  if (!apiKey) {
11
- throw new Error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY).');
12
+ console.error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY) in .env file.');
13
+ process.exit(1);
12
14
  }
13
15
 
16
+ // ── 1. ACIP Core ──
17
+ const core = createCore();
18
+ console.log(`[core] initialized (instance: ${core.instanceId})`);
19
+
20
+ // ── 2. Model Invocation ──
14
21
  const provider = {
15
22
  name: 'openai',
16
23
  apiKey,
17
24
  baseUrl,
18
25
  enabled: true,
19
- models: [
20
- {
21
- id: modelId,
22
- name: modelId,
23
- provider: 'openai',
24
- capabilities: ['chat'],
25
- parameters: {}
26
- }
27
- ]
26
+ models: [{
27
+ id: modelId,
28
+ name: modelId,
29
+ provider: 'openai',
30
+ capabilities: ['chat'],
31
+ parameters: {}
32
+ }]
28
33
  };
29
34
 
30
- const config = {
35
+ const miConfig = {
31
36
  providers: [provider],
32
37
  caching: { enabled: true, ttl: 600, maxSize: 100, strategy: 'lru' },
33
38
  observability: { enabled: true, metricsEnabled: true, tracingEnabled: false, exportInterval: 60000 },
34
39
  streaming: { enabled: false, chunkSize: 1, timeout: 60000 }
35
40
  };
36
41
 
37
- const modelInvocation = new ModelInvocationModule(config);
42
+ const modelInvocation = new ModelInvocationModule(miConfig);
38
43
 
39
44
  await new Promise((resolve, reject) => {
40
45
  modelInvocation.once('ready', () => resolve());
41
46
  modelInvocation.once('error', (error) => reject(error));
42
47
  });
43
48
 
44
- modelInvocation.on('requestStarted', (data) => {
45
- console.log(`Model invocation started: ${data.requestId}`);
46
- });
49
+ console.log('[model-invocation] ready');
47
50
 
48
- modelInvocation.on('requestCompleted', (data) => {
49
- console.log(`Model invocation completed in ${data.duration}ms`);
50
- });
51
+ // ── 3. Context Management (降级运行) ──
52
+ let contextManager = null;
53
+ let contextId = null;
54
+ try {
55
+ const { ContextManager } = await import('@acip/context-management');
56
+ contextManager = new ContextManager(
57
+ core.instanceId,
58
+ core.stateManager,
59
+ core.telemetryService,
60
+ core.eventManager
61
+ );
62
+ await contextManager.initialize();
63
+ await contextManager.createContext('main-conversation');
64
+ contextId = 'main-conversation';
65
+ console.log('[context-management] ready');
66
+ } catch (err) {
67
+ console.warn(`[context-management] skipped: ${err.message}`);
68
+ }
51
69
 
52
- const assistant = createAssistant(modelInvocation, {
53
- modelId,
54
- provider: 'openai'
55
- });
70
+ // ── 4. Data Access (降级运行) ──
71
+ let dataAccess = null;
72
+ try {
73
+ const { DataAccessModule, InMemoryAdapter } = await import('@acip/data-access');
74
+ dataAccess = new DataAccessModule();
75
+ const adapter = new InMemoryAdapter();
76
+ await dataAccess.registerSource('notes', { adapter });
77
+ console.log('[data-access] ready');
78
+ } catch (err) {
79
+ console.warn(`[data-access] skipped: ${err.message}`);
80
+ }
56
81
 
57
- const response = await assistant.sendMessage(
58
- 'Hello! I want to learn about adaptive context management in AI systems.'
59
- );
82
+ // ── 5. Blockchain + Audit (降级运行) ──
83
+ let blockchain = null;
84
+ let auditService = null;
85
+ try {
86
+ const { Blockchain, AuditService } = await import('@acip/blockchain');
87
+ blockchain = new Blockchain();
88
+ auditService = new AuditService(blockchain);
89
+ console.log('[blockchain] ready');
90
+ } catch (err) {
91
+ console.warn(`[blockchain] skipped: ${err.message}`);
92
+ }
93
+
94
+ // ── 6. Security & Authentication (降级运行) ──
95
+ let authManager = null;
96
+ try {
97
+ const { AuthManager } = await import('@acip/security-authentication');
98
+ authManager = new AuthManager({
99
+ passwordPolicy: {
100
+ minLength: 4,
101
+ requireNumbers: false,
102
+ requireLowercase: false,
103
+ requireUppercase: false,
104
+ requireSpecial: false,
105
+ maxRepeatingChars: 0,
106
+ preventCommonPasswords: false
107
+ }
108
+ });
109
+ await authManager.initialize({
110
+ jwtSecret: process.env.JWT_SECRET || 'acip-demo-secret'
111
+ });
112
+ await authManager.start();
113
+
114
+ const adminPassword = process.env.ADMIN_PASSWORD || 'admin';
115
+ try {
116
+ await authManager.registerUser('admin', {
117
+ password: adminPassword,
118
+ roles: ['admin']
119
+ });
120
+ const auth = await authManager.authenticate('admin', adminPassword);
121
+ if (auth.authenticated) {
122
+ console.log('[security] ready — admin authenticated');
123
+ }
124
+ } catch {
125
+ // 用户可能已存在
126
+ }
127
+ console.log('[security-authentication] ready');
128
+ } catch (err) {
129
+ console.warn(`[security-authentication] skipped: ${err.message}`);
130
+ }
60
131
 
61
- console.log('Assistant Response:', response.content);
132
+ // ── 启动交互式助手 ──
133
+ const modules = {
134
+ modelInvocation,
135
+ modelId,
136
+ provider: 'openai',
137
+ contextManager,
138
+ contextId,
139
+ blockchain,
140
+ auditService,
141
+ dataAccess,
142
+ authManager
143
+ };
62
144
 
63
- const history = assistant.getHistory();
64
- console.log(`Conversation has ${history.length} messages`);
145
+ const assistant = createAssistant(modules);
146
+ assistant.startREPL();
65
147
  }
66
148
 
67
149
  main().catch(console.error);
@@ -1,6 +1,7 @@
1
1
  import 'dotenv/config';
2
+ import { createCore } from '@acip/core';
2
3
  import { ModelInvocationModule, type ModelInvocationConfig } from '@acip/model-invocation';
3
- import { createAssistant } from './components/assistant.js';
4
+ import { createAssistant, type AssistantModules } from './components/assistant.js';
4
5
 
5
6
  type ProviderConfigWithEnabled = ModelInvocationConfig['providers'][number] & { enabled: boolean };
6
7
 
@@ -10,64 +11,142 @@ async function main(): Promise<void> {
10
11
  const modelId = process.env.DEFAULT_MODEL_ID || 'gpt-5.2';
11
12
 
12
13
  if (!apiKey) {
13
- throw new Error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY).');
14
+ console.error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY) in .env file.');
15
+ process.exit(1);
14
16
  }
15
17
 
18
+ // ── 1. ACIP Core ──
19
+ const core = createCore();
20
+ console.log(`[core] initialized (instance: ${core.instanceId})`);
21
+
22
+ // ── 2. Model Invocation ──
16
23
  const provider: ProviderConfigWithEnabled = {
17
24
  name: 'openai',
18
25
  apiKey,
19
26
  baseUrl,
20
27
  enabled: true,
21
- models: [
22
- {
23
- id: modelId,
24
- name: modelId,
25
- provider: 'openai',
26
- capabilities: ['chat'],
27
- parameters: {}
28
- }
29
- ]
28
+ models: [{
29
+ id: modelId,
30
+ name: modelId,
31
+ provider: 'openai',
32
+ capabilities: ['chat'],
33
+ parameters: {}
34
+ }]
30
35
  };
31
36
 
32
- const config: ModelInvocationConfig = {
37
+ const miConfig: ModelInvocationConfig = {
33
38
  providers: [provider],
34
39
  caching: { enabled: true, ttl: 600, maxSize: 100, strategy: 'lru' },
35
40
  observability: { enabled: true, metricsEnabled: true, tracingEnabled: false, exportInterval: 60000 },
36
41
  streaming: { enabled: false, chunkSize: 1, timeout: 60000 }
37
42
  };
38
43
 
39
- const modelInvocation = new ModelInvocationModule(config);
44
+ const modelInvocation = new ModelInvocationModule(miConfig);
40
45
 
41
46
  await new Promise<void>((resolve, reject) => {
42
47
  modelInvocation.once('ready', () => resolve());
43
48
  modelInvocation.once('error', (error) => reject(error));
44
49
  });
45
50
 
46
- // 事件监听
47
- modelInvocation.on('requestStarted', (data) => {
48
- console.log(`Model invocation started: ${data.requestId}`);
49
- });
51
+ console.log('[model-invocation] ready');
50
52
 
51
- modelInvocation.on('requestCompleted', (data) => {
52
- console.log(`Model invocation completed in ${data.duration}ms`);
53
- });
53
+ // ── 3. Context Management (降级运行) ──
54
+ let contextManager: any = null;
55
+ let contextId: string | null = null;
56
+ try {
57
+ const { ContextManager } = await import('@acip/context-management');
58
+ contextManager = new ContextManager(
59
+ core.instanceId,
60
+ core.stateManager,
61
+ core.telemetryService,
62
+ core.eventManager
63
+ );
64
+ await contextManager.initialize();
65
+ const ctx = await contextManager.createContext('main-conversation');
66
+ contextId = 'main-conversation';
67
+ console.log('[context-management] ready');
68
+ } catch (err: any) {
69
+ console.warn(`[context-management] skipped: ${err.message}`);
70
+ }
54
71
 
55
- // 创建并启动助手
56
- const assistant = createAssistant(modelInvocation, {
57
- modelId,
58
- provider: 'openai'
59
- });
72
+ // ── 4. Data Access (降级运行) ──
73
+ let dataAccess: any = null;
74
+ try {
75
+ const { DataAccessModule, InMemoryAdapter } = await import('@acip/data-access');
76
+ dataAccess = new DataAccessModule();
77
+ const adapter = new InMemoryAdapter();
78
+ await dataAccess.registerSource('notes', { adapter });
79
+ console.log('[data-access] ready');
80
+ } catch (err: any) {
81
+ console.warn(`[data-access] skipped: ${err.message}`);
82
+ }
60
83
 
61
- // 与助手互动
62
- const response = await assistant.sendMessage(
63
- 'Hello! I want to learn about adaptive context management in AI systems.'
64
- );
84
+ // ── 5. Blockchain + Audit (降级运行) ──
85
+ let blockchain: any = null;
86
+ let auditService: any = null;
87
+ try {
88
+ const { Blockchain, AuditService } = await import('@acip/blockchain');
89
+ blockchain = new Blockchain();
90
+ auditService = new AuditService(blockchain);
91
+ console.log('[blockchain] ready');
92
+ } catch (err: any) {
93
+ console.warn(`[blockchain] skipped: ${err.message}`);
94
+ }
95
+
96
+ // ── 6. Security & Authentication (降级运行) ──
97
+ let authManager: any = null;
98
+ try {
99
+ const { AuthManager } = await import('@acip/security-authentication');
100
+ authManager = new AuthManager({
101
+ passwordPolicy: {
102
+ minLength: 4,
103
+ requireNumbers: false,
104
+ requireLowercase: false,
105
+ requireUppercase: false,
106
+ requireSpecial: false,
107
+ maxRepeatingChars: 0,
108
+ preventCommonPasswords: false
109
+ }
110
+ });
111
+ await authManager.initialize({
112
+ jwtSecret: process.env.JWT_SECRET || 'acip-demo-secret'
113
+ });
114
+ await authManager.start();
115
+
116
+ // 注册 demo 用户
117
+ const adminPassword = process.env.ADMIN_PASSWORD || 'admin';
118
+ try {
119
+ await authManager.registerUser('admin', {
120
+ password: adminPassword,
121
+ roles: ['admin']
122
+ });
123
+ const auth = await authManager.authenticate('admin', adminPassword);
124
+ if (auth.authenticated) {
125
+ console.log('[security] ready — admin authenticated');
126
+ }
127
+ } catch {
128
+ // 用户可能已存在
129
+ }
130
+ console.log('[security-authentication] ready');
131
+ } catch (err: any) {
132
+ console.warn(`[security-authentication] skipped: ${err.message}`);
133
+ }
65
134
 
66
- console.log('Assistant Response:', response.content);
135
+ // ── 启动交互式助手 ──
136
+ const modules: AssistantModules = {
137
+ modelInvocation,
138
+ modelId,
139
+ provider: 'openai',
140
+ contextManager,
141
+ contextId,
142
+ blockchain,
143
+ auditService,
144
+ dataAccess,
145
+ authManager
146
+ };
67
147
 
68
- // 获取对话历史
69
- const history = assistant.getHistory();
70
- console.log(`Conversation has ${history.length} messages`);
148
+ const assistant = createAssistant(modules);
149
+ assistant.startREPL();
71
150
  }
72
151
 
73
152
  main().catch(console.error);
@@ -1,29 +1,37 @@
1
1
  import 'dotenv/config';
2
+ import * as readline from 'readline';
3
+ import { createCore } from '@acip/core';
2
4
  import { ModelInvocationModule } from '@acip/model-invocation';
3
5
 
6
+ const SYSTEM_PROMPT = `You are ACIP Assistant, an AI powered by the Adaptive Contextual Intelligence Protocol (ACIP). ACIP is a distributed AI communication protocol providing semantic routing, resource-aware scheduling, and edge computing support. Help users understand and build with ACIP.`;
7
+
4
8
  async function main() {
5
9
  const apiKey = process.env.OPENAI_API_KEY || process.env.ACIP_API_KEY;
6
10
  const baseUrl = process.env.OPENAI_BASE_URL || process.env.ACIP_BASE_URL;
7
11
  const modelId = process.env.DEFAULT_MODEL_ID || 'gpt-5.2';
8
12
 
9
13
  if (!apiKey) {
10
- throw new Error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY).');
14
+ console.error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY) in .env file.');
15
+ process.exit(1);
11
16
  }
12
17
 
18
+ // 初始化 ACIP Core
19
+ const core = createCore();
20
+ console.log(`ACIP Core initialized (instance: ${core.instanceId})`);
21
+
22
+ // 配置模型调用
13
23
  const provider = {
14
24
  name: 'openai',
15
25
  apiKey,
16
26
  baseUrl,
17
27
  enabled: true,
18
- models: [
19
- {
20
- id: modelId,
21
- name: modelId,
22
- provider: 'openai',
23
- capabilities: ['chat'],
24
- parameters: {}
25
- }
26
- ]
28
+ models: [{
29
+ id: modelId,
30
+ name: modelId,
31
+ provider: 'openai',
32
+ capabilities: ['chat'],
33
+ parameters: {}
34
+ }]
27
35
  };
28
36
 
29
37
  const config = {
@@ -40,16 +48,74 @@ async function main() {
40
48
  modelInvocation.once('error', (error) => reject(error));
41
49
  });
42
50
 
43
- const response = await modelInvocation.invoke({
44
- model: modelId,
45
- provider: 'openai',
46
- messages: [
47
- { role: 'system', content: 'You are a helpful assistant.' },
48
- { role: 'user', content: 'Hello! What can you tell me about ACIP?' }
49
- ]
51
+ console.log('Model Invocation ready');
52
+
53
+ // 对话历史
54
+ const history = [];
55
+
56
+ // 创建 REPL
57
+ const rl = readline.createInterface({
58
+ input: process.stdin,
59
+ output: process.stdout
50
60
  });
51
61
 
52
- console.log('AI Response:', response.content);
62
+ console.log('\n=== ACIP Assistant ===');
63
+ console.log('Type your message to chat with AI.');
64
+ console.log('Commands: /help, /clear, /exit\n');
65
+
66
+ const prompt = () => {
67
+ rl.question('You> ', async (input) => {
68
+ const trimmed = input.trim();
69
+ if (!trimmed) { prompt(); return; }
70
+
71
+ if (trimmed === '/exit' || trimmed === '/quit') {
72
+ console.log('Goodbye!');
73
+ rl.close();
74
+ process.exit(0);
75
+ }
76
+
77
+ if (trimmed === '/help') {
78
+ console.log('\nCommands:');
79
+ console.log(' /help - Show this help');
80
+ console.log(' /clear - Clear conversation history');
81
+ console.log(' /exit - Exit the application\n');
82
+ prompt();
83
+ return;
84
+ }
85
+
86
+ if (trimmed === '/clear') {
87
+ history.length = 0;
88
+ console.log('Conversation history cleared.\n');
89
+ prompt();
90
+ return;
91
+ }
92
+
93
+ try {
94
+ const messages = [
95
+ { role: 'system', content: SYSTEM_PROMPT },
96
+ ...history,
97
+ { role: 'user', content: trimmed }
98
+ ];
99
+
100
+ const response = await modelInvocation.invoke({
101
+ model: modelId,
102
+ provider: 'openai',
103
+ messages
104
+ });
105
+
106
+ history.push({ role: 'user', content: trimmed });
107
+ history.push({ role: 'assistant', content: response.content });
108
+
109
+ console.log(`\nAssistant> ${response.content}\n`);
110
+ } catch (error) {
111
+ console.error(`\nError: ${error.message}\n`);
112
+ }
113
+
114
+ prompt();
115
+ });
116
+ };
117
+
118
+ prompt();
53
119
  }
54
120
 
55
121
  main().catch(console.error);
@@ -1,7 +1,12 @@
1
1
  import 'dotenv/config';
2
+ import * as readline from 'readline';
3
+ import { createCore } from '@acip/core';
2
4
  import { ModelInvocationModule, type ModelInvocationConfig } from '@acip/model-invocation';
3
5
 
4
6
  type ProviderConfigWithEnabled = ModelInvocationConfig['providers'][number] & { enabled: boolean };
7
+ type Message = { role: 'system' | 'user' | 'assistant'; content: string };
8
+
9
+ const SYSTEM_PROMPT = `You are ACIP Assistant, an AI powered by the Adaptive Contextual Intelligence Protocol (ACIP). ACIP is a distributed AI communication protocol providing semantic routing, resource-aware scheduling, and edge computing support. Help users understand and build with ACIP.`;
5
10
 
6
11
  async function main(): Promise<void> {
7
12
  const apiKey = process.env.OPENAI_API_KEY || process.env.ACIP_API_KEY;
@@ -9,23 +14,27 @@ async function main(): Promise<void> {
9
14
  const modelId = process.env.DEFAULT_MODEL_ID || 'gpt-5.2';
10
15
 
11
16
  if (!apiKey) {
12
- throw new Error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY).');
17
+ console.error('Missing API key. Set OPENAI_API_KEY (or ACIP_API_KEY) in .env file.');
18
+ process.exit(1);
13
19
  }
14
20
 
21
+ // 初始化 ACIP Core
22
+ const core = createCore();
23
+ console.log(`ACIP Core initialized (instance: ${core.instanceId})`);
24
+
25
+ // 配置模型调用
15
26
  const provider: ProviderConfigWithEnabled = {
16
27
  name: 'openai',
17
28
  apiKey,
18
29
  baseUrl,
19
30
  enabled: true,
20
- models: [
21
- {
22
- id: modelId,
23
- name: modelId,
24
- provider: 'openai',
25
- capabilities: ['chat'],
26
- parameters: {}
27
- }
28
- ]
31
+ models: [{
32
+ id: modelId,
33
+ name: modelId,
34
+ provider: 'openai',
35
+ capabilities: ['chat'],
36
+ parameters: {}
37
+ }]
29
38
  };
30
39
 
31
40
  const config: ModelInvocationConfig = {
@@ -42,16 +51,74 @@ async function main(): Promise<void> {
42
51
  modelInvocation.once('error', (error) => reject(error));
43
52
  });
44
53
 
45
- const response = await modelInvocation.invoke({
46
- model: modelId,
47
- provider: 'openai',
48
- messages: [
49
- { role: 'system', content: 'You are a helpful assistant.' },
50
- { role: 'user', content: 'Hello! What can you tell me about ACIP?' }
51
- ]
54
+ console.log('Model Invocation ready');
55
+
56
+ // 对话历史
57
+ const history: Message[] = [];
58
+
59
+ // 创建 REPL
60
+ const rl = readline.createInterface({
61
+ input: process.stdin,
62
+ output: process.stdout
52
63
  });
53
64
 
54
- console.log('AI Response:', response.content);
65
+ console.log('\n=== ACIP Assistant ===');
66
+ console.log('Type your message to chat with AI.');
67
+ console.log('Commands: /help, /clear, /exit\n');
68
+
69
+ const prompt = (): void => {
70
+ rl.question('You> ', async (input) => {
71
+ const trimmed = input.trim();
72
+ if (!trimmed) { prompt(); return; }
73
+
74
+ if (trimmed === '/exit' || trimmed === '/quit') {
75
+ console.log('Goodbye!');
76
+ rl.close();
77
+ process.exit(0);
78
+ }
79
+
80
+ if (trimmed === '/help') {
81
+ console.log('\nCommands:');
82
+ console.log(' /help - Show this help');
83
+ console.log(' /clear - Clear conversation history');
84
+ console.log(' /exit - Exit the application\n');
85
+ prompt();
86
+ return;
87
+ }
88
+
89
+ if (trimmed === '/clear') {
90
+ history.length = 0;
91
+ console.log('Conversation history cleared.\n');
92
+ prompt();
93
+ return;
94
+ }
95
+
96
+ try {
97
+ const messages: Message[] = [
98
+ { role: 'system', content: SYSTEM_PROMPT },
99
+ ...history,
100
+ { role: 'user', content: trimmed }
101
+ ];
102
+
103
+ const response = await modelInvocation.invoke({
104
+ model: modelId,
105
+ provider: 'openai',
106
+ messages
107
+ });
108
+
109
+ history.push({ role: 'user', content: trimmed });
110
+ history.push({ role: 'assistant', content: response.content });
111
+
112
+ console.log(`\nAssistant> ${response.content}\n`);
113
+ } catch (error: any) {
114
+ console.error(`\nError: ${error.message}\n`);
115
+ }
116
+
117
+ prompt();
118
+ });
119
+ };
120
+
121
+ prompt();
55
122
  }
56
123
 
57
124
  main().catch(console.error);