wave-agent-sdk 0.0.14 → 0.0.16
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 +11 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +71 -11
- package/dist/constants/prompts.d.ts +14 -0
- package/dist/constants/prompts.d.ts.map +1 -0
- package/dist/constants/prompts.js +61 -0
- package/dist/constants/tools.d.ts +18 -0
- package/dist/constants/tools.d.ts.map +1 -0
- package/dist/constants/tools.js +17 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/managers/aiManager.d.ts +8 -2
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +52 -16
- package/dist/managers/hookManager.d.ts +7 -2
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +10 -0
- package/dist/managers/liveConfigManager.d.ts +1 -1
- package/dist/managers/liveConfigManager.d.ts.map +1 -1
- package/dist/managers/liveConfigManager.js +43 -22
- package/dist/managers/permissionManager.d.ts +50 -1
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +289 -58
- package/dist/managers/planManager.d.ts +21 -0
- package/dist/managers/planManager.d.ts.map +1 -0
- package/dist/managers/planManager.js +35 -0
- package/dist/managers/pluginManager.d.ts +57 -0
- package/dist/managers/pluginManager.d.ts.map +1 -0
- package/dist/managers/pluginManager.js +124 -0
- package/dist/managers/pluginScopeManager.d.ts +35 -0
- package/dist/managers/pluginScopeManager.d.ts.map +1 -0
- package/dist/managers/pluginScopeManager.js +39 -0
- package/dist/managers/skillManager.d.ts +4 -0
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +15 -0
- package/dist/managers/slashCommandManager.d.ts +4 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +45 -3
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +3 -1
- package/dist/managers/toolManager.d.ts +4 -0
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +24 -1
- package/dist/services/GitService.d.ts +16 -0
- package/dist/services/GitService.d.ts.map +1 -0
- package/dist/services/GitService.js +75 -0
- package/dist/services/MarketplaceService.d.ts +62 -0
- package/dist/services/MarketplaceService.d.ts.map +1 -0
- package/dist/services/MarketplaceService.js +320 -0
- package/dist/services/aiService.d.ts +1 -0
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +11 -11
- package/dist/services/configurationService.d.ts +11 -4
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +211 -67
- package/dist/services/fileWatcher.js +3 -3
- package/dist/services/hook.js +1 -1
- package/dist/services/pluginLoader.d.ts +35 -0
- package/dist/services/pluginLoader.d.ts.map +1 -0
- package/dist/services/pluginLoader.js +149 -0
- package/dist/tools/askUserQuestion.d.ts +3 -0
- package/dist/tools/askUserQuestion.d.ts.map +1 -0
- package/dist/tools/askUserQuestion.js +109 -0
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +37 -40
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +17 -19
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +29 -36
- package/dist/tools/exitPlanMode.d.ts +6 -0
- package/dist/tools/exitPlanMode.d.ts.map +1 -0
- package/dist/tools/exitPlanMode.js +76 -0
- package/dist/tools/globTool.d.ts.map +1 -1
- package/dist/tools/globTool.js +4 -3
- package/dist/tools/grepTool.d.ts.map +1 -1
- package/dist/tools/grepTool.js +5 -4
- package/dist/tools/lsTool.d.ts.map +1 -1
- package/dist/tools/lsTool.js +16 -3
- package/dist/tools/lspTool.d.ts.map +1 -1
- package/dist/tools/lspTool.js +3 -2
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +24 -31
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +16 -3
- package/dist/tools/skillTool.d.ts.map +1 -1
- package/dist/tools/skillTool.js +30 -27
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +36 -31
- package/dist/tools/todoWriteTool.d.ts.map +1 -1
- package/dist/tools/todoWriteTool.js +3 -2
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +13 -17
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +36 -1
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +2 -15
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/marketplace.d.ts +43 -0
- package/dist/types/marketplace.d.ts.map +1 -0
- package/dist/types/marketplace.js +1 -0
- package/dist/types/permissions.d.ts +4 -2
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/permissions.js +8 -5
- package/dist/types/plugins.d.ts +35 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/plugins.js +1 -0
- package/dist/types/tools.d.ts +17 -0
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/bashHistory.d.ts +3 -3
- package/dist/utils/bashHistory.d.ts.map +1 -1
- package/dist/utils/bashHistory.js +10 -8
- package/dist/utils/bashParser.d.ts.map +1 -1
- package/dist/utils/bashParser.js +63 -20
- package/dist/utils/configPaths.d.ts +4 -0
- package/dist/utils/configPaths.d.ts.map +1 -1
- package/dist/utils/configPaths.js +6 -0
- package/dist/utils/constants.d.ts +4 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +4 -0
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +4 -2
- package/dist/utils/customCommands.d.ts +6 -0
- package/dist/utils/customCommands.d.ts.map +1 -1
- package/dist/utils/customCommands.js +1 -1
- package/dist/utils/editUtils.d.ts +17 -0
- package/dist/utils/editUtils.d.ts.map +1 -0
- package/dist/utils/editUtils.js +69 -0
- package/dist/utils/markdownParser.d.ts.map +1 -1
- package/dist/utils/markdownParser.js +25 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +2 -1
- package/dist/utils/nameGenerator.d.ts +8 -0
- package/dist/utils/nameGenerator.d.ts.map +1 -0
- package/dist/utils/nameGenerator.js +75 -0
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +19 -9
- package/dist/utils/pathSafety.d.ts.map +1 -1
- package/dist/utils/pathSafety.js +17 -2
- package/package.json +1 -1
- package/src/agent.ts +95 -10
- package/src/constants/prompts.ts +93 -0
- package/src/constants/tools.ts +17 -0
- package/src/index.ts +8 -0
- package/src/managers/aiManager.ts +86 -18
- package/src/managers/hookManager.ts +23 -6
- package/src/managers/liveConfigManager.ts +56 -29
- package/src/managers/permissionManager.ts +361 -61
- package/src/managers/planManager.ts +45 -0
- package/src/managers/pluginManager.ts +182 -0
- package/src/managers/pluginScopeManager.ts +75 -0
- package/src/managers/skillManager.ts +18 -0
- package/src/managers/slashCommandManager.ts +67 -5
- package/src/managers/subagentManager.ts +3 -1
- package/src/managers/toolManager.ts +25 -3
- package/src/services/GitService.ts +97 -0
- package/src/services/MarketplaceService.ts +428 -0
- package/src/services/aiService.ts +33 -16
- package/src/services/configurationService.ts +244 -86
- package/src/services/fileWatcher.ts +3 -3
- package/src/services/hook.ts +1 -1
- package/src/services/pluginLoader.ts +181 -0
- package/src/tools/askUserQuestion.ts +128 -0
- package/src/tools/bashTool.ts +52 -49
- package/src/tools/deleteFileTool.ts +22 -28
- package/src/tools/editTool.ts +42 -48
- package/src/tools/exitPlanMode.ts +93 -0
- package/src/tools/globTool.ts +4 -4
- package/src/tools/grepTool.ts +9 -5
- package/src/tools/lsTool.ts +27 -4
- package/src/tools/lspTool.ts +3 -2
- package/src/tools/multiEditTool.ts +40 -42
- package/src/tools/readTool.ts +23 -4
- package/src/tools/skillTool.ts +35 -30
- package/src/tools/taskTool.ts +39 -33
- package/src/tools/todoWriteTool.ts +3 -2
- package/src/tools/writeTool.ts +19 -27
- package/src/types/commands.ts +1 -0
- package/src/types/config.ts +2 -0
- package/src/types/configuration.ts +42 -1
- package/src/types/hooks.ts +8 -25
- package/src/types/index.ts +3 -0
- package/src/types/marketplace.ts +52 -0
- package/src/types/permissions.ts +29 -6
- package/src/types/plugins.ts +37 -0
- package/src/types/tools.ts +20 -0
- package/src/utils/bashHistory.ts +9 -16
- package/src/utils/bashParser.ts +97 -46
- package/src/utils/configPaths.ts +7 -0
- package/src/utils/constants.ts +5 -0
- package/src/utils/convertMessagesForAPI.ts +4 -2
- package/src/utils/customCommands.ts +1 -1
- package/src/utils/editUtils.ts +82 -0
- package/src/utils/markdownParser.ts +28 -1
- package/src/utils/messageOperations.ts +2 -1
- package/src/utils/nameGenerator.ts +78 -0
- package/src/utils/openaiClient.ts +29 -15
- package/src/utils/pathSafety.ts +16 -2
package/dist/agent.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type MessageManagerCallbacks } from "./managers/messageManager.js";
|
|
|
2
2
|
import { type SubagentManagerCallbacks } from "./managers/subagentManager.js";
|
|
3
3
|
import { type McpManagerCallbacks } from "./managers/mcpManager.js";
|
|
4
4
|
import { type BackgroundBashManagerCallbacks } from "./managers/backgroundBashManager.js";
|
|
5
|
-
import type { SlashCommand, CustomSlashCommand, ILspManager } from "./types/index.js";
|
|
5
|
+
import type { SlashCommand, CustomSlashCommand, ILspManager, PluginConfig } from "./types/index.js";
|
|
6
6
|
import type { Message, Logger, McpServerStatus, GatewayConfig, ModelConfig, Usage, PermissionMode, PermissionCallback } from "./types/index.js";
|
|
7
7
|
import { ClientOptions } from "openai";
|
|
8
8
|
/**
|
|
@@ -39,6 +39,8 @@ export interface AgentOptions {
|
|
|
39
39
|
stream?: boolean;
|
|
40
40
|
/**Optional custom LSP manager - if not provided, a standalone one will be created */
|
|
41
41
|
lspManager?: ILspManager;
|
|
42
|
+
/**Optional local plugins to load */
|
|
43
|
+
plugins?: PluginConfig[];
|
|
42
44
|
}
|
|
43
45
|
export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundBashManagerCallbacks, McpManagerCallbacks, SubagentManagerCallbacks {
|
|
44
46
|
onPermissionModeChange?: (mode: PermissionMode) => void;
|
|
@@ -53,8 +55,11 @@ export declare class Agent {
|
|
|
53
55
|
private mcpManager;
|
|
54
56
|
private lspManager;
|
|
55
57
|
private permissionManager;
|
|
58
|
+
private planManager;
|
|
56
59
|
private subagentManager;
|
|
57
60
|
private slashCommandManager;
|
|
61
|
+
private pluginManager;
|
|
62
|
+
private skillManager;
|
|
58
63
|
private hookManager;
|
|
59
64
|
private liveConfigManager;
|
|
60
65
|
private configurationService;
|
|
@@ -258,6 +263,11 @@ export declare class Agent {
|
|
|
258
263
|
* @param mode - The new permission mode
|
|
259
264
|
*/
|
|
260
265
|
setPermissionMode(mode: PermissionMode): void;
|
|
266
|
+
/**
|
|
267
|
+
* Handle plan mode transition, generating or clearing plan file path
|
|
268
|
+
* @param mode - The current effective permission mode
|
|
269
|
+
*/
|
|
270
|
+
private handlePlanModeTransition;
|
|
261
271
|
/**
|
|
262
272
|
* Add a persistent permission rule
|
|
263
273
|
* @param rule - The rule to add (e.g., "Bash(ls)")
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAc,KAAK,m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f,IAAI,EAAE,SAAS,GAAG,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;IA+ChB,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;IAIhD;;OAEG;IACI,iBAAiB,IAAI,cAAc;IAI1C;;;OAGG;IACI,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IASpD;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;YACW,iBAAiB;CAiChC"}
|
package/dist/agent.js
CHANGED
|
@@ -8,7 +8,9 @@ import { LspManager } from "./managers/lspManager.js";
|
|
|
8
8
|
import { BashManager } from "./managers/bashManager.js";
|
|
9
9
|
import { BackgroundBashManager, } from "./managers/backgroundBashManager.js";
|
|
10
10
|
import { SlashCommandManager } from "./managers/slashCommandManager.js";
|
|
11
|
+
import { PluginManager } from "./managers/pluginManager.js";
|
|
11
12
|
import { PermissionManager } from "./managers/permissionManager.js";
|
|
13
|
+
import { PlanManager } from "./managers/planManager.js";
|
|
12
14
|
import { HookManager } from "./managers/hookManager.js";
|
|
13
15
|
import { LiveConfigManager } from "./managers/liveConfigManager.js";
|
|
14
16
|
import { configValidator } from "./utils/configValidator.js";
|
|
@@ -25,7 +27,7 @@ export class Agent {
|
|
|
25
27
|
return this.configurationService.resolveGatewayConfig(this.options.apiKey, this.options.baseURL, this.options.defaultHeaders, this.options.fetchOptions, this.options.fetch);
|
|
26
28
|
}
|
|
27
29
|
getModelConfig() {
|
|
28
|
-
return this.configurationService.resolveModelConfig(this.options.agentModel, this.options.fastModel, this.options.maxTokens);
|
|
30
|
+
return this.configurationService.resolveModelConfig(this.options.agentModel, this.options.fastModel, this.options.maxTokens, this.getPermissionMode());
|
|
29
31
|
}
|
|
30
32
|
getMaxInputTokens() {
|
|
31
33
|
return this.configurationService.resolveMaxInputTokens(this.options.maxInputTokens);
|
|
@@ -93,12 +95,23 @@ export class Agent {
|
|
|
93
95
|
this.lspManager =
|
|
94
96
|
options.lspManager || new LspManager({ logger: this.logger }); // Initialize LSP manager
|
|
95
97
|
// Initialize permission manager
|
|
96
|
-
this.permissionManager = new PermissionManager({
|
|
98
|
+
this.permissionManager = new PermissionManager({
|
|
99
|
+
logger: this.logger,
|
|
100
|
+
workdir: this.workdir,
|
|
101
|
+
});
|
|
97
102
|
this.permissionManager.setOnConfiguredDefaultModeChange((mode) => {
|
|
103
|
+
this.handlePlanModeTransition(mode);
|
|
98
104
|
this.options.callbacks?.onPermissionModeChange?.(mode);
|
|
99
105
|
});
|
|
106
|
+
// Initialize plan manager
|
|
107
|
+
this.planManager = new PlanManager(this.logger);
|
|
100
108
|
// Initialize configuration service and hooks manager
|
|
101
109
|
this.hookManager = new HookManager(this.workdir, undefined, this.logger); // Initialize hooks manager
|
|
110
|
+
// Initialize skill manager
|
|
111
|
+
this.skillManager = new SkillManager({
|
|
112
|
+
logger: this.logger,
|
|
113
|
+
workdir: this.workdir,
|
|
114
|
+
});
|
|
102
115
|
// Initialize MessageManager
|
|
103
116
|
this.messageManager = new MessageManager({
|
|
104
117
|
callbacks,
|
|
@@ -186,6 +199,7 @@ export class Agent {
|
|
|
186
199
|
logger: this.logger,
|
|
187
200
|
backgroundBashManager: this.backgroundBashManager,
|
|
188
201
|
hookManager: this.hookManager,
|
|
202
|
+
permissionManager: this.permissionManager,
|
|
189
203
|
callbacks: {
|
|
190
204
|
...callbacks,
|
|
191
205
|
onUsageAdded: (usage) => {
|
|
@@ -207,11 +221,26 @@ export class Agent {
|
|
|
207
221
|
workdir: this.workdir,
|
|
208
222
|
logger: this.logger,
|
|
209
223
|
});
|
|
224
|
+
// Initialize plugin manager
|
|
225
|
+
this.pluginManager = new PluginManager({
|
|
226
|
+
workdir: this.workdir,
|
|
227
|
+
logger: this.logger,
|
|
228
|
+
slashCommandManager: this.slashCommandManager,
|
|
229
|
+
mcpManager: this.mcpManager,
|
|
230
|
+
lspManager: this.lspManager instanceof LspManager ? this.lspManager : undefined,
|
|
231
|
+
hookManager: this.hookManager,
|
|
232
|
+
skillManager: this.skillManager,
|
|
233
|
+
configurationService: this.configurationService,
|
|
234
|
+
});
|
|
210
235
|
// Initialize bash manager
|
|
211
236
|
this.bashManager = new BashManager({
|
|
212
237
|
messageManager: this.messageManager,
|
|
213
238
|
workdir: this.workdir,
|
|
214
239
|
});
|
|
240
|
+
// Set initial permission mode if provided
|
|
241
|
+
if (options.permissionMode) {
|
|
242
|
+
this.setPermissionMode(options.permissionMode);
|
|
243
|
+
}
|
|
215
244
|
}
|
|
216
245
|
// Public getter methods
|
|
217
246
|
get sessionId() {
|
|
@@ -370,18 +399,16 @@ export class Agent {
|
|
|
370
399
|
// Initialize managers first
|
|
371
400
|
try {
|
|
372
401
|
// Initialize SkillManager
|
|
373
|
-
|
|
374
|
-
logger: this.logger,
|
|
375
|
-
workdir: this.workdir,
|
|
376
|
-
});
|
|
377
|
-
await skillManager.initialize();
|
|
402
|
+
await this.skillManager.initialize();
|
|
378
403
|
// Initialize SubagentManager (load and cache configurations)
|
|
379
404
|
await this.subagentManager.initialize();
|
|
380
405
|
// Initialize built-in tools with dependencies
|
|
381
406
|
this.toolManager.initializeBuiltInTools({
|
|
382
407
|
subagentManager: this.subagentManager,
|
|
383
|
-
skillManager: skillManager,
|
|
408
|
+
skillManager: this.skillManager,
|
|
384
409
|
});
|
|
410
|
+
// Initialize plugins
|
|
411
|
+
await this.pluginManager.loadPlugins(this.options.plugins || []);
|
|
385
412
|
}
|
|
386
413
|
catch (error) {
|
|
387
414
|
this.logger?.error("Failed to initialize managers and tools:", error);
|
|
@@ -404,6 +431,10 @@ export class Agent {
|
|
|
404
431
|
this.logger?.debug("Loading hooks configuration...");
|
|
405
432
|
const configResult = await this.configurationService.loadMergedConfiguration(this.workdir);
|
|
406
433
|
this.hookManager.loadConfigurationFromWaveConfig(configResult.configuration);
|
|
434
|
+
// Update plugin manager with enabled plugins configuration
|
|
435
|
+
if (configResult.configuration?.enabledPlugins) {
|
|
436
|
+
this.pluginManager.updateEnabledPlugins(configResult.configuration.enabledPlugins);
|
|
437
|
+
}
|
|
407
438
|
this.logger?.debug("Hooks system initialized successfully");
|
|
408
439
|
}
|
|
409
440
|
catch (error) {
|
|
@@ -421,11 +452,11 @@ export class Agent {
|
|
|
421
452
|
this.logger?.debug("Live configuration reload initialized successfully");
|
|
422
453
|
// Update permission manager with configuration-based defaultMode
|
|
423
454
|
const currentConfig = this.liveConfigManager.getCurrentConfiguration();
|
|
424
|
-
if (currentConfig?.defaultMode) {
|
|
455
|
+
if (currentConfig?.permissions?.defaultMode) {
|
|
425
456
|
this.logger?.debug("Applying configured defaultMode to PermissionManager", {
|
|
426
|
-
defaultMode: currentConfig.defaultMode,
|
|
457
|
+
defaultMode: currentConfig.permissions.defaultMode,
|
|
427
458
|
});
|
|
428
|
-
this.permissionManager.updateConfiguredDefaultMode(currentConfig.defaultMode);
|
|
459
|
+
this.permissionManager.updateConfiguredDefaultMode(currentConfig.permissions.defaultMode);
|
|
429
460
|
}
|
|
430
461
|
// Update permission manager with configuration-based allowed rules
|
|
431
462
|
if (currentConfig?.permissions?.allow) {
|
|
@@ -434,6 +465,13 @@ export class Agent {
|
|
|
434
465
|
});
|
|
435
466
|
this.permissionManager.updateAllowedRules(currentConfig.permissions.allow);
|
|
436
467
|
}
|
|
468
|
+
// Update permission manager with configuration-based additionalDirectories
|
|
469
|
+
if (currentConfig?.permissions?.additionalDirectories) {
|
|
470
|
+
this.logger?.debug("Applying configured additionalDirectories to PermissionManager", {
|
|
471
|
+
count: currentConfig.permissions.additionalDirectories.length,
|
|
472
|
+
});
|
|
473
|
+
this.permissionManager.updateAdditionalDirectories(currentConfig.permissions.additionalDirectories);
|
|
474
|
+
}
|
|
437
475
|
}
|
|
438
476
|
catch (error) {
|
|
439
477
|
this.logger?.error("Failed to initialize live configuration reload:", error);
|
|
@@ -803,9 +841,31 @@ export class Agent {
|
|
|
803
841
|
* @param mode - The new permission mode
|
|
804
842
|
*/
|
|
805
843
|
setPermissionMode(mode) {
|
|
844
|
+
this.logger?.debug("Setting permission mode", { mode });
|
|
806
845
|
this.toolManager.setPermissionMode(mode);
|
|
846
|
+
this.handlePlanModeTransition(mode);
|
|
807
847
|
this.options.callbacks?.onPermissionModeChange?.(mode);
|
|
808
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Handle plan mode transition, generating or clearing plan file path
|
|
851
|
+
* @param mode - The current effective permission mode
|
|
852
|
+
*/
|
|
853
|
+
handlePlanModeTransition(mode) {
|
|
854
|
+
if (mode === "plan") {
|
|
855
|
+
this.planManager
|
|
856
|
+
.getOrGeneratePlanFilePath()
|
|
857
|
+
.then(({ path }) => {
|
|
858
|
+
this.logger?.debug("Plan file path generated", { path });
|
|
859
|
+
this.permissionManager.setPlanFilePath(path);
|
|
860
|
+
})
|
|
861
|
+
.catch((error) => {
|
|
862
|
+
this.logger?.error("Failed to generate plan file path", error);
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
this.permissionManager.setPlanFilePath(undefined);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
809
869
|
/**
|
|
810
870
|
* Add a persistent permission rule
|
|
811
871
|
* @param rule - The rule to add (e.g., "Bash(ls)")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
2
|
+
export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
|
|
3
|
+
export declare const ASK_USER_POLICY = "\n# Asking questions as you work\nYou have access to the AskUserQuestion tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about. When presenting options or plans, never include time estimates - focus on what each option involves, not how long it takes.";
|
|
4
|
+
export declare const SUBAGENT_POLICY = "\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.\n- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.";
|
|
5
|
+
export declare const FILE_TOOL_POLICY = "\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit/MultiEdit for editing instead of sed/awk, Write for creating files instead of cat with heredoc or echo redirection, and LS/Glob/Grep for searching and listing files instead of find/ls/grep.";
|
|
6
|
+
export declare const BASH_POLICY = "\n- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.";
|
|
7
|
+
export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
8
|
+
export declare function buildSystemPrompt(basePrompt: string, tools: {
|
|
9
|
+
name?: string;
|
|
10
|
+
function?: {
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
}[]): string;
|
|
14
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/constants/prompts.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,ksFAe8G,CAAC;AAE9I,eAAO,MAAM,sBAAsB,+lBAImH,CAAC;AAEvJ,eAAO,MAAM,eAAe,mVAEgS,CAAC;AAE7T,eAAO,MAAM,eAAe,meAG0P,CAAC;AAEvR,eAAO,MAAM,gBAAgB,+YACwc,CAAC;AAEte,eAAO,MAAM,WAAW,sjBAE4O,CAAC;AAErQ,eAAO,MAAM,qBAAqB,ksFAAqB,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAAE,GACtD,MAAM,CAkCR"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, LS_TOOL_NAME, MULTI_EDIT_TOOL_NAME, READ_TOOL_NAME, TASK_TOOL_NAME, TODO_WRITE_TOOL_NAME, WRITE_TOOL_NAME, } from "./tools.js";
|
|
2
|
+
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
3
|
+
|
|
4
|
+
# Doing tasks
|
|
5
|
+
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
6
|
+
- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.
|
|
7
|
+
- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.
|
|
8
|
+
- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.
|
|
9
|
+
- Don't add features, refactor code, or make "improvements" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.
|
|
10
|
+
- Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.
|
|
11
|
+
- Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task—three similar lines of code is better than a premature abstraction.
|
|
12
|
+
- Avoid backwards-compatibility hacks like renaming unused \`_vars\`, re-exporting types, adding \`// removed\` comments for removed code, etc. If something is unused, delete it completely.
|
|
13
|
+
|
|
14
|
+
# Tool usage policy
|
|
15
|
+
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
16
|
+
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
17
|
+
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
18
|
+
export const TASK_MANAGEMENT_POLICY = `
|
|
19
|
+
# Task Management
|
|
20
|
+
You have access to the ${TODO_WRITE_TOOL_NAME} tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
21
|
+
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
22
|
+
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.`;
|
|
23
|
+
export const ASK_USER_POLICY = `
|
|
24
|
+
# Asking questions as you work
|
|
25
|
+
You have access to the ${ASK_USER_QUESTION_TOOL_NAME} tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about. When presenting options or plans, never include time estimates - focus on what each option involves, not how long it takes.`;
|
|
26
|
+
export const SUBAGENT_POLICY = `
|
|
27
|
+
- When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
|
|
28
|
+
- You should proactively use the ${TASK_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
|
|
29
|
+
- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${TASK_TOOL_NAME} tool with subagent_type=Explore instead of running search commands directly.`;
|
|
30
|
+
export const FILE_TOOL_POLICY = `
|
|
31
|
+
- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: ${READ_TOOL_NAME} for reading files instead of cat/head/tail, ${EDIT_TOOL_NAME}/${MULTI_EDIT_TOOL_NAME} for editing instead of sed/awk, ${WRITE_TOOL_NAME} for creating files instead of cat with heredoc or echo redirection, and ${LS_TOOL_NAME}/${GLOB_TOOL_NAME}/${GREP_TOOL_NAME} for searching and listing files instead of find/ls/grep.`;
|
|
32
|
+
export const BASH_POLICY = `
|
|
33
|
+
- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
|
|
34
|
+
- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.`;
|
|
35
|
+
export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
|
|
36
|
+
export function buildSystemPrompt(basePrompt, tools) {
|
|
37
|
+
let prompt = basePrompt;
|
|
38
|
+
const toolNames = new Set(tools.map((t) => t.function?.name || t.name).filter(Boolean));
|
|
39
|
+
if (toolNames.has(TODO_WRITE_TOOL_NAME)) {
|
|
40
|
+
prompt += TASK_MANAGEMENT_POLICY;
|
|
41
|
+
}
|
|
42
|
+
if (toolNames.has(ASK_USER_QUESTION_TOOL_NAME)) {
|
|
43
|
+
prompt += ASK_USER_POLICY;
|
|
44
|
+
}
|
|
45
|
+
if (toolNames.has(TASK_TOOL_NAME)) {
|
|
46
|
+
prompt += SUBAGENT_POLICY;
|
|
47
|
+
}
|
|
48
|
+
if (toolNames.has(READ_TOOL_NAME) ||
|
|
49
|
+
toolNames.has(EDIT_TOOL_NAME) ||
|
|
50
|
+
toolNames.has(MULTI_EDIT_TOOL_NAME) ||
|
|
51
|
+
toolNames.has(WRITE_TOOL_NAME) ||
|
|
52
|
+
toolNames.has(LS_TOOL_NAME) ||
|
|
53
|
+
toolNames.has(GLOB_TOOL_NAME) ||
|
|
54
|
+
toolNames.has(GREP_TOOL_NAME)) {
|
|
55
|
+
prompt += FILE_TOOL_POLICY;
|
|
56
|
+
}
|
|
57
|
+
if (toolNames.has(BASH_TOOL_NAME)) {
|
|
58
|
+
prompt += BASH_POLICY;
|
|
59
|
+
}
|
|
60
|
+
return prompt;
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
2
|
+
export declare const BASH_TOOL_NAME = "Bash";
|
|
3
|
+
export declare const BASH_OUTPUT_TOOL_NAME = "BashOutput";
|
|
4
|
+
export declare const KILL_BASH_TOOL_NAME = "KillBash";
|
|
5
|
+
export declare const DELETE_FILE_TOOL_NAME = "Delete";
|
|
6
|
+
export declare const EDIT_TOOL_NAME = "Edit";
|
|
7
|
+
export declare const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
|
8
|
+
export declare const GLOB_TOOL_NAME = "Glob";
|
|
9
|
+
export declare const GREP_TOOL_NAME = "Grep";
|
|
10
|
+
export declare const LSP_TOOL_NAME = "LSP";
|
|
11
|
+
export declare const LS_TOOL_NAME = "LS";
|
|
12
|
+
export declare const MULTI_EDIT_TOOL_NAME = "MultiEdit";
|
|
13
|
+
export declare const READ_TOOL_NAME = "Read";
|
|
14
|
+
export declare const SKILL_TOOL_NAME = "Skill";
|
|
15
|
+
export declare const TASK_TOOL_NAME = "Task";
|
|
16
|
+
export declare const TODO_WRITE_TOOL_NAME = "TodoWrite";
|
|
17
|
+
export declare const WRITE_TOOL_NAME = "Write";
|
|
18
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
2
|
+
export const BASH_TOOL_NAME = "Bash";
|
|
3
|
+
export const BASH_OUTPUT_TOOL_NAME = "BashOutput";
|
|
4
|
+
export const KILL_BASH_TOOL_NAME = "KillBash";
|
|
5
|
+
export const DELETE_FILE_TOOL_NAME = "Delete";
|
|
6
|
+
export const EDIT_TOOL_NAME = "Edit";
|
|
7
|
+
export const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
|
8
|
+
export const GLOB_TOOL_NAME = "Glob";
|
|
9
|
+
export const GREP_TOOL_NAME = "Grep";
|
|
10
|
+
export const LSP_TOOL_NAME = "LSP";
|
|
11
|
+
export const LS_TOOL_NAME = "LS";
|
|
12
|
+
export const MULTI_EDIT_TOOL_NAME = "MultiEdit";
|
|
13
|
+
export const READ_TOOL_NAME = "Read";
|
|
14
|
+
export const SKILL_TOOL_NAME = "Skill";
|
|
15
|
+
export const TASK_TOOL_NAME = "Task";
|
|
16
|
+
export const TODO_WRITE_TOOL_NAME = "TodoWrite";
|
|
17
|
+
export const WRITE_TOOL_NAME = "Write";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export * from "./services/session.js";
|
|
|
4
4
|
export * from "./services/hook.js";
|
|
5
5
|
export * from "./services/jsonlHandler.js";
|
|
6
6
|
export * from "./services/configurationService.js";
|
|
7
|
+
export * from "./services/MarketplaceService.js";
|
|
8
|
+
export * from "./constants/tools.js";
|
|
9
|
+
export * from "./managers/pluginManager.js";
|
|
10
|
+
export * from "./managers/pluginScopeManager.js";
|
|
7
11
|
export * from "./agent.js";
|
|
8
12
|
export * from "./utils/bashHistory.js";
|
|
9
13
|
export * from "./utils/bashParser.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;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,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;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,sBAAsB,CAAC;AAGrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AAGjD,cAAc,YAAY,CAAC;AAG3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,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
|
@@ -5,6 +5,12 @@ export * from "./services/session.js";
|
|
|
5
5
|
export * from "./services/hook.js";
|
|
6
6
|
export * from "./services/jsonlHandler.js";
|
|
7
7
|
export * from "./services/configurationService.js"; // New configuration management service
|
|
8
|
+
export * from "./services/MarketplaceService.js";
|
|
9
|
+
// Export constants
|
|
10
|
+
export * from "./constants/tools.js";
|
|
11
|
+
// Export managers
|
|
12
|
+
export * from "./managers/pluginManager.js";
|
|
13
|
+
export * from "./managers/pluginScopeManager.js";
|
|
8
14
|
// Export main agent
|
|
9
15
|
export * from "./agent.js";
|
|
10
16
|
// Export all utilities
|
|
@@ -3,6 +3,7 @@ import type { ToolManager } from "./toolManager.js";
|
|
|
3
3
|
import type { MessageManager } from "./messageManager.js";
|
|
4
4
|
import type { BackgroundBashManager } from "./backgroundBashManager.js";
|
|
5
5
|
import type { HookManager } from "./hookManager.js";
|
|
6
|
+
import type { PermissionManager } from "./permissionManager.js";
|
|
6
7
|
export interface AIManagerCallbacks {
|
|
7
8
|
onCompressionStateChange?: (isCompressing: boolean) => void;
|
|
8
9
|
onUsageAdded?: (usage: Usage) => void;
|
|
@@ -13,6 +14,7 @@ export interface AIManagerOptions {
|
|
|
13
14
|
logger?: Logger;
|
|
14
15
|
backgroundBashManager?: BackgroundBashManager;
|
|
15
16
|
hookManager?: HookManager;
|
|
17
|
+
permissionManager?: PermissionManager;
|
|
16
18
|
callbacks?: AIManagerCallbacks;
|
|
17
19
|
workdir: string;
|
|
18
20
|
systemPrompt?: string;
|
|
@@ -33,6 +35,7 @@ export declare class AIManager {
|
|
|
33
35
|
private messageManager;
|
|
34
36
|
private backgroundBashManager?;
|
|
35
37
|
private hookManager?;
|
|
38
|
+
private permissionManager?;
|
|
36
39
|
private workdir;
|
|
37
40
|
private systemPrompt?;
|
|
38
41
|
private subagentType?;
|
|
@@ -48,7 +51,7 @@ export declare class AIManager {
|
|
|
48
51
|
private isCompressing;
|
|
49
52
|
private callbacks;
|
|
50
53
|
/**
|
|
51
|
-
* Get filtered tool configuration
|
|
54
|
+
* Get filtered tool configuration based on tools list
|
|
52
55
|
*/
|
|
53
56
|
private getFilteredToolsConfig;
|
|
54
57
|
setIsLoading(isLoading: boolean): void;
|
|
@@ -60,7 +63,10 @@ export declare class AIManager {
|
|
|
60
63
|
sendAIMessage(options?: {
|
|
61
64
|
recursionDepth?: number;
|
|
62
65
|
model?: string;
|
|
63
|
-
|
|
66
|
+
/** Rules for automatic tool approval (e.g., "Bash(git status:*)") */
|
|
67
|
+
allowedRules?: string[];
|
|
68
|
+
/** List of tools available to the AI (e.g., ["Bash", "Read"]) */
|
|
69
|
+
tools?: string[];
|
|
64
70
|
maxTokens?: number;
|
|
65
71
|
}): Promise<void>;
|
|
66
72
|
/**
|
|
@@ -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":"AAUA,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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