wave-agent-sdk 0.0.6 → 0.0.8
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/agent.d.ts +32 -20
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +209 -24
- package/dist/constants/events.d.ts +28 -0
- package/dist/constants/events.d.ts.map +1 -0
- package/dist/constants/events.js +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/managers/aiManager.d.ts +34 -1
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +248 -132
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +7 -6
- package/dist/managers/hookManager.d.ts +13 -16
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +81 -44
- package/dist/managers/liveConfigManager.d.ts +58 -0
- package/dist/managers/liveConfigManager.d.ts.map +1 -0
- package/dist/managers/liveConfigManager.js +160 -0
- package/dist/managers/messageManager.d.ts +41 -24
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +168 -49
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +9 -3
- package/dist/managers/subagentManager.d.ts +51 -0
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +190 -19
- package/dist/services/aiService.d.ts +13 -5
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +350 -74
- package/dist/services/configurationWatcher.d.ts +120 -0
- package/dist/services/configurationWatcher.d.ts.map +1 -0
- package/dist/services/configurationWatcher.js +439 -0
- package/dist/services/fileWatcher.d.ts +69 -0
- package/dist/services/fileWatcher.d.ts.map +1 -0
- package/dist/services/fileWatcher.js +213 -0
- package/dist/services/hook.d.ts +91 -9
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +393 -43
- package/dist/services/jsonlHandler.d.ts +62 -0
- package/dist/services/jsonlHandler.d.ts.map +1 -0
- package/dist/services/jsonlHandler.js +257 -0
- package/dist/services/memory.d.ts +9 -0
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +81 -12
- package/dist/services/memoryStore.d.ts +81 -0
- package/dist/services/memoryStore.d.ts.map +1 -0
- package/dist/services/memoryStore.js +200 -0
- package/dist/services/session.d.ts +64 -49
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +310 -132
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +5 -4
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +2 -1
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +3 -2
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +4 -3
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +2 -1
- package/dist/tools/todoWriteTool.d.ts.map +1 -1
- package/dist/tools/todoWriteTool.js +3 -10
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +5 -6
- package/dist/types/commands.d.ts +4 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/core.d.ts +35 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/environment.d.ts +42 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/environment.js +21 -0
- package/dist/types/hooks.d.ts +8 -2
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +8 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/memoryStore.d.ts +82 -0
- package/dist/types/memoryStore.d.ts.map +1 -0
- package/dist/types/memoryStore.js +7 -0
- package/dist/types/messaging.d.ts +21 -9
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/messaging.js +5 -1
- package/dist/types/session.d.ts +20 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +7 -0
- package/dist/utils/bashHistory.d.ts.map +1 -1
- package/dist/utils/bashHistory.js +27 -26
- package/dist/utils/cacheControlUtils.d.ts +121 -0
- package/dist/utils/cacheControlUtils.d.ts.map +1 -0
- package/dist/utils/cacheControlUtils.js +367 -0
- package/dist/utils/commandPathResolver.d.ts +52 -0
- package/dist/utils/commandPathResolver.d.ts.map +1 -0
- package/dist/utils/commandPathResolver.js +145 -0
- package/dist/utils/configPaths.d.ts +85 -0
- package/dist/utils/configPaths.d.ts.map +1 -0
- package/dist/utils/configPaths.js +121 -0
- package/dist/utils/configResolver.d.ts +37 -10
- package/dist/utils/configResolver.d.ts.map +1 -1
- package/dist/utils/configResolver.js +127 -23
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +8 -13
- package/dist/utils/customCommands.d.ts.map +1 -1
- package/dist/utils/customCommands.js +66 -21
- package/dist/utils/fileUtils.d.ts +15 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +61 -0
- package/dist/utils/globalLogger.d.ts +102 -0
- package/dist/utils/globalLogger.d.ts.map +1 -0
- package/dist/utils/globalLogger.js +136 -0
- package/dist/utils/hookMatcher.d.ts +1 -6
- package/dist/utils/hookMatcher.d.ts.map +1 -1
- package/dist/utils/mcpUtils.d.ts.map +1 -1
- package/dist/utils/mcpUtils.js +25 -3
- package/dist/utils/messageOperations.d.ts +27 -27
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +46 -36
- package/dist/utils/pathEncoder.d.ts +104 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +272 -0
- package/dist/utils/subagentParser.d.ts.map +1 -1
- package/dist/utils/subagentParser.js +2 -1
- package/dist/utils/tokenCalculation.d.ts +26 -0
- package/dist/utils/tokenCalculation.d.ts.map +1 -0
- package/dist/utils/tokenCalculation.js +36 -0
- package/package.json +6 -3
- package/src/agent.ts +301 -37
- package/src/constants/events.ts +38 -0
- package/src/index.ts +2 -0
- package/src/managers/aiManager.ts +325 -173
- package/src/managers/backgroundBashManager.ts +7 -6
- package/src/managers/hookManager.ts +106 -84
- package/src/managers/liveConfigManager.ts +248 -0
- package/src/managers/messageManager.ts +237 -100
- package/src/managers/slashCommandManager.ts +9 -7
- package/src/managers/subagentManager.ts +284 -22
- package/src/services/aiService.ts +474 -83
- package/src/services/configurationWatcher.ts +622 -0
- package/src/services/fileWatcher.ts +301 -0
- package/src/services/hook.ts +538 -47
- package/src/services/jsonlHandler.ts +319 -0
- package/src/services/memory.ts +92 -12
- package/src/services/memoryStore.ts +279 -0
- package/src/services/session.ts +381 -157
- package/src/tools/bashTool.ts +5 -4
- package/src/tools/deleteFileTool.ts +2 -1
- package/src/tools/editTool.ts +3 -2
- package/src/tools/multiEditTool.ts +4 -3
- package/src/tools/readTool.ts +2 -1
- package/src/tools/todoWriteTool.ts +3 -11
- package/src/tools/writeTool.ts +7 -6
- package/src/types/commands.ts +6 -0
- package/src/types/core.ts +44 -0
- package/src/types/environment.ts +60 -0
- package/src/types/hooks.ts +21 -8
- package/src/types/index.ts +2 -0
- package/src/types/memoryStore.ts +94 -0
- package/src/types/messaging.ts +21 -10
- package/src/types/session.ts +25 -0
- package/src/utils/bashHistory.ts +27 -27
- package/src/utils/cacheControlUtils.ts +540 -0
- package/src/utils/commandPathResolver.ts +189 -0
- package/src/utils/configPaths.ts +163 -0
- package/src/utils/configResolver.ts +182 -22
- package/src/utils/constants.ts +1 -1
- package/src/utils/convertMessagesForAPI.ts +8 -14
- package/src/utils/customCommands.ts +90 -22
- package/src/utils/fileUtils.ts +65 -0
- package/src/utils/globalLogger.ts +145 -0
- package/src/utils/hookMatcher.ts +1 -12
- package/src/utils/mcpUtils.ts +34 -3
- package/src/utils/messageOperations.ts +77 -60
- package/src/utils/pathEncoder.ts +379 -0
- package/src/utils/subagentParser.ts +2 -1
- package/src/utils/tokenCalculation.ts +43 -0
- package/src/types/index.ts.backup +0 -357
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Store Service
|
|
3
|
+
*
|
|
4
|
+
* Provides in-memory storage for file content with automatic updates.
|
|
5
|
+
* Optimizes performance by keeping frequently accessed files in memory.
|
|
6
|
+
*/
|
|
7
|
+
import { promises as fs } from "fs";
|
|
8
|
+
import { EventEmitter } from "events";
|
|
9
|
+
export class MemoryStoreService extends EventEmitter {
|
|
10
|
+
constructor(logger) {
|
|
11
|
+
super();
|
|
12
|
+
this.store = new Map();
|
|
13
|
+
this.updateCounts = new Map();
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get content from memory store (loads from file if not loaded)
|
|
18
|
+
* Maps to FR-006: Keep AGENTS.md content in memory to avoid repeated reads
|
|
19
|
+
*/
|
|
20
|
+
async getContent(path) {
|
|
21
|
+
const entry = this.store.get(path);
|
|
22
|
+
if (entry && entry.isLoaded) {
|
|
23
|
+
this.logger?.debug(`Live Config: Memory hit for ${path}`);
|
|
24
|
+
return entry.content;
|
|
25
|
+
}
|
|
26
|
+
// Load from file if not in memory
|
|
27
|
+
return await this.loadFromFile(path, "initial_load");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Update memory content from file
|
|
31
|
+
* Maps to FR-007: Update memory content when file changes
|
|
32
|
+
*/
|
|
33
|
+
async updateContent(path) {
|
|
34
|
+
const previousEntry = this.store.get(path);
|
|
35
|
+
const previousSize = previousEntry?.content.length || 0;
|
|
36
|
+
await this.loadFromFile(path, "file_change", previousSize);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get memory store statistics
|
|
40
|
+
* For monitoring and debugging
|
|
41
|
+
*/
|
|
42
|
+
getStats(path) {
|
|
43
|
+
if (path) {
|
|
44
|
+
const entry = this.store.get(path);
|
|
45
|
+
const updateCount = this.updateCounts.get(path) || 0;
|
|
46
|
+
return {
|
|
47
|
+
contentSize: entry?.content.length || 0,
|
|
48
|
+
lastUpdated: entry?.lastModified || 0,
|
|
49
|
+
updateCount,
|
|
50
|
+
isLoaded: entry?.isLoaded || false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Return aggregate stats for all entries
|
|
54
|
+
let totalSize = 0;
|
|
55
|
+
let latestUpdate = 0;
|
|
56
|
+
let totalUpdates = 0;
|
|
57
|
+
let anyLoaded = false;
|
|
58
|
+
for (const [entryPath, entry] of this.store) {
|
|
59
|
+
totalSize += entry.content.length;
|
|
60
|
+
latestUpdate = Math.max(latestUpdate, entry.lastModified);
|
|
61
|
+
totalUpdates += this.updateCounts.get(entryPath) || 0;
|
|
62
|
+
anyLoaded = anyLoaded || entry.isLoaded;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
contentSize: totalSize,
|
|
66
|
+
lastUpdated: latestUpdate,
|
|
67
|
+
updateCount: totalUpdates,
|
|
68
|
+
isLoaded: anyLoaded,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if content is loaded in memory
|
|
73
|
+
* For status checking
|
|
74
|
+
*/
|
|
75
|
+
isLoaded(path) {
|
|
76
|
+
const entry = this.store.get(path);
|
|
77
|
+
return entry?.isLoaded || false;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Manually reload content from file
|
|
81
|
+
* For force refresh scenarios
|
|
82
|
+
*/
|
|
83
|
+
async reloadContent(path) {
|
|
84
|
+
const previousEntry = this.store.get(path);
|
|
85
|
+
const previousSize = previousEntry?.content.length || 0;
|
|
86
|
+
await this.loadFromFile(path, "manual_reload", previousSize);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Remove content from memory store
|
|
90
|
+
* For cleanup when file is deleted
|
|
91
|
+
*/
|
|
92
|
+
removeContent(path) {
|
|
93
|
+
const removed = this.store.delete(path);
|
|
94
|
+
this.updateCounts.delete(path);
|
|
95
|
+
if (removed) {
|
|
96
|
+
this.logger?.info(`Live Config: Removed ${path} from memory store`);
|
|
97
|
+
}
|
|
98
|
+
return removed;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Clear all content from memory store
|
|
102
|
+
* For cleanup and testing
|
|
103
|
+
*/
|
|
104
|
+
clear() {
|
|
105
|
+
const pathCount = this.store.size;
|
|
106
|
+
this.store.clear();
|
|
107
|
+
this.updateCounts.clear();
|
|
108
|
+
if (pathCount > 0) {
|
|
109
|
+
this.logger?.info(`Live Config: Cleared ${pathCount} entries from memory store`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get all stored paths
|
|
114
|
+
* For monitoring and debugging
|
|
115
|
+
*/
|
|
116
|
+
getStoredPaths() {
|
|
117
|
+
return Array.from(this.store.keys());
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if file exists and is accessible
|
|
121
|
+
*/
|
|
122
|
+
async fileExists(path) {
|
|
123
|
+
try {
|
|
124
|
+
await fs.access(path);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async loadFromFile(path, reason, previousSize) {
|
|
132
|
+
try {
|
|
133
|
+
// Check if file exists
|
|
134
|
+
const exists = await this.fileExists(path);
|
|
135
|
+
if (!exists) {
|
|
136
|
+
// Handle file deletion gracefully
|
|
137
|
+
const entry = {
|
|
138
|
+
content: "",
|
|
139
|
+
path,
|
|
140
|
+
lastModified: Date.now(),
|
|
141
|
+
isLoaded: true,
|
|
142
|
+
};
|
|
143
|
+
this.store.set(path, entry);
|
|
144
|
+
this.incrementUpdateCount(path);
|
|
145
|
+
this.logger?.info(`Live Config: File ${path} not found, storing empty content`);
|
|
146
|
+
this.emitUpdateEvent(path, reason, previousSize, 0);
|
|
147
|
+
return "";
|
|
148
|
+
}
|
|
149
|
+
// Read file content
|
|
150
|
+
const content = await fs.readFile(path, "utf-8");
|
|
151
|
+
const stats = await fs.stat(path);
|
|
152
|
+
const entry = {
|
|
153
|
+
content,
|
|
154
|
+
path,
|
|
155
|
+
lastModified: stats.mtime.getTime(),
|
|
156
|
+
isLoaded: true,
|
|
157
|
+
};
|
|
158
|
+
this.store.set(path, entry);
|
|
159
|
+
this.incrementUpdateCount(path);
|
|
160
|
+
this.logger?.info(`Live Config: Loaded ${content.length} bytes from ${path} into memory`);
|
|
161
|
+
this.emitUpdateEvent(path, reason, previousSize, content.length);
|
|
162
|
+
return content;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
const errorMessage = `Live Config: Failed to load ${path} into memory: ${error.message}`;
|
|
166
|
+
this.logger?.error(errorMessage);
|
|
167
|
+
// Return existing content if available, otherwise empty string
|
|
168
|
+
const existingEntry = this.store.get(path);
|
|
169
|
+
if (existingEntry?.isLoaded) {
|
|
170
|
+
this.logger?.warn(`Live Config: Using cached content for ${path} due to read error`);
|
|
171
|
+
return existingEntry.content;
|
|
172
|
+
}
|
|
173
|
+
// Store empty content as fallback
|
|
174
|
+
const entry = {
|
|
175
|
+
content: "",
|
|
176
|
+
path,
|
|
177
|
+
lastModified: Date.now(),
|
|
178
|
+
isLoaded: true,
|
|
179
|
+
};
|
|
180
|
+
this.store.set(path, entry);
|
|
181
|
+
this.emitUpdateEvent(path, reason, previousSize, 0);
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
incrementUpdateCount(path) {
|
|
186
|
+
const current = this.updateCounts.get(path) || 0;
|
|
187
|
+
this.updateCounts.set(path, current + 1);
|
|
188
|
+
}
|
|
189
|
+
emitUpdateEvent(path, reason, previousSize, newSize) {
|
|
190
|
+
const event = {
|
|
191
|
+
path,
|
|
192
|
+
reason,
|
|
193
|
+
timestamp: Date.now(),
|
|
194
|
+
previousSize,
|
|
195
|
+
newSize,
|
|
196
|
+
};
|
|
197
|
+
this.emit("memoryUpdate", event);
|
|
198
|
+
this.logger?.debug(`Live Config: Memory update event for ${path}: ${reason}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Message } from "../types/index.js";
|
|
2
2
|
export interface SessionData {
|
|
3
3
|
id: string;
|
|
4
|
-
timestamp: string;
|
|
5
|
-
version: string;
|
|
6
4
|
messages: Message[];
|
|
7
5
|
metadata: {
|
|
8
6
|
workdir: string;
|
|
@@ -13,91 +11,108 @@ export interface SessionData {
|
|
|
13
11
|
}
|
|
14
12
|
export interface SessionMetadata {
|
|
15
13
|
id: string;
|
|
16
|
-
|
|
14
|
+
sessionType: "main" | "subagent";
|
|
15
|
+
parentSessionId?: string;
|
|
16
|
+
subagentType?: string;
|
|
17
17
|
workdir: string;
|
|
18
|
-
startedAt:
|
|
19
|
-
lastActiveAt:
|
|
18
|
+
startedAt: Date;
|
|
19
|
+
lastActiveAt: Date;
|
|
20
20
|
latestTotalTokens: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
* @returns Resolved session directory path
|
|
23
|
+
* Generate a new UUIDv6-based session ID
|
|
24
|
+
* @returns UUIDv6 string for time-ordered sessions
|
|
26
25
|
*/
|
|
27
|
-
export declare function
|
|
26
|
+
export declare function generateSessionId(): string;
|
|
27
|
+
export declare const SESSION_DIR: string;
|
|
28
28
|
/**
|
|
29
29
|
* Ensure session directory exists
|
|
30
|
-
* @param sessionDir Optional custom session directory
|
|
31
30
|
*/
|
|
32
|
-
export declare function ensureSessionDir(
|
|
31
|
+
export declare function ensureSessionDir(): Promise<void>;
|
|
33
32
|
/**
|
|
34
|
-
* Generate session file path
|
|
33
|
+
* Generate session file path using project-based directory structure
|
|
34
|
+
* Note: With metadata-based approach, we no longer need separate subagent directories
|
|
35
|
+
* @param sessionId - UUIDv6 session identifier
|
|
36
|
+
* @param workdir - Working directory for the session
|
|
37
|
+
* @returns Promise resolving to full file path for the session JSONL file
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSessionFilePath(sessionId: string, workdir: string): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Create a new session with metadata
|
|
42
|
+
* @param sessionId - UUIDv6 session identifier
|
|
43
|
+
* @param workdir - Working directory for the session
|
|
44
|
+
* @param sessionType - Type of session ('main' or 'subagent')
|
|
45
|
+
* @param parentSessionId - Parent session ID for subagent sessions
|
|
46
|
+
* @param subagentType - Type of subagent for subagent sessions
|
|
35
47
|
*/
|
|
36
|
-
export declare function
|
|
48
|
+
export declare function createSession(sessionId: string, workdir: string, sessionType?: "main" | "subagent", parentSessionId?: string, subagentType?: string): Promise<void>;
|
|
37
49
|
/**
|
|
38
|
-
*
|
|
50
|
+
* Append messages to session using JSONL format (new approach)
|
|
39
51
|
*
|
|
40
|
-
* @param sessionId -
|
|
41
|
-
* @param
|
|
52
|
+
* @param sessionId - UUIDv6 session identifier
|
|
53
|
+
* @param newMessages - Array of messages to append
|
|
42
54
|
* @param workdir - Working directory for the session
|
|
43
|
-
* @param latestTotalTokens - Total tokens used in the session
|
|
44
|
-
* @param startedAt - ISO timestamp when session started (defaults to current time)
|
|
45
|
-
* @param sessionDir - Optional custom directory for session storage (defaults to ~/.wave/sessions/)
|
|
46
|
-
* @throws {Error} When session cannot be saved due to permission or disk space issues
|
|
47
55
|
*/
|
|
48
|
-
export declare function
|
|
56
|
+
export declare function appendMessages(sessionId: string, newMessages: Message[], workdir: string): Promise<void>;
|
|
49
57
|
/**
|
|
50
|
-
* Load session data from
|
|
58
|
+
* Load session data from JSONL file (new approach)
|
|
51
59
|
*
|
|
52
|
-
* @param sessionId -
|
|
53
|
-
* @param
|
|
60
|
+
* @param sessionId - UUIDv6 session identifier
|
|
61
|
+
* @param workdir - Working directory for the session
|
|
54
62
|
* @returns Promise that resolves to session data or null if session doesn't exist
|
|
55
|
-
* @throws {Error} When session exists but cannot be read or contains invalid data
|
|
56
63
|
*/
|
|
57
|
-
export declare function
|
|
64
|
+
export declare function loadSessionFromJsonl(sessionId: string, workdir: string): Promise<SessionData | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the most recently active session for a specific working directory (new JSONL approach)
|
|
67
|
+
* Only returns main sessions, skips subagent sessions
|
|
68
|
+
* Sessions are sorted by last active time (most recently active first)
|
|
69
|
+
*
|
|
70
|
+
* @param workdir - Working directory to find the most recently active session for
|
|
71
|
+
* @returns Promise that resolves to the most recently active session data or null if no sessions exist
|
|
72
|
+
*/
|
|
73
|
+
export declare function getLatestSessionFromJsonl(workdir: string): Promise<SessionData | null>;
|
|
58
74
|
/**
|
|
59
|
-
*
|
|
75
|
+
* List all sessions for a specific working directory (convenience wrapper)
|
|
76
|
+
* Only returns main sessions, skips subagent sessions
|
|
60
77
|
*
|
|
61
|
-
* @param workdir - Working directory to
|
|
62
|
-
* @
|
|
63
|
-
* @returns Promise that resolves to the most recent session data or null if no sessions exist
|
|
64
|
-
* @throws {Error} When session directory cannot be accessed or session data is corrupted
|
|
78
|
+
* @param workdir - Working directory to filter sessions by
|
|
79
|
+
* @returns Promise that resolves to array of session metadata objects
|
|
65
80
|
*/
|
|
66
|
-
export declare function
|
|
81
|
+
export declare function listSessions(workdir: string): Promise<SessionMetadata[]>;
|
|
67
82
|
/**
|
|
68
|
-
* List all sessions for a specific working directory
|
|
83
|
+
* List all sessions for a specific working directory using JSONL format (new approach)
|
|
69
84
|
*
|
|
70
85
|
* @param workdir - Working directory to filter sessions by
|
|
71
86
|
* @param includeAllWorkdirs - If true, returns sessions from all working directories
|
|
72
|
-
* @param
|
|
87
|
+
* @param includeSubagentSessions - If true, includes subagent sessions (default: false for user-facing operations)
|
|
73
88
|
* @returns Promise that resolves to array of session metadata objects
|
|
74
|
-
* @throws {Error} When session directory cannot be accessed or read
|
|
75
89
|
*/
|
|
76
|
-
export declare function
|
|
90
|
+
export declare function listSessionsFromJsonl(workdir: string, includeAllWorkdirs?: boolean, includeSubagentSessions?: boolean): Promise<SessionMetadata[]>;
|
|
77
91
|
/**
|
|
78
|
-
* Delete a session from storage
|
|
92
|
+
* Delete a session from JSONL storage (new approach)
|
|
79
93
|
*
|
|
80
|
-
* @param sessionId -
|
|
81
|
-
* @param
|
|
94
|
+
* @param sessionId - UUIDv6 session identifier
|
|
95
|
+
* @param workdir - Working directory for the session
|
|
82
96
|
* @returns Promise that resolves to true if session was deleted, false if it didn't exist
|
|
83
|
-
* @throws {Error} When session exists but cannot be deleted due to permission issues
|
|
84
97
|
*/
|
|
85
|
-
export declare function
|
|
98
|
+
export declare function deleteSessionFromJsonl(sessionId: string, workdir: string): Promise<boolean>;
|
|
86
99
|
/**
|
|
87
|
-
* Clean up expired sessions older than
|
|
100
|
+
* Clean up expired sessions older than 14 days based on file modification time
|
|
88
101
|
*
|
|
89
102
|
* @param workdir - Working directory to clean up sessions for
|
|
90
|
-
* @param sessionDir - Optional custom directory for session storage (defaults to ~/.wave/sessions/)
|
|
91
103
|
* @returns Promise that resolves to the number of sessions that were deleted
|
|
92
|
-
* @throws {Error} When session directory cannot be accessed or sessions cannot be deleted
|
|
93
104
|
*/
|
|
94
|
-
export declare function
|
|
105
|
+
export declare function cleanupExpiredSessionsFromJsonl(workdir: string): Promise<number>;
|
|
95
106
|
/**
|
|
96
|
-
*
|
|
107
|
+
* Clean up empty project directories in the session directory
|
|
108
|
+
*/
|
|
109
|
+
export declare function cleanupEmptyProjectDirectories(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Check if a session exists in JSONL storage (new approach)
|
|
97
112
|
*
|
|
98
|
-
* @param sessionId -
|
|
99
|
-
* @param
|
|
113
|
+
* @param sessionId - UUIDv6 session identifier
|
|
114
|
+
* @param workdir - Working directory for the session
|
|
100
115
|
* @returns Promise that resolves to true if session exists, false otherwise
|
|
101
116
|
*/
|
|
102
|
-
export declare function
|
|
117
|
+
export declare function sessionExistsInJsonl(sessionId: string, workdir: string): Promise<boolean>;
|
|
103
118
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAMjD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAGD,eAAO,MAAM,WAAW,QAAuC,CAAC;AAGhE;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMtD;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAM,GAAG,UAAmB,EACzC,eAAe,CAAC,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,OAAO,EAAE,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAuD7B;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAY7B;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,EAAE,CAAC,CAE5B;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,kBAAkB,UAAQ,EAC1B,uBAAuB,UAAQ,GAC9B,OAAO,CAAC,eAAe,EAAE,CAAC,CAuI5B;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAsDjB;AAED;;GAEG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC,CA+BpE;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAQlB"}
|