wave-agent-sdk 1.0.4 → 1.0.6

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 (194) hide show
  1. package/dist/agent.d.ts +23 -1
  2. package/dist/agent.js +34 -4
  3. package/dist/managers/aiManager.d.ts +36 -0
  4. package/dist/managers/aiManager.js +240 -8
  5. package/dist/managers/messageManager.d.ts +1 -3
  6. package/dist/managers/messageManager.js +19 -9
  7. package/dist/managers/slashCommandManager.js +28 -0
  8. package/dist/managers/subagentManager.d.ts +0 -2
  9. package/dist/services/session.js +2 -9
  10. package/dist/telemetry/instrumentation.d.ts +1 -1
  11. package/dist/telemetry/instrumentation.js +57 -28
  12. package/dist/tools/bashTool.js +16 -6
  13. package/dist/tools/grepTool.js +11 -3
  14. package/dist/types/index.d.ts +3 -0
  15. package/dist/types/messaging.d.ts +2 -0
  16. package/dist/utils/containerSetup.js +0 -3
  17. package/dist/utils/messageOperations.d.ts +10 -1
  18. package/dist/utils/messageOperations.js +19 -1
  19. package/dist/utils/notificationXml.js +5 -0
  20. package/dist/utils/ripgrep.d.ts +4 -4
  21. package/dist/utils/ripgrep.js +4 -27
  22. package/package.json +20 -8
  23. package/bin/rg +0 -79
  24. package/dist/managers/forkedAgentManager.d.ts +0 -50
  25. package/dist/managers/forkedAgentManager.js +0 -130
  26. package/scripts/install_ripgrep.js +0 -111
  27. package/scripts/postinstall.js +0 -38
  28. package/src/agent.ts +0 -1271
  29. package/src/constants/subagents.ts +0 -4
  30. package/src/constants/toolLimits.ts +0 -15
  31. package/src/constants/tools.ts +0 -24
  32. package/src/core/plugin.ts +0 -237
  33. package/src/core/session.ts +0 -9
  34. package/src/index.ts +0 -38
  35. package/src/managers/MemoryRuleManager.ts +0 -198
  36. package/src/managers/aiManager.ts +0 -2429
  37. package/src/managers/backgroundTaskManager.ts +0 -480
  38. package/src/managers/bangManager.ts +0 -119
  39. package/src/managers/cronManager.ts +0 -401
  40. package/src/managers/foregroundTaskManager.ts +0 -30
  41. package/src/managers/forkedAgentManager.ts +0 -216
  42. package/src/managers/hookManager.ts +0 -1089
  43. package/src/managers/liveConfigManager.ts +0 -445
  44. package/src/managers/lspManager.ts +0 -470
  45. package/src/managers/mcpManager.ts +0 -1010
  46. package/src/managers/messageManager.ts +0 -1180
  47. package/src/managers/messageQueue.ts +0 -157
  48. package/src/managers/permissionManager.ts +0 -1140
  49. package/src/managers/planManager.ts +0 -112
  50. package/src/managers/pluginManager.ts +0 -330
  51. package/src/managers/pluginScopeManager.ts +0 -124
  52. package/src/managers/reversionManager.ts +0 -178
  53. package/src/managers/skillManager.ts +0 -578
  54. package/src/managers/slashCommandManager.ts +0 -564
  55. package/src/managers/subagentManager.ts +0 -915
  56. package/src/managers/toolManager.ts +0 -489
  57. package/src/managers/workflowManager.ts +0 -493
  58. package/src/prompts/autoMemory.ts +0 -33
  59. package/src/prompts/autoMemoryExtraction.ts +0 -146
  60. package/src/prompts/index.ts +0 -506
  61. package/src/prompts/planModeReminders.ts +0 -126
  62. package/src/services/GitService.ts +0 -131
  63. package/src/services/MarketplaceService.ts +0 -1052
  64. package/src/services/MemoryRuleService.ts +0 -71
  65. package/src/services/aiService.ts +0 -919
  66. package/src/services/authService.ts +0 -565
  67. package/src/services/autoMemoryService.ts +0 -280
  68. package/src/services/configurationService.ts +0 -1520
  69. package/src/services/fileWatcher.ts +0 -319
  70. package/src/services/hook.ts +0 -348
  71. package/src/services/initializationService.ts +0 -357
  72. package/src/services/interactionService.ts +0 -229
  73. package/src/services/jsonlHandler.ts +0 -295
  74. package/src/services/memory.ts +0 -234
  75. package/src/services/pluginLoader.ts +0 -252
  76. package/src/services/remoteSettingsService.ts +0 -366
  77. package/src/services/reversionService.ts +0 -122
  78. package/src/services/session.ts +0 -922
  79. package/src/services/taskManager.ts +0 -321
  80. package/src/telemetry/events.ts +0 -65
  81. package/src/telemetry/instrumentation.ts +0 -499
  82. package/src/telemetry/sessionTracing.ts +0 -348
  83. package/src/tools/agentTool.ts +0 -322
  84. package/src/tools/askUserQuestion.ts +0 -160
  85. package/src/tools/bashTool.ts +0 -621
  86. package/src/tools/buildTool.ts +0 -61
  87. package/src/tools/cronCreateTool.ts +0 -161
  88. package/src/tools/cronDeleteTool.ts +0 -51
  89. package/src/tools/cronListTool.ts +0 -47
  90. package/src/tools/editTool.ts +0 -313
  91. package/src/tools/enterPlanMode.ts +0 -124
  92. package/src/tools/enterWorktreeTool.ts +0 -190
  93. package/src/tools/exitPlanMode.ts +0 -139
  94. package/src/tools/exitWorktreeTool.ts +0 -236
  95. package/src/tools/globTool.ts +0 -167
  96. package/src/tools/grepTool.ts +0 -399
  97. package/src/tools/lspTool.ts +0 -883
  98. package/src/tools/readTool.ts +0 -426
  99. package/src/tools/skillTool.ts +0 -248
  100. package/src/tools/taskManagementTools.ts +0 -574
  101. package/src/tools/taskStopTool.ts +0 -78
  102. package/src/tools/types.ts +0 -137
  103. package/src/tools/webFetchTool.ts +0 -373
  104. package/src/tools/workflowTool.ts +0 -205
  105. package/src/tools/writeTool.ts +0 -267
  106. package/src/types/agent.ts +0 -128
  107. package/src/types/auth.ts +0 -19
  108. package/src/types/commands.ts +0 -30
  109. package/src/types/config.ts +0 -43
  110. package/src/types/configuration.ts +0 -168
  111. package/src/types/core.ts +0 -105
  112. package/src/types/cron.ts +0 -13
  113. package/src/types/environment.ts +0 -106
  114. package/src/types/fileSearch.ts +0 -4
  115. package/src/types/history.ts +0 -7
  116. package/src/types/hooks.ts +0 -256
  117. package/src/types/index.ts +0 -41
  118. package/src/types/lsp.ts +0 -98
  119. package/src/types/marketplace.ts +0 -71
  120. package/src/types/mcp.ts +0 -43
  121. package/src/types/memoryRule.ts +0 -31
  122. package/src/types/messaging.ts +0 -114
  123. package/src/types/permissions.ts +0 -80
  124. package/src/types/plugins.ts +0 -39
  125. package/src/types/processes.ts +0 -99
  126. package/src/types/reversion.ts +0 -29
  127. package/src/types/session.ts +0 -12
  128. package/src/types/skills.ts +0 -108
  129. package/src/types/tasks.ts +0 -13
  130. package/src/types/telemetry.ts +0 -98
  131. package/src/types/tools.ts +0 -44
  132. package/src/types/workflow.ts +0 -6
  133. package/src/utils/abortUtils.ts +0 -118
  134. package/src/utils/atomicWrite.ts +0 -61
  135. package/src/utils/bashParser.ts +0 -899
  136. package/src/utils/cacheControlUtils.ts +0 -426
  137. package/src/utils/commandArgumentParser.ts +0 -161
  138. package/src/utils/commandPathResolver.ts +0 -88
  139. package/src/utils/configPaths.ts +0 -220
  140. package/src/utils/configValidator.ts +0 -100
  141. package/src/utils/constants.ts +0 -39
  142. package/src/utils/container.ts +0 -92
  143. package/src/utils/containerSetup.ts +0 -371
  144. package/src/utils/convertMessagesForAPI.ts +0 -326
  145. package/src/utils/cronTasks.ts +0 -128
  146. package/src/utils/cronTasksLock.ts +0 -182
  147. package/src/utils/cronToHuman.ts +0 -99
  148. package/src/utils/customCommands.ts +0 -95
  149. package/src/utils/editUtils.ts +0 -20
  150. package/src/utils/fileFormat.ts +0 -40
  151. package/src/utils/fileSearch.ts +0 -151
  152. package/src/utils/fileUtils.ts +0 -223
  153. package/src/utils/gitUtils.ts +0 -315
  154. package/src/utils/globalLogger.ts +0 -128
  155. package/src/utils/groupMessagesByApiRound.ts +0 -121
  156. package/src/utils/hookMatcher.ts +0 -176
  157. package/src/utils/markdownParser.ts +0 -317
  158. package/src/utils/mcpUtils.ts +0 -138
  159. package/src/utils/messageOperations.ts +0 -641
  160. package/src/utils/modelCapabilities.ts +0 -30
  161. package/src/utils/nameGenerator.ts +0 -99
  162. package/src/utils/notificationXml.ts +0 -57
  163. package/src/utils/openaiClient.ts +0 -251
  164. package/src/utils/parseCronExpression.ts +0 -78
  165. package/src/utils/path.ts +0 -72
  166. package/src/utils/pathEncoder.ts +0 -400
  167. package/src/utils/pathSafety.ts +0 -40
  168. package/src/utils/promptHistory.ts +0 -168
  169. package/src/utils/ripgrep.ts +0 -35
  170. package/src/utils/shellResolver.ts +0 -190
  171. package/src/utils/skillParser.ts +0 -246
  172. package/src/utils/stringUtils.ts +0 -156
  173. package/src/utils/subagentParser.ts +0 -279
  174. package/src/utils/taskReminder.ts +0 -96
  175. package/src/utils/tokenCalculation.ts +0 -43
  176. package/src/utils/tokenEstimate.ts +0 -34
  177. package/src/utils/toolResultStorage.ts +0 -117
  178. package/src/utils/worktreeSession.ts +0 -26
  179. package/src/utils/worktreeUtils.ts +0 -786
  180. package/src/workflow/budgetTracker.ts +0 -34
  181. package/src/workflow/concurrencyLimiter.ts +0 -47
  182. package/src/workflow/journal.ts +0 -95
  183. package/src/workflow/progressReporter.ts +0 -141
  184. package/src/workflow/runState.ts +0 -65
  185. package/src/workflow/scriptRuntime.ts +0 -274
  186. package/src/workflow/structuredOutput.ts +0 -123
  187. package/src/workflow/types.ts +0 -101
  188. package/src/workflow/workflowApis.ts +0 -410
  189. package/vendor/ripgrep/linux-aarch64/rg +0 -0
  190. package/vendor/ripgrep/linux-x86_64/rg +0 -0
  191. package/vendor/ripgrep/macos-aarch64/rg +0 -0
  192. package/vendor/ripgrep/macos-x86_64/rg +0 -0
  193. package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
  194. package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
@@ -1,220 +0,0 @@
1
- /**
2
- * Configuration Path Utilities
3
- *
4
- * Centralized utilities for resolving Wave configuration file paths.
5
- * Supports both regular settings.json and local settings.local.json with proper priority.
6
- *
7
- * Priority system:
8
- * - User configs: ~/.wave/settings.json
9
- * - Local configs: {workdir}/.wave/settings.local.json > {workdir}/.wave/settings.json
10
- * - Project configs override user configs (existing behavior)
11
- */
12
-
13
- import { join, dirname } from "path";
14
- import { homedir } from "os";
15
- import { existsSync } from "fs";
16
- import { fileURLToPath } from "url";
17
- import { findUpSync } from "find-up";
18
-
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
21
-
22
- /**
23
- * Resolve the package root directory by finding the nearest package.json.
24
- * Works correctly even when bundled (e.g. esbuild into a VS Code extension),
25
- * as long as vendor/ and builtin/ remain alongside package.json on disk.
26
- */
27
- let _packageRoot: string | undefined;
28
- export function getPackageRoot(): string {
29
- if (_packageRoot) return _packageRoot;
30
- const pkgPath = findUpSync("package.json", { cwd: __dirname });
31
- if (pkgPath) {
32
- _packageRoot = dirname(pkgPath);
33
- return _packageRoot;
34
- }
35
- // Fallback: relative to this file (works during development)
36
- _packageRoot = join(__dirname, "..", "..");
37
- return _packageRoot;
38
- }
39
-
40
- /**
41
- * Get the builtin skills directory path
42
- */
43
- export function getBuiltinSkillsDir(): string {
44
- return join(getPackageRoot(), "builtin", "skills");
45
- }
46
-
47
- /**
48
- * Get the builtin subagents directory path
49
- */
50
- export function getBuiltinSubagentsDir(): string {
51
- return join(getPackageRoot(), "builtin", "subagents");
52
- }
53
-
54
- /**
55
- * Get the builtin plugins directory path
56
- */
57
- export function getBuiltinPluginsDir(): string {
58
- return join(getPackageRoot(), "builtin", "plugins");
59
- }
60
-
61
- /**
62
- * Get the user-specific configuration file path (legacy function)
63
- * @deprecated Use getUserConfigPaths() for better priority support
64
- */
65
- export function getUserConfigPath(): string {
66
- return join(homedir(), ".wave", "settings.json");
67
- }
68
-
69
- /**
70
- * Get the project-specific configuration file path (legacy function)
71
- * @deprecated Use getProjectConfigPaths() for better priority support
72
- */
73
- export function getProjectConfigPath(workdir: string): string {
74
- return join(workdir, ".wave", "settings.json");
75
- }
76
-
77
- /**
78
- * Get the user-specific configuration file paths in priority order
79
- * Returns array with .json only
80
- */
81
- export function getUserConfigPaths(): string[] {
82
- const baseDir = join(homedir(), ".wave");
83
- return [join(baseDir, "settings.json")];
84
- }
85
-
86
- /**
87
- * Get the plugins directory path
88
- */
89
- export function getPluginsDir(): string {
90
- return join(homedir(), ".wave", "plugins");
91
- }
92
-
93
- /**
94
- * Get the local configuration file paths in priority order
95
- * Returns array with .local.json first, then .json
96
- */
97
- export function getProjectConfigPaths(workdir: string): string[] {
98
- const baseDir = join(workdir, ".wave");
99
- return [join(baseDir, "settings.local.json"), join(baseDir, "settings.json")];
100
- }
101
-
102
- /**
103
- * Get all configuration file paths (user and project) in priority order
104
- * Useful for comprehensive configuration detection
105
- */
106
- export function getAllConfigPaths(workdir: string): {
107
- userPaths: string[];
108
- projectPaths: string[];
109
- builtinPaths: string[];
110
- allPaths: string[];
111
- } {
112
- const userPaths = getUserConfigPaths();
113
- const projectPaths = getProjectConfigPaths(workdir);
114
- const builtinPaths = [join(getBuiltinSkillsDir(), "settings", "SKILL.md")];
115
-
116
- return {
117
- userPaths,
118
- projectPaths,
119
- builtinPaths,
120
- allPaths: [...userPaths, ...projectPaths, ...builtinPaths],
121
- };
122
- }
123
-
124
- /**
125
- * Get existing configuration file paths
126
- * Returns only the paths that actually exist on the filesystem
127
- */
128
- export function getExistingConfigPaths(workdir: string): {
129
- userPaths: string[];
130
- projectPaths: string[];
131
- builtinPaths: string[];
132
- existingPaths: string[];
133
- } {
134
- const allPaths = getAllConfigPaths(workdir);
135
-
136
- const existingUserPaths = allPaths.userPaths.filter(existsSync);
137
- const existingProjectPaths = allPaths.projectPaths.filter(existsSync);
138
- const existingBuiltinPaths = allPaths.builtinPaths.filter(existsSync);
139
- const allExistingPaths = allPaths.allPaths.filter(existsSync);
140
-
141
- return {
142
- userPaths: existingUserPaths,
143
- projectPaths: existingProjectPaths,
144
- builtinPaths: existingBuiltinPaths,
145
- existingPaths: allExistingPaths,
146
- };
147
- }
148
-
149
- /**
150
- * Get the first existing configuration file path with the specified priority
151
- * @param paths Array of paths in priority order
152
- * @returns The first path that exists, or undefined if none exist
153
- */
154
- export function getFirstExistingPath(paths: string[]): string | undefined {
155
- return paths.find((path) => existsSync(path));
156
- }
157
-
158
- /**
159
- * Get effective configuration paths (the ones that would actually be used)
160
- * Returns the highest priority existing path for each category
161
- */
162
- export function getEffectiveConfigPaths(workdir: string): {
163
- userPath?: string;
164
- projectPath?: string;
165
- effectivePath?: string; // The path that takes final precedence
166
- } {
167
- const userPaths = getUserConfigPaths();
168
- const projectPaths = getProjectConfigPaths(workdir);
169
-
170
- const userPath = getFirstExistingPath(userPaths);
171
- const projectPath = getFirstExistingPath(projectPaths);
172
-
173
- // Project path takes precedence over user path if both exist
174
- const effectivePath = projectPath || userPath;
175
-
176
- return {
177
- userPath,
178
- projectPath,
179
- effectivePath,
180
- };
181
- }
182
-
183
- /**
184
- * Check if any configuration files exist
185
- */
186
- export function hasAnyConfig(workdir: string): boolean {
187
- const { existingPaths } = getExistingConfigPaths(workdir);
188
- return existingPaths.length > 0;
189
- }
190
-
191
- /**
192
- * Get configuration information for debugging and monitoring
193
- */
194
- export function getConfigurationInfo(workdir: string): {
195
- hasUser: boolean;
196
- hasProject: boolean;
197
- paths: string[];
198
- userPaths: string[];
199
- projectPaths: string[];
200
- existingPaths: string[];
201
- effectivePaths: {
202
- userPath?: string;
203
- projectPath?: string;
204
- effectivePath?: string;
205
- };
206
- } {
207
- const allPaths = getAllConfigPaths(workdir);
208
- const existingPaths = getExistingConfigPaths(workdir);
209
- const effectivePaths = getEffectiveConfigPaths(workdir);
210
-
211
- return {
212
- hasUser: existingPaths.userPaths.length > 0,
213
- hasProject: existingPaths.projectPaths.length > 0,
214
- paths: allPaths.allPaths,
215
- userPaths: allPaths.userPaths,
216
- projectPaths: allPaths.projectPaths,
217
- existingPaths: existingPaths.existingPaths,
218
- effectivePaths,
219
- };
220
- }
@@ -1,100 +0,0 @@
1
- /**
2
- * Configuration validator utilities for Agent Constructor Configuration
3
- * Validates configuration values for correctness and security
4
- */
5
-
6
- import {
7
- GatewayConfig,
8
- ConfigurationError,
9
- CONFIG_ERRORS,
10
- } from "../types/index.js";
11
-
12
- export class ConfigValidator {
13
- /**
14
- * Validates gateway configuration
15
- * @param config - Configuration to validate
16
- * @throws ConfigurationError with descriptive message if invalid
17
- */
18
- static validateGatewayConfig(config: GatewayConfig): void {
19
- // Validate API key if provided
20
- if (config.apiKey !== undefined) {
21
- if (typeof config.apiKey !== "string") {
22
- throw new ConfigurationError(
23
- "API key must be a string if provided.",
24
- "apiKey",
25
- config.apiKey,
26
- );
27
- }
28
- }
29
-
30
- // Validate base URL if provided
31
- if (config.baseURL) {
32
- if (typeof config.baseURL !== "string") {
33
- throw new ConfigurationError(
34
- "Base URL must be a string if provided.",
35
- "baseURL",
36
- config.baseURL,
37
- );
38
- }
39
-
40
- if (config.baseURL.trim() === "") {
41
- throw new ConfigurationError(
42
- CONFIG_ERRORS.EMPTY_BASE_URL,
43
- "baseURL",
44
- config.baseURL,
45
- );
46
- }
47
-
48
- // Basic URL format validation
49
- try {
50
- new URL(config.baseURL);
51
- } catch {
52
- throw new ConfigurationError(
53
- `Base URL must be a valid URL format. Received: ${config.baseURL}`,
54
- "baseURL",
55
- config.baseURL,
56
- );
57
- }
58
- }
59
- }
60
-
61
- /**
62
- * Validates token limit value
63
- * @param maxInputTokens - Token limit to validate
64
- * @throws ConfigurationError if invalid
65
- */
66
- static validateMaxInputTokens(maxInputTokens: number): void {
67
- if (typeof maxInputTokens !== "number") {
68
- throw new ConfigurationError(
69
- CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
70
- "maxInputTokens",
71
- maxInputTokens,
72
- );
73
- }
74
-
75
- if (!Number.isInteger(maxInputTokens)) {
76
- throw new ConfigurationError(
77
- CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
78
- "maxInputTokens",
79
- maxInputTokens,
80
- );
81
- }
82
-
83
- if (maxInputTokens <= 0) {
84
- throw new ConfigurationError(
85
- CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
86
- "maxInputTokens",
87
- maxInputTokens,
88
- );
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * Static configuration validator instance
95
- * Implements ConfigurationValidator interface from types.ts
96
- */
97
- export const configValidator = {
98
- validateGatewayConfig: ConfigValidator.validateGatewayConfig,
99
- validateMaxInputTokens: ConfigValidator.validateMaxInputTokens,
100
- };
@@ -1,39 +0,0 @@
1
- /**
2
- * Application constants definition
3
- */
4
-
5
- import path from "path";
6
- import os from "os";
7
-
8
- /**
9
- * Application data storage directory
10
- * Used to store debug logs, command history and other data
11
- */
12
- export const DATA_DIRECTORY = path.join(os.homedir(), ".wave");
13
-
14
- /**
15
- * Prompt history file path
16
- */
17
- export const PROMPT_HISTORY_FILE = path.join(DATA_DIRECTORY, "history.jsonl");
18
-
19
- /**
20
- * Error log directory path
21
- */
22
- export const ERROR_LOG_DIRECTORY = path.join(DATA_DIRECTORY, "error-logs");
23
-
24
- /**
25
- * User-level memory file path
26
- */
27
- export const USER_MEMORY_FILE = path.join(DATA_DIRECTORY, "AGENTS.md");
28
-
29
- /**
30
- * AI related constants
31
- */
32
- export const DEFAULT_WAVE_MAX_INPUT_TOKENS = 200000; // Default token limit
33
- export const DEFAULT_WAVE_MAX_OUTPUT_TOKENS = 32000; // Default output token limit (aligned with Claude Code)
34
-
35
- /**
36
- * Default server URL for SSO authentication.
37
- * Overridden by WAVE_SERVER_URL env var or programmatic AgentOptions.serverUrl.
38
- */
39
- export const DEFAULT_SERVER_URL = "https://codechat.codewave.163.com";
@@ -1,92 +0,0 @@
1
- /**
2
- * A simple Dependency Injection container to manage late-binding dependencies
3
- * and resolve circular references.
4
- */
5
- export class Container {
6
- private services = new Map<string, unknown>();
7
- private factories = new Map<string, () => unknown>();
8
- private parent?: Container;
9
-
10
- constructor(parent?: Container) {
11
- this.parent = parent;
12
- }
13
-
14
- /**
15
- * Create a child container that inherits from this container
16
- */
17
- createChild(): Container {
18
- return new Container(this);
19
- }
20
-
21
- /**
22
- * Register a singleton instance
23
- */
24
- register<T>(token: string, instance: T): void {
25
- this.services.set(token, instance);
26
- }
27
-
28
- /**
29
- * Register a factory function for lazy resolution
30
- */
31
- provide<T>(token: string, factory: () => T): void {
32
- this.factories.set(token, factory);
33
- }
34
-
35
- /**
36
- * Resolve a service by token
37
- */
38
- get<T>(token: string): T | undefined {
39
- if (this.services.has(token)) {
40
- return this.services.get(token) as T;
41
- }
42
-
43
- const factory = this.factories.get(token);
44
- if (factory) {
45
- const instance = factory() as T;
46
- this.services.set(token, instance);
47
- return instance;
48
- }
49
-
50
- if (this.parent) {
51
- return this.parent.get<T>(token);
52
- }
53
-
54
- return undefined;
55
- }
56
-
57
- /**
58
- * Check if a service exists
59
- */
60
- has(token: string): boolean {
61
- return (
62
- this.services.has(token) ||
63
- this.factories.has(token) ||
64
- (this.parent ? this.parent.has(token) : false)
65
- );
66
- }
67
- }
68
-
69
- // Example usage for ToolManager:
70
- /*
71
- const container = new Container();
72
-
73
- // 1. Provide managers lazily
74
- container.provide('SubagentManager', () => new SubagentManager(...));
75
- container.provide('SkillManager', () => new SkillManager(...));
76
-
77
- // 2. ToolManager can now resolve them only when needed (e.g., in execute)
78
- class ToolManager {
79
- constructor(private container: Container) {}
80
-
81
- async execute(name: string, args: any, context: any) {
82
- const enhancedContext = {
83
- ...context,
84
- subagentManager: this.container.has('SubagentManager')
85
- ? this.container.get('SubagentManager')
86
- : undefined,
87
- // ...
88
- };
89
- // ...
90
- }
91
- }
92
- */