codecane 1.0.207 → 1.0.237
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/background-process-manager.d.ts +50 -0
- package/dist/background-process-manager.js +320 -0
- package/dist/background-process-manager.js.map +1 -0
- package/dist/browser-runner.js +40 -34
- package/dist/browser-runner.js.map +1 -1
- package/dist/checkpoints/checkpoint-manager.d.ts +30 -9
- package/dist/checkpoints/checkpoint-manager.js +119 -32
- package/dist/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/checkpoints/file-manager.js +14 -6
- package/dist/checkpoints/file-manager.js.map +1 -1
- package/dist/cli-handlers/api-key.d.ts +25 -0
- package/dist/cli-handlers/api-key.js +66 -0
- package/dist/cli-handlers/api-key.js.map +1 -0
- package/dist/cli-handlers/checkpoint.d.ts +18 -0
- package/dist/cli-handlers/checkpoint.js +195 -0
- package/dist/cli-handlers/checkpoint.js.map +1 -0
- package/dist/cli-handlers/diff.d.ts +2 -0
- package/dist/cli-handlers/diff.js +31 -0
- package/dist/cli-handlers/diff.js.map +1 -0
- package/dist/cli-handlers/easter-egg.d.ts +1 -0
- package/dist/cli-handlers/easter-egg.js +126 -0
- package/dist/cli-handlers/easter-egg.js.map +1 -0
- package/dist/cli-handlers/inititalization-flow.d.ts +1 -0
- package/dist/cli-handlers/inititalization-flow.js +24 -0
- package/dist/cli-handlers/inititalization-flow.js.map +1 -0
- package/dist/cli.d.ts +8 -11
- package/dist/cli.js +171 -320
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +34 -124
- package/dist/client.js +395 -154
- package/dist/client.js.map +1 -1
- package/dist/code-map/languages.d.ts +0 -1
- package/dist/code-map/languages.js +23 -224
- package/dist/code-map/languages.js.map +1 -1
- package/dist/code-map/parse.js +1 -0
- package/dist/code-map/parse.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +369 -826
- package/dist/common/actions.js +25 -31
- package/dist/common/actions.js.map +1 -1
- package/dist/common/api-keys/constants.d.ts +8 -0
- package/dist/common/api-keys/constants.js +26 -0
- package/dist/common/api-keys/constants.js.map +1 -0
- package/dist/common/api-keys/crypto.d.ts +24 -0
- package/dist/common/api-keys/crypto.js +186 -0
- package/dist/common/api-keys/crypto.js.map +1 -0
- package/dist/common/bigquery/client.d.ts +15 -0
- package/dist/common/bigquery/client.js +246 -0
- package/dist/common/bigquery/client.js.map +1 -0
- package/dist/common/bigquery/schema.d.ts +55 -0
- package/dist/common/bigquery/schema.js +24 -0
- package/dist/common/bigquery/schema.js.map +1 -0
- package/dist/common/billing/auto-topup.d.ts +8 -0
- package/dist/common/billing/auto-topup.js +192 -0
- package/dist/common/billing/auto-topup.js.map +1 -0
- package/dist/common/billing/balance-calculator.d.ts +57 -0
- package/dist/common/billing/balance-calculator.js +218 -0
- package/dist/common/billing/balance-calculator.js.map +1 -0
- package/dist/common/billing/conversion.d.ts +9 -0
- package/dist/common/billing/conversion.js +20 -0
- package/dist/common/billing/conversion.js.map +1 -0
- package/dist/common/billing/credit-conversion.d.ts +24 -0
- package/dist/common/billing/credit-conversion.js +48 -0
- package/dist/common/billing/credit-conversion.js.map +1 -0
- package/dist/common/billing/grant-credits.d.ts +43 -0
- package/dist/common/billing/grant-credits.js +266 -0
- package/dist/common/billing/grant-credits.js.map +1 -0
- package/dist/common/billing/plans.d.ts +13 -0
- package/dist/common/billing/plans.js +44 -0
- package/dist/common/billing/plans.js.map +1 -0
- package/dist/common/browser-actions.d.ts +1 -1
- package/dist/common/browser-actions.js +4 -4
- package/dist/common/browser-actions.js.map +1 -1
- package/dist/common/constants/grant-priorities.d.ts +2 -0
- package/dist/common/constants/grant-priorities.js +10 -0
- package/dist/common/constants/grant-priorities.js.map +1 -0
- package/dist/common/constants/tools.d.ts +2 -0
- package/dist/common/constants/tools.js +24 -3
- package/dist/common/constants/tools.js.map +1 -1
- package/dist/common/constants.d.ts +93 -5
- package/dist/common/constants.js +111 -10
- package/dist/common/constants.js.map +1 -1
- package/dist/common/db/env.mjs +5 -5
- package/dist/common/db/env.mjs.map +1 -1
- package/dist/common/db/schema.d.ts +413 -83
- package/dist/common/db/schema.js +70 -9
- package/dist/common/db/schema.js.map +1 -1
- package/dist/common/db/transaction.d.ts +12 -0
- package/dist/common/db/transaction.js +36 -0
- package/dist/common/db/transaction.js.map +1 -0
- package/dist/common/env.mjs +11 -8
- package/dist/common/env.mjs.map +1 -1
- package/dist/common/json-config/__tests__/__snapshots__/stringify-schema.test.js.snap +66 -0
- package/dist/common/json-config/__tests__/stringify-schema.test.d.ts +1 -0
- package/dist/common/json-config/__tests__/stringify-schema.test.js +66 -0
- package/dist/common/json-config/__tests__/stringify-schema.test.js.map +1 -0
- package/dist/common/json-config/constants.d.ts +82 -0
- package/dist/common/json-config/constants.js +48 -0
- package/dist/common/json-config/constants.js.map +1 -0
- package/dist/common/json-config/parser.d.ts +7 -0
- package/dist/common/json-config/parser.js +51 -0
- package/dist/common/json-config/parser.js.map +1 -0
- package/dist/common/json-config/stringify-schema.d.ts +10 -0
- package/dist/common/json-config/stringify-schema.js +102 -0
- package/dist/common/json-config/stringify-schema.js.map +1 -0
- package/dist/common/project-file-tree.d.ts +2 -1
- package/dist/common/project-file-tree.js +59 -27
- package/dist/common/project-file-tree.js.map +1 -1
- package/dist/common/types/agent-state.d.ts +25 -22
- package/dist/common/types/agent-state.js +2 -0
- package/dist/common/types/agent-state.js.map +1 -1
- package/dist/common/types/grant.d.ts +2 -0
- package/dist/common/types/grant.js +10 -0
- package/dist/common/types/grant.js.map +1 -0
- package/dist/common/types/usage.d.ts +37 -18
- package/dist/common/types/usage.js +9 -6
- package/dist/common/types/usage.js.map +1 -1
- package/dist/common/util/__tests__/saxy.test.d.ts +1 -0
- package/dist/common/util/__tests__/saxy.test.js +262 -0
- package/dist/common/util/__tests__/saxy.test.js.map +1 -0
- package/dist/common/util/__tests__/string.test.js +2 -3
- package/dist/common/util/__tests__/string.test.js.map +1 -1
- package/dist/common/util/changes.d.ts +1 -0
- package/dist/common/util/changes.js +8 -2
- package/dist/common/util/changes.js.map +1 -1
- package/dist/common/util/dates.d.ts +10 -1
- package/dist/common/util/dates.js +11 -2
- package/dist/common/util/dates.js.map +1 -1
- package/dist/common/util/file.d.ts +10 -9
- package/dist/common/util/file.js +12 -4
- package/dist/common/util/file.js.map +1 -1
- package/dist/common/util/logger.d.ts +8 -0
- package/dist/common/util/logger.js +52 -0
- package/dist/common/util/logger.js.map +1 -0
- package/dist/common/util/lru-cache.d.ts +23 -2
- package/dist/common/util/lru-cache.js +44 -18
- package/dist/common/util/lru-cache.js.map +1 -1
- package/dist/common/util/messages.d.ts +3 -0
- package/dist/common/util/messages.js +50 -3
- package/dist/common/util/messages.js.map +1 -1
- package/dist/common/util/min-heap.js +2 -2
- package/dist/common/util/min-heap.js.map +1 -1
- package/dist/common/util/promise.d.ts +1 -1
- package/dist/common/util/promise.js +2 -2
- package/dist/common/util/promise.js.map +1 -1
- package/dist/common/util/saxy.d.ts +8 -0
- package/dist/common/util/saxy.js +35 -12
- package/dist/common/util/saxy.js.map +1 -1
- package/dist/common/util/string.d.ts +7 -1
- package/dist/common/util/string.js +20 -4
- package/dist/common/util/string.js.map +1 -1
- package/dist/common/util/stripe.d.ts +1 -0
- package/dist/common/util/stripe.js +10 -7
- package/dist/common/util/stripe.js.map +1 -1
- package/dist/common/util/sync-failure.d.ts +1 -0
- package/dist/common/util/sync-failure.js +57 -0
- package/dist/common/util/sync-failure.js.map +1 -0
- package/dist/common/websockets/websocket-client.d.ts +2 -1
- package/dist/common/websockets/websocket-client.js +34 -6
- package/dist/common/websockets/websocket-client.js.map +1 -1
- package/dist/common/websockets/websocket-schema.d.ts +1440 -2642
- package/dist/config.d.ts +2 -1
- package/dist/config.js +6 -3
- package/dist/config.js.map +1 -1
- package/dist/credentials.js +3 -2
- package/dist/credentials.js.map +1 -1
- package/dist/dev-process-manager.d.ts +10 -0
- package/dist/dev-process-manager.js +54 -0
- package/dist/dev-process-manager.js.map +1 -0
- package/dist/fingerprint.js +7 -2
- package/dist/fingerprint.js.map +1 -1
- package/dist/index.js +79 -74
- package/dist/index.js.map +1 -1
- package/dist/menu.js +20 -13
- package/dist/menu.js.map +1 -1
- package/dist/project-files.d.ts +10 -6
- package/dist/project-files.js +55 -32
- package/dist/project-files.js.map +1 -1
- package/dist/startup-process-handler.d.ts +2 -0
- package/dist/startup-process-handler.js +21 -0
- package/dist/startup-process-handler.js.map +1 -0
- package/dist/tool-handlers.d.ts +1 -0
- package/dist/tool-handlers.js +46 -23
- package/dist/tool-handlers.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/update-codebuff.js +3 -1
- package/dist/update-codebuff.js.map +1 -1
- package/dist/utils/__tests__/background-process-manager.test.d.ts +1 -0
- package/dist/utils/__tests__/background-process-manager.test.js +289 -0
- package/dist/utils/__tests__/background-process-manager.test.js.map +1 -0
- package/dist/utils/__tests__/response-example-4-files.txt +621 -0
- package/dist/utils/__tests__/tool-renderers.test.d.ts +1 -0
- package/dist/utils/__tests__/tool-renderers.test.js +51 -0
- package/dist/utils/__tests__/tool-renderers.test.js.map +1 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js +29 -21
- package/dist/utils/__tests__/xml-stream-parser.test.js.map +1 -1
- package/dist/utils/terminal.d.ts +12 -1
- package/dist/utils/terminal.js +148 -23
- package/dist/utils/terminal.js.map +1 -1
- package/dist/utils/tool-renderers.js +45 -17
- package/dist/utils/tool-renderers.js.map +1 -1
- package/dist/workers/checkpoint-worker.js +4 -3
- package/dist/workers/checkpoint-worker.js.map +1 -1
- package/package.json +20 -35
- package/dist/common/billing/quota-manager.d.ts +0 -29
- package/dist/common/billing/quota-manager.js +0 -213
- package/dist/common/billing/quota-manager.js.map +0 -1
- package/dist/common/util/tools.d.ts +0 -2
- package/dist/common/util/tools.js +0 -13
- package/dist/common/util/tools.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -2
- package/dist/utils/logger.js +0 -33
- package/dist/utils/logger.js.map +0 -1
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { AgentState } from '../common/types/agent-state';
|
|
1
|
+
import { AgentState, ToolResult } from '../common/types/agent-state';
|
|
2
|
+
export declare class CheckpointsDisabledError extends Error {
|
|
3
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Interface representing a checkpoint of agent state
|
|
4
7
|
*/
|
|
5
8
|
export interface Checkpoint {
|
|
6
9
|
agentStateString: string;
|
|
10
|
+
lastToolResultsString: string;
|
|
7
11
|
/** Promise resolving to the git commit hash for this checkpoint */
|
|
8
12
|
fileStateIdPromise: Promise<string>;
|
|
9
13
|
/** Number of messages in the agent's history at checkpoint time */
|
|
10
14
|
historyLength: number;
|
|
11
15
|
id: number;
|
|
16
|
+
parentId: number;
|
|
12
17
|
timestamp: number;
|
|
13
18
|
/** User input that triggered this checkpoint */
|
|
14
19
|
userInput: string;
|
|
@@ -20,8 +25,11 @@ export interface Checkpoint {
|
|
|
20
25
|
*/
|
|
21
26
|
export declare class CheckpointManager {
|
|
22
27
|
checkpoints: Array<Checkpoint>;
|
|
23
|
-
|
|
28
|
+
currentCheckpointId: number;
|
|
24
29
|
disabledReason: string | null;
|
|
30
|
+
private bareRepoPath;
|
|
31
|
+
/** Stores the undo chain (leaf node first, current node last) */
|
|
32
|
+
private undoIds;
|
|
25
33
|
/** Worker thread for git operations */
|
|
26
34
|
private worker;
|
|
27
35
|
/**
|
|
@@ -33,7 +41,7 @@ export declare class CheckpointManager {
|
|
|
33
41
|
* Execute an operation in the worker thread with timeout handling
|
|
34
42
|
* @param message - The message describing the operation to perform
|
|
35
43
|
* @returns A promise that resolves with the operation result
|
|
36
|
-
* @throws Error if the operation fails or times out
|
|
44
|
+
* @throws {Error} if the operation fails or times out
|
|
37
45
|
*/
|
|
38
46
|
private runWorkerOperation;
|
|
39
47
|
/**
|
|
@@ -44,25 +52,38 @@ export declare class CheckpointManager {
|
|
|
44
52
|
/**
|
|
45
53
|
* Add a new checkpoint of the current agent and file state
|
|
46
54
|
* @param agentState - The current agent state to checkpoint
|
|
55
|
+
* @param lastToolResults - The tool results from the last assistant turn
|
|
47
56
|
* @param userInput - The user input that triggered this checkpoint
|
|
48
|
-
* @returns The
|
|
57
|
+
* @returns The latest checkpoint and whether that checkpoint was created (or already existed)
|
|
58
|
+
* @throws {Error} If the checkpoint cannot be added
|
|
49
59
|
*/
|
|
50
|
-
addCheckpoint(agentState: AgentState, userInput: string): Promise<
|
|
60
|
+
addCheckpoint(agentState: AgentState, lastToolResults: ToolResult[], userInput: string, saveWithNoChanges?: boolean): Promise<{
|
|
61
|
+
checkpoint: Checkpoint;
|
|
62
|
+
created: boolean;
|
|
63
|
+
}>;
|
|
51
64
|
/**
|
|
52
65
|
* Get the most recent checkpoint
|
|
53
66
|
* @returns The most recent checkpoint or null if none exist
|
|
67
|
+
* @throws {CheckpointsDisabledError} If checkpoints are disabled
|
|
68
|
+
* @throws {ReferenceError} If no checkpoints exist
|
|
54
69
|
*/
|
|
55
|
-
getLatestCheckpoint(): Checkpoint
|
|
70
|
+
getLatestCheckpoint(): Checkpoint;
|
|
56
71
|
/**
|
|
57
72
|
* Restore the file state from a specific checkpoint
|
|
58
73
|
* @param id - The ID of the checkpoint to restore
|
|
59
|
-
* @
|
|
74
|
+
* @param resetUndoIds - Whether to reset the chain of undo/redo ids
|
|
75
|
+
* @throws {Error} If the file state cannot be restored
|
|
60
76
|
*/
|
|
61
|
-
restoreCheckointFileState(id
|
|
77
|
+
restoreCheckointFileState({ id, resetUndoIds, }: {
|
|
78
|
+
id: number;
|
|
79
|
+
resetUndoIds?: boolean;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
restoreUndoCheckpoint(): Promise<void>;
|
|
82
|
+
restoreRedoCheckpoint(): Promise<void>;
|
|
62
83
|
/**
|
|
63
84
|
* Clear all checkpoints
|
|
64
85
|
*/
|
|
65
|
-
clearCheckpoints(): void;
|
|
86
|
+
clearCheckpoints(resetBareRepoPath?: boolean): void;
|
|
66
87
|
/**
|
|
67
88
|
* Get a formatted string representation of all checkpoints
|
|
68
89
|
* @param detailed Whether to include detailed information about each checkpoint
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkpointManager = exports.CheckpointManager = void 0;
|
|
6
|
+
exports.checkpointManager = exports.CheckpointManager = exports.CheckpointsDisabledError = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
4
9
|
const path_1 = require("path");
|
|
5
|
-
const picocolors_1 = require("picocolors");
|
|
6
10
|
const worker_threads_1 = require("worker_threads");
|
|
7
11
|
const project_file_tree_1 = require("../common/project-file-tree");
|
|
8
|
-
const
|
|
12
|
+
const picocolors_1 = require("picocolors");
|
|
9
13
|
const project_files_1 = require("../project-files");
|
|
14
|
+
const file_manager_1 = require("./file-manager");
|
|
15
|
+
class CheckpointsDisabledError extends Error {
|
|
16
|
+
constructor(message, options) {
|
|
17
|
+
super(message, options);
|
|
18
|
+
this.name = 'CheckpointsDisabledError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CheckpointsDisabledError = CheckpointsDisabledError;
|
|
10
22
|
/**
|
|
11
23
|
* Manages checkpoints of agent state and file state using git operations in a worker thread.
|
|
12
24
|
* Each checkpoint contains both the agent's conversation state and a git commit
|
|
@@ -14,8 +26,11 @@ const project_files_1 = require("../project-files");
|
|
|
14
26
|
*/
|
|
15
27
|
class CheckpointManager {
|
|
16
28
|
checkpoints = [];
|
|
17
|
-
|
|
29
|
+
currentCheckpointId = 0;
|
|
18
30
|
disabledReason = null;
|
|
31
|
+
bareRepoPath = null;
|
|
32
|
+
/** Stores the undo chain (leaf node first, current node last) */
|
|
33
|
+
undoIds = [];
|
|
19
34
|
/** Worker thread for git operations */
|
|
20
35
|
worker = null;
|
|
21
36
|
/**
|
|
@@ -24,7 +39,7 @@ class CheckpointManager {
|
|
|
24
39
|
*/
|
|
25
40
|
initWorker() {
|
|
26
41
|
if (!this.worker) {
|
|
27
|
-
// NOTE: Uses the built worker
|
|
42
|
+
// NOTE: Uses the built workers/checkpoint-worker.js within dist.
|
|
28
43
|
// So you need to run `bun run build` before running locally.
|
|
29
44
|
const workerPath = __filename.endsWith('.ts')
|
|
30
45
|
? (0, path_1.join)(__dirname, '../../dist', 'workers/checkpoint-worker.js')
|
|
@@ -37,13 +52,16 @@ class CheckpointManager {
|
|
|
37
52
|
* Execute an operation in the worker thread with timeout handling
|
|
38
53
|
* @param message - The message describing the operation to perform
|
|
39
54
|
* @returns A promise that resolves with the operation result
|
|
40
|
-
* @throws Error if the operation fails or times out
|
|
55
|
+
* @throws {Error} if the operation fails or times out
|
|
41
56
|
*/
|
|
42
57
|
async runWorkerOperation(message) {
|
|
43
58
|
const worker = this.initWorker();
|
|
44
59
|
return new Promise((resolve, reject) => {
|
|
45
60
|
const timeoutMs = 30000; // 30 seconds timeout
|
|
46
61
|
const handler = (response) => {
|
|
62
|
+
if (response.id !== message.id) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
47
65
|
if (response.success) {
|
|
48
66
|
resolve(response.result);
|
|
49
67
|
}
|
|
@@ -74,87 +92,156 @@ class CheckpointManager {
|
|
|
74
92
|
/**
|
|
75
93
|
* Add a new checkpoint of the current agent and file state
|
|
76
94
|
* @param agentState - The current agent state to checkpoint
|
|
95
|
+
* @param lastToolResults - The tool results from the last assistant turn
|
|
77
96
|
* @param userInput - The user input that triggered this checkpoint
|
|
78
|
-
* @returns The
|
|
97
|
+
* @returns The latest checkpoint and whether that checkpoint was created (or already existed)
|
|
98
|
+
* @throws {Error} If the checkpoint cannot be added
|
|
79
99
|
*/
|
|
80
|
-
async addCheckpoint(agentState, userInput) {
|
|
100
|
+
async addCheckpoint(agentState, lastToolResults, userInput, saveWithNoChanges = false) {
|
|
81
101
|
if (this.disabledReason !== null) {
|
|
82
|
-
|
|
102
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
83
103
|
}
|
|
84
104
|
const id = this.checkpoints.length + 1;
|
|
85
105
|
const projectDir = (0, project_files_1.getProjectRoot)();
|
|
106
|
+
if (projectDir === os_1.default.homedir()) {
|
|
107
|
+
this.disabledReason = 'In home directory';
|
|
108
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
109
|
+
}
|
|
86
110
|
const bareRepoPath = this.getBareRepoPath();
|
|
87
111
|
const relativeFilepaths = (0, project_file_tree_1.getAllFilePaths)(agentState.fileContext.fileTree);
|
|
88
112
|
if (relativeFilepaths.length >= project_file_tree_1.DEFAULT_MAX_FILES) {
|
|
89
113
|
this.disabledReason = 'Project too large';
|
|
90
|
-
|
|
114
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
91
115
|
}
|
|
92
|
-
const needToStage =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
const needToStage = saveWithNoChanges ||
|
|
117
|
+
(await (0, file_manager_1.hasUnsavedChanges)({
|
|
118
|
+
projectDir,
|
|
119
|
+
bareRepoPath,
|
|
120
|
+
relativeFilepaths,
|
|
121
|
+
})) ||
|
|
122
|
+
saveWithNoChanges;
|
|
97
123
|
if (!needToStage && this.checkpoints.length > 0) {
|
|
98
|
-
return
|
|
124
|
+
return {
|
|
125
|
+
checkpoint: this.checkpoints[this.checkpoints.length - 1],
|
|
126
|
+
created: false,
|
|
127
|
+
};
|
|
99
128
|
}
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
let fileStateIdPromise;
|
|
130
|
+
if (needToStage) {
|
|
131
|
+
const params = {
|
|
102
132
|
type: 'store',
|
|
103
133
|
projectDir,
|
|
104
134
|
bareRepoPath,
|
|
105
135
|
message: `Checkpoint ${id}`,
|
|
106
136
|
relativeFilepaths,
|
|
107
|
-
}
|
|
108
|
-
|
|
137
|
+
};
|
|
138
|
+
fileStateIdPromise = this.runWorkerOperation({
|
|
139
|
+
...params,
|
|
140
|
+
id: JSON.stringify(params),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
fileStateIdPromise = (0, file_manager_1.getLatestCommit)({ bareRepoPath });
|
|
145
|
+
}
|
|
109
146
|
const checkpoint = {
|
|
110
147
|
agentStateString: JSON.stringify(agentState),
|
|
148
|
+
lastToolResultsString: JSON.stringify(lastToolResults),
|
|
111
149
|
fileStateIdPromise,
|
|
112
150
|
historyLength: agentState.messageHistory.length,
|
|
113
151
|
id,
|
|
152
|
+
parentId: this.currentCheckpointId,
|
|
114
153
|
timestamp: Date.now(),
|
|
115
154
|
userInput,
|
|
116
155
|
};
|
|
117
156
|
this.checkpoints.push(checkpoint);
|
|
118
|
-
|
|
157
|
+
this.currentCheckpointId = id;
|
|
158
|
+
this.undoIds = [];
|
|
159
|
+
return { checkpoint, created: true };
|
|
119
160
|
}
|
|
120
161
|
/**
|
|
121
162
|
* Get the most recent checkpoint
|
|
122
163
|
* @returns The most recent checkpoint or null if none exist
|
|
164
|
+
* @throws {CheckpointsDisabledError} If checkpoints are disabled
|
|
165
|
+
* @throws {ReferenceError} If no checkpoints exist
|
|
123
166
|
*/
|
|
124
167
|
getLatestCheckpoint() {
|
|
125
168
|
if (this.disabledReason !== null) {
|
|
126
|
-
|
|
169
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
127
170
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
171
|
+
if (this.checkpoints.length === 0) {
|
|
172
|
+
throw new ReferenceError('No checkpoints available');
|
|
173
|
+
}
|
|
174
|
+
return this.checkpoints[this.checkpoints.length - 1];
|
|
131
175
|
}
|
|
132
176
|
/**
|
|
133
177
|
* Restore the file state from a specific checkpoint
|
|
134
178
|
* @param id - The ID of the checkpoint to restore
|
|
135
|
-
* @
|
|
179
|
+
* @param resetUndoIds - Whether to reset the chain of undo/redo ids
|
|
180
|
+
* @throws {Error} If the file state cannot be restored
|
|
136
181
|
*/
|
|
137
|
-
async restoreCheckointFileState(id) {
|
|
182
|
+
async restoreCheckointFileState({ id, resetUndoIds = false, }) {
|
|
183
|
+
if (this.disabledReason !== null) {
|
|
184
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
185
|
+
}
|
|
138
186
|
const checkpoint = this.checkpoints[id - 1];
|
|
139
187
|
if (!checkpoint) {
|
|
140
|
-
|
|
188
|
+
throw new ReferenceError('No checkpoints available');
|
|
141
189
|
}
|
|
142
190
|
const relativeFilepaths = (0, project_file_tree_1.getAllFilePaths)(JSON.parse(checkpoint.agentStateString).fileContext
|
|
143
191
|
.fileTree);
|
|
144
|
-
|
|
192
|
+
const params = {
|
|
145
193
|
type: 'restore',
|
|
146
194
|
projectDir: (0, project_files_1.getProjectRoot)(),
|
|
147
195
|
bareRepoPath: this.getBareRepoPath(),
|
|
148
196
|
commit: await checkpoint.fileStateIdPromise,
|
|
149
197
|
relativeFilepaths,
|
|
150
|
-
}
|
|
151
|
-
|
|
198
|
+
};
|
|
199
|
+
await this.runWorkerOperation({ ...params, id: JSON.stringify(params) });
|
|
200
|
+
this.currentCheckpointId = id;
|
|
201
|
+
if (resetUndoIds) {
|
|
202
|
+
this.undoIds = [];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async restoreUndoCheckpoint() {
|
|
206
|
+
if (this.disabledReason !== null) {
|
|
207
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
208
|
+
}
|
|
209
|
+
const currentCheckpoint = this.checkpoints[this.currentCheckpointId - 1];
|
|
210
|
+
(0, assert_1.default)(currentCheckpoint, `Internal error: checkpoint #${this.currentCheckpointId} not found`);
|
|
211
|
+
if (currentCheckpoint.parentId === 0) {
|
|
212
|
+
throw new ReferenceError('Already at earliest change');
|
|
213
|
+
}
|
|
214
|
+
await this.restoreCheckointFileState({ id: currentCheckpoint.parentId });
|
|
215
|
+
this.undoIds.push(currentCheckpoint.id);
|
|
216
|
+
}
|
|
217
|
+
async restoreRedoCheckpoint() {
|
|
218
|
+
if (this.disabledReason !== null) {
|
|
219
|
+
throw new CheckpointsDisabledError(this.disabledReason);
|
|
220
|
+
}
|
|
221
|
+
const targetId = this.undoIds.pop();
|
|
222
|
+
if (targetId === undefined) {
|
|
223
|
+
throw new ReferenceError('Nothing to redo');
|
|
224
|
+
}
|
|
225
|
+
// Check if targetId is either 0 or undefined
|
|
226
|
+
(0, assert_1.default)(targetId, `Internal error: Checkpoint ID ${targetId} found in undo list`);
|
|
227
|
+
try {
|
|
228
|
+
await this.restoreCheckointFileState({ id: targetId });
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
this.undoIds.push(targetId);
|
|
232
|
+
throw new Error('Unable to restore checkpoint', { cause: error });
|
|
233
|
+
}
|
|
152
234
|
}
|
|
153
235
|
/**
|
|
154
236
|
* Clear all checkpoints
|
|
155
237
|
*/
|
|
156
|
-
clearCheckpoints() {
|
|
238
|
+
clearCheckpoints(resetBareRepoPath = false) {
|
|
157
239
|
this.checkpoints = [];
|
|
240
|
+
this.currentCheckpointId = 0;
|
|
241
|
+
this.undoIds = [];
|
|
242
|
+
if (resetBareRepoPath) {
|
|
243
|
+
this.bareRepoPath = null;
|
|
244
|
+
}
|
|
158
245
|
}
|
|
159
246
|
/**
|
|
160
247
|
* Get a formatted string representation of all checkpoints
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-manager.js","sourceRoot":"","sources":["../../src/checkpoints/checkpoint-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkpoint-manager.js","sourceRoot":"","sources":["../../src/checkpoints/checkpoint-manager.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,4CAAmB;AACnB,+BAA2B;AAC3B,mDAAuC;AAEvC,gEAA6E;AAE7E,2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CAAA;gBAC7C,KAAK,CAAC,IAAI,CAAC,KAAK,IAAA,iBAAI,EAAC,UAAU,CAAC,KAAK,YAAY,EAAE,CAAC,CAAA;YACtD,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC,iCAAiC;QAClD,CAAC,CAAC,CAAA;QAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACF;AApTD,8CAoTC;AAED,iEAAiE;AACpD,QAAA,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAA"}
|
|
@@ -10,12 +10,13 @@ exports.getLatestCommit = getLatestCommit;
|
|
|
10
10
|
exports.initializeCheckpointFileManager = initializeCheckpointFileManager;
|
|
11
11
|
exports.storeFileState = storeFileState;
|
|
12
12
|
exports.restoreFileState = restoreFileState;
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
13
14
|
const crypto_1 = require("crypto");
|
|
14
15
|
const fs_1 = __importDefault(require("fs"));
|
|
15
16
|
exports.fs = fs_1.default;
|
|
16
|
-
const
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
17
18
|
const path_1 = require("path");
|
|
18
|
-
const
|
|
19
|
+
const isomorphic_git_1 = require("isomorphic-git");
|
|
19
20
|
const project_files_1 = require("../project-files");
|
|
20
21
|
/**
|
|
21
22
|
* Checks if the native git command is available on the system.
|
|
@@ -63,7 +64,7 @@ async function hasUnsavedChanges({ projectDir, bareRepoPath, relativeFilepaths,
|
|
|
63
64
|
projectDir,
|
|
64
65
|
'status',
|
|
65
66
|
'--porcelain',
|
|
66
|
-
]).toString();
|
|
67
|
+
], { stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
67
68
|
return output.trim().length > 0;
|
|
68
69
|
}
|
|
69
70
|
catch (error) {
|
|
@@ -113,6 +114,9 @@ async function getLatestCommit({ bareRepoPath, }) {
|
|
|
113
114
|
* @param relativeFilepaths - Array of file paths relative to projectDir to track
|
|
114
115
|
*/
|
|
115
116
|
async function initializeCheckpointFileManager({ projectDir, relativeFilepaths, }) {
|
|
117
|
+
if (projectDir === os_1.default.homedir()) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
116
120
|
const bareRepoPath = getBareRepoPath(projectDir);
|
|
117
121
|
// Create the bare repo directory if it doesn't exist
|
|
118
122
|
fs_1.default.mkdirSync(bareRepoPath, { recursive: true });
|
|
@@ -166,12 +170,12 @@ async function gitAddAll({ projectDir, bareRepoPath, relativeFilepaths, }) {
|
|
|
166
170
|
}
|
|
167
171
|
// Stage files with isomorphic-git
|
|
168
172
|
// Get status of all files in the project directory
|
|
169
|
-
const currStatusMatrix = await (0, isomorphic_git_1.statusMatrix)({
|
|
173
|
+
const currStatusMatrix = (await (0, isomorphic_git_1.statusMatrix)({
|
|
170
174
|
fs: fs_1.default,
|
|
171
175
|
dir: projectDir,
|
|
172
176
|
gitdir: bareRepoPath,
|
|
173
177
|
filepaths: relativeFilepaths,
|
|
174
|
-
});
|
|
178
|
+
})) ?? [];
|
|
175
179
|
for (const [filepath, , workdirStatus, stageStatus] of currStatusMatrix) {
|
|
176
180
|
if (workdirStatus === stageStatus) {
|
|
177
181
|
continue;
|
|
@@ -208,6 +212,7 @@ async function gitCommit({ projectDir, bareRepoPath, message, }) {
|
|
|
208
212
|
'-m',
|
|
209
213
|
message,
|
|
210
214
|
], { stdio: 'ignore' });
|
|
215
|
+
return await getLatestCommit({ bareRepoPath });
|
|
211
216
|
}
|
|
212
217
|
catch (error) {
|
|
213
218
|
// Failed to commit, continue to isomorphic-git implementation
|
|
@@ -231,8 +236,11 @@ async function gitCommit({ projectDir, bareRepoPath, message, }) {
|
|
|
231
236
|
'checkout',
|
|
232
237
|
'master',
|
|
233
238
|
], { stdio: 'ignore' });
|
|
239
|
+
return commitHash;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
// Unable to checkout with git
|
|
234
243
|
}
|
|
235
|
-
catch (error) { }
|
|
236
244
|
}
|
|
237
245
|
await (0, isomorphic_git_1.checkout)({ fs: fs_1.default, dir: projectDir, gitdir: bareRepoPath, ref: 'master' });
|
|
238
246
|
return commitHash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../src/checkpoints/file-manager.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../src/checkpoints/file-manager.ts"],"names":[],"mappings":";;;;;;AA4CA,0CAGC;AAUD,8CAwCC;AAQD,0CAuBC;AASD,0EAoCC;AAmJD,wCAkBC;AAWD,4CAmDC;AAhZD,iDAA4C;AAC5C,mCAAmC;AACnC,4CAAmB;AAiZV,aAjZF,YAAE,CAiZE;AAhZX,4CAAmB;AACnB,+BAA2B;AAE3B,mDASuB;AAEvB,oDAAoD;AAEpD;;;;GAIG;AACH,IAAI,kBAAkB,GAAmB,IAAI,CAAA;AAC7C,SAAS,qBAAqB;IAC5B,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,IAAA,4BAAY,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;YACvD,kBAAkB,GAAG,IAAI,CAAA;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kBAAkB,GAAG,KAAK,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,YAAY,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnE,OAAO,IAAA,WAAI,EAAC,IAAA,iCAAiB,GAAE,EAAE,YAAY,CAAC,CAAA;AAChD,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CAAC,E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QACV,YAAY;QACZ,iBAAiB;KAClB,CAAC,CAAA;IAEF,OAAO,MAAM,SAAS,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAA;AAC/D,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,gBAAgB,CAAC,EACrC,UAAU,EACV,YAAY,EACZ,MAAM,EACN,iBAAiB,GAMlB;IACC,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,IAAI,qBAAqB,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,IAAA,4BAAY,EAAC,KAAK,EAAE;gBAClB,WAAW;gBACX,YAAY;gBACZ,aAAa;gBACb,UAAU;gBACV,OAAO;gBACP,QAAQ;gBACR,MAAM;aACP,CAAC,CAAA;YACF,OAAM;QACR,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+DAA+D;QACjE,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,MAAM,IAAA,yBAAQ,EAAC;QACb,EAAE,EAAF,YAAE;QACF,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,YAAY;QACpB,GAAG,EAAE,MAAM;QACX,SAAS,EAAE,iBAAiB;QAC5B,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,gDAAgD;IAChD,MAAM,OAAO,CAAC,GAAG,CACf,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACjC,IAAA,2BAAU,EAAC;QACT,EAAE,EAAF,YAAE;QACF,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,GAAG,EAAE,MAAM;KACZ,CAAC,CACH,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Client } from '../client';
|
|
2
|
+
import { ApiKeyType } from '../common/api-keys/constants';
|
|
3
|
+
export type ApiKeyDetectionResult = {
|
|
4
|
+
status: 'found';
|
|
5
|
+
type: ApiKeyType;
|
|
6
|
+
key: string;
|
|
7
|
+
} | {
|
|
8
|
+
status: 'prefix_only';
|
|
9
|
+
type: ApiKeyType;
|
|
10
|
+
prefix: string;
|
|
11
|
+
length: number;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'not_found';
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Detects if the user input contains a known API key pattern.
|
|
17
|
+
* Returns information about the detected key or prefix.
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectApiKey(userInput: string): ApiKeyDetectionResult;
|
|
20
|
+
/**
|
|
21
|
+
* Handles the result of API key detection.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handleApiKeyInput(client: Client, detectionResult: Exclude<ApiKeyDetectionResult, {
|
|
24
|
+
status: 'not_found';
|
|
25
|
+
}>, readyPromise: Promise<any>, returnControlToUser: () => void): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectApiKey = detectApiKey;
|
|
4
|
+
exports.handleApiKeyInput = handleApiKeyInput;
|
|
5
|
+
const picocolors_1 = require("picocolors");
|
|
6
|
+
const constants_1 = require("../common/api-keys/constants");
|
|
7
|
+
/**
|
|
8
|
+
* Detects if the user input contains a known API key pattern.
|
|
9
|
+
* Returns information about the detected key or prefix.
|
|
10
|
+
*/
|
|
11
|
+
function detectApiKey(userInput) {
|
|
12
|
+
// Build regex patterns for each key type
|
|
13
|
+
const keyPatterns = constants_1.API_KEY_TYPES.map((keyType) => {
|
|
14
|
+
const prefix = constants_1.KEY_PREFIXES[keyType];
|
|
15
|
+
const length = constants_1.KEY_LENGTHS[keyType];
|
|
16
|
+
const escapedPrefix = prefix.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
17
|
+
return {
|
|
18
|
+
type: keyType,
|
|
19
|
+
prefix: prefix,
|
|
20
|
+
length: length,
|
|
21
|
+
// Regex to find the key potentially surrounded by whitespace or at start/end
|
|
22
|
+
regex: new RegExp(`(?:^|\\s)(${escapedPrefix}[^\\s]{${length - prefix.length}})(?:\\s|$)`),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
// Test input against each pattern for a full match
|
|
26
|
+
for (const patternInfo of keyPatterns) {
|
|
27
|
+
const match = userInput.match(patternInfo.regex);
|
|
28
|
+
if (match && match[1]) {
|
|
29
|
+
// Found a full, valid key pattern
|
|
30
|
+
return { status: 'found', type: patternInfo.type, key: match[1] };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// If no full key matched, check if the input *starts* with any known prefix
|
|
34
|
+
for (const patternInfo of keyPatterns) {
|
|
35
|
+
if (userInput.includes(patternInfo.prefix)) {
|
|
36
|
+
// Found a prefix, but it didn't match the full pattern (wrong length/format)
|
|
37
|
+
return {
|
|
38
|
+
status: 'prefix_only',
|
|
39
|
+
type: patternInfo.type,
|
|
40
|
+
prefix: patternInfo.prefix,
|
|
41
|
+
length: patternInfo.length,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// No valid key or known prefix detected
|
|
46
|
+
return { status: 'not_found' };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handles the result of API key detection.
|
|
50
|
+
*/
|
|
51
|
+
async function handleApiKeyInput(client, detectionResult, readyPromise, returnControlToUser) {
|
|
52
|
+
switch (detectionResult.status) {
|
|
53
|
+
case 'found':
|
|
54
|
+
await readyPromise;
|
|
55
|
+
// Call the client method to add the valid key
|
|
56
|
+
await client.handleAddApiKey(detectionResult.type, detectionResult.key);
|
|
57
|
+
// Note: client.handleAddApiKey calls returnControlToUser internally
|
|
58
|
+
break;
|
|
59
|
+
case 'prefix_only':
|
|
60
|
+
// Print the warning for incorrect format/length
|
|
61
|
+
console.log((0, picocolors_1.yellow)(`Input looks like a ${detectionResult.type} API key but has the wrong length or format. Expected ${detectionResult.length} characters starting with "${detectionResult.prefix}".`));
|
|
62
|
+
returnControlToUser(); // Give the user a fresh prompt after the warning
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=api-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../src/cli-handlers/api-key.ts"],"names":[],"mappings":";;AAaA,oCAyCC;AAKD,8CA0BC;AArFD,2CAAmC;AAEnC,yDAAgG;AAOhG;;;GAGG;AACH,SAAgB,YAAY,CAAC,SAAiB;IAC5C,yCAAyC;IACzC,MAAM,WAAW,GAAG,yBAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAChD,MAAM,MAAM,GAAG,wBAAY,CAAC,OAAO,CAAC,CAAA;QACpC,MAAM,MAAM,GAAG,uBAAW,CAAC,OAAO,CAAC,CAAA;QACnC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAA;QACtE,OAAO;YACL,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACd,6EAA6E;YAC7E,KAAK,EAAE,IAAI,MAAM,CACf,aAAa,aAAa,UAAU,MAAM,GAAG,MAAM,CAAC,MAAM,aAAa,CACxE;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,mDAAmD;IACnD,KAAK,MAAM,WAAW,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAChD,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,kCAAkC;YAClC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QACnE,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,KAAK,MAAM,WAAW,IAAI,WAAW,EAAE,CAAC;QACtC,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,6EAA6E;YAC7E,OAAO;gBACL,MAAM,EAAE,aAAa;gBACrB,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,MAAM,EAAE,WAAW,CAAC,MAAM;gBAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;aAC3B,CAAA;QACH,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA;AAChC,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,eAAwE,EACxE,YAA0B,EAC1B,mBAA+B;IAE/B,QAAQ,eAAe,CAAC,MAAM,EAAE,CAAC;QAC/B,KAAK,OAAO;YACV,MAAM,YAAY,CAAA;YAClB,8CAA8C;YAC9C,MAAM,MAAM,CAAC,eAAe,CAC1B,eAAe,CAAC,IAAI,EACpB,eAAe,CAAC,GAAG,CACpB,CAAA;YACD,oEAAoE;YACpE,MAAK;QACP,KAAK,aAAa;YAChB,gDAAgD;YAChD,OAAO,CAAC,GAAG,CACT,IAAA,mBAAM,EACJ,sBAAsB,eAAe,CAAC,IAAI,yDAAyD,eAAe,CAAC,MAAM,8BAA8B,eAAe,CAAC,MAAM,IAAI,CAClL,CACF,CAAA;YACD,mBAAmB,EAAE,CAAA,CAAC,iDAAiD;YACvE,MAAK;IACT,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Interface as ReadlineInterface } from 'readline';
|
|
2
|
+
import type { Client } from '../client';
|
|
3
|
+
export declare const checkpointCommands: {
|
|
4
|
+
readonly save: readonly [readonly ["checkpoint"], "Save current state as a new checkpoint"];
|
|
5
|
+
readonly list: readonly [readonly ["checkpoint list", "checkpoints"], "List all saved checkpoints"];
|
|
6
|
+
readonly clear: readonly [readonly ["checkpoint clear"], "Clear all checkpoints"];
|
|
7
|
+
readonly undo: readonly [readonly ["undo", "u"], "Undo to previous checkpoint"];
|
|
8
|
+
readonly redo: readonly [readonly ["redo", "r"], "Redo previously undone checkpoint"];
|
|
9
|
+
readonly restore: readonly [readonly [RegExp], "Restore to checkpoint number <n>"];
|
|
10
|
+
};
|
|
11
|
+
export declare function displayCheckpointMenu(): void;
|
|
12
|
+
export declare function isCheckpointCommand(userInput: string, type?: keyof typeof checkpointCommands | null): boolean | RegExpMatchArray;
|
|
13
|
+
export declare function listCheckpoints(): Promise<void>;
|
|
14
|
+
export declare function handleUndo(client: Client, rl: ReadlineInterface): Promise<string>;
|
|
15
|
+
export declare function handleRedo(client: Client, rl: ReadlineInterface): Promise<string>;
|
|
16
|
+
export declare function handleRestoreCheckpoint(id: number, client: Client, rl: ReadlineInterface): Promise<string>;
|
|
17
|
+
export declare function handleClearCheckpoints(): void;
|
|
18
|
+
export declare function saveCheckpoint(userInput: string, client: Client, readyPromise: Promise<any>, saveWithNoChanges?: boolean): Promise<void>;
|