wave-agent-sdk 0.0.7 → 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 (240) hide show
  1. package/dist/agent.d.ts +105 -24
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +438 -53
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +4 -0
  7. package/dist/managers/aiManager.d.ts +18 -7
  8. package/dist/managers/aiManager.d.ts.map +1 -1
  9. package/dist/managers/aiManager.js +254 -142
  10. package/dist/managers/backgroundBashManager.d.ts.map +1 -1
  11. package/dist/managers/backgroundBashManager.js +11 -9
  12. package/dist/managers/hookManager.d.ts +6 -6
  13. package/dist/managers/hookManager.d.ts.map +1 -1
  14. package/dist/managers/hookManager.js +81 -39
  15. package/dist/managers/liveConfigManager.d.ts +95 -0
  16. package/dist/managers/liveConfigManager.d.ts.map +1 -0
  17. package/dist/managers/liveConfigManager.js +442 -0
  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 +41 -24
  22. package/dist/managers/messageManager.d.ts.map +1 -1
  23. package/dist/managers/messageManager.js +184 -73
  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 +4 -2
  32. package/dist/managers/subagentManager.d.ts +42 -6
  33. package/dist/managers/subagentManager.d.ts.map +1 -1
  34. package/dist/managers/subagentManager.js +213 -62
  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 +15 -5
  39. package/dist/services/aiService.d.ts.map +1 -1
  40. package/dist/services/aiService.js +446 -77
  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 +69 -0
  45. package/dist/services/fileWatcher.d.ts.map +1 -0
  46. package/dist/services/fileWatcher.js +212 -0
  47. package/dist/services/hook.d.ts +5 -40
  48. package/dist/services/hook.d.ts.map +1 -1
  49. package/dist/services/hook.js +47 -109
  50. package/dist/services/jsonlHandler.d.ts +71 -0
  51. package/dist/services/jsonlHandler.d.ts.map +1 -0
  52. package/dist/services/jsonlHandler.js +236 -0
  53. package/dist/services/memory.d.ts.map +1 -1
  54. package/dist/services/memory.js +33 -11
  55. package/dist/services/session.d.ts +116 -52
  56. package/dist/services/session.d.ts.map +1 -1
  57. package/dist/services/session.js +415 -143
  58. package/dist/tools/bashTool.d.ts.map +1 -1
  59. package/dist/tools/bashTool.js +77 -17
  60. package/dist/tools/deleteFileTool.d.ts.map +1 -1
  61. package/dist/tools/deleteFileTool.js +27 -1
  62. package/dist/tools/editTool.d.ts.map +1 -1
  63. package/dist/tools/editTool.js +33 -8
  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 +30 -10
  69. package/dist/tools/readTool.d.ts.map +1 -1
  70. package/dist/tools/readTool.js +113 -3
  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 +30 -15
  78. package/dist/types/commands.d.ts +4 -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 +45 -0
  86. package/dist/types/core.d.ts.map +1 -1
  87. package/dist/types/environment.d.ts +83 -0
  88. package/dist/types/environment.d.ts.map +1 -0
  89. package/dist/types/environment.js +21 -0
  90. package/dist/types/fileSearch.d.ts +5 -0
  91. package/dist/types/fileSearch.d.ts.map +1 -0
  92. package/dist/types/fileSearch.js +1 -0
  93. package/dist/types/hooks.d.ts +18 -3
  94. package/dist/types/hooks.d.ts.map +1 -1
  95. package/dist/types/hooks.js +8 -8
  96. package/dist/types/index.d.ts +7 -0
  97. package/dist/types/index.d.ts.map +1 -1
  98. package/dist/types/index.js +7 -0
  99. package/dist/types/lsp.d.ts +90 -0
  100. package/dist/types/lsp.d.ts.map +1 -0
  101. package/dist/types/lsp.js +4 -0
  102. package/dist/types/messaging.d.ts +19 -12
  103. package/dist/types/messaging.d.ts.map +1 -1
  104. package/dist/types/permissions.d.ts +35 -0
  105. package/dist/types/permissions.d.ts.map +1 -0
  106. package/dist/types/permissions.js +12 -0
  107. package/dist/types/session.d.ts +15 -0
  108. package/dist/types/session.d.ts.map +1 -0
  109. package/dist/types/session.js +7 -0
  110. package/dist/types/skills.d.ts +1 -0
  111. package/dist/types/skills.d.ts.map +1 -1
  112. package/dist/types/tools.d.ts +35 -0
  113. package/dist/types/tools.d.ts.map +1 -0
  114. package/dist/types/tools.js +4 -0
  115. package/dist/utils/abortUtils.d.ts +34 -0
  116. package/dist/utils/abortUtils.d.ts.map +1 -0
  117. package/dist/utils/abortUtils.js +92 -0
  118. package/dist/utils/bashHistory.d.ts +4 -0
  119. package/dist/utils/bashHistory.d.ts.map +1 -1
  120. package/dist/utils/bashHistory.js +48 -30
  121. package/dist/utils/builtinSubagents.d.ts +7 -0
  122. package/dist/utils/builtinSubagents.d.ts.map +1 -0
  123. package/dist/utils/builtinSubagents.js +65 -0
  124. package/dist/utils/cacheControlUtils.d.ts +96 -0
  125. package/dist/utils/cacheControlUtils.d.ts.map +1 -0
  126. package/dist/utils/cacheControlUtils.js +324 -0
  127. package/dist/utils/commandPathResolver.d.ts +52 -0
  128. package/dist/utils/commandPathResolver.d.ts.map +1 -0
  129. package/dist/utils/commandPathResolver.js +145 -0
  130. package/dist/utils/configPaths.d.ts +85 -0
  131. package/dist/utils/configPaths.d.ts.map +1 -0
  132. package/dist/utils/configPaths.js +121 -0
  133. package/dist/utils/constants.d.ts +1 -13
  134. package/dist/utils/constants.d.ts.map +1 -1
  135. package/dist/utils/constants.js +2 -14
  136. package/dist/utils/convertMessagesForAPI.d.ts +2 -1
  137. package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
  138. package/dist/utils/convertMessagesForAPI.js +39 -18
  139. package/dist/utils/customCommands.d.ts.map +1 -1
  140. package/dist/utils/customCommands.js +66 -21
  141. package/dist/utils/fileSearch.d.ts +14 -0
  142. package/dist/utils/fileSearch.d.ts.map +1 -0
  143. package/dist/utils/fileSearch.js +88 -0
  144. package/dist/utils/fileUtils.d.ts +27 -0
  145. package/dist/utils/fileUtils.d.ts.map +1 -0
  146. package/dist/utils/fileUtils.js +145 -0
  147. package/dist/utils/globalLogger.d.ts +88 -0
  148. package/dist/utils/globalLogger.d.ts.map +1 -0
  149. package/dist/utils/globalLogger.js +120 -0
  150. package/dist/utils/largeOutputHandler.d.ts +15 -0
  151. package/dist/utils/largeOutputHandler.d.ts.map +1 -0
  152. package/dist/utils/largeOutputHandler.js +40 -0
  153. package/dist/utils/markdownParser.d.ts.map +1 -1
  154. package/dist/utils/markdownParser.js +1 -17
  155. package/dist/utils/mcpUtils.d.ts.map +1 -1
  156. package/dist/utils/mcpUtils.js +25 -3
  157. package/dist/utils/messageOperations.d.ts +20 -18
  158. package/dist/utils/messageOperations.d.ts.map +1 -1
  159. package/dist/utils/messageOperations.js +30 -38
  160. package/dist/utils/pathEncoder.d.ts +108 -0
  161. package/dist/utils/pathEncoder.d.ts.map +1 -0
  162. package/dist/utils/pathEncoder.js +279 -0
  163. package/dist/utils/subagentParser.d.ts +2 -2
  164. package/dist/utils/subagentParser.d.ts.map +1 -1
  165. package/dist/utils/subagentParser.js +12 -8
  166. package/dist/utils/tokenCalculation.d.ts +26 -0
  167. package/dist/utils/tokenCalculation.d.ts.map +1 -0
  168. package/dist/utils/tokenCalculation.js +36 -0
  169. package/dist/utils/tokenEstimator.d.ts +39 -0
  170. package/dist/utils/tokenEstimator.d.ts.map +1 -0
  171. package/dist/utils/tokenEstimator.js +55 -0
  172. package/package.json +6 -6
  173. package/src/agent.ts +586 -78
  174. package/src/index.ts +4 -0
  175. package/src/managers/aiManager.ts +341 -192
  176. package/src/managers/backgroundBashManager.ts +11 -9
  177. package/src/managers/hookManager.ts +102 -54
  178. package/src/managers/liveConfigManager.ts +634 -0
  179. package/src/managers/lspManager.ts +434 -0
  180. package/src/managers/messageManager.ts +258 -121
  181. package/src/managers/permissionManager.ts +276 -0
  182. package/src/managers/skillManager.ts +3 -1
  183. package/src/managers/slashCommandManager.ts +5 -3
  184. package/src/managers/subagentManager.ts +295 -76
  185. package/src/managers/toolManager.ts +95 -3
  186. package/src/services/aiService.ts +656 -84
  187. package/src/services/configurationService.ts +762 -0
  188. package/src/services/fileWatcher.ts +300 -0
  189. package/src/services/hook.ts +54 -144
  190. package/src/services/jsonlHandler.ts +303 -0
  191. package/src/services/memory.ts +34 -11
  192. package/src/services/session.ts +522 -173
  193. package/src/tools/bashTool.ts +94 -20
  194. package/src/tools/deleteFileTool.ts +38 -1
  195. package/src/tools/editTool.ts +44 -9
  196. package/src/tools/lspTool.ts +760 -0
  197. package/src/tools/multiEditTool.ts +41 -11
  198. package/src/tools/readTool.ts +127 -3
  199. package/src/tools/skillTool.ts +2 -2
  200. package/src/tools/todoWriteTool.ts +33 -1
  201. package/src/tools/types.ts +15 -9
  202. package/src/tools/writeTool.ts +43 -16
  203. package/src/types/commands.ts +6 -1
  204. package/src/types/config.ts +5 -0
  205. package/src/types/configuration.ts +73 -0
  206. package/src/types/core.ts +55 -0
  207. package/src/types/environment.ts +104 -0
  208. package/src/types/fileSearch.ts +4 -0
  209. package/src/types/hooks.ts +32 -16
  210. package/src/types/index.ts +7 -0
  211. package/src/types/lsp.ts +96 -0
  212. package/src/types/messaging.ts +21 -14
  213. package/src/types/permissions.ts +48 -0
  214. package/src/types/session.ts +20 -0
  215. package/src/types/skills.ts +1 -0
  216. package/src/types/tools.ts +38 -0
  217. package/src/utils/abortUtils.ts +118 -0
  218. package/src/utils/bashHistory.ts +55 -31
  219. package/src/utils/builtinSubagents.ts +71 -0
  220. package/src/utils/cacheControlUtils.ts +475 -0
  221. package/src/utils/commandPathResolver.ts +189 -0
  222. package/src/utils/configPaths.ts +163 -0
  223. package/src/utils/constants.ts +2 -17
  224. package/src/utils/convertMessagesForAPI.ts +44 -18
  225. package/src/utils/customCommands.ts +90 -22
  226. package/src/utils/fileSearch.ts +107 -0
  227. package/src/utils/fileUtils.ts +160 -0
  228. package/src/utils/globalLogger.ts +128 -0
  229. package/src/utils/largeOutputHandler.ts +55 -0
  230. package/src/utils/markdownParser.ts +1 -19
  231. package/src/utils/mcpUtils.ts +34 -3
  232. package/src/utils/messageOperations.ts +47 -53
  233. package/src/utils/pathEncoder.ts +394 -0
  234. package/src/utils/subagentParser.ts +13 -9
  235. package/src/utils/tokenCalculation.ts +43 -0
  236. package/src/utils/tokenEstimator.ts +68 -0
  237. package/dist/utils/configResolver.d.ts +0 -38
  238. package/dist/utils/configResolver.d.ts.map +0 -1
  239. package/dist/utils/configResolver.js +0 -106
  240. package/src/utils/configResolver.ts +0 -142
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Environment Variable System Types
3
+ *
4
+ * Provides comprehensive TypeScript types for environment variable validation,
5
+ * merging, and conflict resolution in the Wave Agent SDK.
6
+ */
7
+
8
+ /**
9
+ * Result of environment variable validation
10
+ */
11
+ export interface EnvironmentValidationResult {
12
+ isValid: boolean;
13
+ errors: string[];
14
+ warnings: string[];
15
+ }
16
+
17
+ /**
18
+ * Context containing merged environment variables and conflict information
19
+ */
20
+ export interface MergedEnvironmentContext {
21
+ userVars: Record<string, string>;
22
+ projectVars: Record<string, string>;
23
+ mergedVars: Record<string, string>;
24
+ conflicts: Array<{
25
+ key: string;
26
+ userValue: string;
27
+ projectValue: string;
28
+ resolvedValue: string;
29
+ }>;
30
+ }
31
+
32
+ /**
33
+ * Type guard to check if a value is a valid environment variables object
34
+ */
35
+ export function isValidEnvironmentVars(
36
+ env: unknown,
37
+ ): env is Record<string, string> {
38
+ if (typeof env !== "object" || env === null) {
39
+ return false;
40
+ }
41
+
42
+ // Check if all keys and values are strings
43
+ for (const [key, value] of Object.entries(env)) {
44
+ if (typeof key !== "string" || typeof value !== "string") {
45
+ return false;
46
+ }
47
+ }
48
+
49
+ return true;
50
+ }
51
+
52
+ /**
53
+ * Configuration options for environment merging
54
+ */
55
+ export interface EnvironmentMergeOptions {
56
+ /** Whether to include warnings for conflicting variables */
57
+ includeConflictWarnings?: boolean;
58
+ /** Whether to validate variable names for common patterns */
59
+ validateVariableNames?: boolean;
60
+ }
61
+
62
+ /**
63
+ * Result of environment variable processing operations
64
+ */
65
+ export interface EnvironmentProcessResult {
66
+ /** The processed environment variables */
67
+ processedVars: Record<string, string>;
68
+ /** Any conflicts that occurred during processing */
69
+ conflicts: EnvironmentConflict[];
70
+ /** Non-critical warnings during processing */
71
+ warnings: string[];
72
+ /** Whether the variables were successfully applied to process.env */
73
+ applied: boolean;
74
+ }
75
+
76
+ /**
77
+ * Enhanced environment merge context with conflict details
78
+ */
79
+ export interface EnvironmentMergeContext {
80
+ /** User-provided environment variables */
81
+ userVars: Record<string, string>;
82
+ /** Project-provided environment variables */
83
+ projectVars: Record<string, string>;
84
+ /** Final merged environment variables */
85
+ mergedVars: Record<string, string>;
86
+ /** Detailed conflict information */
87
+ conflicts: EnvironmentConflict[];
88
+ }
89
+
90
+ /**
91
+ * Detailed information about an environment variable conflict
92
+ */
93
+ export interface EnvironmentConflict {
94
+ /** The environment variable key */
95
+ key: string;
96
+ /** Value from user configuration */
97
+ userValue: string;
98
+ /** Value from project configuration */
99
+ projectValue: string;
100
+ /** Final resolved value (which source won) */
101
+ resolvedValue: string;
102
+ /** Which source provided the final value */
103
+ source: "user" | "project";
104
+ }
@@ -0,0 +1,4 @@
1
+ export interface FileItem {
2
+ path: string;
3
+ type: "file" | "directory";
4
+ }
@@ -5,21 +5,14 @@
5
5
  * enabling automated actions at specific workflow points.
6
6
  */
7
7
 
8
- import { join } from "path";
9
- import { homedir } from "os";
10
-
11
- // Session path utility (from session.ts)
12
- export function getSessionFilePath(sessionId: string): string {
13
- const shortId = sessionId.split("_")[2] || sessionId.slice(-8);
14
- return join(homedir(), ".wave", "sessions", `session_${shortId}.json`);
15
- }
16
-
17
8
  // Hook event types - trigger points in the AI workflow
18
9
  export type HookEvent =
19
10
  | "PreToolUse"
20
11
  | "PostToolUse"
21
12
  | "UserPromptSubmit"
22
- | "Stop";
13
+ | "Stop"
14
+ | "SubagentStop"
15
+ | "Notification";
23
16
 
24
17
  // Individual hook command configuration
25
18
  export interface HookCommand {
@@ -33,8 +26,19 @@ export interface HookEventConfig {
33
26
  hooks: HookCommand[];
34
27
  }
35
28
 
36
- // Root configuration structure for all hook definitions
37
- export interface HookConfiguration {
29
+ // Root configuration structure for all Wave Agent settings including hooks and environment variables
30
+ export interface WaveConfiguration {
31
+ hooks?: Partial<Record<HookEvent, HookEventConfig[]>>;
32
+ env?: Record<string, string>; // Environment variables key-value pairs
33
+ defaultMode?: "default" | "bypassPermissions" | "acceptEdits"; // Default permission mode for restricted tools
34
+ /** New field for persistent permissions */
35
+ permissions?: {
36
+ allow?: string[];
37
+ };
38
+ }
39
+
40
+ // Legacy alias for backward compatibility - will be deprecated
41
+ export interface HookConfiguration extends WaveConfiguration {
38
42
  hooks: Partial<Record<HookEvent, HookEventConfig[]>>;
39
43
  }
40
44
 
@@ -104,9 +108,14 @@ export class HookConfigurationError extends Error {
104
108
 
105
109
  // Type guards for runtime validation
106
110
  export function isValidHookEvent(event: string): event is HookEvent {
107
- return ["PreToolUse", "PostToolUse", "UserPromptSubmit", "Stop"].includes(
108
- event,
109
- );
111
+ return [
112
+ "PreToolUse",
113
+ "PostToolUse",
114
+ "UserPromptSubmit",
115
+ "Stop",
116
+ "SubagentStop",
117
+ "Notification",
118
+ ].includes(event);
110
119
  }
111
120
 
112
121
  export function isValidHookCommand(cmd: unknown): cmd is HookCommand {
@@ -144,13 +153,16 @@ export interface HookJsonInput {
144
153
  session_id: string; // Format: "wave_session_{uuid}_{shortId}"
145
154
  transcript_path: string; // Format: "~/.wave/sessions/session_{shortId}.json"
146
155
  cwd: string; // Absolute path to current working directory
147
- hook_event_name: HookEvent; // "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop"
156
+ hook_event_name: HookEvent; // "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop" | "SubagentStop" | "Notification"
148
157
 
149
158
  // Optional fields based on event type
150
159
  tool_name?: string; // Present for PreToolUse, PostToolUse
151
160
  tool_input?: unknown; // Present for PreToolUse, PostToolUse
152
161
  tool_response?: unknown; // Present for PostToolUse only
153
162
  user_prompt?: string; // Present for UserPromptSubmit only
163
+ subagent_type?: string; // Present when hook is executed by a subagent
164
+ message?: string; // Present for Notification events
165
+ notification_type?: string; // Present for Notification events
154
166
  }
155
167
 
156
168
  // Extended context interface for passing additional data to hook executor
@@ -160,7 +172,11 @@ export interface ExtendedHookExecutionContext extends HookExecutionContext {
160
172
  cwd?: string; // Current working directory
161
173
  toolInput?: unknown; // Tool input parameters (PreToolUse/PostToolUse)
162
174
  toolResponse?: unknown; // Tool execution result (PostToolUse only)
175
+ env?: Record<string, string>; // Additional environment variables (from configuration)
163
176
  userPrompt?: string; // User prompt text (UserPromptSubmit only)
177
+ subagentType?: string; // Subagent type when hook is executed by a subagent
178
+ message?: string; // Notification message (Notification only)
179
+ notificationType?: string; // Notification type (Notification only)
164
180
  }
165
181
 
166
182
  // Environment variables injected into hook processes
@@ -21,3 +21,10 @@ export * from "./processes.js";
21
21
  export * from "./commands.js";
22
22
  export * from "./skills.js";
23
23
  export * from "./config.js";
24
+ export * from "./session.js";
25
+ export * from "./environment.js";
26
+ export * from "./configuration.js"; // New configuration management types
27
+ export * from "./permissions.js";
28
+ export * from "./tools.js"; // Tool parameter types
29
+ export * from "./fileSearch.js"; // File search types
30
+ export * from "./lsp.js";
@@ -0,0 +1,96 @@
1
+ /**
2
+ * LSP (Language Server Protocol) configuration and communication types
3
+ */
4
+
5
+ export interface LspServerConfig {
6
+ command: string;
7
+ args?: string[];
8
+ extensionToLanguage: Record<string, string>;
9
+ transport?: "stdio" | "socket";
10
+ env?: Record<string, string>;
11
+ initializationOptions?: unknown;
12
+ settings?: unknown;
13
+ workspaceFolder?: string;
14
+ startupTimeout?: number;
15
+ shutdownTimeout?: number;
16
+ restartOnCrash?: boolean;
17
+ maxRestarts?: number;
18
+ }
19
+
20
+ export interface LspConfig {
21
+ [language: string]: LspServerConfig;
22
+ }
23
+
24
+ export interface LspPosition {
25
+ line: number;
26
+ character: number;
27
+ }
28
+
29
+ export interface LspRange {
30
+ start: LspPosition;
31
+ end: LspPosition;
32
+ }
33
+
34
+ export interface LspLocation {
35
+ uri: string;
36
+ range: LspRange;
37
+ }
38
+
39
+ export interface LspLocationLink {
40
+ originSelectionRange?: LspRange;
41
+ targetUri: string;
42
+ targetRange: LspRange;
43
+ targetSelectionRange?: LspRange;
44
+ }
45
+
46
+ export interface LspHover {
47
+ contents:
48
+ | string
49
+ | { kind: string; value: string }
50
+ | Array<string | { kind: string; value: string }>;
51
+ range?: LspRange;
52
+ }
53
+
54
+ export interface LspSymbolInformation {
55
+ name: string;
56
+ kind: number;
57
+ location: LspLocation;
58
+ containerName?: string;
59
+ }
60
+
61
+ export interface LspDocumentSymbol {
62
+ name: string;
63
+ detail?: string;
64
+ kind: number;
65
+ range: LspRange;
66
+ selectionRange: LspRange;
67
+ children?: LspDocumentSymbol[];
68
+ }
69
+
70
+ export interface LspCallHierarchyItem {
71
+ name: string;
72
+ kind: number;
73
+ detail?: string;
74
+ uri: string;
75
+ range: LspRange;
76
+ selectionRange: LspRange;
77
+ }
78
+
79
+ export interface LspCallHierarchyIncomingCall {
80
+ from: LspCallHierarchyItem;
81
+ fromRanges: LspRange[];
82
+ }
83
+
84
+ export interface LspCallHierarchyOutgoingCall {
85
+ to: LspCallHierarchyItem;
86
+ fromRanges: LspRange[];
87
+ }
88
+
89
+ export interface ILspManager {
90
+ execute(args: {
91
+ operation: string;
92
+ filePath: string;
93
+ line: number;
94
+ character: number;
95
+ }): Promise<{ success: boolean; content: string }>;
96
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { Usage } from "./core.js";
7
+ import type { SubagentConfiguration } from "../utils/subagentParser.js";
7
8
 
8
9
  export enum MessageSource {
9
10
  USER = "user",
@@ -14,6 +15,7 @@ export interface Message {
14
15
  role: "user" | "assistant";
15
16
  blocks: MessageBlock[];
16
17
  usage?: Usage; // Usage data for this message's AI operation (assistant messages only)
18
+ additionalFields?: Record<string, unknown>; // Additional metadata from AI responses
17
19
  }
18
20
 
19
21
  export type MessageBlock =
@@ -21,11 +23,11 @@ export type MessageBlock =
21
23
  | ErrorBlock
22
24
  | ToolBlock
23
25
  | ImageBlock
24
- | DiffBlock
25
26
  | CommandOutputBlock
26
27
  | CompressBlock
27
28
  | MemoryBlock
28
- | SubagentBlock;
29
+ | SubagentBlock
30
+ | ReasoningBlock;
29
31
 
30
32
  export interface TextBlock {
31
33
  type: "text";
@@ -51,10 +53,18 @@ export interface ToolBlock {
51
53
  }>;
52
54
  id?: string;
53
55
  name?: string;
54
- isRunning?: boolean; // Mark if tool is actually executing
56
+ /**
57
+ * Tool execution stage:
58
+ * - 'start': Tool call initiated (from AI service streaming)
59
+ * - 'streaming': Tool parameters being streamed (from AI service)
60
+ * - 'running': Tool execution in progress (from AI manager)
61
+ * - 'end': Tool execution completed (from AI manager)
62
+ */
63
+ stage: "start" | "streaming" | "running" | "end";
55
64
  success?: boolean;
56
65
  error?: string | Error;
57
66
  compactParams?: string; // Compact parameter display
67
+ parametersChunk?: string; // Incremental parameter updates for streaming
58
68
  }
59
69
 
60
70
  export interface ImageBlock {
@@ -62,16 +72,6 @@ export interface ImageBlock {
62
72
  imageUrls?: string[];
63
73
  }
64
74
 
65
- export interface DiffBlock {
66
- type: "diff";
67
- path: string;
68
- diffResult: Array<{
69
- value: string;
70
- added?: boolean;
71
- removed?: boolean;
72
- }>;
73
- }
74
-
75
75
  export interface CommandOutputBlock {
76
76
  type: "command_output";
77
77
  command: string;
@@ -83,6 +83,7 @@ export interface CommandOutputBlock {
83
83
  export interface CompressBlock {
84
84
  type: "compress";
85
85
  content: string;
86
+ sessionId: string;
86
87
  }
87
88
 
88
89
  export interface MemoryBlock {
@@ -98,5 +99,11 @@ export interface SubagentBlock {
98
99
  subagentId: string;
99
100
  subagentName: string;
100
101
  status: "active" | "completed" | "error" | "aborted";
101
- messages: Message[];
102
+ sessionId: string;
103
+ configuration: SubagentConfiguration;
104
+ }
105
+
106
+ export interface ReasoningBlock {
107
+ type: "reasoning";
108
+ content: string;
102
109
  }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Permission system types for Wave Agent SDK
3
+ * Dependencies: None
4
+ */
5
+
6
+ /** Permission mode configuration */
7
+ export type PermissionMode = "default" | "bypassPermissions" | "acceptEdits";
8
+
9
+ /** Result of a permission check */
10
+ export interface PermissionDecision {
11
+ /** Whether to allow or deny the operation */
12
+ behavior: "allow" | "deny";
13
+ /** Optional message explaining the decision (required for deny) */
14
+ message?: string;
15
+ /** Signal to change the session's permission mode */
16
+ newPermissionMode?: PermissionMode;
17
+ /** Signal to persist a new allowed rule */
18
+ newPermissionRule?: string;
19
+ }
20
+
21
+ /** Callback function for custom permission logic */
22
+ export type PermissionCallback = (
23
+ context: ToolPermissionContext,
24
+ ) => Promise<PermissionDecision>;
25
+
26
+ /** Internal context passed to PermissionManager */
27
+ export interface ToolPermissionContext {
28
+ /** Name of the tool being executed */
29
+ toolName: string;
30
+ /** Current permission mode */
31
+ permissionMode: PermissionMode;
32
+ /** Custom permission callback if provided */
33
+ canUseToolCallback?: PermissionCallback;
34
+ /** Tool input parameters for better context */
35
+ toolInput?: Record<string, unknown>;
36
+ }
37
+
38
+ /** List of tools that require permission checks in default mode */
39
+ export const RESTRICTED_TOOLS = [
40
+ "Edit",
41
+ "MultiEdit",
42
+ "Delete",
43
+ "Bash",
44
+ "Write",
45
+ ] as const;
46
+
47
+ /** Type for restricted tool names */
48
+ export type RestrictedTool = (typeof RESTRICTED_TOOLS)[number];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Session management types for project-based organization with JSONL format
3
+ * Dependencies: Core messaging types
4
+ *
5
+ * SIMPLIFIED: Removed unused interfaces to focus on core functionality
6
+ */
7
+
8
+ import type { Message } from "./messaging.js";
9
+
10
+ // Enhanced message interface for JSONL storage (extends existing Message)
11
+ export interface SessionMessage extends Message {
12
+ timestamp: string; // ISO 8601 - added for JSONL format
13
+ // Inherits: role: "user" | "assistant", blocks: MessageBlock[], usage?, additionalFields?
14
+ }
15
+
16
+ // Session filename structure for simple filename-based metadata
17
+ export interface SessionFilename {
18
+ sessionId: string;
19
+ sessionType: "main" | "subagent";
20
+ }
@@ -61,6 +61,7 @@ export interface SkillManagerOptions {
61
61
  personalSkillsPath?: string;
62
62
  scanTimeout?: number;
63
63
  logger?: Logger;
64
+ workdir?: string;
64
65
  }
65
66
 
66
67
  export interface ParsedSkillFile {
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Tool parameter types for edit and write operations
3
+ */
4
+
5
+ /**
6
+ * Parameters for the Write tool
7
+ */
8
+ export interface WriteToolParameters {
9
+ file_path: string;
10
+ content: string;
11
+ }
12
+
13
+ /**
14
+ * Parameters for a single edit operation in the Edit tool
15
+ */
16
+ export interface EditOperation {
17
+ old_string: string;
18
+ new_string: string;
19
+ replace_all?: boolean;
20
+ }
21
+
22
+ /**
23
+ * Parameters for the Edit tool
24
+ */
25
+ export interface EditToolParameters {
26
+ file_path: string;
27
+ old_string: string;
28
+ new_string: string;
29
+ replace_all?: boolean;
30
+ }
31
+
32
+ /**
33
+ * Parameters for the MultiEdit tool
34
+ */
35
+ export interface MultiEditToolParameters {
36
+ file_path: string;
37
+ edits: EditOperation[];
38
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Utilities for safe AbortSignal listener management to prevent memory leaks
3
+ */
4
+
5
+ /**
6
+ * Safely adds a one-time abort listener that automatically cleans up after firing
7
+ * @param signal - The AbortSignal to listen to
8
+ * @param callback - The function to call when aborted
9
+ * @returns A cleanup function to manually remove the listener if needed
10
+ */
11
+ export function addOnceAbortListener(
12
+ signal: AbortSignal,
13
+ callback: () => void,
14
+ ): () => void {
15
+ if (signal.aborted) {
16
+ // Signal already aborted, call immediately
17
+ callback();
18
+ return () => {}; // No cleanup needed
19
+ }
20
+
21
+ const handler = () => {
22
+ callback();
23
+ };
24
+
25
+ // Use { once: true } to automatically remove listener after first call
26
+ signal.addEventListener("abort", handler, { once: true });
27
+
28
+ // Return cleanup function for manual removal if needed
29
+ return () => {
30
+ signal.removeEventListener("abort", handler);
31
+ };
32
+ }
33
+
34
+ /**
35
+ * Creates a Promise that rejects when the AbortSignal is aborted
36
+ * Uses once-only listener to prevent accumulation
37
+ * @param signal - The AbortSignal to listen to
38
+ * @param errorMessage - Optional custom error message
39
+ * @returns Promise that rejects on abort
40
+ */
41
+ export function createAbortPromise(
42
+ signal: AbortSignal,
43
+ errorMessage: string = "Operation was aborted",
44
+ ): Promise<never> {
45
+ return new Promise<never>((_, reject) => {
46
+ if (signal.aborted) {
47
+ reject(new Error(errorMessage));
48
+ return;
49
+ }
50
+
51
+ // Use once-only listener to prevent accumulation
52
+ signal.addEventListener(
53
+ "abort",
54
+ () => {
55
+ reject(new Error(errorMessage));
56
+ },
57
+ { once: true },
58
+ );
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Wrapper that manages abort signal listeners with automatic cleanup
64
+ * @param signal - The AbortSignal to manage
65
+ * @param operation - Function that sets up listeners and returns cleanup
66
+ * @returns Promise that resolves with the operation result
67
+ */
68
+ export async function withAbortCleanup<T>(
69
+ signal: AbortSignal,
70
+ operation: (signal: AbortSignal) => Promise<T>,
71
+ ): Promise<T> {
72
+ // Track all cleanup functions
73
+ const cleanups: (() => void)[] = [];
74
+
75
+ try {
76
+ const result = await operation(signal);
77
+ return result;
78
+ } finally {
79
+ // Clean up all listeners
80
+ cleanups.forEach((cleanup) => cleanup());
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Consolidates multiple abort listeners into a single listener
86
+ * Useful when multiple handlers need to respond to the same abort signal
87
+ * @param signal - The AbortSignal to listen to
88
+ * @param callbacks - Array of functions to call when aborted
89
+ * @returns Cleanup function to remove the consolidated listener
90
+ */
91
+ export function addConsolidatedAbortListener(
92
+ signal: AbortSignal,
93
+ callbacks: (() => void)[],
94
+ ): () => void {
95
+ if (signal.aborted) {
96
+ // Signal already aborted, call all callbacks immediately
97
+ callbacks.forEach((cb) => cb());
98
+ return () => {}; // No cleanup needed
99
+ }
100
+
101
+ const handler = () => {
102
+ callbacks.forEach((cb) => {
103
+ try {
104
+ cb();
105
+ } catch (error) {
106
+ console.error("Error in abort callback:", error);
107
+ }
108
+ });
109
+ };
110
+
111
+ // Use { once: true } to automatically remove listener after first call
112
+ signal.addEventListener("abort", handler, { once: true });
113
+
114
+ // Return cleanup function for manual removal if needed
115
+ return () => {
116
+ signal.removeEventListener("abort", handler);
117
+ };
118
+ }