@xagent-ai/cli 1.3.0 → 1.3.2
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/.github/release.yml +76 -0
- package/.github/workflows/ci.yml +3 -0
- package/.github/workflows/release.yml +11 -17
- package/README.md +2 -2
- package/README_CN.md +2 -2
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +7 -3
- package/dist/agents.js.map +1 -1
- package/dist/ai-client/factory.d.ts +0 -12
- package/dist/ai-client/factory.d.ts.map +1 -1
- package/dist/ai-client/factory.js +0 -32
- package/dist/ai-client/factory.js.map +1 -1
- package/dist/ai-client/index.js +1 -1
- package/dist/ai-client/index.js.map +1 -1
- package/dist/ai-client/providers/anthropic.d.ts.map +1 -1
- package/dist/ai-client/providers/anthropic.js +10 -4
- package/dist/ai-client/providers/anthropic.js.map +1 -1
- package/dist/ai-client/providers/openai.d.ts.map +1 -1
- package/dist/ai-client/providers/openai.js +8 -4
- package/dist/ai-client/providers/openai.js.map +1 -1
- package/dist/ai-client/providers/remote.d.ts +0 -1
- package/dist/ai-client/providers/remote.d.ts.map +1 -1
- package/dist/ai-client/providers/remote.js +11 -10
- package/dist/ai-client/providers/remote.js.map +1 -1
- package/dist/ai-client/types.d.ts +14 -0
- package/dist/ai-client/types.d.ts.map +1 -1
- package/dist/ai-client/types.js +17 -0
- package/dist/ai-client/types.js.map +1 -1
- package/dist/ai-client-factory.d.ts.map +1 -1
- package/dist/ai-client-factory.js +4 -4
- package/dist/ai-client-factory.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -12
- package/dist/auth.js.map +1 -1
- package/dist/cancellation.d.ts.map +1 -1
- package/dist/cancellation.js +3 -5
- package/dist/cancellation.js.map +1 -1
- package/dist/checkpoint.d.ts +1 -0
- package/dist/checkpoint.d.ts.map +1 -1
- package/dist/checkpoint.js +38 -4
- package/dist/checkpoint.js.map +1 -1
- package/dist/cli.js +132 -32
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/context-compressor.d.ts +1 -2
- package/dist/context-compressor.d.ts.map +1 -1
- package/dist/context-compressor.js +22 -17
- package/dist/context-compressor.js.map +1 -1
- package/dist/conversation.d.ts +1 -1
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +8 -7
- package/dist/conversation.js.map +1 -1
- package/dist/gui-subagent/action-parser/actionParser.js +2 -2
- package/dist/gui-subagent/action-parser/actionParser.js.map +1 -1
- package/dist/gui-subagent/agent/gui-agent.d.ts +10 -0
- package/dist/gui-subagent/agent/gui-agent.d.ts.map +1 -1
- package/dist/gui-subagent/agent/gui-agent.js +105 -32
- package/dist/gui-subagent/agent/gui-agent.js.map +1 -1
- package/dist/gui-subagent/index.d.ts +7 -0
- package/dist/gui-subagent/index.d.ts.map +1 -1
- package/dist/gui-subagent/index.js +2 -0
- package/dist/gui-subagent/index.js.map +1 -1
- package/dist/gui-subagent/operator/computer-operator.d.ts.map +1 -1
- package/dist/gui-subagent/operator/computer-operator.js +2 -0
- package/dist/gui-subagent/operator/computer-operator.js.map +1 -1
- package/dist/input-processor.js +2 -2
- package/dist/input-processor.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +84 -21
- package/dist/mcp.js.map +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +3 -3
- package/dist/memory.js.map +1 -1
- package/dist/output-util.d.ts +27 -0
- package/dist/output-util.d.ts.map +1 -0
- package/dist/output-util.js +74 -0
- package/dist/output-util.js.map +1 -0
- package/dist/retry.js +1 -1
- package/dist/retry.js.map +1 -1
- package/dist/ripgrep.d.ts.map +1 -1
- package/dist/ripgrep.js +5 -3
- package/dist/ripgrep.js.map +1 -1
- package/dist/sdk-output-adapter.d.ts +265 -0
- package/dist/sdk-output-adapter.d.ts.map +1 -0
- package/dist/sdk-output-adapter.js +701 -0
- package/dist/sdk-output-adapter.js.map +1 -0
- package/dist/sdk-session.d.ts +13 -0
- package/dist/sdk-session.d.ts.map +1 -0
- package/dist/sdk-session.js +50 -0
- package/dist/sdk-session.js.map +1 -0
- package/dist/session-manager.js +3 -3
- package/dist/session-manager.js.map +1 -1
- package/dist/session.d.ts +96 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +849 -262
- package/dist/session.js.map +1 -1
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +5 -4
- package/dist/shell.js.map +1 -1
- package/dist/skill-installer.js +3 -3
- package/dist/skill-installer.js.map +1 -1
- package/dist/skill-invoker.d.ts +1 -1
- package/dist/skill-invoker.d.ts.map +1 -1
- package/dist/skill-invoker.js +2 -2
- package/dist/skill-invoker.js.map +1 -1
- package/dist/skill-loader.js +6 -5
- package/dist/skill-loader.js.map +1 -1
- package/dist/skill-manager.d.ts.map +1 -1
- package/dist/skill-manager.js +3 -2
- package/dist/skill-manager.js.map +1 -1
- package/dist/slash-commands.d.ts +1 -1
- package/dist/slash-commands.d.ts.map +1 -1
- package/dist/slash-commands.js +24 -11
- package/dist/slash-commands.js.map +1 -1
- package/dist/smart-approval.d.ts +20 -1
- package/dist/smart-approval.d.ts.map +1 -1
- package/dist/smart-approval.js +58 -1
- package/dist/smart-approval.js.map +1 -1
- package/dist/system-prompt-generator.js +3 -3
- package/dist/system-prompt-generator.js.map +1 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +9 -8
- package/dist/theme.js.map +1 -1
- package/dist/tools.d.ts +15 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +487 -215
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +12 -9
- package/dist/update.js.map +1 -1
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +1 -2
- package/dist/workflow.js.map +1 -1
- package/docs/third-party-models.md +16 -15
- package/package.json +3 -1
- package/src/agents.ts +7 -3
- package/src/ai-client/factory.ts +1 -36
- package/src/ai-client/index.ts +1 -1
- package/src/ai-client/providers/anthropic.ts +12 -3
- package/src/ai-client/providers/openai.ts +10 -4
- package/src/ai-client/providers/remote.ts +13 -10
- package/src/ai-client/types.ts +19 -0
- package/src/ai-client-factory.ts +5 -5
- package/src/auth.ts +11 -13
- package/src/cancellation.ts +3 -6
- package/src/checkpoint.ts +41 -4
- package/src/cli.ts +154 -37
- package/src/config.ts +1 -1
- package/src/context-compressor.ts +27 -22
- package/src/conversation.ts +9 -7
- package/src/gui-subagent/action-parser/actionParser.ts +2 -2
- package/src/gui-subagent/agent/gui-agent.ts +117 -34
- package/src/gui-subagent/index.ts +8 -0
- package/src/gui-subagent/operator/computer-operator.ts +2 -1
- package/src/input-processor.ts +2 -2
- package/src/logger.ts +2 -4
- package/src/mcp.ts +87 -23
- package/src/memory.ts +3 -4
- package/src/output-util.ts +80 -0
- package/src/retry.ts +1 -1
- package/src/ripgrep.ts +5 -3
- package/src/sdk-output-adapter.ts +842 -0
- package/src/sdk-session.ts +62 -0
- package/src/session-manager.ts +3 -3
- package/src/session.ts +942 -302
- package/src/shell.ts +6 -5
- package/src/skill-installer.ts +3 -3
- package/src/skill-invoker.ts +3 -4
- package/src/skill-loader.ts +7 -7
- package/src/skill-manager.ts +4 -3
- package/src/slash-commands.ts +24 -16
- package/src/smart-approval.ts +76 -1
- package/src/system-prompt-generator.ts +3 -3
- package/src/theme.ts +10 -9
- package/src/tools.ts +563 -267
- package/src/types.ts +118 -0
- package/src/update.ts +12 -9
- package/src/workflow.ts +2 -4
- package/test/cli-launch.test.ts +279 -0
- package/vitest.config.ts +2 -0
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/src/ai-client-factory.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import type { Message, CompletionOptions, CompletionResponse, AIConfig, RemoteTaskManager, Model, RemoteModelsResponse } from './ai-client/types.js';
|
|
15
15
|
import { AuthConfig, AuthType } from './types.js';
|
|
16
|
-
import { ProviderFactory,
|
|
16
|
+
import { ProviderFactory, type AIProvider } from './ai-client/index.js';
|
|
17
17
|
import type { RemoteAIProvider } from './ai-client/types.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -62,19 +62,19 @@ class ProviderAdapter implements AIClientInterface {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// Optional methods - not available in local mode
|
|
65
|
-
completeTask?(
|
|
65
|
+
completeTask?(_taskId: string): Promise<void> {
|
|
66
66
|
throw new Error('completeTask is only available in remote mode');
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
cancelTask?(
|
|
69
|
+
cancelTask?(_taskId: string): Promise<void> {
|
|
70
70
|
throw new Error('cancelTask is only available in remote mode');
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
failTask?(
|
|
73
|
+
failTask?(_taskId: string, _reason: 'timeout' | 'failure'): Promise<void> {
|
|
74
74
|
throw new Error('failTask is only available in remote mode');
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
invokeVLM?(
|
|
77
|
+
invokeVLM?(_messages: Message[], _systemPrompt: string, _options?: { taskId?: string; status?: 'begin' | 'continue'; signal?: AbortSignal }): Promise<string> {
|
|
78
78
|
throw new Error('invokeVLM is only available in remote mode');
|
|
79
79
|
}
|
|
80
80
|
|
package/src/auth.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import open from 'open';
|
|
3
|
-
import { select,
|
|
3
|
+
import { select, text, password } from '@clack/prompts';
|
|
4
4
|
import https from 'https';
|
|
5
5
|
import { AuthConfig, AuthType } from './types.js';
|
|
6
6
|
import { getLogger } from './logger.js';
|
|
@@ -59,14 +59,13 @@ export interface ThirdPartyProvider {
|
|
|
59
59
|
|
|
60
60
|
export const THIRD_PARTY_PROVIDERS: ThirdPartyProvider[] = [
|
|
61
61
|
{
|
|
62
|
-
name: 'Zhipu AI (GLM-
|
|
62
|
+
name: 'Zhipu AI (GLM-5)',
|
|
63
63
|
baseUrl: 'https://open.bigmodel.cn/api/coding/paas/v4/',
|
|
64
|
-
defaultModel: 'glm-
|
|
65
|
-
description: 'Zhipu AI GLM-
|
|
64
|
+
defaultModel: 'glm-5',
|
|
65
|
+
description: 'Zhipu AI GLM-5 series models',
|
|
66
66
|
models: [
|
|
67
|
+
'glm-5',
|
|
67
68
|
'glm-4.7',
|
|
68
|
-
'glm-4',
|
|
69
|
-
'glm-4-plus',
|
|
70
69
|
'glm-4-0520',
|
|
71
70
|
'glm-4-air',
|
|
72
71
|
'glm-4-airx',
|
|
@@ -105,9 +104,9 @@ export const THIRD_PARTY_PROVIDERS: ThirdPartyProvider[] = [
|
|
|
105
104
|
{
|
|
106
105
|
name: 'MiniMax',
|
|
107
106
|
baseUrl: 'https://api.minimax.chat/anthropic',
|
|
108
|
-
defaultModel: 'MiniMax-M2.
|
|
107
|
+
defaultModel: 'MiniMax-M2.5',
|
|
109
108
|
description: 'MiniMax (Anthropic-compatible format)',
|
|
110
|
-
models: ['MiniMax-M2.1', 'MiniMax-M2.1-lightning', 'MiniMax-M2', 'MiniMax-M2-Stable'],
|
|
109
|
+
models: ['MiniMax-M2.5', 'MiniMax-M2.1', 'MiniMax-M2.1-lightning', 'MiniMax-M2', 'MiniMax-M2-Stable'],
|
|
111
110
|
},
|
|
112
111
|
{
|
|
113
112
|
name: '01.AI (Yi)',
|
|
@@ -182,7 +181,7 @@ export class AuthService {
|
|
|
182
181
|
// 2. 调用后端验证用户
|
|
183
182
|
const xagentApiBaseUrl = this.authConfig.xagentApiBaseUrl || 'https://www.xagent-colife.net';
|
|
184
183
|
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
|
|
185
|
-
|
|
184
|
+
await axios.get(`${xagentApiBaseUrl}/api/auth/me`, {
|
|
186
185
|
headers: { Authorization: `Bearer ${token}` },
|
|
187
186
|
httpsAgent,
|
|
188
187
|
});
|
|
@@ -322,7 +321,7 @@ export class AuthService {
|
|
|
322
321
|
const response = await axios.post(
|
|
323
322
|
`${this.authConfig.baseUrl}/v1/messages`,
|
|
324
323
|
{
|
|
325
|
-
model: 'MiniMax-M2',
|
|
324
|
+
model: 'MiniMax-M2.5',
|
|
326
325
|
max_tokens: 1,
|
|
327
326
|
messages: [{ role: 'user', content: 'test' }],
|
|
328
327
|
},
|
|
@@ -405,14 +404,13 @@ export class AuthService {
|
|
|
405
404
|
// Local dev: frontend runs on port 3000
|
|
406
405
|
// Production: frontend is served via nginx reverse proxy at the same domain
|
|
407
406
|
let loginUrl: string;
|
|
408
|
-
let callbackUrl: string;
|
|
409
407
|
|
|
410
408
|
// Always use frontend URL for login page
|
|
411
409
|
const frontendUrl = isLocalDev
|
|
412
410
|
? process.env.FRONTEND_URL || 'http://localhost:3000'
|
|
413
411
|
: webBaseUrl;
|
|
414
412
|
|
|
415
|
-
callbackUrl = `${webBaseUrl}/callback`;
|
|
413
|
+
const callbackUrl = `${webBaseUrl}/callback`;
|
|
416
414
|
loginUrl = `${frontendUrl}/login?callback=${encodeURIComponent(callbackUrl)}`;
|
|
417
415
|
|
|
418
416
|
// 如果已有保存的token,通过URL参数传给Web页面
|
|
@@ -654,7 +652,7 @@ export async function selectAuthType(): Promise<AuthType> {
|
|
|
654
652
|
{ value: AuthType.OAUTH_XAGENT, label: 'Log in with xAgent – Start your free trial' },
|
|
655
653
|
{
|
|
656
654
|
value: AuthType.OPENAI_COMPATIBLE,
|
|
657
|
-
label: 'Use third-party model APIs (e.g., Zhipu
|
|
655
|
+
label: 'Use third-party model APIs (e.g., Zhipu glm-5, MiniMax)',
|
|
658
656
|
},
|
|
659
657
|
],
|
|
660
658
|
})) as AuthType;
|
package/src/cancellation.ts
CHANGED
|
@@ -29,13 +29,10 @@ export class CancellationManager extends EventEmitter {
|
|
|
29
29
|
// Use readline's keypress handling
|
|
30
30
|
readline.emitKeypressEvents(process.stdin);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const self = this;
|
|
34
|
-
|
|
35
|
-
this.keyPressHandler = function(str: string, key: readline.Key) {
|
|
32
|
+
this.keyPressHandler = (str: string, key: readline.Key) => {
|
|
36
33
|
// ESC 可以通过 str 为空且 name 为 'escape' 或 sequence 为 '\x1b' 来检测
|
|
37
34
|
if (str === '\u001B' || key.name === 'escape' || key.sequence === '\x1b') {
|
|
38
|
-
|
|
35
|
+
this.cancel();
|
|
39
36
|
}
|
|
40
37
|
};
|
|
41
38
|
|
|
@@ -148,7 +145,7 @@ export class CancellationManager extends EventEmitter {
|
|
|
148
145
|
});
|
|
149
146
|
|
|
150
147
|
// Listen for cancellation event
|
|
151
|
-
const onCancelled = (
|
|
148
|
+
const onCancelled = (_opId: string | null) => {
|
|
152
149
|
if (rejectCancellation) {
|
|
153
150
|
rejectCancellation(new Error('Operation cancelled by user'));
|
|
154
151
|
}
|
package/src/checkpoint.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { exec } from 'child_process';
|
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
import crypto from 'crypto';
|
|
7
7
|
import { Checkpoint, ChatMessage, ToolCall } from './types.js';
|
|
8
|
+
import { output as logOutput } from './output-util.js';
|
|
9
|
+
import { icons } from './theme.js';
|
|
8
10
|
|
|
9
11
|
const execAsync = promisify(exec);
|
|
10
12
|
|
|
@@ -47,6 +49,7 @@ export class CheckpointManager {
|
|
|
47
49
|
await fs.access(gitDir);
|
|
48
50
|
} catch {
|
|
49
51
|
console.log('Initializing shadow Git repository for checkpoints...');
|
|
52
|
+
await logOutput('info', 'Initializing shadow Git repository for checkpoints...');
|
|
50
53
|
await execAsync('git init', { cwd: this.snapshotsDir });
|
|
51
54
|
await execAsync('git config user.email "xagent@checkpoint.local"', { cwd: this.snapshotsDir });
|
|
52
55
|
await execAsync('git config user.name "xAgent Checkpoint"', { cwd: this.snapshotsDir });
|
|
@@ -67,6 +70,7 @@ export class CheckpointManager {
|
|
|
67
70
|
}
|
|
68
71
|
} catch (error) {
|
|
69
72
|
console.error('Failed to load existing checkpoints:', error);
|
|
73
|
+
await logOutput('error', 'Failed to load existing checkpoints', { error: (error as Error).message });
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -92,7 +96,8 @@ export class CheckpointManager {
|
|
|
92
96
|
this.checkpoints.set(checkpointId, checkpoint);
|
|
93
97
|
await this.cleanupOldCheckpoints();
|
|
94
98
|
|
|
95
|
-
console.log(
|
|
99
|
+
console.log(`${icons.success} Checkpoint created: ${checkpointId}`);
|
|
100
|
+
await logOutput('success', `Checkpoint created: ${checkpointId}`);
|
|
96
101
|
return checkpoint;
|
|
97
102
|
}
|
|
98
103
|
|
|
@@ -103,6 +108,7 @@ export class CheckpointManager {
|
|
|
103
108
|
await execAsync(`git tag ${checkpointId}`, { cwd: this.snapshotsDir });
|
|
104
109
|
} catch (error) {
|
|
105
110
|
console.error('Failed to create Git snapshot:', error);
|
|
111
|
+
await logOutput('error', 'Failed to create Git snapshot', { error: (error as Error).message });
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
|
|
@@ -121,10 +127,12 @@ export class CheckpointManager {
|
|
|
121
127
|
console.log(`Restoring checkpoint: ${checkpointId}`);
|
|
122
128
|
console.log(`Description: ${checkpoint.description}`);
|
|
123
129
|
console.log(`Created: ${new Date(checkpoint.timestamp).toLocaleString()}`);
|
|
130
|
+
await logOutput('info', `Restoring checkpoint: ${checkpointId}`, { description: checkpoint.description, timestamp: checkpoint.timestamp });
|
|
124
131
|
|
|
125
132
|
await this.restoreGitSnapshot(checkpointId);
|
|
126
133
|
|
|
127
|
-
console.log(
|
|
134
|
+
console.log(`${icons.success} Checkpoint restored successfully`);
|
|
135
|
+
await logOutput('success', `Checkpoint restored successfully: ${checkpointId}`);
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
private async restoreGitSnapshot(checkpointId: string): Promise<void> {
|
|
@@ -132,6 +140,7 @@ export class CheckpointManager {
|
|
|
132
140
|
await execAsync(`git checkout ${checkpointId}`, { cwd: this.snapshotsDir });
|
|
133
141
|
} catch (error) {
|
|
134
142
|
console.error('Failed to restore Git snapshot:', error);
|
|
143
|
+
await logOutput('error', 'Failed to restore Git snapshot', { error: (error as Error).message });
|
|
135
144
|
throw new Error(`Failed to restore checkpoint: ${error}`);
|
|
136
145
|
}
|
|
137
146
|
}
|
|
@@ -160,12 +169,15 @@ export class CheckpointManager {
|
|
|
160
169
|
await execAsync(`git tag -d ${checkpointId}`, { cwd: this.snapshotsDir });
|
|
161
170
|
} catch (error) {
|
|
162
171
|
console.warn('Failed to delete Git tag:', error);
|
|
172
|
+
await logOutput('warning', `Failed to delete Git tag: ${checkpointId}`);
|
|
163
173
|
}
|
|
164
174
|
|
|
165
175
|
this.checkpoints.delete(checkpointId);
|
|
166
|
-
console.log(
|
|
176
|
+
console.log(`${icons.success} Checkpoint deleted: ${checkpointId}`);
|
|
177
|
+
await logOutput('success', `Checkpoint deleted: ${checkpointId}`);
|
|
167
178
|
} catch (error) {
|
|
168
179
|
console.error('Failed to delete checkpoint:', error);
|
|
180
|
+
await logOutput('error', 'Failed to delete checkpoint', { error: (error as Error).message });
|
|
169
181
|
throw error;
|
|
170
182
|
}
|
|
171
183
|
}
|
|
@@ -184,10 +196,34 @@ export class CheckpointManager {
|
|
|
184
196
|
await this.deleteCheckpoint(checkpoint.id);
|
|
185
197
|
} catch (error) {
|
|
186
198
|
console.error(`Failed to delete old checkpoint ${checkpoint.id}:`, error);
|
|
199
|
+
await logOutput('error', `Failed to delete old checkpoint ${checkpoint.id}`, { error: (error as Error).message });
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
202
|
}
|
|
190
203
|
|
|
204
|
+
async cleanupAllCheckpoints(): Promise<void> {
|
|
205
|
+
try {
|
|
206
|
+
const checkpoints = this.listCheckpoints();
|
|
207
|
+
|
|
208
|
+
for (const checkpoint of checkpoints) {
|
|
209
|
+
const metadataPath = path.join(this.checkpointsDir, `${checkpoint.id}.json`);
|
|
210
|
+
try {
|
|
211
|
+
await fs.unlink(metadataPath);
|
|
212
|
+
} catch {
|
|
213
|
+
// Ignore if file doesn't exist
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
this.checkpoints.delete(checkpoint.id);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
console.log(`${icons.success} Checkpoint data cleaned up`);
|
|
220
|
+
await logOutput('success', 'Checkpoint data cleaned up');
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error('Failed to cleanup checkpoint data:', error);
|
|
223
|
+
await logOutput('error', 'Failed to cleanup checkpoint data', { error: (error as Error).message });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
191
227
|
isEnabled(): boolean {
|
|
192
228
|
return this.enabled;
|
|
193
229
|
}
|
|
@@ -201,7 +237,7 @@ export class CheckpointManager {
|
|
|
201
237
|
await fs.rm(this.snapshotsDir, { recursive: true, force: true });
|
|
202
238
|
await fs.rm(this.checkpointsDir, { recursive: true, force: true });
|
|
203
239
|
this.checkpoints.clear();
|
|
204
|
-
console.log(
|
|
240
|
+
console.log(`${icons.success} Checkpoint data cleaned up`);
|
|
205
241
|
} catch (error) {
|
|
206
242
|
console.error('Failed to cleanup checkpoint data:', error);
|
|
207
243
|
}
|
|
@@ -217,3 +253,4 @@ export function getCheckpointManager(projectRoot?: string, enabled?: boolean, ma
|
|
|
217
253
|
}
|
|
218
254
|
return checkpointManagerInstance!;
|
|
219
255
|
}
|
|
256
|
+
|