@codebolt/codeboltjs 5.0.9 → 5.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Codebolt.d.ts +20 -1
- package/dist/core/Codebolt.js +18 -16
- package/dist/core/websocket.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -3
- package/dist/modules/agentDeliberation.js +3 -1
- package/dist/modules/environment.d.ts +24 -0
- package/dist/modules/environment.js +51 -0
- package/dist/modules/swarm.d.ts +2 -8
- package/dist/modules/swarm.js +0 -14
- package/dist/tools/environment/environment-create.d.ts +23 -0
- package/dist/tools/environment/environment-create.js +90 -0
- package/dist/tools/environment/environment-delete.d.ts +17 -0
- package/dist/tools/environment/environment-delete.js +70 -0
- package/dist/tools/environment/environment-get.d.ts +17 -0
- package/dist/tools/environment/environment-get.js +73 -0
- package/dist/tools/environment/environment-list.d.ts +15 -0
- package/dist/tools/environment/environment-list.js +72 -0
- package/dist/tools/environment/environment-providers.d.ts +24 -0
- package/dist/tools/environment/environment-providers.js +130 -0
- package/dist/tools/environment/environment-restart.d.ts +17 -0
- package/dist/tools/environment/environment-restart.js +70 -0
- package/dist/tools/environment/environment-send-message.d.ts +19 -0
- package/dist/tools/environment/environment-send-message.js +74 -0
- package/dist/tools/environment/environment-start.d.ts +17 -0
- package/dist/tools/environment/environment-start.js +70 -0
- package/dist/tools/environment/environment-statistics.d.ts +15 -0
- package/dist/tools/environment/environment-statistics.js +69 -0
- package/dist/tools/environment/environment-status.d.ts +17 -0
- package/dist/tools/environment/environment-status.js +72 -0
- package/dist/tools/environment/environment-stop.d.ts +17 -0
- package/dist/tools/environment/environment-stop.js +70 -0
- package/dist/tools/environment/environment-update.d.ts +19 -0
- package/dist/tools/environment/environment-update.js +74 -0
- package/dist/tools/environment/index.d.ts +31 -0
- package/dist/tools/environment/index.js +61 -0
- package/dist/tools/index.d.ts +16 -2
- package/dist/tools/index.js +45 -5
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +38 -1
- package/dist/tools/tool-search.d.ts +49 -0
- package/dist/tools/tool-search.js +140 -0
- package/dist/tools/toolSearch/index.d.ts +9 -0
- package/dist/tools/toolSearch/index.js +15 -0
- package/dist/tools/toolSearch/tool-search-tool.d.ts +32 -0
- package/dist/tools/toolSearch/tool-search-tool.js +110 -0
- package/dist/types/agentDeliberation.d.ts +15 -1
- package/dist/types/agentDeliberation.js +2 -0
- package/dist/types/job.d.ts +1 -1
- package/package.json +20 -19
package/dist/tools/index.js
CHANGED
|
@@ -20,9 +20,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
23
|
+
exports.SearchMcpToolTool = exports.CodebaseSearchTool = exports.SearchFilesTool = exports.GrepTool = exports.GlobTool = exports.EventQueueAcknowledgeTool = exports.EventQueueWaitNextTool = exports.EventQueueGetPendingTool = exports.EventQueueGetStatsTool = exports.EventQueueSendMessageTool = exports.EventQueueAddEventTool = exports.agentEventQueueTools = exports.EnvironmentSendMessageTool = exports.EnvironmentStatisticsTool = exports.EnvironmentGetRunningProvidersTool = exports.EnvironmentGetLocalProvidersTool = exports.EnvironmentStatusTool = exports.EnvironmentRestartTool = exports.EnvironmentStopTool = exports.EnvironmentStartTool = exports.EnvironmentDeleteTool = exports.EnvironmentUpdateTool = exports.EnvironmentCreateTool = exports.EnvironmentGetTool = exports.EnvironmentListTool = exports.environmentTools = exports.dbmemoryTools = exports.webSearchTools = exports.ragTools = exports.memoryIngestionTools = exports.reviewMergeRequestTools = exports.roadmapTools = exports.kvStoreTools = exports.actionPlanTools = exports.actionBlockTools = exports.fileTools = exports.ReadManyFilesTool = exports.ListDirectoryTool = exports.EditTool = exports.WriteFileTool = exports.ReadFileTool = exports.ToolSearchTool = exports.toolSearchTools = exports.ToolSearchEngine = exports.defaultRegistry = exports.ToolRegistry = exports.Kind = exports.BaseDeclarativeTool = exports.DeclarativeTool = exports.BaseToolInvocation = void 0;
|
|
24
|
+
exports.TaskGetTool = exports.TaskListTool = exports.TaskDeleteTool = exports.TaskUpdateTool = exports.TaskCreateTool = exports.threadTools = exports.ThreadUpdateStatusTool = exports.ThreadGetMessagesTool = exports.ThreadDeleteTool = exports.ThreadUpdateTool = exports.ThreadStartTool = exports.ThreadGetTool = exports.ThreadListTool = exports.ThreadCreateBackgroundTool = exports.ThreadCreateStartTool = exports.ThreadCreateTool = exports.agentTools = exports.AgentDetailsTool = exports.AgentListTool = exports.AgentStartTool = exports.AgentFindTool = exports.browserTools = exports.BrowserSearchTool = exports.BrowserEnterTool = exports.BrowserCloseTool = exports.BrowserGetUrlTool = exports.BrowserGetMarkdownTool = exports.BrowserGetHtmlTool = exports.BrowserGetContentTool = exports.BrowserScrollTool = exports.BrowserTypeTool = exports.BrowserClickTool = exports.BrowserScreenshotTool = exports.BrowserNavigateTool = exports.gitTools = exports.GitCloneTool = exports.GitDiffTool = exports.GitLogsTool = exports.GitBranchTool = exports.GitCheckoutTool = exports.GitPullTool = exports.GitPushTool = exports.GitCommitTool = exports.GitAddTool = exports.GitStatusTool = exports.GitInitTool = exports.terminalTools = exports.ExecuteCommandTool = exports.searchTools = exports.ListCodeDefinitionNamesTool = void 0;
|
|
25
|
+
exports.persistentMemoryTools = exports.outputParsersTools = exports.knowledgeGraphTools = exports.hookTools = exports.fsTools = exports.eventLogTools = exports.episodicMemoryTools = exports.autoTestingTools = exports.groupFeedbackTools = exports.contextRuleEngineTools = exports.contextAssemblyTools = exports.backgroundChildThreadsTools = exports.codemapTools = exports.codebaseSearchTools = exports.agentPortfolioTools = exports.agentDeliberationTools = exports.historyTools = exports.codeutilsTools = exports.debugTools = exports.vectordbTools = exports.tokenizerTools = exports.contextTools = exports.adminTools = exports.reviewTools = exports.collaborationTools = exports.testingTools = exports.calendarTools = exports.jobTools = exports.planningTools = exports.knowledgeTools = exports.mcpTools = exports.capabilityTools = exports.chatTools = exports.todoTools = exports.memoryTools = exports.llmTools = exports.projectTools = exports.stateTools = exports.orchestratorTools = exports.OrchestratorUpdateStatusTool = exports.OrchestratorDeleteTool = exports.OrchestratorUpdateSettingsTool = exports.OrchestratorUpdateTool = exports.OrchestratorCreateTool = exports.OrchestratorGetSettingsTool = exports.OrchestratorGetTool = exports.OrchestratorListTool = exports.taskTools = exports.TaskExecuteTool = exports.TaskAssignTool = void 0;
|
|
26
|
+
exports.allTools = exports.completionTools = exports.utilsTools = exports.userMessageUtilitiesTools = exports.userMessageManagerTools = exports.requirementPlanTools = exports.projectStructureUpdateRequestTools = void 0;
|
|
26
27
|
// Export types
|
|
27
28
|
__exportStar(require("./types"), exports);
|
|
28
29
|
// Export base classes
|
|
@@ -35,6 +36,13 @@ Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { re
|
|
|
35
36
|
var registry_1 = require("./registry");
|
|
36
37
|
Object.defineProperty(exports, "ToolRegistry", { enumerable: true, get: function () { return registry_1.ToolRegistry; } });
|
|
37
38
|
Object.defineProperty(exports, "defaultRegistry", { enumerable: true, get: function () { return registry_1.defaultRegistry; } });
|
|
39
|
+
// Export tool search engine
|
|
40
|
+
var tool_search_1 = require("./tool-search");
|
|
41
|
+
Object.defineProperty(exports, "ToolSearchEngine", { enumerable: true, get: function () { return tool_search_1.ToolSearchEngine; } });
|
|
42
|
+
// Export toolSearch tools
|
|
43
|
+
var toolSearch_1 = require("./toolSearch");
|
|
44
|
+
Object.defineProperty(exports, "toolSearchTools", { enumerable: true, get: function () { return toolSearch_1.toolSearchTools; } });
|
|
45
|
+
Object.defineProperty(exports, "ToolSearchTool", { enumerable: true, get: function () { return toolSearch_1.ToolSearchTool; } });
|
|
38
46
|
// Export utilities
|
|
39
47
|
__exportStar(require("./utils"), exports);
|
|
40
48
|
// Export file tools
|
|
@@ -72,6 +80,22 @@ Object.defineProperty(exports, "webSearchTools", { enumerable: true, get: functi
|
|
|
72
80
|
// Export dbmemory tools
|
|
73
81
|
var dbmemory_1 = require("./dbmemory");
|
|
74
82
|
Object.defineProperty(exports, "dbmemoryTools", { enumerable: true, get: function () { return dbmemory_1.dbmemoryTools; } });
|
|
83
|
+
// Export environment tools
|
|
84
|
+
var environment_1 = require("./environment");
|
|
85
|
+
Object.defineProperty(exports, "environmentTools", { enumerable: true, get: function () { return environment_1.environmentTools; } });
|
|
86
|
+
Object.defineProperty(exports, "EnvironmentListTool", { enumerable: true, get: function () { return environment_1.EnvironmentListTool; } });
|
|
87
|
+
Object.defineProperty(exports, "EnvironmentGetTool", { enumerable: true, get: function () { return environment_1.EnvironmentGetTool; } });
|
|
88
|
+
Object.defineProperty(exports, "EnvironmentCreateTool", { enumerable: true, get: function () { return environment_1.EnvironmentCreateTool; } });
|
|
89
|
+
Object.defineProperty(exports, "EnvironmentUpdateTool", { enumerable: true, get: function () { return environment_1.EnvironmentUpdateTool; } });
|
|
90
|
+
Object.defineProperty(exports, "EnvironmentDeleteTool", { enumerable: true, get: function () { return environment_1.EnvironmentDeleteTool; } });
|
|
91
|
+
Object.defineProperty(exports, "EnvironmentStartTool", { enumerable: true, get: function () { return environment_1.EnvironmentStartTool; } });
|
|
92
|
+
Object.defineProperty(exports, "EnvironmentStopTool", { enumerable: true, get: function () { return environment_1.EnvironmentStopTool; } });
|
|
93
|
+
Object.defineProperty(exports, "EnvironmentRestartTool", { enumerable: true, get: function () { return environment_1.EnvironmentRestartTool; } });
|
|
94
|
+
Object.defineProperty(exports, "EnvironmentStatusTool", { enumerable: true, get: function () { return environment_1.EnvironmentStatusTool; } });
|
|
95
|
+
Object.defineProperty(exports, "EnvironmentGetLocalProvidersTool", { enumerable: true, get: function () { return environment_1.EnvironmentGetLocalProvidersTool; } });
|
|
96
|
+
Object.defineProperty(exports, "EnvironmentGetRunningProvidersTool", { enumerable: true, get: function () { return environment_1.EnvironmentGetRunningProvidersTool; } });
|
|
97
|
+
Object.defineProperty(exports, "EnvironmentStatisticsTool", { enumerable: true, get: function () { return environment_1.EnvironmentStatisticsTool; } });
|
|
98
|
+
Object.defineProperty(exports, "EnvironmentSendMessageTool", { enumerable: true, get: function () { return environment_1.EnvironmentSendMessageTool; } });
|
|
75
99
|
// Export agentEventQueue tools
|
|
76
100
|
var agentEventQueue_1 = require("./agentEventQueue");
|
|
77
101
|
Object.defineProperty(exports, "agentEventQueueTools", { enumerable: true, get: function () { return agentEventQueue_1.agentEventQueueTools; } });
|
|
@@ -385,6 +409,7 @@ const codebaseSearch_2 = require("./codebaseSearch");
|
|
|
385
409
|
const codemap_2 = require("./codemap");
|
|
386
410
|
const backgroundChildThreads_2 = require("./backgroundChildThreads");
|
|
387
411
|
const agentEventQueue_2 = require("./agentEventQueue");
|
|
412
|
+
const environment_2 = require("./environment");
|
|
388
413
|
const contextAssembly_2 = require("./contextAssembly");
|
|
389
414
|
const contextRuleEngine_2 = require("./contextRuleEngine");
|
|
390
415
|
const groupFeedback_2 = require("./groupFeedback");
|
|
@@ -401,6 +426,7 @@ const requirementPlan_2 = require("./requirementPlan");
|
|
|
401
426
|
const userMessageManager_2 = require("./userMessageManager");
|
|
402
427
|
const userMessageUtilities_2 = require("./userMessageUtilities");
|
|
403
428
|
const utils_2 = require("./utils");
|
|
429
|
+
const toolSearch_2 = require("./toolSearch");
|
|
404
430
|
/**
|
|
405
431
|
* All available tools combined
|
|
406
432
|
*/
|
|
@@ -457,7 +483,7 @@ exports.allTools = [
|
|
|
457
483
|
// ...episodicMemoryTools,
|
|
458
484
|
// ...eventLogTools,
|
|
459
485
|
// ...fsTools,
|
|
460
|
-
// ...hookTools,
|
|
486
|
+
// ...hookTools,x
|
|
461
487
|
// ...knowledgeGraphTools,
|
|
462
488
|
// ...outputParsersTools,
|
|
463
489
|
// ...persistentMemoryTools,
|
|
@@ -465,14 +491,18 @@ exports.allTools = [
|
|
|
465
491
|
...requirementPlan_2.requirementPlanTools,
|
|
466
492
|
// ...userMessageUtilitiesTools,
|
|
467
493
|
// ...utilsTools,
|
|
468
|
-
|
|
494
|
+
...agentEventQueue_2.agentEventQueueTools,
|
|
469
495
|
...completion_2.completionTools,
|
|
496
|
+
...environment_2.environmentTools,
|
|
497
|
+
...toolSearch_2.toolSearchTools,
|
|
470
498
|
];
|
|
471
499
|
/**
|
|
472
500
|
* Create and populate the default tools registry
|
|
473
501
|
*/
|
|
474
502
|
const toolsRegistry = new registry_2.ToolRegistry();
|
|
475
503
|
toolsRegistry.registerTools(exports.allTools);
|
|
504
|
+
// Initialize the ToolSearchTool with all registered tools so it can search them
|
|
505
|
+
toolSearch_2.ToolSearchTool.setTools(exports.allTools);
|
|
476
506
|
/**
|
|
477
507
|
* Tools module providing LLM-ready tool definitions
|
|
478
508
|
*/
|
|
@@ -509,6 +539,14 @@ const tools = {
|
|
|
509
539
|
* Get tool names
|
|
510
540
|
*/
|
|
511
541
|
getToolNames: () => toolsRegistry.getToolNames(),
|
|
542
|
+
/**
|
|
543
|
+
* Search for tools matching a query using full-text search (powered by MiniSearch)
|
|
544
|
+
*/
|
|
545
|
+
searchTools: (query, options) => toolsRegistry.searchTools(query, options),
|
|
546
|
+
/**
|
|
547
|
+
* Get auto-complete suggestions for a partial tool query
|
|
548
|
+
*/
|
|
549
|
+
suggestTools: (query, options) => toolsRegistry.suggestTools(query, options),
|
|
512
550
|
// Tool categories for convenience
|
|
513
551
|
file: file_2.fileTools,
|
|
514
552
|
search: search_2.searchTools,
|
|
@@ -568,5 +606,7 @@ const tools = {
|
|
|
568
606
|
utils: utils_2.utilsTools,
|
|
569
607
|
agentEventQueue: agentEventQueue_2.agentEventQueueTools,
|
|
570
608
|
completion: completion_2.completionTools,
|
|
609
|
+
environment: environment_2.environmentTools,
|
|
610
|
+
toolSearch: toolSearch_2.toolSearchTools,
|
|
571
611
|
};
|
|
572
612
|
exports.default = tools;
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
* Tool Registry for managing and executing tools
|
|
3
3
|
*/
|
|
4
4
|
import type { AnyDeclarativeTool, ToolResult, OpenAIToolSchema, OpenAIFunctionCall } from './types';
|
|
5
|
+
import { type ToolSearchResult, type ToolSearchOptions } from './tool-search';
|
|
5
6
|
/**
|
|
6
7
|
* Registry for managing tools
|
|
7
8
|
*/
|
|
8
9
|
export declare class ToolRegistry {
|
|
9
10
|
private tools;
|
|
11
|
+
private searchEngine;
|
|
12
|
+
private searchIndexDirty;
|
|
10
13
|
/**
|
|
11
14
|
* Register a tool with the registry
|
|
12
15
|
* @param tool - The tool to register
|
|
@@ -83,6 +86,24 @@ export declare class ToolRegistry {
|
|
|
83
86
|
* Clear all registered tools
|
|
84
87
|
*/
|
|
85
88
|
clear(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Ensure the search index is up to date
|
|
91
|
+
*/
|
|
92
|
+
private ensureSearchIndex;
|
|
93
|
+
/**
|
|
94
|
+
* Search for tools matching a query using full-text search
|
|
95
|
+
* @param query - The search query (e.g. "create environment", "file read", "git commit")
|
|
96
|
+
* @param options - Search options (limit, fuzzy, prefix, kind filter, boost)
|
|
97
|
+
* @returns Array of matching tools sorted by relevance
|
|
98
|
+
*/
|
|
99
|
+
searchTools(query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
100
|
+
/**
|
|
101
|
+
* Get auto-complete suggestions for a partial query
|
|
102
|
+
* @param query - The partial query to get suggestions for
|
|
103
|
+
* @param options - Search options (limit, fuzzy, kind filter)
|
|
104
|
+
* @returns Array of suggested tool matches
|
|
105
|
+
*/
|
|
106
|
+
suggestTools(query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
86
107
|
}
|
|
87
108
|
/**
|
|
88
109
|
* Default global registry instance
|
package/dist/tools/registry.js
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.defaultRegistry = exports.ToolRegistry = void 0;
|
|
7
7
|
const types_1 = require("./types");
|
|
8
|
+
const tool_search_1 = require("./tool-search");
|
|
8
9
|
/**
|
|
9
10
|
* Registry for managing tools
|
|
10
11
|
*/
|
|
11
12
|
class ToolRegistry {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.tools = new Map();
|
|
15
|
+
this.searchEngine = new tool_search_1.ToolSearchEngine();
|
|
16
|
+
this.searchIndexDirty = true;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Register a tool with the registry
|
|
@@ -21,6 +24,7 @@ class ToolRegistry {
|
|
|
21
24
|
console.warn(`Tool "${tool.name}" is already registered. Overwriting.`);
|
|
22
25
|
}
|
|
23
26
|
this.tools.set(tool.name, tool);
|
|
27
|
+
this.searchIndexDirty = true;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* Register multiple tools at once
|
|
@@ -37,7 +41,10 @@ class ToolRegistry {
|
|
|
37
41
|
* @returns true if the tool was found and removed
|
|
38
42
|
*/
|
|
39
43
|
unregisterTool(name) {
|
|
40
|
-
|
|
44
|
+
const result = this.tools.delete(name);
|
|
45
|
+
if (result)
|
|
46
|
+
this.searchIndexDirty = true;
|
|
47
|
+
return result;
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
* Get a tool by name
|
|
@@ -189,6 +196,36 @@ class ToolRegistry {
|
|
|
189
196
|
*/
|
|
190
197
|
clear() {
|
|
191
198
|
this.tools.clear();
|
|
199
|
+
this.searchIndexDirty = true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Ensure the search index is up to date
|
|
203
|
+
*/
|
|
204
|
+
ensureSearchIndex() {
|
|
205
|
+
if (this.searchIndexDirty) {
|
|
206
|
+
this.searchEngine.buildIndex(this.tools);
|
|
207
|
+
this.searchIndexDirty = false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Search for tools matching a query using full-text search
|
|
212
|
+
* @param query - The search query (e.g. "create environment", "file read", "git commit")
|
|
213
|
+
* @param options - Search options (limit, fuzzy, prefix, kind filter, boost)
|
|
214
|
+
* @returns Array of matching tools sorted by relevance
|
|
215
|
+
*/
|
|
216
|
+
searchTools(query, options) {
|
|
217
|
+
this.ensureSearchIndex();
|
|
218
|
+
return this.searchEngine.search(query, options);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get auto-complete suggestions for a partial query
|
|
222
|
+
* @param query - The partial query to get suggestions for
|
|
223
|
+
* @param options - Search options (limit, fuzzy, kind filter)
|
|
224
|
+
* @returns Array of suggested tool matches
|
|
225
|
+
*/
|
|
226
|
+
suggestTools(query, options) {
|
|
227
|
+
this.ensureSearchIndex();
|
|
228
|
+
return this.searchEngine.suggest(query, options);
|
|
192
229
|
}
|
|
193
230
|
}
|
|
194
231
|
exports.ToolRegistry = ToolRegistry;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Search Engine - Full-text search over registered tools using MiniSearch
|
|
3
|
+
*/
|
|
4
|
+
import type { AnyDeclarativeTool } from './types';
|
|
5
|
+
export interface ToolSearchResult {
|
|
6
|
+
/** Tool name (internal identifier) */
|
|
7
|
+
name: string;
|
|
8
|
+
/** User-friendly display name */
|
|
9
|
+
displayName: string;
|
|
10
|
+
/** Tool description */
|
|
11
|
+
description: string;
|
|
12
|
+
/** Tool kind/category */
|
|
13
|
+
kind: string;
|
|
14
|
+
/** Search relevance score */
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ToolSearchOptions {
|
|
18
|
+
/** Maximum number of results to return (default: 10) */
|
|
19
|
+
limit?: number;
|
|
20
|
+
/** Enable fuzzy matching (default: 0.2) */
|
|
21
|
+
fuzzy?: number | boolean;
|
|
22
|
+
/** Enable prefix matching (default: true) */
|
|
23
|
+
prefix?: boolean;
|
|
24
|
+
/** Filter by tool kind */
|
|
25
|
+
kind?: string;
|
|
26
|
+
/** Field-specific boost weights */
|
|
27
|
+
boost?: Record<string, number>;
|
|
28
|
+
}
|
|
29
|
+
export declare class ToolSearchEngine {
|
|
30
|
+
private miniSearch;
|
|
31
|
+
private indexed;
|
|
32
|
+
constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Build the search index from a map of tools
|
|
35
|
+
*/
|
|
36
|
+
buildIndex(tools: Map<string, AnyDeclarativeTool>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Search for tools matching a query
|
|
39
|
+
*/
|
|
40
|
+
search(query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
41
|
+
/**
|
|
42
|
+
* Get auto-complete suggestions for a partial query
|
|
43
|
+
*/
|
|
44
|
+
suggest(query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
45
|
+
/**
|
|
46
|
+
* Get the number of indexed tools
|
|
47
|
+
*/
|
|
48
|
+
get size(): number;
|
|
49
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Search Engine - Full-text search over registered tools using MiniSearch
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ToolSearchEngine = void 0;
|
|
10
|
+
const minisearch_1 = __importDefault(require("minisearch"));
|
|
11
|
+
class ToolSearchEngine {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.indexed = false;
|
|
14
|
+
this.miniSearch = new minisearch_1.default({
|
|
15
|
+
fields: ['name', 'displayName', 'description', 'kind', 'parameterNames'],
|
|
16
|
+
storeFields: ['name', 'displayName', 'description', 'kind'],
|
|
17
|
+
searchOptions: {
|
|
18
|
+
boost: { displayName: 3, description: 2, name: 1.5, kind: 1, parameterNames: 0.5 },
|
|
19
|
+
fuzzy: 0.2,
|
|
20
|
+
prefix: true,
|
|
21
|
+
},
|
|
22
|
+
tokenize: (text) => {
|
|
23
|
+
// Split on spaces, underscores, hyphens, and camelCase boundaries
|
|
24
|
+
return text
|
|
25
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
26
|
+
.replace(/[_\-]/g, ' ')
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.split(/\s+/)
|
|
29
|
+
.filter(t => t.length > 0);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the search index from a map of tools
|
|
35
|
+
*/
|
|
36
|
+
buildIndex(tools) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
// Clear existing index
|
|
39
|
+
if (this.indexed) {
|
|
40
|
+
this.miniSearch.removeAll();
|
|
41
|
+
}
|
|
42
|
+
const documents = [];
|
|
43
|
+
for (const [name, tool] of tools) {
|
|
44
|
+
const params = (_b = (_a = tool.schema) === null || _a === void 0 ? void 0 : _a.function) === null || _b === void 0 ? void 0 : _b.parameters;
|
|
45
|
+
const paramNames = (params === null || params === void 0 ? void 0 : params.properties)
|
|
46
|
+
? Object.keys(params.properties).filter(p => p !== 'explanation').join(' ')
|
|
47
|
+
: '';
|
|
48
|
+
documents.push({
|
|
49
|
+
id: name,
|
|
50
|
+
name: tool.name,
|
|
51
|
+
displayName: tool.displayName,
|
|
52
|
+
description: tool.description,
|
|
53
|
+
kind: tool.kind,
|
|
54
|
+
parameterNames: paramNames,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
this.miniSearch.addAll(documents);
|
|
58
|
+
this.indexed = true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Search for tools matching a query
|
|
62
|
+
*/
|
|
63
|
+
search(query, options) {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!this.indexed) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const limit = (_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 10;
|
|
69
|
+
const searchOpts = {};
|
|
70
|
+
if ((options === null || options === void 0 ? void 0 : options.fuzzy) !== undefined) {
|
|
71
|
+
searchOpts.fuzzy = options.fuzzy;
|
|
72
|
+
}
|
|
73
|
+
if ((options === null || options === void 0 ? void 0 : options.prefix) !== undefined) {
|
|
74
|
+
searchOpts.prefix = options.prefix;
|
|
75
|
+
}
|
|
76
|
+
if (options === null || options === void 0 ? void 0 : options.boost) {
|
|
77
|
+
searchOpts.boost = options.boost;
|
|
78
|
+
}
|
|
79
|
+
if (options === null || options === void 0 ? void 0 : options.kind) {
|
|
80
|
+
const kindFilter = options.kind;
|
|
81
|
+
searchOpts.filter = (result) => result.kind === kindFilter;
|
|
82
|
+
}
|
|
83
|
+
const results = this.miniSearch.search(query, searchOpts);
|
|
84
|
+
return results.slice(0, limit).map(r => ({
|
|
85
|
+
name: r.name,
|
|
86
|
+
displayName: r.displayName,
|
|
87
|
+
description: r.description,
|
|
88
|
+
kind: r.kind,
|
|
89
|
+
score: r.score,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get auto-complete suggestions for a partial query
|
|
94
|
+
*/
|
|
95
|
+
suggest(query, options) {
|
|
96
|
+
var _a;
|
|
97
|
+
if (!this.indexed) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const limit = (_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 5;
|
|
101
|
+
const suggestOpts = {};
|
|
102
|
+
if ((options === null || options === void 0 ? void 0 : options.fuzzy) !== undefined) {
|
|
103
|
+
suggestOpts.fuzzy = options.fuzzy;
|
|
104
|
+
}
|
|
105
|
+
if (options === null || options === void 0 ? void 0 : options.kind) {
|
|
106
|
+
const kindFilter = options.kind;
|
|
107
|
+
suggestOpts.filter = (result) => result.kind === kindFilter;
|
|
108
|
+
}
|
|
109
|
+
const suggestions = this.miniSearch.autoSuggest(query, suggestOpts);
|
|
110
|
+
// autoSuggest returns grouped suggestions; map them to tool results
|
|
111
|
+
const toolNames = new Set();
|
|
112
|
+
const results = [];
|
|
113
|
+
for (const suggestion of suggestions) {
|
|
114
|
+
// Search for this suggestion to get actual tool matches
|
|
115
|
+
const searchResults = this.miniSearch.search(suggestion.suggestion, { prefix: true });
|
|
116
|
+
for (const r of searchResults) {
|
|
117
|
+
if (!toolNames.has(r.name) && results.length < limit) {
|
|
118
|
+
toolNames.add(r.name);
|
|
119
|
+
results.push({
|
|
120
|
+
name: r.name,
|
|
121
|
+
displayName: r.displayName,
|
|
122
|
+
description: r.description,
|
|
123
|
+
kind: r.kind,
|
|
124
|
+
score: r.score * suggestion.score,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (results.length >= limit)
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
return results;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get the number of indexed tools
|
|
135
|
+
*/
|
|
136
|
+
get size() {
|
|
137
|
+
return this.miniSearch.documentCount;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.ToolSearchEngine = ToolSearchEngine;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Search Tool - Searches for available tools using full-text search (MiniSearch)
|
|
3
|
+
*/
|
|
4
|
+
export { ToolSearchTool, type ToolSearchToolParams } from './tool-search-tool';
|
|
5
|
+
import { ToolSearchTool } from './tool-search-tool';
|
|
6
|
+
/**
|
|
7
|
+
* All tool search tools
|
|
8
|
+
*/
|
|
9
|
+
export declare const toolSearchTools: ToolSearchTool[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Search Tool - Searches for available tools using full-text search (MiniSearch)
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toolSearchTools = exports.ToolSearchTool = void 0;
|
|
7
|
+
var tool_search_tool_1 = require("./tool-search-tool");
|
|
8
|
+
Object.defineProperty(exports, "ToolSearchTool", { enumerable: true, get: function () { return tool_search_tool_1.ToolSearchTool; } });
|
|
9
|
+
const tool_search_tool_2 = require("./tool-search-tool");
|
|
10
|
+
/**
|
|
11
|
+
* All tool search tools
|
|
12
|
+
*/
|
|
13
|
+
exports.toolSearchTools = [
|
|
14
|
+
new tool_search_tool_2.ToolSearchTool(),
|
|
15
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Search Tool - An LLM-callable tool that searches for available tools
|
|
3
|
+
* Uses MiniSearch for full-text fuzzy search over all registered tools
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolInvocation, ToolResult } from '../types';
|
|
6
|
+
import { BaseDeclarativeTool } from '../base-tool';
|
|
7
|
+
import type { AnyDeclarativeTool } from '../types';
|
|
8
|
+
export interface ToolSearchToolParams {
|
|
9
|
+
/** One sentence explanation of why this tool is being used */
|
|
10
|
+
explanation?: string;
|
|
11
|
+
/** The search query to find relevant tools (e.g. "create environment", "read file", "git commit") */
|
|
12
|
+
query: string;
|
|
13
|
+
/** Maximum number of results to return (default: 10) */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Filter results by tool kind (e.g. "read", "edit", "execute", "delete") */
|
|
16
|
+
kind?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class ToolSearchTool extends BaseDeclarativeTool<ToolSearchToolParams, ToolResult> {
|
|
19
|
+
static readonly Name: string;
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the search index with a set of tools.
|
|
23
|
+
* Call this before using the tool so the search engine knows what tools are available.
|
|
24
|
+
* @param tools - Array of tools to index
|
|
25
|
+
*/
|
|
26
|
+
static setTools(tools: AnyDeclarativeTool[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get the currently indexed tools
|
|
29
|
+
*/
|
|
30
|
+
static getIndexedTools(): AnyDeclarativeTool[];
|
|
31
|
+
protected createInvocation(params: ToolSearchToolParams): ToolInvocation<ToolSearchToolParams, ToolResult>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Search Tool - An LLM-callable tool that searches for available tools
|
|
4
|
+
* Uses MiniSearch for full-text fuzzy search over all registered tools
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ToolSearchTool = void 0;
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const base_tool_1 = require("../base-tool");
|
|
10
|
+
const tool_search_1 = require("../tool-search");
|
|
11
|
+
// Singleton search engine instance shared across invocations
|
|
12
|
+
let searchEngine = null;
|
|
13
|
+
let indexedTools = [];
|
|
14
|
+
class ToolSearchInvocation extends base_tool_1.BaseToolInvocation {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super(params);
|
|
17
|
+
}
|
|
18
|
+
async execute() {
|
|
19
|
+
var _a;
|
|
20
|
+
try {
|
|
21
|
+
if (!searchEngine) {
|
|
22
|
+
return {
|
|
23
|
+
llmContent: 'Tool search index not initialized. Call ToolSearchTool.setTools() first.',
|
|
24
|
+
returnDisplay: 'Error: search index not initialized',
|
|
25
|
+
error: {
|
|
26
|
+
message: 'Tool search index not initialized',
|
|
27
|
+
type: types_1.ToolErrorType.EXECUTION_FAILED,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const results = searchEngine.search(this.params.query, {
|
|
32
|
+
limit: (_a = this.params.limit) !== null && _a !== void 0 ? _a : 10,
|
|
33
|
+
kind: this.params.kind,
|
|
34
|
+
});
|
|
35
|
+
if (results.length === 0) {
|
|
36
|
+
return {
|
|
37
|
+
llmContent: `No tools found matching "${this.params.query}".`,
|
|
38
|
+
returnDisplay: `No tools found for: ${this.params.query}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
let output = `Found ${results.length} tool(s) matching "${this.params.query}":\n\n`;
|
|
42
|
+
for (const r of results) {
|
|
43
|
+
output += `- **${r.name}** (${r.kind}): ${r.description} [score: ${r.score.toFixed(2)}]\n`;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
llmContent: output,
|
|
47
|
+
returnDisplay: `Found ${results.length} tool(s)`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
52
|
+
return {
|
|
53
|
+
llmContent: `Error searching tools: ${errorMessage}`,
|
|
54
|
+
returnDisplay: `Error: ${errorMessage}`,
|
|
55
|
+
error: { message: errorMessage, type: types_1.ToolErrorType.EXECUTION_FAILED },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class ToolSearchTool extends base_tool_1.BaseDeclarativeTool {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(ToolSearchTool.Name, 'ToolSearch', 'Searches for available tools by name, description, or functionality using full-text search. Use this to discover which tools are available for a given task.', types_1.Kind.Search, {
|
|
63
|
+
properties: {
|
|
64
|
+
explanation: {
|
|
65
|
+
description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal.",
|
|
66
|
+
type: 'string',
|
|
67
|
+
},
|
|
68
|
+
query: {
|
|
69
|
+
description: 'The search query to find relevant tools (e.g. "create environment", "read file", "git commit").',
|
|
70
|
+
type: 'string',
|
|
71
|
+
},
|
|
72
|
+
limit: {
|
|
73
|
+
description: 'Maximum number of results to return (default: 10).',
|
|
74
|
+
type: 'number',
|
|
75
|
+
},
|
|
76
|
+
kind: {
|
|
77
|
+
description: 'Filter results by tool kind: "read", "edit", "delete", "execute", "search", "fetch", "other".',
|
|
78
|
+
type: 'string',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
required: ['query'],
|
|
82
|
+
type: 'object',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Initialize the search index with a set of tools.
|
|
87
|
+
* Call this before using the tool so the search engine knows what tools are available.
|
|
88
|
+
* @param tools - Array of tools to index
|
|
89
|
+
*/
|
|
90
|
+
static setTools(tools) {
|
|
91
|
+
indexedTools = tools;
|
|
92
|
+
searchEngine = new tool_search_1.ToolSearchEngine();
|
|
93
|
+
const toolMap = new Map();
|
|
94
|
+
for (const tool of tools) {
|
|
95
|
+
toolMap.set(tool.name, tool);
|
|
96
|
+
}
|
|
97
|
+
searchEngine.buildIndex(toolMap);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the currently indexed tools
|
|
101
|
+
*/
|
|
102
|
+
static getIndexedTools() {
|
|
103
|
+
return indexedTools;
|
|
104
|
+
}
|
|
105
|
+
createInvocation(params) {
|
|
106
|
+
return new ToolSearchInvocation(params);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.ToolSearchTool = ToolSearchTool;
|
|
110
|
+
ToolSearchTool.Name = 'tool_search';
|
|
@@ -5,6 +5,7 @@ export declare enum AgentDeliberationAction {
|
|
|
5
5
|
UPDATE = "agentdeliberation.update",
|
|
6
6
|
RESPOND = "agentdeliberation.respond",
|
|
7
7
|
VOTE = "agentdeliberation.vote",
|
|
8
|
+
VOTE_OPTION = "agentdeliberation.vote-option",
|
|
8
9
|
WINNER = "agentdeliberation.winner",
|
|
9
10
|
SUMMARY = "agentdeliberation.summary"
|
|
10
11
|
}
|
|
@@ -15,10 +16,17 @@ export declare enum AgentDeliberationResponseType {
|
|
|
15
16
|
UPDATE_RESPONSE = "agentdeliberation.update.response",
|
|
16
17
|
RESPOND_RESPONSE = "agentdeliberation.respond.response",
|
|
17
18
|
VOTE_RESPONSE = "agentdeliberation.vote.response",
|
|
19
|
+
VOTE_OPTION_RESPONSE = "agentdeliberation.vote-option.response",
|
|
18
20
|
WINNER_RESPONSE = "agentdeliberation.winner.response",
|
|
19
21
|
SUMMARY_RESPONSE = "agentdeliberation.summary.response"
|
|
20
22
|
}
|
|
21
23
|
export type DeliberationStatus = 'draft' | 'collecting-responses' | 'voting' | 'completed' | 'closed';
|
|
24
|
+
export interface DeliberationOption {
|
|
25
|
+
id: string;
|
|
26
|
+
text: string;
|
|
27
|
+
proposedBy: string;
|
|
28
|
+
voteCount: number;
|
|
29
|
+
}
|
|
22
30
|
export interface Deliberation {
|
|
23
31
|
id: string;
|
|
24
32
|
type: DeliberationType;
|
|
@@ -36,6 +44,7 @@ export interface Deliberation {
|
|
|
36
44
|
summary?: string;
|
|
37
45
|
summaryAuthorId?: string;
|
|
38
46
|
summaryAuthorName?: string;
|
|
47
|
+
options?: DeliberationOption[];
|
|
39
48
|
createdAt: string;
|
|
40
49
|
updatedAt: string;
|
|
41
50
|
deletedAt?: string;
|
|
@@ -65,6 +74,10 @@ export interface ICreateDeliberationParams {
|
|
|
65
74
|
creatorName: string;
|
|
66
75
|
participants?: string[];
|
|
67
76
|
status?: DeliberationStatus;
|
|
77
|
+
options?: {
|
|
78
|
+
text: string;
|
|
79
|
+
proposedBy: string;
|
|
80
|
+
}[];
|
|
68
81
|
}
|
|
69
82
|
export interface IGetDeliberationParams {
|
|
70
83
|
id: string;
|
|
@@ -92,7 +105,8 @@ export interface IRespondParams {
|
|
|
92
105
|
}
|
|
93
106
|
export interface IVoteParams {
|
|
94
107
|
deliberationId: string;
|
|
95
|
-
responseId
|
|
108
|
+
responseId?: string;
|
|
109
|
+
optionId?: string;
|
|
96
110
|
voterId: string;
|
|
97
111
|
voterName: string;
|
|
98
112
|
}
|