wave-agent-sdk 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +32 -20
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +202 -20
- package/dist/constants/events.d.ts +28 -0
- package/dist/constants/events.d.ts.map +1 -0
- package/dist/constants/events.js +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/managers/aiManager.d.ts +34 -1
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +243 -128
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +7 -6
- package/dist/managers/hookManager.d.ts +9 -4
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +62 -30
- package/dist/managers/liveConfigManager.d.ts +58 -0
- package/dist/managers/liveConfigManager.d.ts.map +1 -0
- package/dist/managers/liveConfigManager.js +160 -0
- package/dist/managers/messageManager.d.ts +38 -13
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +163 -30
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +4 -1
- package/dist/managers/subagentManager.d.ts +51 -0
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +189 -18
- package/dist/services/aiService.d.ts +13 -5
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +350 -74
- package/dist/services/configurationWatcher.d.ts +120 -0
- package/dist/services/configurationWatcher.d.ts.map +1 -0
- package/dist/services/configurationWatcher.js +439 -0
- package/dist/services/fileWatcher.d.ts +69 -0
- package/dist/services/fileWatcher.d.ts.map +1 -0
- package/dist/services/fileWatcher.js +213 -0
- package/dist/services/hook.d.ts +91 -9
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +393 -43
- package/dist/services/jsonlHandler.d.ts +62 -0
- package/dist/services/jsonlHandler.d.ts.map +1 -0
- package/dist/services/jsonlHandler.js +257 -0
- package/dist/services/memory.d.ts +9 -0
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +81 -12
- package/dist/services/memoryStore.d.ts +81 -0
- package/dist/services/memoryStore.d.ts.map +1 -0
- package/dist/services/memoryStore.js +200 -0
- package/dist/services/session.d.ts +64 -49
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +310 -132
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +5 -4
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +2 -1
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +3 -2
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +4 -3
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +2 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +5 -6
- package/dist/types/commands.d.ts +4 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/core.d.ts +35 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/environment.d.ts +42 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/environment.js +21 -0
- package/dist/types/hooks.d.ts +8 -2
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +8 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/memoryStore.d.ts +82 -0
- package/dist/types/memoryStore.d.ts.map +1 -0
- package/dist/types/memoryStore.js +7 -0
- package/dist/types/messaging.d.ts +14 -2
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/session.d.ts +20 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +7 -0
- package/dist/utils/bashHistory.d.ts.map +1 -1
- package/dist/utils/bashHistory.js +27 -26
- package/dist/utils/cacheControlUtils.d.ts +121 -0
- package/dist/utils/cacheControlUtils.d.ts.map +1 -0
- package/dist/utils/cacheControlUtils.js +367 -0
- package/dist/utils/commandPathResolver.d.ts +52 -0
- package/dist/utils/commandPathResolver.d.ts.map +1 -0
- package/dist/utils/commandPathResolver.js +145 -0
- package/dist/utils/configPaths.d.ts +85 -0
- package/dist/utils/configPaths.d.ts.map +1 -0
- package/dist/utils/configPaths.js +121 -0
- package/dist/utils/configResolver.d.ts +37 -10
- package/dist/utils/configResolver.d.ts.map +1 -1
- package/dist/utils/configResolver.js +127 -23
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +7 -5
- package/dist/utils/customCommands.d.ts.map +1 -1
- package/dist/utils/customCommands.js +66 -21
- package/dist/utils/fileUtils.d.ts +15 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +61 -0
- package/dist/utils/globalLogger.d.ts +102 -0
- package/dist/utils/globalLogger.d.ts.map +1 -0
- package/dist/utils/globalLogger.js +136 -0
- package/dist/utils/mcpUtils.d.ts.map +1 -1
- package/dist/utils/mcpUtils.js +25 -3
- package/dist/utils/messageOperations.d.ts +20 -8
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +25 -16
- package/dist/utils/pathEncoder.d.ts +104 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +272 -0
- package/dist/utils/subagentParser.d.ts.map +1 -1
- package/dist/utils/subagentParser.js +2 -1
- package/dist/utils/tokenCalculation.d.ts +26 -0
- package/dist/utils/tokenCalculation.d.ts.map +1 -0
- package/dist/utils/tokenCalculation.js +36 -0
- package/package.json +6 -3
- package/src/agent.ts +298 -34
- package/src/constants/events.ts +38 -0
- package/src/index.ts +2 -0
- package/src/managers/aiManager.ts +323 -170
- package/src/managers/backgroundBashManager.ts +7 -6
- package/src/managers/hookManager.ts +83 -40
- package/src/managers/liveConfigManager.ts +248 -0
- package/src/managers/messageManager.ts +230 -63
- package/src/managers/slashCommandManager.ts +4 -1
- package/src/managers/subagentManager.ts +283 -21
- package/src/services/aiService.ts +474 -83
- package/src/services/configurationWatcher.ts +622 -0
- package/src/services/fileWatcher.ts +301 -0
- package/src/services/hook.ts +538 -47
- package/src/services/jsonlHandler.ts +319 -0
- package/src/services/memory.ts +92 -12
- package/src/services/memoryStore.ts +279 -0
- package/src/services/session.ts +381 -157
- package/src/tools/bashTool.ts +5 -4
- package/src/tools/deleteFileTool.ts +2 -1
- package/src/tools/editTool.ts +3 -2
- package/src/tools/multiEditTool.ts +4 -3
- package/src/tools/readTool.ts +2 -1
- package/src/tools/writeTool.ts +7 -6
- package/src/types/commands.ts +6 -0
- package/src/types/core.ts +44 -0
- package/src/types/environment.ts +60 -0
- package/src/types/hooks.ts +21 -8
- package/src/types/index.ts +2 -0
- package/src/types/memoryStore.ts +94 -0
- package/src/types/messaging.ts +14 -2
- package/src/types/session.ts +25 -0
- package/src/utils/bashHistory.ts +27 -27
- package/src/utils/cacheControlUtils.ts +540 -0
- package/src/utils/commandPathResolver.ts +189 -0
- package/src/utils/configPaths.ts +163 -0
- package/src/utils/configResolver.ts +182 -22
- package/src/utils/constants.ts +1 -1
- package/src/utils/convertMessagesForAPI.ts +7 -5
- package/src/utils/customCommands.ts +90 -22
- package/src/utils/fileUtils.ts +65 -0
- package/src/utils/globalLogger.ts +145 -0
- package/src/utils/mcpUtils.ts +34 -3
- package/src/utils/messageOperations.ts +42 -20
- package/src/utils/pathEncoder.ts +379 -0
- package/src/utils/subagentParser.ts +2 -1
- package/src/utils/tokenCalculation.ts +43 -0
package/dist/agent.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type MessageManagerCallbacks } from "./managers/messageManager.js";
|
|
2
|
+
import { type SubagentManagerCallbacks } from "./managers/subagentManager.js";
|
|
2
3
|
import { type McpManagerCallbacks } from "./managers/mcpManager.js";
|
|
3
4
|
import { type BackgroundBashManagerCallbacks } from "./managers/backgroundBashManager.js";
|
|
4
5
|
import type { SlashCommand, CustomSlashCommand } from "./types/index.js";
|
|
5
|
-
import type { Message, Logger, McpServerStatus, Usage } from "./types/index.js";
|
|
6
|
+
import type { Message, Logger, McpServerStatus, GatewayConfig, ModelConfig, Usage } from "./types/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* Configuration options for Agent instances
|
|
8
9
|
*
|
|
@@ -25,14 +26,8 @@ export interface AgentOptions {
|
|
|
25
26
|
workdir?: string;
|
|
26
27
|
/**Optional custom system prompt - if provided, replaces default system prompt */
|
|
27
28
|
systemPrompt?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Optional custom directory for session file storage
|
|
30
|
-
* @default join(homedir(), ".wave", "sessions")
|
|
31
|
-
* @example "/path/to/custom/sessions"
|
|
32
|
-
*/
|
|
33
|
-
sessionDir?: string;
|
|
34
29
|
}
|
|
35
|
-
export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundBashManagerCallbacks, McpManagerCallbacks {
|
|
30
|
+
export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundBashManagerCallbacks, McpManagerCallbacks, SubagentManagerCallbacks {
|
|
36
31
|
}
|
|
37
32
|
export declare class Agent {
|
|
38
33
|
private messageManager;
|
|
@@ -45,12 +40,19 @@ export declare class Agent {
|
|
|
45
40
|
private subagentManager;
|
|
46
41
|
private slashCommandManager;
|
|
47
42
|
private hookManager;
|
|
43
|
+
private memoryStore;
|
|
44
|
+
private liveConfigManager;
|
|
48
45
|
private workdir;
|
|
49
46
|
private systemPrompt?;
|
|
50
47
|
private _usages;
|
|
51
48
|
private gatewayConfig;
|
|
52
49
|
private modelConfig;
|
|
53
50
|
private tokenLimit;
|
|
51
|
+
private readonly constructorApiKey?;
|
|
52
|
+
private readonly constructorBaseURL?;
|
|
53
|
+
private readonly constructorAgentModel?;
|
|
54
|
+
private readonly constructorFastModel?;
|
|
55
|
+
private readonly constructorTokenLimit?;
|
|
54
56
|
/**
|
|
55
57
|
* Agent constructor - handles configuration resolution and validation
|
|
56
58
|
*
|
|
@@ -59,7 +61,6 @@ export declare class Agent {
|
|
|
59
61
|
* Agent.create() to maintain API consistency.
|
|
60
62
|
*
|
|
61
63
|
* @param options - Configuration options for the Agent instance
|
|
62
|
-
* @param options.sessionDir - Optional custom directory for session storage
|
|
63
64
|
*/
|
|
64
65
|
private constructor();
|
|
65
66
|
get sessionId(): string;
|
|
@@ -80,6 +81,8 @@ export declare class Agent {
|
|
|
80
81
|
get userInputHistory(): string[];
|
|
81
82
|
/** Get working directory */
|
|
82
83
|
get workingDirectory(): string;
|
|
84
|
+
/** Get merged environment variables from Wave configuration */
|
|
85
|
+
get environmentVars(): Record<string, string> | undefined;
|
|
83
86
|
/** Get AI loading status */
|
|
84
87
|
get isLoading(): boolean;
|
|
85
88
|
/** Get message compression status */
|
|
@@ -112,9 +115,6 @@ export declare class Agent {
|
|
|
112
115
|
* @param options - Configuration options for the Agent instance
|
|
113
116
|
* @param options.apiKey - API key for the AI service (or set WAVE_API_KEY env var)
|
|
114
117
|
* @param options.baseURL - Base URL for the AI service (or set WAVE_BASE_URL env var)
|
|
115
|
-
* @param options.sessionDir - Optional custom directory for session file storage.
|
|
116
|
-
* If not provided, defaults to ~/.wave/sessions/. Can be relative or absolute path.
|
|
117
|
-
* Examples: "./app-sessions", "/var/myapp/sessions", "~/Documents/sessions"
|
|
118
118
|
* @param options.callbacks - Optional callbacks for various Agent events
|
|
119
119
|
* @param options.restoreSessionId - Optional session ID to restore from
|
|
120
120
|
* @param options.continueLastSession - Whether to continue the last session automatically
|
|
@@ -126,23 +126,21 @@ export declare class Agent {
|
|
|
126
126
|
*
|
|
127
127
|
* @example
|
|
128
128
|
* ```typescript
|
|
129
|
-
* // Basic usage
|
|
129
|
+
* // Basic usage
|
|
130
130
|
* const agent = await Agent.create({
|
|
131
131
|
* apiKey: 'your-api-key',
|
|
132
132
|
* baseURL: 'https://api.example.com'
|
|
133
133
|
* });
|
|
134
|
-
*
|
|
135
|
-
* // Custom session directory
|
|
136
|
-
* const agent = await Agent.create({
|
|
137
|
-
* apiKey: 'your-api-key',
|
|
138
|
-
* baseURL: 'https://api.example.com',
|
|
139
|
-
* sessionDir: './app-sessions'
|
|
140
|
-
* });
|
|
141
134
|
* ```
|
|
142
135
|
*/
|
|
143
136
|
static create(options: AgentOptions): Promise<Agent>;
|
|
144
137
|
/** Private initialization method, handles async initialization logic */
|
|
145
138
|
private initialize;
|
|
139
|
+
/**
|
|
140
|
+
* Restore subagent sessions associated with the current main session
|
|
141
|
+
* This method is called after the main session is restored to load any subagent sessions
|
|
142
|
+
*/
|
|
143
|
+
private restoreSubagentSessions;
|
|
146
144
|
abortAIMessage(): void;
|
|
147
145
|
/** Execute bash command */
|
|
148
146
|
executeBashCommand(command: string): Promise<void>;
|
|
@@ -180,5 +178,19 @@ export declare class Agent {
|
|
|
180
178
|
getCustomCommand(commandId: string): CustomSlashCommand | undefined;
|
|
181
179
|
/** Get all custom commands */
|
|
182
180
|
getCustomCommands(): CustomSlashCommand[];
|
|
181
|
+
/**
|
|
182
|
+
* Update Agent configuration from live settings.json changes
|
|
183
|
+
* This method refreshes all configuration-dependent components with new values
|
|
184
|
+
* Note: Constructor values still take precedence over live configuration
|
|
185
|
+
*/
|
|
186
|
+
updateConfiguration(): void;
|
|
187
|
+
/**
|
|
188
|
+
* Get current Agent configuration for debugging
|
|
189
|
+
*/
|
|
190
|
+
getCurrentConfiguration(): {
|
|
191
|
+
gatewayConfig: GatewayConfig;
|
|
192
|
+
modelConfig: ModelConfig;
|
|
193
|
+
tokenLimit: number;
|
|
194
|
+
};
|
|
183
195
|
}
|
|
184
196
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceR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M,CAAA;KAAE,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC;IAmFhB,iDAAiD;IACpC,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,GAAG,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;IAqChB,gCAAgC;IACzB,aAAa,IAAI,eAAe,EAAE;IAIzC,yBAAyB;IACZ,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE,4BAA4B;IACf,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtE,uCAAuC;IAChC,gBAAgB,IAAI,YAAY,EAAE;IAIzC,oCAAoC;IAC7B,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIlD,6BAA6B;IACtB,oBAAoB,IAAI,IAAI;IAInC,iCAAiC;IAC1B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI1E,8BAA8B;IACvB,iBAAiB,IAAI,kBAAkB,EAAE;IAMhD;;;;OAIG;IACI,mBAAmB,IAAI,IAAI;IA6DlC;;OAEG;IACI,uBAAuB,IAAI;QAChC,aAAa,EAAE,aAAa,CAAC;QAC7B,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;KACpB;CAOF"}
|
package/dist/agent.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { MessageManager, } from "./managers/messageManager.js";
|
|
2
2
|
import { AIManager } from "./managers/aiManager.js";
|
|
3
3
|
import { ToolManager } from "./managers/toolManager.js";
|
|
4
|
-
import { SubagentManager } from "./managers/subagentManager.js";
|
|
4
|
+
import { SubagentManager, } from "./managers/subagentManager.js";
|
|
5
5
|
import * as memory from "./services/memory.js";
|
|
6
6
|
import { McpManager } from "./managers/mcpManager.js";
|
|
7
7
|
import { BashManager } from "./managers/bashManager.js";
|
|
8
8
|
import { BackgroundBashManager, } from "./managers/backgroundBashManager.js";
|
|
9
9
|
import { SlashCommandManager } from "./managers/slashCommandManager.js";
|
|
10
10
|
import { HookManager } from "./managers/hookManager.js";
|
|
11
|
+
import { MemoryStoreService } from "./services/memoryStore.js";
|
|
12
|
+
import { initializeMemoryStore } from "./services/memory.js";
|
|
13
|
+
import { LiveConfigManager } from "./managers/liveConfigManager.js";
|
|
11
14
|
import { configResolver } from "./utils/configResolver.js";
|
|
12
15
|
import { configValidator } from "./utils/configValidator.js";
|
|
13
16
|
import { SkillManager } from "./managers/skillManager.js";
|
|
17
|
+
import { loadSessionFromJsonl } from "./services/session.js";
|
|
18
|
+
import { setGlobalLogger } from "./utils/globalLogger.js";
|
|
14
19
|
export class Agent {
|
|
15
20
|
/**
|
|
16
21
|
* Agent constructor - handles configuration resolution and validation
|
|
@@ -20,23 +25,31 @@ export class Agent {
|
|
|
20
25
|
* Agent.create() to maintain API consistency.
|
|
21
26
|
*
|
|
22
27
|
* @param options - Configuration options for the Agent instance
|
|
23
|
-
* @param options.sessionDir - Optional custom directory for session storage
|
|
24
28
|
*/
|
|
25
29
|
constructor(options) {
|
|
26
30
|
this.bashManager = null;
|
|
27
31
|
this._usages = []; // Usage tracking array
|
|
28
|
-
const { callbacks = {}, logger, workdir, systemPrompt
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const { callbacks = {}, logger, workdir, systemPrompt } = options;
|
|
33
|
+
// Set working directory first so it can be used for configuration resolution
|
|
34
|
+
this.workdir = workdir || process.cwd();
|
|
35
|
+
// Store original constructor values for live config updates
|
|
36
|
+
this.constructorApiKey = options.apiKey;
|
|
37
|
+
this.constructorBaseURL = options.baseURL;
|
|
38
|
+
this.constructorAgentModel = options.agentModel;
|
|
39
|
+
this.constructorFastModel = options.fastModel;
|
|
40
|
+
this.constructorTokenLimit = options.tokenLimit;
|
|
41
|
+
// Resolve configuration from constructor args and environment variables with live config support
|
|
42
|
+
const gatewayConfig = configResolver.resolveGatewayConfig(options.apiKey, options.baseURL, this.workdir);
|
|
43
|
+
const modelConfig = configResolver.resolveModelConfig(options.agentModel, options.fastModel, this.workdir);
|
|
44
|
+
const tokenLimit = configResolver.resolveTokenLimit(options.tokenLimit, this.workdir);
|
|
33
45
|
// Validate resolved configuration
|
|
34
46
|
configValidator.validateGatewayConfig(gatewayConfig);
|
|
35
47
|
configValidator.validateTokenLimit(tokenLimit);
|
|
36
48
|
configValidator.validateModelConfig(modelConfig.agentModel, modelConfig.fastModel);
|
|
37
49
|
this.logger = logger; // Save the passed logger
|
|
38
|
-
this.workdir = workdir || process.cwd(); // Set working directory, default to current working directory
|
|
39
50
|
this.systemPrompt = systemPrompt; // Save custom system prompt
|
|
51
|
+
// Set global logger for SDK-wide access
|
|
52
|
+
setGlobalLogger(logger || null);
|
|
40
53
|
// Store resolved configuration
|
|
41
54
|
this.gatewayConfig = gatewayConfig;
|
|
42
55
|
this.modelConfig = modelConfig;
|
|
@@ -50,13 +63,47 @@ export class Agent {
|
|
|
50
63
|
mcpManager: this.mcpManager,
|
|
51
64
|
logger: this.logger,
|
|
52
65
|
}); // Initialize tool registry, pass MCP manager
|
|
66
|
+
this.memoryStore = new MemoryStoreService(this.logger); // Initialize memory store service
|
|
67
|
+
initializeMemoryStore(this.memoryStore); // Initialize global memory store reference
|
|
53
68
|
this.hookManager = new HookManager(this.workdir, undefined, this.logger); // Initialize hooks manager
|
|
69
|
+
this.liveConfigManager = new LiveConfigManager({
|
|
70
|
+
workdir: this.workdir,
|
|
71
|
+
logger: this.logger,
|
|
72
|
+
onConfigurationChanged: () => {
|
|
73
|
+
// Update Agent configuration (AIManager, SubagentManager)
|
|
74
|
+
this.updateConfiguration();
|
|
75
|
+
// Reload hook configuration
|
|
76
|
+
try {
|
|
77
|
+
this.hookManager.loadConfigurationFromSettings();
|
|
78
|
+
this.logger?.info("Live Config: Hook configuration reloaded successfully");
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.logger?.error(`Live Config: Failed to reload hook configuration: ${error.message}`);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
onMemoryStoreFileChanged: async (filePath, changeType) => {
|
|
85
|
+
try {
|
|
86
|
+
if (changeType === "unlink") {
|
|
87
|
+
// Handle file deletion gracefully
|
|
88
|
+
this.memoryStore.removeContent(filePath);
|
|
89
|
+
this.logger?.info("Live Config: Removed AGENTS.md from memory store due to file deletion");
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Update memory store content for add/change
|
|
93
|
+
await this.memoryStore.updateContent(filePath);
|
|
94
|
+
this.logger?.info("Live Config: Updated AGENTS.md content in memory store");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.logger?.error(`Live Config: Failed to update memory store: ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}); // Initialize live configuration manager
|
|
54
102
|
// Initialize MessageManager
|
|
55
103
|
this.messageManager = new MessageManager({
|
|
56
104
|
callbacks,
|
|
57
105
|
workdir: this.workdir,
|
|
58
106
|
logger: this.logger,
|
|
59
|
-
sessionDir,
|
|
60
107
|
});
|
|
61
108
|
// Initialize subagent manager with all dependencies in constructor
|
|
62
109
|
// IMPORTANT: Must be initialized AFTER MessageManager
|
|
@@ -64,10 +111,18 @@ export class Agent {
|
|
|
64
111
|
workdir: this.workdir,
|
|
65
112
|
parentToolManager: this.toolManager,
|
|
66
113
|
parentMessageManager: this.messageManager,
|
|
114
|
+
callbacks: {
|
|
115
|
+
onSubagentUserMessageAdded: callbacks.onSubagentUserMessageAdded,
|
|
116
|
+
onSubagentAssistantMessageAdded: callbacks.onSubagentAssistantMessageAdded,
|
|
117
|
+
onSubagentAssistantContentUpdated: callbacks.onSubagentAssistantContentUpdated,
|
|
118
|
+
onSubagentToolBlockUpdated: callbacks.onSubagentToolBlockUpdated,
|
|
119
|
+
onSubagentMessagesChange: callbacks.onSubagentMessagesChange,
|
|
120
|
+
}, // Pass subagent callbacks for forwarding
|
|
67
121
|
logger: this.logger,
|
|
68
122
|
gatewayConfig,
|
|
69
123
|
modelConfig,
|
|
70
124
|
tokenLimit,
|
|
125
|
+
hookManager: this.hookManager,
|
|
71
126
|
onUsageAdded: (usage) => this.addUsage(usage),
|
|
72
127
|
});
|
|
73
128
|
// Initialize AI manager with resolved configuration
|
|
@@ -147,6 +202,10 @@ export class Agent {
|
|
|
147
202
|
get workingDirectory() {
|
|
148
203
|
return this.workdir;
|
|
149
204
|
}
|
|
205
|
+
/** Get merged environment variables from Wave configuration */
|
|
206
|
+
get environmentVars() {
|
|
207
|
+
return this.hookManager.getEnvironmentVars();
|
|
208
|
+
}
|
|
150
209
|
/** Get AI loading status */
|
|
151
210
|
get isLoading() {
|
|
152
211
|
return this.aiManager.isLoading;
|
|
@@ -185,9 +244,6 @@ export class Agent {
|
|
|
185
244
|
* @param options - Configuration options for the Agent instance
|
|
186
245
|
* @param options.apiKey - API key for the AI service (or set WAVE_API_KEY env var)
|
|
187
246
|
* @param options.baseURL - Base URL for the AI service (or set WAVE_BASE_URL env var)
|
|
188
|
-
* @param options.sessionDir - Optional custom directory for session file storage.
|
|
189
|
-
* If not provided, defaults to ~/.wave/sessions/. Can be relative or absolute path.
|
|
190
|
-
* Examples: "./app-sessions", "/var/myapp/sessions", "~/Documents/sessions"
|
|
191
247
|
* @param options.callbacks - Optional callbacks for various Agent events
|
|
192
248
|
* @param options.restoreSessionId - Optional session ID to restore from
|
|
193
249
|
* @param options.continueLastSession - Whether to continue the last session automatically
|
|
@@ -199,18 +255,11 @@ export class Agent {
|
|
|
199
255
|
*
|
|
200
256
|
* @example
|
|
201
257
|
* ```typescript
|
|
202
|
-
* // Basic usage
|
|
258
|
+
* // Basic usage
|
|
203
259
|
* const agent = await Agent.create({
|
|
204
260
|
* apiKey: 'your-api-key',
|
|
205
261
|
* baseURL: 'https://api.example.com'
|
|
206
262
|
* });
|
|
207
|
-
*
|
|
208
|
-
* // Custom session directory
|
|
209
|
-
* const agent = await Agent.create({
|
|
210
|
-
* apiKey: 'your-api-key',
|
|
211
|
-
* baseURL: 'https://api.example.com',
|
|
212
|
-
* sessionDir: './app-sessions'
|
|
213
|
-
* });
|
|
214
263
|
* ```
|
|
215
264
|
*/
|
|
216
265
|
static async create(options) {
|
|
@@ -261,6 +310,16 @@ export class Agent {
|
|
|
261
310
|
this.logger?.error("Failed to initialize hooks system:", error);
|
|
262
311
|
// Don't throw error to prevent app startup failure
|
|
263
312
|
}
|
|
313
|
+
// Initialize live configuration reload
|
|
314
|
+
try {
|
|
315
|
+
this.logger?.debug("Initializing live configuration reload...");
|
|
316
|
+
await this.liveConfigManager.initialize();
|
|
317
|
+
this.logger?.debug("Live configuration reload initialized successfully");
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
this.logger?.error("Failed to initialize live configuration reload:", error);
|
|
321
|
+
// Don't throw error to prevent app startup failure - continue without live reload
|
|
322
|
+
}
|
|
264
323
|
// Handle session restoration or set provided messages
|
|
265
324
|
if (options?.messages) {
|
|
266
325
|
// If messages are provided, use them directly (useful for testing)
|
|
@@ -273,6 +332,67 @@ export class Agent {
|
|
|
273
332
|
await this.messageManager.handleSessionRestoration(options?.restoreSessionId, options?.continueLastSession);
|
|
274
333
|
// Rebuild usage array from restored messages
|
|
275
334
|
this.rebuildUsageFromMessages();
|
|
335
|
+
// After main session is restored, restore any associated subagent sessions
|
|
336
|
+
await this.restoreSubagentSessions();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Restore subagent sessions associated with the current main session
|
|
341
|
+
* This method is called after the main session is restored to load any subagent sessions
|
|
342
|
+
*/
|
|
343
|
+
async restoreSubagentSessions() {
|
|
344
|
+
try {
|
|
345
|
+
// Only attempt to restore subagent sessions if we have messages (session was restored)
|
|
346
|
+
if (this.messages.length === 0) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
// Extract sessionId -> subagentId mapping from SubagentBlocks
|
|
350
|
+
const subagentBlockMap = new Map(); // sessionId -> { subagentId, configuration }
|
|
351
|
+
for (const message of this.messages) {
|
|
352
|
+
if (message.role === "assistant" && message.blocks) {
|
|
353
|
+
for (const block of message.blocks) {
|
|
354
|
+
if (block.type === "subagent" &&
|
|
355
|
+
block.sessionId &&
|
|
356
|
+
block.subagentId &&
|
|
357
|
+
block.configuration) {
|
|
358
|
+
subagentBlockMap.set(block.sessionId, {
|
|
359
|
+
subagentId: block.subagentId,
|
|
360
|
+
configuration: block.configuration,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (subagentBlockMap.size === 0) {
|
|
367
|
+
return; // No subagent blocks found
|
|
368
|
+
}
|
|
369
|
+
// Load subagent sessions using sessionIds
|
|
370
|
+
const subagentSessions = [];
|
|
371
|
+
for (const [sessionId, blockData] of subagentBlockMap) {
|
|
372
|
+
try {
|
|
373
|
+
const sessionData = await loadSessionFromJsonl(sessionId, this.messageManager.getWorkdir());
|
|
374
|
+
if (sessionData) {
|
|
375
|
+
subagentSessions.push({
|
|
376
|
+
sessionData,
|
|
377
|
+
subagentId: blockData.subagentId, // Use the subagentId from SubagentBlock
|
|
378
|
+
configuration: blockData.configuration, // Include configuration
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
this.logger?.warn(`Failed to load subagent session ${sessionId}:`, error);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (subagentSessions.length > 0) {
|
|
387
|
+
this.logger?.debug(`Found ${subagentSessions.length} subagent sessions to restore`);
|
|
388
|
+
// Restore subagent sessions through the SubagentManager
|
|
389
|
+
await this.subagentManager.restoreSubagentSessions(subagentSessions);
|
|
390
|
+
this.logger?.debug("Subagent sessions restored successfully");
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
this.logger?.warn("Failed to restore subagent sessions:", error);
|
|
395
|
+
// Don't throw error to prevent app startup failure
|
|
276
396
|
}
|
|
277
397
|
}
|
|
278
398
|
abortAIMessage() {
|
|
@@ -318,6 +438,21 @@ export class Agent {
|
|
|
318
438
|
await this.mcpManager.cleanup();
|
|
319
439
|
// Cleanup subagent manager
|
|
320
440
|
this.subagentManager.cleanup();
|
|
441
|
+
// Cleanup live configuration reload
|
|
442
|
+
try {
|
|
443
|
+
await this.liveConfigManager.shutdown();
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
this.logger?.error("Error shutting down live configuration reload:", error);
|
|
447
|
+
}
|
|
448
|
+
// Cleanup memory store
|
|
449
|
+
try {
|
|
450
|
+
this.memoryStore.clear();
|
|
451
|
+
this.logger?.debug("Memory store cleared successfully");
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
this.logger?.error("Error clearing memory store:", error);
|
|
455
|
+
}
|
|
321
456
|
}
|
|
322
457
|
async sendMessage(content, images) {
|
|
323
458
|
try {
|
|
@@ -439,4 +574,51 @@ export class Agent {
|
|
|
439
574
|
getCustomCommands() {
|
|
440
575
|
return this.slashCommandManager.getCustomCommands();
|
|
441
576
|
}
|
|
577
|
+
// ========== Live Configuration Management ==========
|
|
578
|
+
/**
|
|
579
|
+
* Update Agent configuration from live settings.json changes
|
|
580
|
+
* This method refreshes all configuration-dependent components with new values
|
|
581
|
+
* Note: Constructor values still take precedence over live configuration
|
|
582
|
+
*/
|
|
583
|
+
updateConfiguration() {
|
|
584
|
+
try {
|
|
585
|
+
this.logger?.info("Live Config: Updating Agent configuration from live settings");
|
|
586
|
+
// Re-resolve configuration with current workdir, preserving constructor overrides
|
|
587
|
+
// We need to track what was explicitly provided in constructor vs. what should use live config
|
|
588
|
+
const newGatewayConfig = configResolver.resolveGatewayConfig(this.constructorApiKey, // Preserve constructor override if provided
|
|
589
|
+
this.constructorBaseURL, // Preserve constructor override if provided
|
|
590
|
+
this.workdir);
|
|
591
|
+
const newModelConfig = configResolver.resolveModelConfig(this.constructorAgentModel, // Preserve constructor override if provided
|
|
592
|
+
this.constructorFastModel, // Preserve constructor override if provided
|
|
593
|
+
this.workdir);
|
|
594
|
+
const newTokenLimit = configResolver.resolveTokenLimit(this.constructorTokenLimit, this.workdir);
|
|
595
|
+
// Validate new configuration
|
|
596
|
+
configValidator.validateGatewayConfig(newGatewayConfig);
|
|
597
|
+
configValidator.validateTokenLimit(newTokenLimit);
|
|
598
|
+
configValidator.validateModelConfig(newModelConfig.agentModel, newModelConfig.fastModel);
|
|
599
|
+
// Update stored configuration
|
|
600
|
+
this.gatewayConfig = newGatewayConfig;
|
|
601
|
+
this.modelConfig = newModelConfig;
|
|
602
|
+
this.tokenLimit = newTokenLimit;
|
|
603
|
+
// Update AIManager with new configuration
|
|
604
|
+
this.aiManager.updateConfiguration(newGatewayConfig, newModelConfig, newTokenLimit);
|
|
605
|
+
// Update SubagentManager with new configuration
|
|
606
|
+
this.subagentManager.updateConfiguration(newGatewayConfig, newModelConfig, newTokenLimit);
|
|
607
|
+
this.logger?.info(`Live Config: Agent configuration updated successfully - model: ${newModelConfig.agentModel}, tokenLimit: ${newTokenLimit}`);
|
|
608
|
+
}
|
|
609
|
+
catch (error) {
|
|
610
|
+
this.logger?.error(`Live Config: Failed to update Agent configuration: ${error.message}`);
|
|
611
|
+
// Don't throw - continue with previous configuration
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Get current Agent configuration for debugging
|
|
616
|
+
*/
|
|
617
|
+
getCurrentConfiguration() {
|
|
618
|
+
return {
|
|
619
|
+
gatewayConfig: { ...this.gatewayConfig },
|
|
620
|
+
modelConfig: { ...this.modelConfig },
|
|
621
|
+
tokenLimit: this.tokenLimit,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
442
624
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export declare const CONFIGURATION_EVENTS: {
|
|
11
|
+
readonly CONFIGURATION_CHANGE: "configurationChange";
|
|
12
|
+
readonly WATCHER_ERROR: "watcherError";
|
|
13
|
+
};
|
|
14
|
+
export declare const FILE_WATCHER_EVENTS: {
|
|
15
|
+
readonly CHANGE: "change";
|
|
16
|
+
readonly CREATE: "create";
|
|
17
|
+
readonly DELETE: "delete";
|
|
18
|
+
readonly RENAME: "rename";
|
|
19
|
+
};
|
|
20
|
+
export declare const MEMORY_STORE_EVENTS: {
|
|
21
|
+
readonly FILE_ADDED: "fileAdded";
|
|
22
|
+
readonly FILE_CHANGED: "fileChanged";
|
|
23
|
+
readonly FILE_REMOVED: "fileRemoved";
|
|
24
|
+
};
|
|
25
|
+
export type ConfigurationEventName = (typeof CONFIGURATION_EVENTS)[keyof typeof CONFIGURATION_EVENTS];
|
|
26
|
+
export type FileWatcherEventName = (typeof FILE_WATCHER_EVENTS)[keyof typeof FILE_WATCHER_EVENTS];
|
|
27
|
+
export type MemoryStoreEventName = (typeof MEMORY_STORE_EVENTS)[keyof typeof MEMORY_STORE_EVENTS];
|
|
28
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/constants/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAGX,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAGX,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAGX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AACnE,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AACjE,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
// Configuration Watcher Events
|
|
11
|
+
export const CONFIGURATION_EVENTS = {
|
|
12
|
+
CONFIGURATION_CHANGE: "configurationChange",
|
|
13
|
+
WATCHER_ERROR: "watcherError",
|
|
14
|
+
};
|
|
15
|
+
// File Watcher Events
|
|
16
|
+
export const FILE_WATCHER_EVENTS = {
|
|
17
|
+
CHANGE: "change",
|
|
18
|
+
CREATE: "create",
|
|
19
|
+
DELETE: "delete",
|
|
20
|
+
RENAME: "rename",
|
|
21
|
+
};
|
|
22
|
+
// Memory Store Events
|
|
23
|
+
export const MEMORY_STORE_EVENTS = {
|
|
24
|
+
FILE_ADDED: "fileAdded",
|
|
25
|
+
FILE_CHANGED: "fileChanged",
|
|
26
|
+
FILE_REMOVED: "fileRemoved",
|
|
27
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ export * from "./services/aiService.js";
|
|
|
2
2
|
export * from "./services/memory.js";
|
|
3
3
|
export * from "./services/session.js";
|
|
4
4
|
export * from "./services/hook.js";
|
|
5
|
+
export * from "./services/jsonlHandler.js";
|
|
5
6
|
export * from "./agent.js";
|
|
6
7
|
export * from "./utils/bashHistory.js";
|
|
7
8
|
export * from "./utils/convertMessagesForAPI.js";
|
|
8
9
|
export * from "./utils/fileFilter.js";
|
|
10
|
+
export * from "./utils/globalLogger.js";
|
|
9
11
|
export * from "./utils/mcpUtils.js";
|
|
10
12
|
export * from "./utils/messageOperations.js";
|
|
11
13
|
export * from "./utils/path.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,YAAY,CAAC;AAG3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,14 @@ export * from "./services/aiService.js";
|
|
|
3
3
|
export * from "./services/memory.js";
|
|
4
4
|
export * from "./services/session.js";
|
|
5
5
|
export * from "./services/hook.js";
|
|
6
|
+
export * from "./services/jsonlHandler.js";
|
|
6
7
|
// Export main agent
|
|
7
8
|
export * from "./agent.js";
|
|
8
9
|
// Export all utilities
|
|
9
10
|
export * from "./utils/bashHistory.js";
|
|
10
11
|
export * from "./utils/convertMessagesForAPI.js";
|
|
11
12
|
export * from "./utils/fileFilter.js";
|
|
13
|
+
export * from "./utils/globalLogger.js";
|
|
12
14
|
export * from "./utils/mcpUtils.js";
|
|
13
15
|
export * from "./utils/messageOperations.js";
|
|
14
16
|
export * from "./utils/path.js";
|
|
@@ -16,6 +16,7 @@ export interface AIManagerOptions {
|
|
|
16
16
|
callbacks?: AIManagerCallbacks;
|
|
17
17
|
workdir: string;
|
|
18
18
|
systemPrompt?: string;
|
|
19
|
+
subagentType?: string;
|
|
19
20
|
gatewayConfig: GatewayConfig;
|
|
20
21
|
modelConfig: ModelConfig;
|
|
21
22
|
tokenLimit: number;
|
|
@@ -31,12 +32,43 @@ export declare class AIManager {
|
|
|
31
32
|
private hookManager?;
|
|
32
33
|
private workdir;
|
|
33
34
|
private systemPrompt?;
|
|
35
|
+
private subagentType?;
|
|
34
36
|
private gatewayConfig;
|
|
35
37
|
private modelConfig;
|
|
36
38
|
private tokenLimit;
|
|
37
39
|
constructor(options: AIManagerOptions);
|
|
38
40
|
private isCompressing;
|
|
39
41
|
private callbacks;
|
|
42
|
+
/**
|
|
43
|
+
* Update gateway configuration at runtime for live config reload
|
|
44
|
+
* @param newConfig - New gateway configuration
|
|
45
|
+
*/
|
|
46
|
+
updateGatewayConfig(newConfig: GatewayConfig): void;
|
|
47
|
+
/**
|
|
48
|
+
* Update model configuration at runtime for live config reload
|
|
49
|
+
* @param newConfig - New model configuration
|
|
50
|
+
*/
|
|
51
|
+
updateModelConfig(newConfig: ModelConfig): void;
|
|
52
|
+
/**
|
|
53
|
+
* Update token limit at runtime for live config reload
|
|
54
|
+
* @param newLimit - New token limit
|
|
55
|
+
*/
|
|
56
|
+
updateTokenLimit(newLimit: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Update all configurations at once for live config reload
|
|
59
|
+
* @param newGatewayConfig - New gateway configuration
|
|
60
|
+
* @param newModelConfig - New model configuration
|
|
61
|
+
* @param newTokenLimit - New token limit
|
|
62
|
+
*/
|
|
63
|
+
updateConfiguration(newGatewayConfig: GatewayConfig, newModelConfig: ModelConfig, newTokenLimit: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Get current configuration for debugging
|
|
66
|
+
*/
|
|
67
|
+
getCurrentConfiguration(): {
|
|
68
|
+
gatewayConfig: GatewayConfig;
|
|
69
|
+
modelConfig: ModelConfig;
|
|
70
|
+
tokenLimit: number;
|
|
71
|
+
};
|
|
40
72
|
/**
|
|
41
73
|
* Get filtered tool configuration
|
|
42
74
|
*/
|
|
@@ -53,7 +85,8 @@ export declare class AIManager {
|
|
|
53
85
|
allowedTools?: string[];
|
|
54
86
|
}): Promise<void>;
|
|
55
87
|
/**
|
|
56
|
-
* Execute Stop hooks when AI response cycle completes
|
|
88
|
+
* Execute Stop or SubagentStop hooks when AI response cycle completes
|
|
89
|
+
* Uses "SubagentStop" hook name when triggered by a subagent, otherwise uses "Stop"
|
|
57
90
|
* @returns Promise<boolean> - true if should continue conversation, false if should stop
|
|
58
91
|
*/
|
|
59
92
|
private executeStopHooks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,WAAW,EACX,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,WAAW,kBAAkB;IACjC,wBAAwB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KA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