@codebolt/codeboltjs 5.0.8 → 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 +48 -5
- package/dist/core/Codebolt.js +76 -16
- package/dist/core/websocket.js +16 -18
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -3
- package/dist/modules/agentDeliberation.js +3 -1
- package/dist/modules/dynamicPanel.d.ts +106 -0
- package/dist/modules/dynamicPanel.js +122 -0
- package/dist/modules/environment.d.ts +24 -0
- package/dist/modules/environment.js +51 -0
- package/dist/modules/mcp.js +3 -0
- package/dist/tools/actionBlock/action-block-start.js +1 -4
- package/dist/tools/actionPlan/action-plan-create.js +1 -2
- package/dist/tools/completion/attempt-completion.d.ts +25 -0
- package/dist/tools/completion/attempt-completion.js +45 -0
- package/dist/tools/completion/index.d.ts +3 -0
- package/dist/tools/completion/index.js +9 -0
- 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 +20 -3
- package/dist/tools/index.js +55 -8
- package/dist/tools/job/index.d.ts +3 -1
- package/dist/tools/job/index.js +5 -1
- package/dist/tools/job/job-remove-dependency.d.ts +28 -0
- package/dist/tools/job/job-remove-dependency.js +86 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +38 -1
- package/dist/tools/requirementPlan/requirement-plan-review.js +1 -1
- package/dist/tools/thread/thread-create-background.js +1 -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/tools/utils/schema-validator.d.ts +1 -0
- package/dist/tools/utils/schema-validator.js +13 -1
- package/dist/types/agentDeliberation.d.ts +15 -1
- package/dist/types/agentDeliberation.js +2 -0
- package/package.json +20 -19
- package/dist/modules/codeboltEvent.d.ts +0 -57
- package/dist/modules/codeboltEvent.js +0 -217
- package/dist/tools/browser/browser-action.d.ts +0 -56
- package/dist/tools/browser/browser-action.js +0 -265
- package/dist/tools/codeboltEvent/event-add-running-agent.d.ts +0 -25
- package/dist/tools/codeboltEvent/event-add-running-agent.js +0 -69
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.js +0 -64
- package/dist/tools/codeboltEvent/event-get-running-agent-count.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-get-running-agent-count.js +0 -55
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.js +0 -56
- package/dist/tools/codeboltEvent/event-wait-for-external-event.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-wait-for-external-event.js +0 -55
- package/dist/tools/codeboltEvent/index.d.ts +0 -19
- package/dist/tools/codeboltEvent/index.js +0 -33
- package/dist/tools/event/event-add-running-agent.d.ts +0 -32
- package/dist/tools/event/event-add-running-agent.js +0 -77
- package/dist/tools/event/event-check-agent-event.d.ts +0 -19
- package/dist/tools/event/event-check-agent-event.js +0 -63
- package/dist/tools/event/event-check-completion.d.ts +0 -19
- package/dist/tools/event/event-check-completion.js +0 -73
- package/dist/tools/event/event-check-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-check-grouped-completion.js +0 -63
- package/dist/tools/event/event-get-running-count.d.ts +0 -19
- package/dist/tools/event/event-get-running-count.js +0 -55
- package/dist/tools/event/event-on-agent-event.d.ts +0 -19
- package/dist/tools/event/event-on-agent-event.js +0 -63
- package/dist/tools/event/event-on-completion.d.ts +0 -19
- package/dist/tools/event/event-on-completion.js +0 -73
- package/dist/tools/event/event-on-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-on-grouped-completion.js +0 -63
- package/dist/tools/event/event-wait-any.d.ts +0 -19
- package/dist/tools/event/event-wait-any.js +0 -66
- package/dist/tools/event/index.d.ts +0 -25
- package/dist/tools/event/index.js +0 -48
- package/dist/tools/git/git-action.d.ts +0 -48
- package/dist/tools/git/git-action.js +0 -279
- package/dist/tools/kvStore/kv-store-create-instance.d.ts +0 -26
- package/dist/tools/kvStore/kv-store-create-instance.js +0 -79
- package/dist/tools/kvStore/kv-store-get.d.ts +0 -30
- package/dist/tools/kvStore/kv-store-get.js +0 -80
- package/dist/tools/kvStore/kv-store-set.d.ts +0 -38
- package/dist/tools/kvStore/kv-store-set.js +0 -86
- package/dist/tools/memoryIngestion/mi-create-pipeline.d.ts +0 -44
- package/dist/tools/memoryIngestion/mi-create-pipeline.js +0 -114
- package/dist/tools/memoryIngestion/mi-list.d.ts +0 -22
- package/dist/tools/memoryIngestion/mi-list.js +0 -66
- package/dist/tools/orchestration/agent-details.d.ts +0 -15
- package/dist/tools/orchestration/agent-details.js +0 -98
- package/dist/tools/orchestration/agent-find.d.ts +0 -18
- package/dist/tools/orchestration/agent-find.js +0 -125
- package/dist/tools/orchestration/agent-list.d.ts +0 -13
- package/dist/tools/orchestration/agent-list.js +0 -106
- package/dist/tools/orchestration/agent-management.d.ts +0 -44
- package/dist/tools/orchestration/agent-management.js +0 -250
- package/dist/tools/orchestration/agent-start.d.ts +0 -18
- package/dist/tools/orchestration/agent-start.js +0 -90
- package/dist/tools/orchestration/index.d.ts +0 -49
- package/dist/tools/orchestration/index.js +0 -102
- package/dist/tools/orchestration/task-assign.d.ts +0 -18
- package/dist/tools/orchestration/task-assign.js +0 -84
- package/dist/tools/orchestration/task-create.d.ts +0 -20
- package/dist/tools/orchestration/task-create.js +0 -97
- package/dist/tools/orchestration/task-delete.d.ts +0 -16
- package/dist/tools/orchestration/task-delete.js +0 -77
- package/dist/tools/orchestration/task-execute.d.ts +0 -18
- package/dist/tools/orchestration/task-execute.js +0 -84
- package/dist/tools/orchestration/task-get.d.ts +0 -16
- package/dist/tools/orchestration/task-get.js +0 -89
- package/dist/tools/orchestration/task-list.d.ts +0 -13
- package/dist/tools/orchestration/task-list.js +0 -74
- package/dist/tools/orchestration/task-management.d.ts +0 -52
- package/dist/tools/orchestration/task-management.js +0 -231
- package/dist/tools/orchestration/task-update.d.ts +0 -22
- package/dist/tools/orchestration/task-update.js +0 -96
- package/dist/tools/orchestration/thread-create-background.d.ts +0 -18
- package/dist/tools/orchestration/thread-create-background.js +0 -94
- package/dist/tools/orchestration/thread-create-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-create-start.js +0 -85
- package/dist/tools/orchestration/thread-create.d.ts +0 -16
- package/dist/tools/orchestration/thread-create.js +0 -85
- package/dist/tools/orchestration/thread-delete.d.ts +0 -16
- package/dist/tools/orchestration/thread-delete.js +0 -77
- package/dist/tools/orchestration/thread-get-messages.d.ts +0 -24
- package/dist/tools/orchestration/thread-get-messages.js +0 -122
- package/dist/tools/orchestration/thread-get.d.ts +0 -16
- package/dist/tools/orchestration/thread-get.js +0 -85
- package/dist/tools/orchestration/thread-list.d.ts +0 -16
- package/dist/tools/orchestration/thread-list.js +0 -85
- package/dist/tools/orchestration/thread-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-start.js +0 -82
- package/dist/tools/orchestration/thread-update-status.d.ts +0 -18
- package/dist/tools/orchestration/thread-update-status.js +0 -89
- package/dist/tools/orchestration/thread-update.d.ts +0 -18
- package/dist/tools/orchestration/thread-update.js +0 -89
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Job Remove Dependency Tool - Removes a dependency between two jobs
|
|
4
|
+
* Wraps the SDK's jobService.removeDependency() method
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.JobRemoveDependencyTool = void 0;
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const base_tool_1 = require("../base-tool");
|
|
13
|
+
const job_1 = __importDefault(require("../../modules/job"));
|
|
14
|
+
class JobRemoveDependencyToolInvocation extends base_tool_1.BaseToolInvocation {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super(params);
|
|
17
|
+
}
|
|
18
|
+
async execute() {
|
|
19
|
+
try {
|
|
20
|
+
const response = await job_1.default.removeDependency(this.params.job_id, this.params.depends_on_job_id);
|
|
21
|
+
if (!response.job) {
|
|
22
|
+
return {
|
|
23
|
+
llmContent: `Failed to remove dependency: Job not found or operation failed`,
|
|
24
|
+
returnDisplay: `Failed to remove dependency between jobs`,
|
|
25
|
+
error: {
|
|
26
|
+
message: 'Failed to remove dependency: Job not found or operation failed',
|
|
27
|
+
type: types_1.ToolErrorType.EXECUTION_FAILED,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
llmContent: `Successfully removed dependency: ${this.params.job_id} no longer depends on ${this.params.depends_on_job_id}\n\nUpdated Job:\n${JSON.stringify(response.job, null, 2)}`,
|
|
33
|
+
returnDisplay: `Removed dependency: ${this.params.job_id} -/-> ${this.params.depends_on_job_id}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
38
|
+
return {
|
|
39
|
+
llmContent: `Error removing dependency: ${errorMessage}`,
|
|
40
|
+
returnDisplay: `Error removing dependency: ${errorMessage}`,
|
|
41
|
+
error: {
|
|
42
|
+
message: errorMessage,
|
|
43
|
+
type: types_1.ToolErrorType.EXECUTION_FAILED,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Implementation of the JobRemoveDependency tool
|
|
51
|
+
*/
|
|
52
|
+
class JobRemoveDependencyTool extends base_tool_1.BaseDeclarativeTool {
|
|
53
|
+
constructor() {
|
|
54
|
+
super(JobRemoveDependencyTool.Name, 'JobRemoveDependency', `Removes a dependency between two jobs. The dependency from the first job (job_id) on the second job (depends_on_job_id) will be removed, potentially unblocking the first job.`, types_1.Kind.Edit, {
|
|
55
|
+
properties: {
|
|
56
|
+
job_id: {
|
|
57
|
+
description: 'The ID of the job to remove a dependency from',
|
|
58
|
+
type: 'string',
|
|
59
|
+
},
|
|
60
|
+
depends_on_job_id: {
|
|
61
|
+
description: 'The ID of the dependency job to remove',
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ['job_id', 'depends_on_job_id'],
|
|
66
|
+
type: 'object',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
validateToolParamValues(params) {
|
|
70
|
+
if (!params.job_id || params.job_id.trim() === '') {
|
|
71
|
+
return "The 'job_id' parameter must be non-empty.";
|
|
72
|
+
}
|
|
73
|
+
if (!params.depends_on_job_id || params.depends_on_job_id.trim() === '') {
|
|
74
|
+
return "The 'depends_on_job_id' parameter must be non-empty.";
|
|
75
|
+
}
|
|
76
|
+
if (params.job_id === params.depends_on_job_id) {
|
|
77
|
+
return "A job cannot have a dependency on itself.";
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
createInvocation(params) {
|
|
82
|
+
return new JobRemoveDependencyToolInvocation(params);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.JobRemoveDependencyTool = JobRemoveDependencyTool;
|
|
86
|
+
JobRemoveDependencyTool.Name = 'job_remove_dependency';
|
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;
|
|
@@ -22,7 +22,7 @@ class RequirementPlanReviewInvocation extends base_tool_1.BaseToolInvocation {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
|
-
llmContent: `Requirement plan review status: ${response.status || 'pending'}`,
|
|
25
|
+
llmContent: `Requirement plan review status: ${response.data.status || 'pending'} `,
|
|
26
26
|
returnDisplay: `Review status: ${response.status || 'pending'}`,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -95,7 +95,7 @@ class ThreadCreateBackgroundTool extends base_tool_1.BaseDeclarativeTool {
|
|
|
95
95
|
type: 'string',
|
|
96
96
|
},
|
|
97
97
|
isGrouped: {
|
|
98
|
-
description: 'Whether the thread belongs to a group
|
|
98
|
+
description: 'Whether the thread belongs to a group',
|
|
99
99
|
type: 'boolean',
|
|
100
100
|
},
|
|
101
101
|
},
|
|
@@ -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';
|
|
@@ -8,6 +8,16 @@ exports.SchemaValidator = void 0;
|
|
|
8
8
|
* Simple JSON Schema validator
|
|
9
9
|
*/
|
|
10
10
|
class SchemaValidator {
|
|
11
|
+
static tryParseJson(value) {
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
return value;
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(value);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
static validate(schema, data) {
|
|
12
22
|
if (!schema || typeof schema !== 'object') {
|
|
13
23
|
return null; // No schema to validate against
|
|
@@ -49,7 +59,9 @@ class SchemaValidator {
|
|
|
49
59
|
const dataObj = data;
|
|
50
60
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
51
61
|
if (key in dataObj) {
|
|
52
|
-
|
|
62
|
+
// Try parsing JSON strings before validating nested properties
|
|
63
|
+
const resolvedValue = this.tryParseJson(dataObj[key]);
|
|
64
|
+
const propError = this.validate(propSchema, resolvedValue);
|
|
53
65
|
if (propError) {
|
|
54
66
|
return `Property '${key}': ${propError}`;
|
|
55
67
|
}
|
|
@@ -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
|
}
|