byterover-cli 1.7.2 → 1.8.0
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/README.md +17 -3
- package/dist/agent/core/domain/tools/constants.d.ts +0 -15
- package/dist/agent/core/domain/tools/constants.js +0 -15
- package/dist/agent/core/interfaces/i-cipher-agent.d.ts +6 -0
- package/dist/agent/core/interfaces/i-curate-service.d.ts +12 -0
- package/dist/agent/infra/llm/internal-llm-service.d.ts +13 -0
- package/dist/agent/infra/llm/internal-llm-service.js +61 -21
- package/dist/agent/infra/tools/implementations/curate-tool.d.ts +133 -0
- package/dist/agent/infra/tools/implementations/curate-tool.js +14 -0
- package/dist/agent/infra/tools/implementations/search-knowledge-service.js +91 -14
- package/dist/agent/infra/tools/index.d.ts +0 -4
- package/dist/agent/infra/tools/index.js +0 -4
- package/dist/agent/infra/tools/tool-registry.js +0 -113
- package/dist/agent/resources/prompts/curate-detail-preservation.yml +73 -0
- package/dist/agent/resources/prompts/system-prompt.yml +69 -3
- package/dist/server/core/domain/knowledge/markdown-writer.d.ts +13 -0
- package/dist/server/core/domain/knowledge/markdown-writer.js +116 -8
- package/dist/server/infra/executor/curate-executor.js +1 -1
- package/dist/server/infra/executor/direct-search-responder.d.ts +45 -0
- package/dist/server/infra/executor/direct-search-responder.js +86 -0
- package/dist/server/infra/executor/folder-pack-executor.d.ts +13 -5
- package/dist/server/infra/executor/folder-pack-executor.js +739 -39
- package/dist/server/infra/executor/query-executor.d.ts +49 -3
- package/dist/server/infra/executor/query-executor.js +194 -9
- package/dist/server/infra/executor/query-result-cache.d.ts +87 -0
- package/dist/server/infra/executor/query-result-cache.js +127 -0
- package/dist/server/infra/executor/query-similarity.d.ts +28 -0
- package/dist/server/infra/executor/query-similarity.js +41 -0
- package/dist/server/infra/process/agent-worker.js +9 -2
- package/dist/server/infra/process/inline-agent-executor.js +16 -5
- package/dist/server/infra/usecase/curate-use-case.js +6 -1
- package/dist/server/infra/usecase/query-use-case.js +10 -0
- package/dist/server/utils/file-validator.js +78 -1
- package/dist/tui/hooks/use-slash-completion.js +25 -4
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/agent/infra/tools/implementations/bash-exec-tool.d.ts +0 -13
- package/dist/agent/infra/tools/implementations/bash-exec-tool.js +0 -110
- package/dist/agent/infra/tools/implementations/bash-output-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/bash-output-tool.js +0 -43
- package/dist/agent/infra/tools/implementations/batch-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/batch-tool.js +0 -142
- package/dist/agent/infra/tools/implementations/create-knowledge-topic-tool.d.ts +0 -11
- package/dist/agent/infra/tools/implementations/create-knowledge-topic-tool.js +0 -149
- package/dist/agent/infra/tools/implementations/delete-memory-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/delete-memory-tool.js +0 -37
- package/dist/agent/infra/tools/implementations/edit-file-tool.d.ts +0 -13
- package/dist/agent/infra/tools/implementations/edit-file-tool.js +0 -50
- package/dist/agent/infra/tools/implementations/edit-memory-tool.d.ts +0 -13
- package/dist/agent/infra/tools/implementations/edit-memory-tool.js +0 -53
- package/dist/agent/infra/tools/implementations/kill-process-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/kill-process-tool.js +0 -55
- package/dist/agent/infra/tools/implementations/list-memories-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/list-memories-tool.js +0 -63
- package/dist/agent/infra/tools/implementations/read-memory-tool.d.ts +0 -12
- package/dist/agent/infra/tools/implementations/read-memory-tool.js +0 -39
- package/dist/agent/infra/tools/implementations/read-todos-tool.d.ts +0 -11
- package/dist/agent/infra/tools/implementations/read-todos-tool.js +0 -39
- package/dist/agent/infra/tools/implementations/search-history-tool.d.ts +0 -10
- package/dist/agent/infra/tools/implementations/search-history-tool.js +0 -36
- package/dist/agent/infra/tools/implementations/spec-analyze-tool.d.ts +0 -7
- package/dist/agent/infra/tools/implementations/spec-analyze-tool.js +0 -78
- package/dist/agent/infra/tools/implementations/write-memory-tool.d.ts +0 -13
- package/dist/agent/infra/tools/implementations/write-memory-tool.js +0 -52
- package/dist/agent/infra/tools/implementations/write-todos-tool.d.ts +0 -13
- package/dist/agent/infra/tools/implementations/write-todos-tool.js +0 -121
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { DirectoryManager } from '../../../../server/core/domain/knowledge/directory-manager.js';
|
|
4
|
-
import { MarkdownWriter } from '../../../../server/core/domain/knowledge/markdown-writer.js';
|
|
5
|
-
import { sanitizeFolderName } from '../../../../server/utils/file-helpers.js';
|
|
6
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
7
|
-
const CreateKnowledgeTopicInputSchema = z.object({
|
|
8
|
-
// Base path for knowledge storage
|
|
9
|
-
basePath: z.string().default('.brv/context-tree'),
|
|
10
|
-
domains: z.array(z.string()).describe('Array of domain names (dynamically created based on content)'),
|
|
11
|
-
// Manual topics (optional)
|
|
12
|
-
topics: z
|
|
13
|
-
.array(z.object({
|
|
14
|
-
domain: z.string().describe('Domain category name (can be any semantically meaningful name)'),
|
|
15
|
-
name: z.string().describe('Topic name'),
|
|
16
|
-
relations: z
|
|
17
|
-
.array(z.string())
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('Related topics using domain/topic or domain/topic/subtopic notation'),
|
|
20
|
-
snippets: z.array(z.string()).describe('Code/text snippets'),
|
|
21
|
-
subtopics: z
|
|
22
|
-
.array(z.object({
|
|
23
|
-
name: z.string().describe('Subtopic name'),
|
|
24
|
-
relations: z
|
|
25
|
-
.array(z.string())
|
|
26
|
-
.optional()
|
|
27
|
-
.describe('Related topics using domain/topic or domain/topic/subtopic notation'),
|
|
28
|
-
snippets: z.array(z.string()).describe('Code/text snippets'),
|
|
29
|
-
}))
|
|
30
|
-
.describe('Array of subtopics'),
|
|
31
|
-
}))
|
|
32
|
-
.describe('Array of topics for each domain'),
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Execute function for create knowledge topic tool
|
|
36
|
-
*/
|
|
37
|
-
async function executeCreateKnowledgeTopic(input, _context) {
|
|
38
|
-
const { basePath, topics } = input;
|
|
39
|
-
// Ensure base knowledge structure exists
|
|
40
|
-
await DirectoryManager.ensureKnowledgeStructure(basePath);
|
|
41
|
-
const created = [];
|
|
42
|
-
const updated = [];
|
|
43
|
-
// Process each topic sequentially (domains/topics must be created in order)
|
|
44
|
-
/* eslint-disable no-await-in-loop -- Sequential processing required for domain/topic hierarchy */
|
|
45
|
-
for (const topicData of topics) {
|
|
46
|
-
const { domain, name: topicName, relations, snippets, subtopics: subtopicData } = topicData;
|
|
47
|
-
// Create or update domain folder
|
|
48
|
-
const domainPath = join(basePath, sanitizeFolderName(domain));
|
|
49
|
-
const domainResult = await DirectoryManager.createOrUpdateDomain(domainPath);
|
|
50
|
-
// Create or update topic folder
|
|
51
|
-
const topicPath = join(domainPath, sanitizeFolderName(topicName));
|
|
52
|
-
const topicResult = await DirectoryManager.createOrUpdateTopic(topicPath);
|
|
53
|
-
// Generate and write topic context.md
|
|
54
|
-
const topicContextContent = MarkdownWriter.generateContext({
|
|
55
|
-
name: topicName,
|
|
56
|
-
relations,
|
|
57
|
-
snippets,
|
|
58
|
-
});
|
|
59
|
-
const topicContextPath = join(topicPath, 'context.md');
|
|
60
|
-
await DirectoryManager.writeFileAtomic(topicContextPath, topicContextContent);
|
|
61
|
-
// Process subtopics in parallel
|
|
62
|
-
const subtopicResults = await Promise.all(subtopicData.map(async (subtopic) => {
|
|
63
|
-
// Create subtopic folder
|
|
64
|
-
const subtopicPath = join(topicPath, sanitizeFolderName(subtopic.name));
|
|
65
|
-
const subtopicResult = await DirectoryManager.createOrUpdateTopic(subtopicPath);
|
|
66
|
-
// Generate and write subtopic context.md
|
|
67
|
-
const subtopicContextContent = MarkdownWriter.generateContext({
|
|
68
|
-
name: subtopic.name,
|
|
69
|
-
relations: subtopic.relations,
|
|
70
|
-
snippets: subtopic.snippets,
|
|
71
|
-
});
|
|
72
|
-
const subtopicContextPath = join(subtopicPath, 'context.md');
|
|
73
|
-
await DirectoryManager.writeFileAtomic(subtopicContextPath, subtopicContextContent);
|
|
74
|
-
return {
|
|
75
|
-
existed: !subtopicResult.created,
|
|
76
|
-
name: subtopic.name,
|
|
77
|
-
};
|
|
78
|
-
}));
|
|
79
|
-
// Separate created vs updated subtopics
|
|
80
|
-
const createdSubtopics = subtopicResults.filter((r) => !r.existed).map((r) => r.name);
|
|
81
|
-
const updatedSubtopics = subtopicResults.filter((r) => r.existed).map((r) => r.name);
|
|
82
|
-
// Track what was created vs updated
|
|
83
|
-
if (domainResult.created || topicResult.created) {
|
|
84
|
-
created.push({
|
|
85
|
-
domain,
|
|
86
|
-
subtopics: createdSubtopics,
|
|
87
|
-
topic: topicName,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
updated.push({
|
|
92
|
-
domain,
|
|
93
|
-
subtopics: updatedSubtopics,
|
|
94
|
-
topic: topicName,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/* eslint-enable no-await-in-loop */
|
|
99
|
-
return {
|
|
100
|
-
created,
|
|
101
|
-
updated,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Creates the create knowledge topic tool.
|
|
106
|
-
*
|
|
107
|
-
* Creates organized knowledge topics within domain folders, where each topic and subtopic
|
|
108
|
-
* has its own folder containing a context.md file with relevant snippets. This tool should
|
|
109
|
-
* be used after detecting domains to organize the extracted knowledge into a structured hierarchy.
|
|
110
|
-
*
|
|
111
|
-
* @returns Configured create knowledge topic tool
|
|
112
|
-
*/
|
|
113
|
-
export function createCreateKnowledgeTopicTool() {
|
|
114
|
-
return {
|
|
115
|
-
description: `Create organized knowledge topics within dynamically-created domain folders. This tool structures knowledge by creating domain, topic, and subtopic folders, each containing a context.md file with relevant snippets and optional relations.
|
|
116
|
-
|
|
117
|
-
**Dynamic Domain Creation:**
|
|
118
|
-
Domains are created dynamically based on the content being organized. Choose domain names that:
|
|
119
|
-
- Are semantically meaningful and descriptive (e.g., "authentication", "api_design", "data_models")
|
|
120
|
-
- Use snake_case format (1-3 words)
|
|
121
|
-
- Group related concepts together
|
|
122
|
-
- Avoid overly generic names (e.g., "misc", "other") or overly specific names
|
|
123
|
-
|
|
124
|
-
**Hierarchical Structure:**
|
|
125
|
-
- Domain folders (e.g., .brv/context-tree/authentication/)
|
|
126
|
-
- Topic folders (e.g., .brv/context-tree/authentication/oauth_flow/)
|
|
127
|
-
- Topic context.md files (e.g., .brv/context-tree/authentication/oauth_flow/context.md)
|
|
128
|
-
- Subtopic folders (e.g., .brv/context-tree/authentication/oauth_flow/token_refresh/)
|
|
129
|
-
- Subtopic context.md files (e.g., .brv/context-tree/authentication/oauth_flow/token_refresh/context.md)
|
|
130
|
-
|
|
131
|
-
**Each topic should include:**
|
|
132
|
-
1. A clear topic name
|
|
133
|
-
2. Relevant code/text snippets that demonstrate the knowledge
|
|
134
|
-
3. Optional relations to other topics using domain/topic or domain/topic/subtopic notation
|
|
135
|
-
4. Subtopics (optional) that break down the topic into smaller pieces
|
|
136
|
-
|
|
137
|
-
**Relations** enhance knowledge discovery by linking related contexts. Example:
|
|
138
|
-
- relations: ['authentication/session_management', 'api_design/endpoints/validation']
|
|
139
|
-
|
|
140
|
-
**The tool automatically:**
|
|
141
|
-
- Creates the base knowledge structure if it doesn't exist
|
|
142
|
-
- Creates domain, topic, and subtopic folders as needed
|
|
143
|
-
- Generates context.md files with snippets and relations
|
|
144
|
-
- Handles existing topics gracefully (updates instead of recreating)`,
|
|
145
|
-
execute: executeCreateKnowledgeTopic,
|
|
146
|
-
id: ToolName.CREATE_KNOWLEDGE_TOPIC,
|
|
147
|
-
inputSchema: CreateKnowledgeTopicInputSchema,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { MemoryManager } from '../../memory/memory-manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Delete memory tool.
|
|
5
|
-
*
|
|
6
|
-
* Removes a memory from the scratch pad. Also deletes any blob attachments
|
|
7
|
-
* associated with the memory. Use this to clean up outdated or unnecessary context.
|
|
8
|
-
*
|
|
9
|
-
* @param memoryManager - Memory manager service dependency
|
|
10
|
-
* @returns Configured delete memory tool
|
|
11
|
-
*/
|
|
12
|
-
export declare function createDeleteMemoryTool(memoryManager: MemoryManager): Tool;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for delete memory tool.
|
|
5
|
-
*/
|
|
6
|
-
const DeleteMemoryInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
id: z.string().min(1).describe('Unique identifier of the memory to delete'),
|
|
9
|
-
})
|
|
10
|
-
.strict();
|
|
11
|
-
/**
|
|
12
|
-
* Delete memory tool.
|
|
13
|
-
*
|
|
14
|
-
* Removes a memory from the scratch pad. Also deletes any blob attachments
|
|
15
|
-
* associated with the memory. Use this to clean up outdated or unnecessary context.
|
|
16
|
-
*
|
|
17
|
-
* @param memoryManager - Memory manager service dependency
|
|
18
|
-
* @returns Configured delete memory tool
|
|
19
|
-
*/
|
|
20
|
-
export function createDeleteMemoryTool(memoryManager) {
|
|
21
|
-
return {
|
|
22
|
-
description: 'Delete a memory by ID. Removes the memory and all associated attachments from the scratch pad. Use this to clean up outdated context.',
|
|
23
|
-
async execute(input, _context) {
|
|
24
|
-
const { id } = input;
|
|
25
|
-
// Delete memory
|
|
26
|
-
await memoryManager.delete(id);
|
|
27
|
-
// Return confirmation
|
|
28
|
-
return {
|
|
29
|
-
deleted: true,
|
|
30
|
-
id,
|
|
31
|
-
message: `Memory ${id} has been deleted successfully`,
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
id: ToolName.DELETE_MEMORY,
|
|
35
|
-
inputSchema: DeleteMemoryInputSchema,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { IFileSystem } from '../../../core/interfaces/i-file-system.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates the edit file tool.
|
|
5
|
-
*
|
|
6
|
-
* Edits a file by replacing text.
|
|
7
|
-
* By default, requires oldString to be unique (only one occurrence).
|
|
8
|
-
* Set replaceAll to true to replace all occurrences.
|
|
9
|
-
*
|
|
10
|
-
* @param fileSystemService - File system service dependency
|
|
11
|
-
* @returns Configured edit file tool
|
|
12
|
-
*/
|
|
13
|
-
export declare function createEditFileTool(fileSystemService: IFileSystem): Tool;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for edit file tool.
|
|
5
|
-
*/
|
|
6
|
-
const EditFileInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
filePath: z.string().describe('Absolute path to the file to edit'),
|
|
9
|
-
newString: z.string().describe('Replacement text'),
|
|
10
|
-
oldString: z.string().describe('Text to replace (must be unique unless replaceAll is true)'),
|
|
11
|
-
replaceAll: z
|
|
12
|
-
.boolean()
|
|
13
|
-
.optional()
|
|
14
|
-
.default(false)
|
|
15
|
-
.describe('Replace all occurrences (default: false, requires unique match)'),
|
|
16
|
-
})
|
|
17
|
-
.strict();
|
|
18
|
-
/**
|
|
19
|
-
* Creates the edit file tool.
|
|
20
|
-
*
|
|
21
|
-
* Edits a file by replacing text.
|
|
22
|
-
* By default, requires oldString to be unique (only one occurrence).
|
|
23
|
-
* Set replaceAll to true to replace all occurrences.
|
|
24
|
-
*
|
|
25
|
-
* @param fileSystemService - File system service dependency
|
|
26
|
-
* @returns Configured edit file tool
|
|
27
|
-
*/
|
|
28
|
-
export function createEditFileTool(fileSystemService) {
|
|
29
|
-
return {
|
|
30
|
-
description: 'Edit a file by replacing text. By default requires unique match (set replaceAll=true for multiple replacements).',
|
|
31
|
-
async execute(input, _context) {
|
|
32
|
-
const { filePath, newString, oldString, replaceAll } = input;
|
|
33
|
-
// Call file system service
|
|
34
|
-
const result = await fileSystemService.editFile(filePath, {
|
|
35
|
-
newString,
|
|
36
|
-
oldString,
|
|
37
|
-
replaceAll,
|
|
38
|
-
}, {});
|
|
39
|
-
// Return formatted result
|
|
40
|
-
return {
|
|
41
|
-
bytesWritten: result.bytesWritten,
|
|
42
|
-
path: result.path,
|
|
43
|
-
replacements: result.replacements,
|
|
44
|
-
success: result.success,
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
id: ToolName.EDIT_FILE,
|
|
48
|
-
inputSchema: EditFileInputSchema,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { MemoryManager } from '../../memory/memory-manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates the edit memory tool.
|
|
5
|
-
*
|
|
6
|
-
* Updates an existing memory's content, tags, or pinned status. Metadata is merged
|
|
7
|
-
* while content and tags are replaced if provided. Use this to refine or update
|
|
8
|
-
* context in the scratch pad.
|
|
9
|
-
*
|
|
10
|
-
* @param memoryManager - Memory manager service dependency
|
|
11
|
-
* @returns Configured edit memory tool
|
|
12
|
-
*/
|
|
13
|
-
export declare function createEditMemoryTool(memoryManager: MemoryManager): Tool;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for edit memory tool.
|
|
5
|
-
*/
|
|
6
|
-
const EditMemoryInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
content: z
|
|
9
|
-
.string()
|
|
10
|
-
.min(1, 'Memory content cannot be empty')
|
|
11
|
-
.max(10_000, 'Memory content cannot exceed 10,000 characters')
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('Updated content for the memory'),
|
|
14
|
-
id: z.string().min(1).describe('Unique identifier of the memory to edit'),
|
|
15
|
-
pinned: z.boolean().optional().describe('Updated pinned status'),
|
|
16
|
-
})
|
|
17
|
-
.strict();
|
|
18
|
-
/**
|
|
19
|
-
* Creates the edit memory tool.
|
|
20
|
-
*
|
|
21
|
-
* Updates an existing memory's content, tags, or pinned status. Metadata is merged
|
|
22
|
-
* while content and tags are replaced if provided. Use this to refine or update
|
|
23
|
-
* context in the scratch pad.
|
|
24
|
-
*
|
|
25
|
-
* @param memoryManager - Memory manager service dependency
|
|
26
|
-
* @returns Configured edit memory tool
|
|
27
|
-
*/
|
|
28
|
-
export function createEditMemoryTool(memoryManager) {
|
|
29
|
-
return {
|
|
30
|
-
description: 'Edit an existing memory. Update content, tags, or pinned status. Use this to refine or update previously stored context.',
|
|
31
|
-
async execute(input, _context) {
|
|
32
|
-
const { content, id, pinned } = input;
|
|
33
|
-
// Build update input
|
|
34
|
-
const updateInput = {};
|
|
35
|
-
if (content !== undefined) {
|
|
36
|
-
updateInput.content = content;
|
|
37
|
-
}
|
|
38
|
-
if (pinned !== undefined) {
|
|
39
|
-
updateInput.metadata = { pinned };
|
|
40
|
-
}
|
|
41
|
-
// Update memory
|
|
42
|
-
const updatedMemory = await memoryManager.update(id, updateInput);
|
|
43
|
-
// Return formatted result
|
|
44
|
-
return {
|
|
45
|
-
content: updatedMemory.content,
|
|
46
|
-
id: updatedMemory.id,
|
|
47
|
-
updatedAt: new Date(updatedMemory.updatedAt).toISOString(),
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
id: ToolName.EDIT_MEMORY,
|
|
51
|
-
inputSchema: EditMemoryInputSchema,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { IProcessService } from '../../../core/interfaces/i-process-service.js';
|
|
3
|
-
/**
|
|
4
|
-
* Create kill_process tool.
|
|
5
|
-
*
|
|
6
|
-
* Terminates a background process started by bash_exec.
|
|
7
|
-
* Uses graceful shutdown (SIGTERM) with escalation to SIGKILL after 5 seconds.
|
|
8
|
-
*
|
|
9
|
-
* @param processService - Process service for killing processes
|
|
10
|
-
* @returns kill_process tool instance
|
|
11
|
-
*/
|
|
12
|
-
export declare function createKillProcessTool(processService: IProcessService): Tool;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for kill_process tool.
|
|
5
|
-
*/
|
|
6
|
-
const KillProcessInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
/**
|
|
9
|
-
* Unique process identifier from bash_exec.
|
|
10
|
-
*/
|
|
11
|
-
processId: z.string().describe('Unique process identifier from bash_exec'),
|
|
12
|
-
})
|
|
13
|
-
.strict();
|
|
14
|
-
/**
|
|
15
|
-
* Create kill_process tool.
|
|
16
|
-
*
|
|
17
|
-
* Terminates a background process started by bash_exec.
|
|
18
|
-
* Uses graceful shutdown (SIGTERM) with escalation to SIGKILL after 5 seconds.
|
|
19
|
-
*
|
|
20
|
-
* @param processService - Process service for killing processes
|
|
21
|
-
* @returns kill_process tool instance
|
|
22
|
-
*/
|
|
23
|
-
export function createKillProcessTool(processService) {
|
|
24
|
-
return {
|
|
25
|
-
description: `Terminate a background process started by bash_exec.
|
|
26
|
-
|
|
27
|
-
Features:
|
|
28
|
-
- Graceful shutdown: Sends SIGTERM first to allow cleanup
|
|
29
|
-
- Force kill: Escalates to SIGKILL after 5 seconds if still running
|
|
30
|
-
- Idempotent: Safe to call on already-terminated processes
|
|
31
|
-
|
|
32
|
-
Signal handling:
|
|
33
|
-
1. Sends SIGTERM (allows process to cleanup gracefully)
|
|
34
|
-
2. Waits 5 seconds
|
|
35
|
-
3. Sends SIGKILL if process still running (force terminate)
|
|
36
|
-
|
|
37
|
-
Use cases:
|
|
38
|
-
- Stop long-running commands that are no longer needed
|
|
39
|
-
- Cancel background processes that are taking too long
|
|
40
|
-
- Clean up processes before starting new ones`,
|
|
41
|
-
async execute(input, _context) {
|
|
42
|
-
const { processId } = input;
|
|
43
|
-
// Kill process via process service
|
|
44
|
-
await processService.killProcess(processId);
|
|
45
|
-
// Return success confirmation
|
|
46
|
-
return {
|
|
47
|
-
message: `Process ${processId} terminated successfully`,
|
|
48
|
-
processId,
|
|
49
|
-
success: true,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
id: ToolName.KILL_PROCESS,
|
|
53
|
-
inputSchema: KillProcessInputSchema,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { MemoryManager } from '../../memory/memory-manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates the list memories tool.
|
|
5
|
-
*
|
|
6
|
-
* Lists and filters memories stored in the scratch pad. Supports filtering by
|
|
7
|
-
* tags, pinned status, and source. Results are sorted by most recently updated first.
|
|
8
|
-
*
|
|
9
|
-
* @param memoryManager - Memory manager service dependency
|
|
10
|
-
* @returns Configured list memories tool
|
|
11
|
-
*/
|
|
12
|
-
export declare function createListMemoriesTool(memoryManager: MemoryManager): Tool;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for list memories tool.
|
|
5
|
-
*/
|
|
6
|
-
const ListMemoriesInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
limit: z
|
|
9
|
-
.number()
|
|
10
|
-
.int()
|
|
11
|
-
.positive()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('Maximum number of memories to return'),
|
|
14
|
-
offset: z
|
|
15
|
-
.number()
|
|
16
|
-
.int()
|
|
17
|
-
.nonnegative()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('Number of memories to skip (for pagination)'),
|
|
20
|
-
pinned: z.boolean().optional().describe('Filter by pinned status'),
|
|
21
|
-
source: z
|
|
22
|
-
.enum(['agent', 'system', 'user'])
|
|
23
|
-
.optional()
|
|
24
|
-
.describe('Filter by source (default: agent)'),
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
/**
|
|
28
|
-
* Creates the list memories tool.
|
|
29
|
-
*
|
|
30
|
-
* Lists and filters memories stored in the scratch pad. Supports filtering by
|
|
31
|
-
* tags, pinned status, and source. Results are sorted by most recently updated first.
|
|
32
|
-
*
|
|
33
|
-
* @param memoryManager - Memory manager service dependency
|
|
34
|
-
* @returns Configured list memories tool
|
|
35
|
-
*/
|
|
36
|
-
export function createListMemoriesTool(memoryManager) {
|
|
37
|
-
return {
|
|
38
|
-
description: 'List and filter memories from the scratch pad. Returns memories sorted by most recent first. Use this to discover what context has been stored.',
|
|
39
|
-
async execute(input, _context) {
|
|
40
|
-
const { limit, offset, pinned, source } = input;
|
|
41
|
-
// List memories with filters
|
|
42
|
-
const memories = await memoryManager.list({
|
|
43
|
-
limit,
|
|
44
|
-
offset,
|
|
45
|
-
pinned,
|
|
46
|
-
source,
|
|
47
|
-
});
|
|
48
|
-
// Return formatted result with preview
|
|
49
|
-
return {
|
|
50
|
-
count: memories.length,
|
|
51
|
-
memories: memories.map(m => ({
|
|
52
|
-
contentPreview: m.content.length > 200 ? `${m.content.slice(0, 200)}...` : m.content,
|
|
53
|
-
createdAt: new Date(m.createdAt).toISOString(),
|
|
54
|
-
id: m.id,
|
|
55
|
-
pinned: m.metadata?.pinned ?? false,
|
|
56
|
-
updatedAt: new Date(m.updatedAt).toISOString(),
|
|
57
|
-
})),
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
id: ToolName.LIST_MEMORIES,
|
|
61
|
-
inputSchema: ListMemoriesInputSchema,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { MemoryManager } from '../../memory/memory-manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* Read memory tool.
|
|
5
|
-
*
|
|
6
|
-
* Retrieves a specific memory by its ID. Use this to recall previously stored
|
|
7
|
-
* context, intermediate results, or findings from the scratch pad.
|
|
8
|
-
*
|
|
9
|
-
* @param memoryManager - Memory manager service dependency
|
|
10
|
-
* @returns Configured read memory tool
|
|
11
|
-
*/
|
|
12
|
-
export declare function createReadMemoryTool(memoryManager: MemoryManager): Tool;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for read memory tool.
|
|
5
|
-
*/
|
|
6
|
-
const ReadMemoryInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
id: z.string().min(1).describe('Unique identifier of the memory to retrieve'),
|
|
9
|
-
})
|
|
10
|
-
.strict();
|
|
11
|
-
/**
|
|
12
|
-
* Read memory tool.
|
|
13
|
-
*
|
|
14
|
-
* Retrieves a specific memory by its ID. Use this to recall previously stored
|
|
15
|
-
* context, intermediate results, or findings from the scratch pad.
|
|
16
|
-
*
|
|
17
|
-
* @param memoryManager - Memory manager service dependency
|
|
18
|
-
* @returns Configured read memory tool
|
|
19
|
-
*/
|
|
20
|
-
export function createReadMemoryTool(memoryManager) {
|
|
21
|
-
return {
|
|
22
|
-
description: 'Read a specific memory by ID. Use this to retrieve previously stored context, findings, or intermediate results from the scratch pad.',
|
|
23
|
-
async execute(input, _context) {
|
|
24
|
-
const { id } = input;
|
|
25
|
-
// Retrieve memory
|
|
26
|
-
const memory = await memoryManager.get(id);
|
|
27
|
-
// Return formatted result
|
|
28
|
-
return {
|
|
29
|
-
content: memory.content,
|
|
30
|
-
createdAt: new Date(memory.createdAt).toISOString(),
|
|
31
|
-
id: memory.id,
|
|
32
|
-
metadata: memory.metadata,
|
|
33
|
-
updatedAt: new Date(memory.updatedAt).toISOString(),
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
id: ToolName.READ_MEMORY,
|
|
37
|
-
inputSchema: ReadMemoryInputSchema,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
import type { ITodoStorage } from '../../../core/interfaces/i-todo-storage.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates the read todos tool.
|
|
5
|
-
*
|
|
6
|
-
* Reads the current todo list from session storage.
|
|
7
|
-
*
|
|
8
|
-
* @param todoStorage - Storage service for retrieving todos
|
|
9
|
-
* @returns Configured read todos tool
|
|
10
|
-
*/
|
|
11
|
-
export declare function createReadTodosTool(todoStorage: ITodoStorage): Tool;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for read todos tool.
|
|
5
|
-
* No parameters required - reads todos for current session.
|
|
6
|
-
*/
|
|
7
|
-
const ReadTodosInputSchema = z.object({}).strict();
|
|
8
|
-
/**
|
|
9
|
-
* Tool description for read todos.
|
|
10
|
-
*/
|
|
11
|
-
const TOOL_DESCRIPTION = `Read the current todo list for this session.
|
|
12
|
-
|
|
13
|
-
Use this tool to check the current state of your task list before making updates.
|
|
14
|
-
Returns all todo items with their id, content, activeForm, and status.`;
|
|
15
|
-
/**
|
|
16
|
-
* Creates the read todos tool.
|
|
17
|
-
*
|
|
18
|
-
* Reads the current todo list from session storage.
|
|
19
|
-
*
|
|
20
|
-
* @param todoStorage - Storage service for retrieving todos
|
|
21
|
-
* @returns Configured read todos tool
|
|
22
|
-
*/
|
|
23
|
-
export function createReadTodosTool(todoStorage) {
|
|
24
|
-
return {
|
|
25
|
-
description: TOOL_DESCRIPTION,
|
|
26
|
-
async execute(_input, context) {
|
|
27
|
-
const sessionId = context?.sessionId ?? 'default';
|
|
28
|
-
const todos = await todoStorage.get(sessionId);
|
|
29
|
-
const incompleteCount = todos.filter((t) => t.status !== 'completed').length;
|
|
30
|
-
return {
|
|
31
|
-
content: JSON.stringify(todos, null, 2),
|
|
32
|
-
metadata: { todos },
|
|
33
|
-
title: `${incompleteCount} todos`,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
id: ToolName.READ_TODOS,
|
|
37
|
-
inputSchema: ReadTodosInputSchema,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Tool } from '../../../core/domain/tools/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the search history tool.
|
|
4
|
-
*
|
|
5
|
-
* NOTE: This is a stub implementation. SearchService is not yet implemented.
|
|
6
|
-
* This tool will throw an error until the SearchService is available.
|
|
7
|
-
*
|
|
8
|
-
* @returns Configured search history tool (stub)
|
|
9
|
-
*/
|
|
10
|
-
export declare function createSearchHistoryTool(): Tool;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ToolName } from '../../../core/domain/tools/constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input schema for search history tool.
|
|
5
|
-
*/
|
|
6
|
-
const SearchHistoryInputSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
limit: z.number().optional().default(20).describe('Maximum number of results to return (default: 20)'),
|
|
9
|
-
mode: z
|
|
10
|
-
.enum(['messages', 'sessions'])
|
|
11
|
-
.describe('Search mode: "messages" searches for individual messages, "sessions" finds sessions containing the query'),
|
|
12
|
-
offset: z.number().optional().default(0).describe('Offset for pagination (default: 0)'),
|
|
13
|
-
query: z.string().describe('The search query to find in conversation history'),
|
|
14
|
-
role: z.enum(['user', 'assistant', 'system', 'tool']).optional().describe('Filter by message role (optional)'),
|
|
15
|
-
sessionId: z.string().optional().describe('Limit search to a specific session (optional)'),
|
|
16
|
-
})
|
|
17
|
-
.strict();
|
|
18
|
-
/**
|
|
19
|
-
* Creates the search history tool.
|
|
20
|
-
*
|
|
21
|
-
* NOTE: This is a stub implementation. SearchService is not yet implemented.
|
|
22
|
-
* This tool will throw an error until the SearchService is available.
|
|
23
|
-
*
|
|
24
|
-
* @returns Configured search history tool (stub)
|
|
25
|
-
*/
|
|
26
|
-
export function createSearchHistoryTool() {
|
|
27
|
-
return {
|
|
28
|
-
description: 'Search conversation history. Supports searching messages or sessions. Can filter by role and session.',
|
|
29
|
-
async execute(_input, _context) {
|
|
30
|
-
// Stub implementation - SearchService not yet available
|
|
31
|
-
throw new Error('Search history tool is not yet implemented. This feature requires the SearchService which is not currently available.');
|
|
32
|
-
},
|
|
33
|
-
id: ToolName.SEARCH_HISTORY,
|
|
34
|
-
inputSchema: SearchHistoryInputSchema,
|
|
35
|
-
};
|
|
36
|
-
}
|