kimi-code-memory-mcp-server 0.1.1 → 0.1.2
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/CHANGELOG.md +14 -1
- package/README.en.md +342 -0
- package/README.md +214 -137
- package/assets/contextFlow.svg +144 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/context/wire-context.d.ts +3 -0
- package/dist/context/wire-context.js +20 -50
- package/dist/context/wire-context.js.map +1 -1
- package/dist/dao/constants.d.ts +33 -0
- package/dist/dao/constants.js +17 -0
- package/dist/dao/constants.js.map +1 -0
- package/dist/dao/index-catalog.d.ts +19 -0
- package/dist/dao/index-catalog.js +94 -0
- package/dist/dao/index-catalog.js.map +1 -0
- package/dist/dao/index-reconciler.d.ts +13 -0
- package/dist/dao/index-reconciler.js +162 -0
- package/dist/dao/index-reconciler.js.map +1 -0
- package/dist/dao/index-store.d.ts +31 -0
- package/dist/dao/index-store.js +128 -0
- package/dist/dao/index-store.js.map +1 -0
- package/dist/dao/index.d.ts +12 -31
- package/dist/dao/index.js +50 -404
- package/dist/dao/index.js.map +1 -1
- package/dist/dao/memory-store.js +2 -10
- package/dist/dao/memory-store.js.map +1 -1
- package/dist/dao/memory-tree-renderer.d.ts +22 -0
- package/dist/dao/memory-tree-renderer.js +75 -0
- package/dist/dao/memory-tree-renderer.js.map +1 -0
- package/dist/prompts/index.d.ts +26 -0
- package/dist/prompts/index.js +103 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/refine/adapter.d.ts +6 -0
- package/dist/refine/adapter.js +28 -0
- package/dist/refine/adapter.js.map +1 -0
- package/dist/refine/constants.d.ts +35 -0
- package/dist/refine/constants.js +107 -0
- package/dist/refine/constants.js.map +1 -0
- package/dist/refine/extractor.d.ts +12 -0
- package/dist/refine/extractor.js +122 -0
- package/dist/refine/extractor.js.map +1 -0
- package/dist/refine/store.d.ts +19 -0
- package/dist/refine/store.js +139 -0
- package/dist/refine/store.js.map +1 -0
- package/dist/refine/types.d.ts +56 -0
- package/dist/refine/types.js +5 -0
- package/dist/refine/types.js.map +1 -0
- package/dist/refined-manager.d.ts +10 -56
- package/dist/refined-manager.js +22 -341
- package/dist/refined-manager.js.map +1 -1
- package/dist/resources/index.d.ts +15 -0
- package/dist/resources/index.js +134 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/server.js +46 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/context-tools.d.ts +16 -51
- package/dist/tools/context-tools.js +247 -55
- package/dist/tools/context-tools.js.map +1 -1
- package/dist/tools/index.d.ts +5 -827
- package/dist/tools/index.js +23 -354
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/memory-tools.d.ts +4 -60
- package/dist/tools/memory-tools.js +129 -79
- package/dist/tools/memory-tools.js.map +1 -1
- package/dist/tools/system-tools.d.ts +3 -34
- package/dist/tools/system-tools.js +86 -32
- package/dist/tools/system-tools.js.map +1 -1
- package/dist/tools/theme-tools.d.ts +3 -31
- package/dist/tools/theme-tools.js +78 -22
- package/dist/tools/theme-tools.js.map +1 -1
- package/dist/tools/types.d.ts +21 -0
- package/dist/tools/types.js +13 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types.d.ts +4 -2
- package/dist/utils/action-entities.d.ts +16 -0
- package/dist/utils/action-entities.js +35 -0
- package/dist/utils/action-entities.js.map +1 -0
- package/dist/utils/date.d.ts +11 -0
- package/dist/utils/date.js +13 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/file-helpers.d.ts +10 -0
- package/dist/utils/file-helpers.js +28 -0
- package/dist/utils/file-helpers.js.map +1 -0
- package/dist/utils/headings.d.ts +5 -0
- package/dist/utils/headings.js +21 -0
- package/dist/utils/headings.js.map +1 -0
- package/dist/utils/search.d.ts +17 -0
- package/dist/utils/search.js +60 -0
- package/dist/utils/search.js.map +1 -0
- package/dist/utils/tools.d.ts +5 -0
- package/dist/utils/tools.js +10 -0
- package/dist/utils/tools.js.map +1 -0
- package/dist/vis/api.d.ts +82 -0
- package/dist/vis/api.js +212 -0
- package/dist/vis/api.js.map +1 -0
- package/dist/vis/auto-start.d.ts +12 -0
- package/dist/vis/auto-start.js +87 -0
- package/dist/vis/auto-start.js.map +1 -0
- package/dist/vis/server.d.ts +14 -0
- package/dist/vis/server.js +103 -0
- package/dist/vis/server.js.map +1 -0
- package/dist/vis/static/app.js +395 -0
- package/dist/vis/static/index.html +95 -0
- package/dist/vis/static/style.css +707 -0
- package/dist/vis-cli.d.ts +7 -0
- package/dist/vis-cli.js +140 -0
- package/dist/vis-cli.js.map +1 -0
- package/docs/0.agent-memory-market-research.md +354 -0
- package/docs/1.memory-system-proposal-for-kimi-code.md +688 -0
- package/docs/2.memory-architecture-overview.md +417 -0
- package/docs/3.memory-skill-prompt-design.md +430 -0
- package/docs/4.kimi-code-native-evolution-roadmap.md +559 -0
- package/docs/5.decision-guard-design-notes.md +500 -0
- package/docs/ARCHITECTURE.md +2 -2
- package/docs/design-story.md +350 -0
- package/docs/three-layer-memory-model.md +153 -0
- package/docs/three-layer-memory-model.zh-CN.md +153 -0
- package/package.json +12 -6
- package/README.zh-CN.md +0 -292
package/dist/tools/index.js
CHANGED
|
@@ -1,369 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool registry: schemas and dispatch.
|
|
3
3
|
*/
|
|
4
|
+
import { toolResult } from '../utils/tools.js';
|
|
4
5
|
import { createMemoryTools } from './memory-tools.js';
|
|
5
6
|
import { createContextTools } from './context-tools.js';
|
|
6
7
|
import { createThemeTools } from './theme-tools.js';
|
|
7
8
|
import { createSystemTools } from './system-tools.js';
|
|
8
9
|
export function createTools(ctx) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
remember: memory.handleRemember,
|
|
15
|
-
recall: memory.handleRecall,
|
|
16
|
-
recall_recent: memory.handleRecallRecent,
|
|
17
|
-
search: memory.handleSearch,
|
|
18
|
-
list_tags: memory.handleListTags,
|
|
19
|
-
list: memory.handleList,
|
|
20
|
-
delete: memory.handleDelete,
|
|
21
|
-
move: memory.handleMove,
|
|
22
|
-
load_workspace_context: context.handleLoadWorkspaceContext,
|
|
23
|
-
load_more_context: context.handleLoadMoreContext,
|
|
24
|
-
search_context: context.handleSearchContext,
|
|
25
|
-
list_search_views: context.handleListSearchViews,
|
|
26
|
-
load_turn_context: context.handleLoadTurnContext,
|
|
27
|
-
tag_theme: theme.handleTagTheme,
|
|
28
|
-
trace_theme: theme.handleTraceTheme,
|
|
29
|
-
list_themes: theme.handleListThemes,
|
|
30
|
-
refine_session_turns: theme.handleRefineSessionTurns,
|
|
31
|
-
get_current_workspace: system.handleGetCurrentWorkspace,
|
|
32
|
-
organize_memories: system.handleOrganize,
|
|
33
|
-
sync_workspace_index: system.handleSyncWorkspaceIndex,
|
|
34
|
-
bootstrap_workspace: system.handleBootstrapWorkspace,
|
|
35
|
-
};
|
|
36
|
-
const toolSchemas = [
|
|
37
|
-
{
|
|
38
|
-
name: 'remember',
|
|
39
|
-
description: 'Write or overwrite a memory entry as a Markdown file with YAML frontmatter.',
|
|
40
|
-
inputSchema: {
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
key: { type: 'string', description: 'Unique identifier used as filename base' },
|
|
44
|
-
content: {
|
|
45
|
-
type: 'string',
|
|
46
|
-
description: 'Markdown body content. For decisions include rationale, impact, and related files. ' +
|
|
47
|
-
'For rules include scope and consequence. For knowledge include scenario and related files/interfaces. ' +
|
|
48
|
-
'For references include URL and relevance. Example decision: "# Use SQLite\n\n## Rationale\n- Single-file deployment\n- No extra service\n\n## Impact\nAll cache reads/writes go through src/cache.js.\n\n## Related files\nsrc/cache.js, docs/cache.md"',
|
|
49
|
-
},
|
|
50
|
-
folder: {
|
|
51
|
-
type: 'string',
|
|
52
|
-
description: 'Subfolder under the workspace (default: memory)',
|
|
53
|
-
},
|
|
54
|
-
tags: {
|
|
55
|
-
type: 'array',
|
|
56
|
-
items: { type: 'string' },
|
|
57
|
-
description: 'Tags stored in YAML frontmatter',
|
|
58
|
-
},
|
|
59
|
-
themes: {
|
|
60
|
-
type: 'array',
|
|
61
|
-
items: { type: 'string' },
|
|
62
|
-
description: 'Optional theme names to associate with this memory',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
required: ['key'],
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'recall',
|
|
70
|
-
description: 'Read a memory entry by key and folder.',
|
|
71
|
-
inputSchema: {
|
|
72
|
-
type: 'object',
|
|
73
|
-
properties: {
|
|
74
|
-
key: { type: 'string', description: 'Memory key' },
|
|
75
|
-
folder: { type: 'string', description: 'Subfolder (default: memory)' },
|
|
76
|
-
},
|
|
77
|
-
required: ['key'],
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: 'recall_recent',
|
|
82
|
-
description: 'Return the most recently updated memory entries, optionally filtered.',
|
|
83
|
-
inputSchema: {
|
|
84
|
-
type: 'object',
|
|
85
|
-
properties: {
|
|
86
|
-
n: { type: 'number', description: 'Maximum number of entries to return (default: 10)' },
|
|
87
|
-
folder: { type: 'string', description: 'Filter to a specific subfolder' },
|
|
88
|
-
tag: { type: 'string', description: 'Filter to entries containing this tag' },
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'search',
|
|
94
|
-
description: 'Case-insensitive keyword search across memory titles and contents.',
|
|
95
|
-
inputSchema: {
|
|
96
|
-
type: 'object',
|
|
97
|
-
properties: {
|
|
98
|
-
query: { type: 'string', description: 'Keyword to search' },
|
|
99
|
-
folder: { type: 'string', description: 'Limit search to a subfolder' },
|
|
100
|
-
},
|
|
101
|
-
required: ['query'],
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'list_tags',
|
|
106
|
-
description: 'List all tags used in the current workspace.',
|
|
107
|
-
inputSchema: { type: 'object', properties: {} },
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'get_current_workspace',
|
|
111
|
-
description: 'Return the current cwd, workspace id and store path.',
|
|
112
|
-
inputSchema: { type: 'object', properties: {} },
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'load_workspace_context',
|
|
116
|
-
description: 'Load the workspace context for session resumption: recent conversation parsed from the active wire.jsonl.',
|
|
117
|
-
inputSchema: {
|
|
118
|
-
type: 'object',
|
|
119
|
-
properties: {
|
|
120
|
-
detailed_rounds: {
|
|
121
|
-
type: 'number',
|
|
122
|
-
description: 'Number of most recent rounds to return in full detail.',
|
|
123
|
-
},
|
|
124
|
-
summary_rounds: {
|
|
125
|
-
type: 'number',
|
|
126
|
-
description: 'Number of preceding rounds to return as summaries.',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
name: 'load_more_context',
|
|
133
|
-
description: 'Load older conversation rounds from the active wire.jsonl, summarized, before a given turn id.',
|
|
134
|
-
inputSchema: {
|
|
135
|
-
type: 'object',
|
|
136
|
-
properties: {
|
|
137
|
-
before_turn_id: {
|
|
138
|
-
type: 'number',
|
|
139
|
-
description: 'Exclusive turn id; return rounds older than this.',
|
|
140
|
-
},
|
|
141
|
-
limit: {
|
|
142
|
-
type: 'number',
|
|
143
|
-
description: 'Maximum number of older rounds to return.',
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
required: ['before_turn_id'],
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'search_context',
|
|
151
|
-
description: 'Search conversation rounds across all workspace session wires by keywords and optional date range.',
|
|
152
|
-
inputSchema: {
|
|
153
|
-
type: 'object',
|
|
154
|
-
properties: {
|
|
155
|
-
query: { type: 'string', description: 'Keywords to search for in conversation rounds' },
|
|
156
|
-
date_from: { type: 'string', description: 'Optional start date in YYYY-MM-DD format' },
|
|
157
|
-
date_to: { type: 'string', description: 'Optional end date in YYYY-MM-DD format' },
|
|
158
|
-
limit: { type: 'number', description: 'Maximum number of matching rounds to return' },
|
|
159
|
-
cluster_gap_seconds: {
|
|
160
|
-
type: 'number',
|
|
161
|
-
description: '相邻 turn 被归为同一「簇」的最大时间间隔(秒)。一个簇代表一段连续的讨论或决策。默认 90 秒;协作节奏慢可适当调大,话题切换快则调小。',
|
|
162
|
-
},
|
|
163
|
-
max_cluster_size: {
|
|
164
|
-
type: 'number',
|
|
165
|
-
description: '单个 cluster 最多包含的 turn 数,防止连续讨论过长时上下文爆炸。默认 15。',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
required: ['query'],
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: 'list_search_views',
|
|
173
|
-
description: 'List saved search views. Each view records the clusters discovered by a previous search_context call. Use these views as candidate sets before creating or extending a theme.',
|
|
174
|
-
inputSchema: {
|
|
175
|
-
type: 'object',
|
|
176
|
-
properties: {
|
|
177
|
-
limit: { type: 'number', description: 'Maximum number of recent views to return' },
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
name: 'load_turn_context',
|
|
183
|
-
description: 'Load the full detailed content of specific conversation turns by sessionId and turnId.',
|
|
184
|
-
inputSchema: {
|
|
185
|
-
type: 'object',
|
|
186
|
-
properties: {
|
|
187
|
-
references: {
|
|
188
|
-
type: 'array',
|
|
189
|
-
description: 'Array of { sessionId, turnId } references identifying the conversation rounds to load',
|
|
190
|
-
items: {
|
|
191
|
-
type: 'object',
|
|
192
|
-
properties: {
|
|
193
|
-
sessionId: { type: 'string', description: 'Session identifier' },
|
|
194
|
-
turnId: { type: 'number', description: 'Turn identifier within the session' },
|
|
195
|
-
},
|
|
196
|
-
required: ['sessionId', 'turnId'],
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
required: ['references'],
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: 'list',
|
|
205
|
-
description: 'List all memory entries in the workspace, optionally filtered by folder.',
|
|
206
|
-
inputSchema: {
|
|
207
|
-
type: 'object',
|
|
208
|
-
properties: {
|
|
209
|
-
folder: { type: 'string', description: 'Filter to a specific subfolder' },
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: 'delete',
|
|
215
|
-
description: 'Delete a memory entry by key and folder.',
|
|
216
|
-
inputSchema: {
|
|
217
|
-
type: 'object',
|
|
218
|
-
properties: {
|
|
219
|
-
key: { type: 'string', description: 'Memory key' },
|
|
220
|
-
folder: { type: 'string', description: 'Subfolder (default: memory)' },
|
|
221
|
-
},
|
|
222
|
-
required: ['key'],
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
name: 'move',
|
|
227
|
-
description: 'Move a memory entry to another folder, optionally renaming it.',
|
|
228
|
-
inputSchema: {
|
|
229
|
-
type: 'object',
|
|
230
|
-
properties: {
|
|
231
|
-
key: { type: 'string', description: 'Memory key' },
|
|
232
|
-
folder: { type: 'string', description: 'Source subfolder (default: memory)' },
|
|
233
|
-
toFolder: { type: 'string', description: 'Destination subfolder' },
|
|
234
|
-
newKey: { type: 'string', description: 'Optional new key to rename the memory' },
|
|
235
|
-
},
|
|
236
|
-
required: ['key', 'toFolder'],
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: 'organize_memories',
|
|
241
|
-
description: 'Two-stage workspace memory organizer. Empty call returns existing essence + pending memory files + rules. Call with content to store the organized essence.md.',
|
|
242
|
-
inputSchema: {
|
|
243
|
-
type: 'object',
|
|
244
|
-
properties: {
|
|
245
|
-
content: {
|
|
246
|
-
type: 'string',
|
|
247
|
-
description: 'Organized essence Markdown body. Key facts should cite sources inline using `> 来源:memory/<folder>/key`.',
|
|
248
|
-
},
|
|
249
|
-
sources: {
|
|
250
|
-
type: 'array',
|
|
251
|
-
items: { type: 'string' },
|
|
252
|
-
description: 'Optional list of memory/ keys incorporated into the essence, returned in the tool result for tracking.',
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
name: 'sync_workspace_index',
|
|
259
|
-
description: 'Reconciles index.json with the filesystem. Empty call scans and reports mismatches. Call with folderComments to set folder descriptions.',
|
|
260
|
-
inputSchema: {
|
|
261
|
-
type: 'object',
|
|
262
|
-
properties: {
|
|
263
|
-
folderComments: {
|
|
264
|
-
type: 'object',
|
|
265
|
-
description: 'Optional map of folder paths to comments.',
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
name: 'bootstrap_workspace',
|
|
272
|
-
description: 'Session bootstrap: loads workspace context, essence, notes refs, and a memory index tree with recent changes marked [new].',
|
|
273
|
-
inputSchema: {
|
|
274
|
-
type: 'object',
|
|
275
|
-
properties: {
|
|
276
|
-
detailed_rounds: {
|
|
277
|
-
type: 'number',
|
|
278
|
-
description: 'Number of most recent rounds to return in full detail.',
|
|
279
|
-
},
|
|
280
|
-
summary_rounds: {
|
|
281
|
-
type: 'number',
|
|
282
|
-
description: 'Number of preceding rounds to return as summaries.',
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
name: 'tag_theme',
|
|
289
|
-
description: '仔细分析 turn 内容与 theme 确定相关后,将 turn 挂载到 theme。禁止仅凭关键词匹配挂载;必须确认内容 genuinely belongs to the theme 才可关联。如果 theme 不存在会自动创建。',
|
|
290
|
-
inputSchema: {
|
|
291
|
-
type: 'object',
|
|
292
|
-
properties: {
|
|
293
|
-
theme: {
|
|
294
|
-
type: 'string',
|
|
295
|
-
description: 'Theme identifier. A theme is a semantic group, not a keyword tag.',
|
|
296
|
-
},
|
|
297
|
-
sessionId: {
|
|
298
|
-
type: 'string',
|
|
299
|
-
description: 'Optional session id of a conversation turn to attach',
|
|
300
|
-
},
|
|
301
|
-
turnId: { type: 'number', description: 'Optional turn id within the session' },
|
|
302
|
-
memoryKey: { type: 'string', description: 'Optional memory key to attach' },
|
|
303
|
-
memoryFolder: { type: 'string', description: 'Optional memory folder (default: memory)' },
|
|
304
|
-
memoryTitle: {
|
|
305
|
-
type: 'string',
|
|
306
|
-
description: 'Optional display title for the memory reference',
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
required: ['theme'],
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
name: 'trace_theme',
|
|
314
|
-
description: 'Trace the evolution of a theme across sessions and memories. Returns associated turns and memories sorted by time.',
|
|
315
|
-
inputSchema: {
|
|
316
|
-
type: 'object',
|
|
317
|
-
properties: {
|
|
318
|
-
theme: { type: 'string', description: 'Theme identifier' },
|
|
319
|
-
includeTurnContent: {
|
|
320
|
-
type: 'boolean',
|
|
321
|
-
description: 'If true, load full turn content from wire.jsonl (default: false)',
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
required: ['theme'],
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
name: 'list_themes',
|
|
329
|
-
description: 'List all theme identifiers stored in the current workspace.',
|
|
330
|
-
inputSchema: { type: 'object', properties: {} },
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
name: 'refine_session_turns',
|
|
334
|
-
description: 'Read a session wire.jsonl and generate Refined Turn Summaries. Output is written to refined/<sessionId>.jsonl.',
|
|
335
|
-
inputSchema: {
|
|
336
|
-
type: 'object',
|
|
337
|
-
properties: {
|
|
338
|
-
sessionId: {
|
|
339
|
-
type: 'string',
|
|
340
|
-
description: 'Session identifier (default: current session)',
|
|
341
|
-
},
|
|
342
|
-
session_id: { type: 'string', description: 'Alias for sessionId' },
|
|
343
|
-
turnIds: {
|
|
344
|
-
type: 'array',
|
|
345
|
-
items: { type: 'number' },
|
|
346
|
-
description: 'Optional list of turnIds to refine',
|
|
347
|
-
},
|
|
348
|
-
limit: {
|
|
349
|
-
type: 'number',
|
|
350
|
-
description: 'Optional limit: refine only the most recent N turns',
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
},
|
|
10
|
+
const tools = [
|
|
11
|
+
...createMemoryTools(ctx),
|
|
12
|
+
...createContextTools(ctx),
|
|
13
|
+
...createThemeTools(ctx),
|
|
14
|
+
...createSystemTools(ctx),
|
|
355
15
|
];
|
|
356
|
-
|
|
16
|
+
const toolSchemas = tools.map(({ name, description, inputSchema }) => ({
|
|
17
|
+
name,
|
|
18
|
+
description,
|
|
19
|
+
inputSchema,
|
|
20
|
+
}));
|
|
21
|
+
const handlers = Object.fromEntries(tools.map((tool) => [tool.name, tool.handler]));
|
|
22
|
+
async function dispatch(name, args = {}) {
|
|
357
23
|
const handler = handlers[name];
|
|
358
24
|
if (!handler) {
|
|
359
|
-
return
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
25
|
+
return toolResult({ error: `Unknown tool: ${name}` }, true);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return await handler(args);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
return toolResult({
|
|
32
|
+
success: false,
|
|
33
|
+
error: err instanceof Error ? err.message : String(err),
|
|
34
|
+
}, true);
|
|
365
35
|
}
|
|
366
|
-
return Promise.resolve(handler(args));
|
|
367
36
|
}
|
|
368
37
|
return { toolSchemas, dispatch };
|
|
369
38
|
}
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,UAAU,WAAW,CAAC,GAAQ;IAClC,MAAM,KAAK,GAAqB;QAC9B,GAAG,iBAAiB,CAAC,GAAG,CAAC;QACzB,GAAG,kBAAkB,CAAC,GAAG,CAAC;QAC1B,GAAG,gBAAgB,CAAC,GAAG,CAAC;QACxB,GAAG,iBAAiB,CAAC,GAAG,CAAC;KAC1B,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QACrE,IAAI;QACJ,WAAW;QACX,WAAW;KACZ,CAAC,CAAC,CAAC;IAEJ,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CACjC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACwB,CAAC;IAEzE,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,OAAgC,EAAE;QACtE,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,iBAAiB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,UAAU,CACf;gBACE,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,EACD,IAAI,CACL,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -1,62 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory CRUD tools: remember, recall,
|
|
2
|
+
* Memory CRUD tools: remember, recall, search, list, list_tags, delete, move.
|
|
3
3
|
*/
|
|
4
|
-
import type { Ctx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
content: {
|
|
8
|
-
type: string;
|
|
9
|
-
text: string;
|
|
10
|
-
}[];
|
|
11
|
-
isError: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
handleRecall: (args: RecallArgs) => Promise<{
|
|
14
|
-
content: {
|
|
15
|
-
type: string;
|
|
16
|
-
text: string;
|
|
17
|
-
}[];
|
|
18
|
-
isError: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
handleRecallRecent: (args: RecallRecentArgs) => {
|
|
21
|
-
content: {
|
|
22
|
-
type: string;
|
|
23
|
-
text: string;
|
|
24
|
-
}[];
|
|
25
|
-
isError: boolean;
|
|
26
|
-
};
|
|
27
|
-
handleSearch: (args: SearchArgs) => {
|
|
28
|
-
content: {
|
|
29
|
-
type: string;
|
|
30
|
-
text: string;
|
|
31
|
-
}[];
|
|
32
|
-
isError: boolean;
|
|
33
|
-
};
|
|
34
|
-
handleListTags: () => {
|
|
35
|
-
content: {
|
|
36
|
-
type: string;
|
|
37
|
-
text: string;
|
|
38
|
-
}[];
|
|
39
|
-
isError: boolean;
|
|
40
|
-
};
|
|
41
|
-
handleList: (args: RecallRecentArgs) => {
|
|
42
|
-
content: {
|
|
43
|
-
type: string;
|
|
44
|
-
text: string;
|
|
45
|
-
}[];
|
|
46
|
-
isError: boolean;
|
|
47
|
-
};
|
|
48
|
-
handleDelete: (args: DeleteArgs) => Promise<{
|
|
49
|
-
content: {
|
|
50
|
-
type: string;
|
|
51
|
-
text: string;
|
|
52
|
-
}[];
|
|
53
|
-
isError: boolean;
|
|
54
|
-
}>;
|
|
55
|
-
handleMove: (args: MoveArgs) => Promise<{
|
|
56
|
-
content: {
|
|
57
|
-
type: string;
|
|
58
|
-
text: string;
|
|
59
|
-
}[];
|
|
60
|
-
isError: boolean;
|
|
61
|
-
}>;
|
|
62
|
-
};
|
|
4
|
+
import type { Ctx } from '../types.js';
|
|
5
|
+
import type { ToolDefinition } from './types.js';
|
|
6
|
+
export declare function createMemoryTools(ctx: Ctx): ToolDefinition[];
|