wave-agent-sdk 0.0.8 → 0.0.10

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.
Files changed (236) hide show
  1. package/dist/agent.d.ts +92 -23
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +340 -137
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -0
  7. package/dist/managers/aiManager.d.ts +14 -36
  8. package/dist/managers/aiManager.d.ts.map +1 -1
  9. package/dist/managers/aiManager.js +74 -77
  10. package/dist/managers/backgroundBashManager.d.ts.map +1 -1
  11. package/dist/managers/backgroundBashManager.js +4 -3
  12. package/dist/managers/hookManager.d.ts +3 -8
  13. package/dist/managers/hookManager.d.ts.map +1 -1
  14. package/dist/managers/hookManager.js +39 -29
  15. package/dist/managers/liveConfigManager.d.ts +55 -18
  16. package/dist/managers/liveConfigManager.d.ts.map +1 -1
  17. package/dist/managers/liveConfigManager.js +372 -90
  18. package/dist/managers/lspManager.d.ts +43 -0
  19. package/dist/managers/lspManager.d.ts.map +1 -0
  20. package/dist/managers/lspManager.js +326 -0
  21. package/dist/managers/messageManager.d.ts +8 -16
  22. package/dist/managers/messageManager.d.ts.map +1 -1
  23. package/dist/managers/messageManager.js +52 -74
  24. package/dist/managers/permissionManager.d.ts +66 -0
  25. package/dist/managers/permissionManager.d.ts.map +1 -0
  26. package/dist/managers/permissionManager.js +208 -0
  27. package/dist/managers/skillManager.d.ts +1 -0
  28. package/dist/managers/skillManager.d.ts.map +1 -1
  29. package/dist/managers/skillManager.js +2 -1
  30. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  31. package/dist/managers/slashCommandManager.js +0 -1
  32. package/dist/managers/subagentManager.d.ts +8 -23
  33. package/dist/managers/subagentManager.d.ts.map +1 -1
  34. package/dist/managers/subagentManager.js +97 -117
  35. package/dist/managers/toolManager.d.ts +38 -1
  36. package/dist/managers/toolManager.d.ts.map +1 -1
  37. package/dist/managers/toolManager.js +66 -2
  38. package/dist/services/aiService.d.ts +3 -1
  39. package/dist/services/aiService.d.ts.map +1 -1
  40. package/dist/services/aiService.js +123 -30
  41. package/dist/services/configurationService.d.ts +116 -0
  42. package/dist/services/configurationService.d.ts.map +1 -0
  43. package/dist/services/configurationService.js +585 -0
  44. package/dist/services/fileWatcher.d.ts.map +1 -1
  45. package/dist/services/fileWatcher.js +5 -6
  46. package/dist/services/hook.d.ts +7 -124
  47. package/dist/services/hook.d.ts.map +1 -1
  48. package/dist/services/hook.js +46 -458
  49. package/dist/services/jsonlHandler.d.ts +24 -15
  50. package/dist/services/jsonlHandler.d.ts.map +1 -1
  51. package/dist/services/jsonlHandler.js +67 -88
  52. package/dist/services/memory.d.ts +0 -9
  53. package/dist/services/memory.d.ts.map +1 -1
  54. package/dist/services/memory.js +2 -49
  55. package/dist/services/session.d.ts +82 -33
  56. package/dist/services/session.d.ts.map +1 -1
  57. package/dist/services/session.js +275 -181
  58. package/dist/tools/bashTool.d.ts.map +1 -1
  59. package/dist/tools/bashTool.js +72 -13
  60. package/dist/tools/deleteFileTool.d.ts.map +1 -1
  61. package/dist/tools/deleteFileTool.js +25 -0
  62. package/dist/tools/editTool.d.ts.map +1 -1
  63. package/dist/tools/editTool.js +30 -6
  64. package/dist/tools/lspTool.d.ts +6 -0
  65. package/dist/tools/lspTool.d.ts.map +1 -0
  66. package/dist/tools/lspTool.js +589 -0
  67. package/dist/tools/multiEditTool.d.ts.map +1 -1
  68. package/dist/tools/multiEditTool.js +26 -7
  69. package/dist/tools/readTool.d.ts.map +1 -1
  70. package/dist/tools/readTool.js +111 -2
  71. package/dist/tools/skillTool.js +2 -2
  72. package/dist/tools/todoWriteTool.d.ts.map +1 -1
  73. package/dist/tools/todoWriteTool.js +23 -0
  74. package/dist/tools/types.d.ts +11 -8
  75. package/dist/tools/types.d.ts.map +1 -1
  76. package/dist/tools/writeTool.d.ts.map +1 -1
  77. package/dist/tools/writeTool.js +25 -9
  78. package/dist/types/commands.d.ts +0 -1
  79. package/dist/types/commands.d.ts.map +1 -1
  80. package/dist/types/config.d.ts +4 -0
  81. package/dist/types/config.d.ts.map +1 -1
  82. package/dist/types/configuration.d.ts +69 -0
  83. package/dist/types/configuration.d.ts.map +1 -0
  84. package/dist/types/configuration.js +8 -0
  85. package/dist/types/core.d.ts +10 -0
  86. package/dist/types/core.d.ts.map +1 -1
  87. package/dist/types/environment.d.ts +41 -0
  88. package/dist/types/environment.d.ts.map +1 -1
  89. package/dist/types/fileSearch.d.ts +5 -0
  90. package/dist/types/fileSearch.d.ts.map +1 -0
  91. package/dist/types/fileSearch.js +1 -0
  92. package/dist/types/hooks.d.ts +11 -2
  93. package/dist/types/hooks.d.ts.map +1 -1
  94. package/dist/types/hooks.js +1 -7
  95. package/dist/types/index.d.ts +5 -0
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/index.js +5 -0
  98. package/dist/types/lsp.d.ts +90 -0
  99. package/dist/types/lsp.d.ts.map +1 -0
  100. package/dist/types/lsp.js +4 -0
  101. package/dist/types/messaging.d.ts +6 -11
  102. package/dist/types/messaging.d.ts.map +1 -1
  103. package/dist/types/permissions.d.ts +35 -0
  104. package/dist/types/permissions.d.ts.map +1 -0
  105. package/dist/types/permissions.js +12 -0
  106. package/dist/types/session.d.ts +1 -6
  107. package/dist/types/session.d.ts.map +1 -1
  108. package/dist/types/skills.d.ts +1 -0
  109. package/dist/types/skills.d.ts.map +1 -1
  110. package/dist/types/tools.d.ts +35 -0
  111. package/dist/types/tools.d.ts.map +1 -0
  112. package/dist/types/tools.js +4 -0
  113. package/dist/utils/abortUtils.d.ts +34 -0
  114. package/dist/utils/abortUtils.d.ts.map +1 -0
  115. package/dist/utils/abortUtils.js +92 -0
  116. package/dist/utils/bashHistory.d.ts +4 -0
  117. package/dist/utils/bashHistory.d.ts.map +1 -1
  118. package/dist/utils/bashHistory.js +21 -4
  119. package/dist/utils/builtinSubagents.d.ts +7 -0
  120. package/dist/utils/builtinSubagents.d.ts.map +1 -0
  121. package/dist/utils/builtinSubagents.js +65 -0
  122. package/dist/utils/cacheControlUtils.d.ts +8 -33
  123. package/dist/utils/cacheControlUtils.d.ts.map +1 -1
  124. package/dist/utils/cacheControlUtils.js +83 -126
  125. package/dist/utils/constants.d.ts +0 -12
  126. package/dist/utils/constants.d.ts.map +1 -1
  127. package/dist/utils/constants.js +1 -13
  128. package/dist/utils/convertMessagesForAPI.d.ts +2 -1
  129. package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
  130. package/dist/utils/convertMessagesForAPI.js +33 -14
  131. package/dist/utils/fileSearch.d.ts +14 -0
  132. package/dist/utils/fileSearch.d.ts.map +1 -0
  133. package/dist/utils/fileSearch.js +88 -0
  134. package/dist/utils/fileUtils.d.ts +14 -2
  135. package/dist/utils/fileUtils.d.ts.map +1 -1
  136. package/dist/utils/fileUtils.js +101 -17
  137. package/dist/utils/globalLogger.d.ts +0 -14
  138. package/dist/utils/globalLogger.d.ts.map +1 -1
  139. package/dist/utils/globalLogger.js +0 -16
  140. package/dist/utils/largeOutputHandler.d.ts +15 -0
  141. package/dist/utils/largeOutputHandler.d.ts.map +1 -0
  142. package/dist/utils/largeOutputHandler.js +40 -0
  143. package/dist/utils/markdownParser.d.ts.map +1 -1
  144. package/dist/utils/markdownParser.js +1 -17
  145. package/dist/utils/messageOperations.d.ts +1 -11
  146. package/dist/utils/messageOperations.d.ts.map +1 -1
  147. package/dist/utils/messageOperations.js +7 -24
  148. package/dist/utils/pathEncoder.d.ts +4 -0
  149. package/dist/utils/pathEncoder.d.ts.map +1 -1
  150. package/dist/utils/pathEncoder.js +16 -9
  151. package/dist/utils/subagentParser.d.ts +2 -2
  152. package/dist/utils/subagentParser.d.ts.map +1 -1
  153. package/dist/utils/subagentParser.js +10 -7
  154. package/dist/utils/tokenEstimator.d.ts +39 -0
  155. package/dist/utils/tokenEstimator.d.ts.map +1 -0
  156. package/dist/utils/tokenEstimator.js +55 -0
  157. package/package.json +5 -8
  158. package/src/agent.ts +460 -216
  159. package/src/index.ts +2 -0
  160. package/src/managers/aiManager.ts +107 -111
  161. package/src/managers/backgroundBashManager.ts +4 -3
  162. package/src/managers/hookManager.ts +44 -39
  163. package/src/managers/liveConfigManager.ts +524 -138
  164. package/src/managers/lspManager.ts +434 -0
  165. package/src/managers/messageManager.ts +73 -103
  166. package/src/managers/permissionManager.ts +276 -0
  167. package/src/managers/skillManager.ts +3 -1
  168. package/src/managers/slashCommandManager.ts +1 -2
  169. package/src/managers/subagentManager.ts +116 -159
  170. package/src/managers/toolManager.ts +95 -3
  171. package/src/services/aiService.ts +207 -26
  172. package/src/services/configurationService.ts +762 -0
  173. package/src/services/fileWatcher.ts +5 -6
  174. package/src/services/hook.ts +50 -631
  175. package/src/services/jsonlHandler.ts +84 -100
  176. package/src/services/memory.ts +2 -59
  177. package/src/services/session.ts +338 -213
  178. package/src/tools/bashTool.ts +89 -16
  179. package/src/tools/deleteFileTool.ts +36 -0
  180. package/src/tools/editTool.ts +41 -7
  181. package/src/tools/lspTool.ts +760 -0
  182. package/src/tools/multiEditTool.ts +37 -8
  183. package/src/tools/readTool.ts +125 -2
  184. package/src/tools/skillTool.ts +2 -2
  185. package/src/tools/todoWriteTool.ts +33 -1
  186. package/src/tools/types.ts +15 -9
  187. package/src/tools/writeTool.ts +36 -10
  188. package/src/types/commands.ts +0 -1
  189. package/src/types/config.ts +5 -0
  190. package/src/types/configuration.ts +73 -0
  191. package/src/types/core.ts +11 -0
  192. package/src/types/environment.ts +44 -0
  193. package/src/types/fileSearch.ts +4 -0
  194. package/src/types/hooks.ts +14 -11
  195. package/src/types/index.ts +5 -0
  196. package/src/types/lsp.ts +96 -0
  197. package/src/types/messaging.ts +8 -13
  198. package/src/types/permissions.ts +48 -0
  199. package/src/types/session.ts +3 -8
  200. package/src/types/skills.ts +1 -0
  201. package/src/types/tools.ts +38 -0
  202. package/src/utils/abortUtils.ts +118 -0
  203. package/src/utils/bashHistory.ts +28 -4
  204. package/src/utils/builtinSubagents.ts +71 -0
  205. package/src/utils/cacheControlUtils.ts +106 -171
  206. package/src/utils/constants.ts +1 -16
  207. package/src/utils/convertMessagesForAPI.ts +38 -14
  208. package/src/utils/fileSearch.ts +107 -0
  209. package/src/utils/fileUtils.ts +114 -19
  210. package/src/utils/globalLogger.ts +0 -17
  211. package/src/utils/largeOutputHandler.ts +55 -0
  212. package/src/utils/markdownParser.ts +1 -19
  213. package/src/utils/messageOperations.ts +7 -35
  214. package/src/utils/pathEncoder.ts +24 -9
  215. package/src/utils/subagentParser.ts +11 -8
  216. package/src/utils/tokenEstimator.ts +68 -0
  217. package/dist/constants/events.d.ts +0 -28
  218. package/dist/constants/events.d.ts.map +0 -1
  219. package/dist/constants/events.js +0 -27
  220. package/dist/services/configurationWatcher.d.ts +0 -120
  221. package/dist/services/configurationWatcher.d.ts.map +0 -1
  222. package/dist/services/configurationWatcher.js +0 -439
  223. package/dist/services/memoryStore.d.ts +0 -81
  224. package/dist/services/memoryStore.d.ts.map +0 -1
  225. package/dist/services/memoryStore.js +0 -200
  226. package/dist/types/memoryStore.d.ts +0 -82
  227. package/dist/types/memoryStore.d.ts.map +0 -1
  228. package/dist/types/memoryStore.js +0 -7
  229. package/dist/utils/configResolver.d.ts +0 -65
  230. package/dist/utils/configResolver.d.ts.map +0 -1
  231. package/dist/utils/configResolver.js +0 -210
  232. package/src/constants/events.ts +0 -38
  233. package/src/services/configurationWatcher.ts +0 -622
  234. package/src/services/memoryStore.ts +0 -279
  235. package/src/types/memoryStore.ts +0 -94
  236. package/src/utils/configResolver.ts +0 -302
@@ -1,200 +0,0 @@
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,82 +0,0 @@
1
- /**
2
- * Memory Store Type Definitions
3
- *
4
- * Provides TypeScript types for in-memory file storage system,
5
- * enabling optimized access to frequently read files like AGENTS.md.
6
- */
7
- export interface MemoryStore {
8
- content: string;
9
- lastModified: number;
10
- path: string;
11
- isLoaded: boolean;
12
- }
13
- export interface MemoryStoreEntry {
14
- content: string;
15
- path: string;
16
- lastModified: number;
17
- isLoaded: boolean;
18
- }
19
- export interface MemoryStoreStats {
20
- contentSize: number;
21
- lastUpdated: number;
22
- updateCount: number;
23
- isLoaded: boolean;
24
- }
25
- export interface MemoryUpdateEvent {
26
- path: string;
27
- reason: "file_change" | "initial_load" | "manual_reload";
28
- timestamp: number;
29
- previousSize?: number;
30
- newSize: number;
31
- }
32
- /**
33
- * Memory Store Service Interface
34
- * Maps to FR-006, FR-007: Memory storage and updates
35
- */
36
- export interface MemoryStoreService {
37
- /**
38
- * Get content from memory store (loads from file if not loaded)
39
- * Maps to FR-006: Keep AGENTS.md content in memory to avoid repeated reads
40
- */
41
- getContent(path: string): Promise<string>;
42
- /**
43
- * Update memory content from file
44
- * Maps to FR-007: Update memory content when file changes
45
- */
46
- updateContent(path: string): Promise<void>;
47
- /**
48
- * Get memory store statistics
49
- * For monitoring and debugging
50
- */
51
- getStats(path?: string): MemoryStoreStats;
52
- /**
53
- * Check if content is loaded in memory
54
- * For status checking
55
- */
56
- isLoaded(path: string): boolean;
57
- /**
58
- * Manually reload content from file
59
- * For force refresh scenarios
60
- */
61
- reloadContent(path: string): Promise<void>;
62
- /**
63
- * Remove content from memory store
64
- * For cleanup when file is deleted
65
- */
66
- removeContent(path: string): boolean;
67
- /**
68
- * Clear all content from memory store
69
- * For cleanup and testing
70
- */
71
- clear(): void;
72
- /**
73
- * Get all stored paths
74
- * For monitoring and debugging
75
- */
76
- getStoredPaths(): string[];
77
- /**
78
- * Check if file exists and is accessible
79
- */
80
- fileExists(path: string): Promise<boolean>;
81
- }
82
- //# sourceMappingURL=memoryStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryStore.d.ts","sourceRoot":"","sources":["../../src/types/memoryStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAE1C;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAErC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;;OAGG;IACH,cAAc,IAAI,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Memory Store Type Definitions
3
- *
4
- * Provides TypeScript types for in-memory file storage system,
5
- * enabling optimized access to frequently read files like AGENTS.md.
6
- */
7
- export {};
@@ -1,65 +0,0 @@
1
- /**
2
- * Configuration resolver utilities for Agent Constructor Configuration
3
- * Resolves configuration from constructor arguments with environment fallbacks
4
- * Supports live configuration updates and cache invalidation
5
- */
6
- import { GatewayConfig, ModelConfig } from "../types/index.js";
7
- export declare class ConfigResolver {
8
- /**
9
- * Resolves gateway configuration from constructor args and environment with live config support
10
- * @param apiKey - API key from constructor (optional)
11
- * @param baseURL - Base URL from constructor (optional)
12
- * @param workdir - Working directory for loading live configuration (optional)
13
- * @returns Resolved gateway configuration
14
- * @throws ConfigurationError if required configuration is missing after fallbacks
15
- */
16
- static resolveGatewayConfig(apiKey?: string, baseURL?: string, workdir?: string): GatewayConfig;
17
- /**
18
- * Resolves model configuration with fallbacks and live config support
19
- * @param agentModel - Agent model from constructor (optional)
20
- * @param fastModel - Fast model from constructor (optional)
21
- * @param workdir - Working directory for loading live configuration (optional)
22
- * @returns Resolved model configuration with defaults
23
- */
24
- static resolveModelConfig(agentModel?: string, fastModel?: string, workdir?: string): ModelConfig;
25
- /**
26
- * Resolves token limit with fallbacks and live config support
27
- * @param constructorLimit - Token limit from constructor (optional)
28
- * @param workdir - Working directory for loading live configuration (optional)
29
- * @returns Resolved token limit
30
- */
31
- static resolveTokenLimit(constructorLimit?: number, workdir?: string): number;
32
- /**
33
- * Invalidate configuration cache to force reload from settings.json
34
- * @param workdir - Working directory to invalidate cache for (optional)
35
- */
36
- static invalidateCache(workdir?: string): void;
37
- /**
38
- * Refresh configuration cache by reloading from settings.json
39
- * @param workdir - Working directory to refresh cache for (optional)
40
- */
41
- static refreshCache(workdir?: string): void;
42
- /**
43
- * Get current cache status for monitoring
44
- * @returns Cache information or null if no cache
45
- */
46
- static getCacheStatus(): {
47
- workdir?: string;
48
- lastUpdated: number;
49
- envVarCount: number;
50
- isValid: boolean;
51
- } | null;
52
- }
53
- /**
54
- * Static configuration resolver instance
55
- * Implements ConfigurationResolver interface from types.ts with backward compatibility
56
- */
57
- export declare const configResolver: {
58
- resolveGatewayConfig: (apiKey?: string, baseURL?: string, workdir?: string) => GatewayConfig;
59
- resolveModelConfig: (agentModel?: string, fastModel?: string, workdir?: string) => ModelConfig;
60
- resolveTokenLimit: (constructorLimit?: number, workdir?: string) => number;
61
- invalidateCache: typeof ConfigResolver.invalidateCache;
62
- refreshCache: typeof ConfigResolver.refreshCache;
63
- getCacheStatus: typeof ConfigResolver.getCacheStatus;
64
- };
65
- //# sourceMappingURL=configResolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configResolver.d.ts","sourceRoot":"","sources":["../../src/utils/configResolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AA8E3B,qBAAa,cAAc;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,oBAAoB,CACzB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,aAAa;IAyDhB;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,WAAW;IA4Bd;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CACtB,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM;IAuBT;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAa9C;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ3C;;;OAGG;IACH,MAAM,CAAC,cAAc,IAAI;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,IAAI;CAYT;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;oCACO,MAAM,YAAY,MAAM,YAAY,MAAM;sCAG3D,MAAM,cACP,MAAM,YACR,MAAM;2CAEqB,MAAM,YAAY,MAAM;;;;CAOhE,CAAC"}
@@ -1,210 +0,0 @@
1
- /**
2
- * Configuration resolver utilities for Agent Constructor Configuration
3
- * Resolves configuration from constructor arguments with environment fallbacks
4
- * Supports live configuration updates and cache invalidation
5
- */
6
- import { ConfigurationError, CONFIG_ERRORS, } from "../types/index.js";
7
- import { DEFAULT_TOKEN_LIMIT } from "./constants.js";
8
- import { loadMergedWaveConfig } from "../services/hook.js";
9
- import { getGlobalLogger } from "./globalLogger.js";
10
- let configCache = null;
11
- /**
12
- * Initialize configuration cache with current environment variables from settings.json
13
- */
14
- function initializeConfigurationCache(workdir) {
15
- try {
16
- const waveConfig = workdir ? loadMergedWaveConfig(workdir) : null;
17
- const envVars = waveConfig?.env || {};
18
- configCache = {
19
- workdir,
20
- lastUpdated: Date.now(),
21
- environmentVars: envVars,
22
- isValid: true,
23
- };
24
- const logger = getGlobalLogger();
25
- logger?.debug(`Live Config: Configuration cache initialized with ${Object.keys(envVars).length} environment variables`);
26
- }
27
- catch (error) {
28
- const logger = getGlobalLogger();
29
- logger?.error(`Live Config: Failed to initialize configuration cache: ${error.message}`);
30
- configCache = {
31
- workdir,
32
- lastUpdated: Date.now(),
33
- environmentVars: {},
34
- isValid: false,
35
- };
36
- }
37
- }
38
- /**
39
- * Get current environment variable value with live configuration support
40
- */
41
- function getCurrentEnvironmentValue(key, workdir) {
42
- // Initialize cache if not present or workdir changed
43
- if (!configCache || configCache.workdir !== workdir) {
44
- initializeConfigurationCache(workdir);
45
- }
46
- // Use cached environment variables if available and valid
47
- if (configCache && configCache.isValid) {
48
- const cachedValue = configCache.environmentVars[key];
49
- if (cachedValue !== undefined) {
50
- const logger = getGlobalLogger();
51
- logger?.debug(`Live Config: Using cached environment variable ${key}=${cachedValue}`);
52
- return cachedValue;
53
- }
54
- }
55
- // Fallback to process environment
56
- return process.env[key];
57
- }
58
- export class ConfigResolver {
59
- /**
60
- * Resolves gateway configuration from constructor args and environment with live config support
61
- * @param apiKey - API key from constructor (optional)
62
- * @param baseURL - Base URL from constructor (optional)
63
- * @param workdir - Working directory for loading live configuration (optional)
64
- * @returns Resolved gateway configuration
65
- * @throws ConfigurationError if required configuration is missing after fallbacks
66
- */
67
- static resolveGatewayConfig(apiKey, baseURL, workdir) {
68
- // Resolve API key: constructor > live configuration > environment variable
69
- // Note: Explicitly provided empty strings should be treated as invalid, not fall back to env
70
- let resolvedApiKey;
71
- if (apiKey !== undefined) {
72
- resolvedApiKey = apiKey;
73
- }
74
- else {
75
- resolvedApiKey = getCurrentEnvironmentValue("AIGW_TOKEN", workdir) || "";
76
- }
77
- if (!resolvedApiKey && apiKey === undefined) {
78
- const envValue = getCurrentEnvironmentValue("AIGW_TOKEN", workdir);
79
- throw new ConfigurationError(CONFIG_ERRORS.MISSING_API_KEY, "apiKey", {
80
- constructor: apiKey,
81
- environment: envValue,
82
- });
83
- }
84
- if (resolvedApiKey.trim() === "") {
85
- throw new ConfigurationError(CONFIG_ERRORS.EMPTY_API_KEY, "apiKey", resolvedApiKey);
86
- }
87
- // Resolve base URL: constructor > live configuration > environment variable
88
- // Note: Explicitly provided empty strings should be treated as invalid, not fall back to env
89
- let resolvedBaseURL;
90
- if (baseURL !== undefined) {
91
- resolvedBaseURL = baseURL;
92
- }
93
- else {
94
- resolvedBaseURL = getCurrentEnvironmentValue("AIGW_URL", workdir) || "";
95
- }
96
- if (!resolvedBaseURL && baseURL === undefined) {
97
- const envValue = getCurrentEnvironmentValue("AIGW_URL", workdir);
98
- throw new ConfigurationError(CONFIG_ERRORS.MISSING_BASE_URL, "baseURL", {
99
- constructor: baseURL,
100
- environment: envValue,
101
- });
102
- }
103
- if (resolvedBaseURL.trim() === "") {
104
- throw new ConfigurationError(CONFIG_ERRORS.EMPTY_BASE_URL, "baseURL", resolvedBaseURL);
105
- }
106
- return {
107
- apiKey: resolvedApiKey,
108
- baseURL: resolvedBaseURL,
109
- };
110
- }
111
- /**
112
- * Resolves model configuration with fallbacks and live config support
113
- * @param agentModel - Agent model from constructor (optional)
114
- * @param fastModel - Fast model from constructor (optional)
115
- * @param workdir - Working directory for loading live configuration (optional)
116
- * @returns Resolved model configuration with defaults
117
- */
118
- static resolveModelConfig(agentModel, fastModel, workdir) {
119
- // Default values as per data-model.md
120
- const DEFAULT_AGENT_MODEL = "claude-sonnet-4-20250514";
121
- const DEFAULT_FAST_MODEL = "gemini-2.5-flash";
122
- // Resolve agent model: constructor > live configuration > environment > default
123
- const resolvedAgentModel = agentModel ||
124
- getCurrentEnvironmentValue("AIGW_MODEL", workdir) ||
125
- DEFAULT_AGENT_MODEL;
126
- // Resolve fast model: constructor > live configuration > environment > default
127
- const resolvedFastModel = fastModel ||
128
- getCurrentEnvironmentValue("AIGW_FAST_MODEL", workdir) ||
129
- DEFAULT_FAST_MODEL;
130
- const logger = getGlobalLogger();
131
- logger?.debug(`Live Config: Resolved models - agent: ${resolvedAgentModel}, fast: ${resolvedFastModel}`);
132
- return {
133
- agentModel: resolvedAgentModel,
134
- fastModel: resolvedFastModel,
135
- };
136
- }
137
- /**
138
- * Resolves token limit with fallbacks and live config support
139
- * @param constructorLimit - Token limit from constructor (optional)
140
- * @param workdir - Working directory for loading live configuration (optional)
141
- * @returns Resolved token limit
142
- */
143
- static resolveTokenLimit(constructorLimit, workdir) {
144
- // If constructor value provided, use it
145
- if (constructorLimit !== undefined) {
146
- return constructorLimit;
147
- }
148
- // Try live configuration then environment variable
149
- const envTokenLimit = getCurrentEnvironmentValue("TOKEN_LIMIT", workdir);
150
- if (envTokenLimit) {
151
- const parsed = parseInt(envTokenLimit, 10);
152
- if (!isNaN(parsed)) {
153
- const logger = getGlobalLogger();
154
- logger?.debug(`Live Config: Resolved token limit from configuration: ${parsed}`);
155
- return parsed;
156
- }
157
- }
158
- // Use default
159
- return DEFAULT_TOKEN_LIMIT;
160
- }
161
- /**
162
- * Invalidate configuration cache to force reload from settings.json
163
- * @param workdir - Working directory to invalidate cache for (optional)
164
- */
165
- static invalidateCache(workdir) {
166
- if (configCache &&
167
- (workdir === undefined || configCache.workdir === workdir)) {
168
- const logger = getGlobalLogger();
169
- logger?.info(`Live Config: Configuration cache invalidated for workdir: ${workdir || "global"}`);
170
- configCache = null;
171
- }
172
- }
173
- /**
174
- * Refresh configuration cache by reloading from settings.json
175
- * @param workdir - Working directory to refresh cache for (optional)
176
- */
177
- static refreshCache(workdir) {
178
- const logger = getGlobalLogger();
179
- logger?.info(`Live Config: Refreshing configuration cache for workdir: ${workdir || "global"}`);
180
- initializeConfigurationCache(workdir);
181
- }
182
- /**
183
- * Get current cache status for monitoring
184
- * @returns Cache information or null if no cache
185
- */
186
- static getCacheStatus() {
187
- if (!configCache) {
188
- return null;
189
- }
190
- return {
191
- workdir: configCache.workdir,
192
- lastUpdated: configCache.lastUpdated,
193
- envVarCount: Object.keys(configCache.environmentVars).length,
194
- isValid: configCache.isValid,
195
- };
196
- }
197
- }
198
- /**
199
- * Static configuration resolver instance
200
- * Implements ConfigurationResolver interface from types.ts with backward compatibility
201
- */
202
- export const configResolver = {
203
- resolveGatewayConfig: (apiKey, baseURL, workdir) => ConfigResolver.resolveGatewayConfig(apiKey, baseURL, workdir),
204
- resolveModelConfig: (agentModel, fastModel, workdir) => ConfigResolver.resolveModelConfig(agentModel, fastModel, workdir),
205
- resolveTokenLimit: (constructorLimit, workdir) => ConfigResolver.resolveTokenLimit(constructorLimit, workdir),
206
- // Live configuration management methods
207
- invalidateCache: ConfigResolver.invalidateCache,
208
- refreshCache: ConfigResolver.refreshCache,
209
- getCacheStatus: ConfigResolver.getCacheStatus,
210
- };
@@ -1,38 +0,0 @@
1
- /**
2
- * Event name constants to prevent typos and ensure consistency
3
- *
4
- * Using constants instead of magic strings prevents bugs like:
5
- * - ConfigurationWatcher emitting 'configurationChange'
6
- * - LiveConfigManager listening for 'configurationChanged'
7
- *
8
- * This pattern ensures compile-time validation of event names.
9
- */
10
-
11
- // Configuration Watcher Events
12
- export const CONFIGURATION_EVENTS = {
13
- CONFIGURATION_CHANGE: "configurationChange",
14
- WATCHER_ERROR: "watcherError",
15
- } as const;
16
-
17
- // File Watcher Events
18
- export const FILE_WATCHER_EVENTS = {
19
- CHANGE: "change",
20
- CREATE: "create",
21
- DELETE: "delete",
22
- RENAME: "rename",
23
- } as const;
24
-
25
- // Memory Store Events
26
- export const MEMORY_STORE_EVENTS = {
27
- FILE_ADDED: "fileAdded",
28
- FILE_CHANGED: "fileChanged",
29
- FILE_REMOVED: "fileRemoved",
30
- } as const;
31
-
32
- // Type exports for better TypeScript support
33
- export type ConfigurationEventName =
34
- (typeof CONFIGURATION_EVENTS)[keyof typeof CONFIGURATION_EVENTS];
35
- export type FileWatcherEventName =
36
- (typeof FILE_WATCHER_EVENTS)[keyof typeof FILE_WATCHER_EVENTS];
37
- export type MemoryStoreEventName =
38
- (typeof MEMORY_STORE_EVENTS)[keyof typeof MEMORY_STORE_EVENTS];