daedalus-cli 0.4.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/Daedalus.bat +18 -0
- package/LICENSE +21 -0
- package/README.md +254 -0
- package/dist/agents/agent.d.ts +10 -0
- package/dist/agents/agent.d.ts.map +1 -0
- package/dist/agents/agent.js +3 -0
- package/dist/agents/agent.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +18 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +171 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/roles.d.ts +14 -0
- package/dist/agents/roles.d.ts.map +1 -0
- package/dist/agents/roles.js +126 -0
- package/dist/agents/roles.js.map +1 -0
- package/dist/config/index.d.ts +485 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +237 -0
- package/dist/config/index.js.map +1 -0
- package/dist/highlight.d.ts +4 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +42 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1386 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/fts.d.ts +40 -0
- package/dist/indexing/fts.d.ts.map +1 -0
- package/dist/indexing/fts.js +121 -0
- package/dist/indexing/fts.js.map +1 -0
- package/dist/indexing/indexer.d.ts +22 -0
- package/dist/indexing/indexer.d.ts.map +1 -0
- package/dist/indexing/indexer.js +518 -0
- package/dist/indexing/indexer.js.map +1 -0
- package/dist/onboarding/wizard.d.ts +2 -0
- package/dist/onboarding/wizard.d.ts.map +1 -0
- package/dist/onboarding/wizard.js +231 -0
- package/dist/onboarding/wizard.js.map +1 -0
- package/dist/router/health.d.ts +6 -0
- package/dist/router/health.d.ts.map +1 -0
- package/dist/router/health.js +74 -0
- package/dist/router/health.js.map +1 -0
- package/dist/router/index.d.ts +33 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +214 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/rate-limiter.d.ts +7 -0
- package/dist/router/rate-limiter.d.ts.map +1 -0
- package/dist/router/rate-limiter.js +36 -0
- package/dist/router/rate-limiter.js.map +1 -0
- package/dist/router/types.d.ts +81 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +3 -0
- package/dist/router/types.js.map +1 -0
- package/dist/session/jsonl.d.ts +20 -0
- package/dist/session/jsonl.d.ts.map +1 -0
- package/dist/session/jsonl.js +61 -0
- package/dist/session/jsonl.js.map +1 -0
- package/dist/session/manager.d.ts +42 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +184 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/memory.d.ts +23 -0
- package/dist/session/memory.d.ts.map +1 -0
- package/dist/session/memory.js +88 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/sqlite.d.ts +59 -0
- package/dist/session/sqlite.d.ts.map +1 -0
- package/dist/session/sqlite.js +174 -0
- package/dist/session/sqlite.js.map +1 -0
- package/dist/tools/builtin/delegation.d.ts +17 -0
- package/dist/tools/builtin/delegation.d.ts.map +1 -0
- package/dist/tools/builtin/delegation.js +85 -0
- package/dist/tools/builtin/delegation.js.map +1 -0
- package/dist/tools/builtin/diff-ui.d.ts +21 -0
- package/dist/tools/builtin/diff-ui.d.ts.map +1 -0
- package/dist/tools/builtin/diff-ui.js +211 -0
- package/dist/tools/builtin/diff-ui.js.map +1 -0
- package/dist/tools/builtin/files.d.ts +29 -0
- package/dist/tools/builtin/files.d.ts.map +1 -0
- package/dist/tools/builtin/files.js +286 -0
- package/dist/tools/builtin/files.js.map +1 -0
- package/dist/tools/builtin/git.d.ts +7 -0
- package/dist/tools/builtin/git.d.ts.map +1 -0
- package/dist/tools/builtin/git.js +11 -0
- package/dist/tools/builtin/git.js.map +1 -0
- package/dist/tools/builtin/indexing.d.ts +22 -0
- package/dist/tools/builtin/indexing.d.ts.map +1 -0
- package/dist/tools/builtin/indexing.js +159 -0
- package/dist/tools/builtin/indexing.js.map +1 -0
- package/dist/tools/builtin/project-config.d.ts +17 -0
- package/dist/tools/builtin/project-config.d.ts.map +1 -0
- package/dist/tools/builtin/project-config.js +66 -0
- package/dist/tools/builtin/project-config.js.map +1 -0
- package/dist/tools/builtin/terminal.d.ts +7 -0
- package/dist/tools/builtin/terminal.d.ts.map +1 -0
- package/dist/tools/builtin/terminal.js +99 -0
- package/dist/tools/builtin/terminal.js.map +1 -0
- package/dist/tools/builtin/todo.d.ts +20 -0
- package/dist/tools/builtin/todo.d.ts.map +1 -0
- package/dist/tools/builtin/todo.js +36 -0
- package/dist/tools/builtin/todo.js.map +1 -0
- package/dist/tools/builtin/web.d.ts +10 -0
- package/dist/tools/builtin/web.d.ts.map +1 -0
- package/dist/tools/builtin/web.js +67 -0
- package/dist/tools/builtin/web.js.map +1 -0
- package/dist/tools/daedalus-spinner.d.ts +29 -0
- package/dist/tools/daedalus-spinner.d.ts.map +1 -0
- package/dist/tools/daedalus-spinner.js +77 -0
- package/dist/tools/daedalus-spinner.js.map +1 -0
- package/dist/tools/definitions.d.ts +5 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +296 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/executor.d.ts +4 -0
- package/dist/tools/executor.d.ts.map +1 -0
- package/dist/tools/executor.js +86 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/mcp/http.d.ts +23 -0
- package/dist/tools/mcp/http.d.ts.map +1 -0
- package/dist/tools/mcp/http.js +200 -0
- package/dist/tools/mcp/http.js.map +1 -0
- package/dist/tools/mcp/registry.d.ts +16 -0
- package/dist/tools/mcp/registry.d.ts.map +1 -0
- package/dist/tools/mcp/registry.js +92 -0
- package/dist/tools/mcp/registry.js.map +1 -0
- package/dist/tools/mcp/stdio.d.ts +26 -0
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/mcp/stdio.js +157 -0
- package/dist/tools/mcp/stdio.js.map +1 -0
- package/dist/tools/mcp/tool-executor.d.ts +3 -0
- package/dist/tools/mcp/tool-executor.d.ts.map +1 -0
- package/dist/tools/mcp/tool-executor.js +23 -0
- package/dist/tools/mcp/tool-executor.js.map +1 -0
- package/dist/tools/mcp/types.d.ts +26 -0
- package/dist/tools/mcp/types.d.ts.map +1 -0
- package/dist/tools/mcp/types.js +3 -0
- package/dist/tools/mcp/types.js.map +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// Built-in tool definitions for OpenAI function calling
|
|
2
|
+
// These match the tool implementations in tools/builtin/
|
|
3
|
+
export const BUILTIN_TOOLS = [
|
|
4
|
+
{
|
|
5
|
+
type: 'function',
|
|
6
|
+
function: {
|
|
7
|
+
name: 'read_file',
|
|
8
|
+
description: 'Read a file with optional line range. Returns content with line numbers.',
|
|
9
|
+
parameters: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
path: { type: 'string', description: 'Absolute or relative file path' },
|
|
13
|
+
offset: { type: 'integer', description: 'Starting line number (1-indexed)', minimum: 1, default: 1 },
|
|
14
|
+
limit: { type: 'integer', description: 'Maximum lines to read', minimum: 1, maximum: 2000, default: 1000 },
|
|
15
|
+
},
|
|
16
|
+
required: ['path'],
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'function',
|
|
23
|
+
function: {
|
|
24
|
+
name: 'write_file',
|
|
25
|
+
description: 'Create or completely overwrite a file. Creates parent directories automatically.',
|
|
26
|
+
parameters: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
path: { type: 'string', description: 'Absolute or relative file path' },
|
|
30
|
+
content: { type: 'string', description: 'Complete file content to write' },
|
|
31
|
+
},
|
|
32
|
+
required: ['path', 'content'],
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'function',
|
|
39
|
+
function: {
|
|
40
|
+
name: 'patch',
|
|
41
|
+
description: 'Apply a targeted edit by replacing old_string with new_string. Use for precise changes.',
|
|
42
|
+
parameters: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
path: { type: 'string', description: 'File path to edit' },
|
|
46
|
+
old_string: { type: 'string', description: 'Exact text to find and replace (include context for uniqueness)' },
|
|
47
|
+
new_string: { type: 'string', description: 'Replacement text (empty string to delete)' },
|
|
48
|
+
replace_all: { type: 'boolean', description: 'Replace all occurrences', default: false },
|
|
49
|
+
},
|
|
50
|
+
required: ['path', 'old_string', 'new_string'],
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'function',
|
|
57
|
+
function: {
|
|
58
|
+
name: 'search_files',
|
|
59
|
+
description: 'Search file contents (ripgrep) or find files by name. Fast, regex-supported.',
|
|
60
|
+
parameters: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
pattern: { type: 'string', description: 'Regex pattern for content search, or glob for file search' },
|
|
64
|
+
target: { type: 'string', enum: ['content', 'files'], description: 'Search inside files or find files by name', default: 'content' },
|
|
65
|
+
path: { type: 'string', description: 'Directory to search in', default: '.' },
|
|
66
|
+
file_glob: { type: 'string', description: 'Filter files by glob pattern (e.g. "*.ts")' },
|
|
67
|
+
limit: { type: 'integer', description: 'Max results', minimum: 1, maximum: 200, default: 50 },
|
|
68
|
+
},
|
|
69
|
+
required: ['pattern'],
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'function',
|
|
76
|
+
function: {
|
|
77
|
+
name: 'list_files',
|
|
78
|
+
description: 'List directory tree with optional depth and glob filter.',
|
|
79
|
+
parameters: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
path: { type: 'string', description: 'Directory path', default: '.' },
|
|
83
|
+
depth: { type: 'integer', description: 'Max recursion depth', minimum: 1, maximum: 10, default: 3 },
|
|
84
|
+
glob: { type: 'string', description: 'Glob pattern to filter (e.g. "**/*.ts")' },
|
|
85
|
+
},
|
|
86
|
+
required: [],
|
|
87
|
+
additionalProperties: false,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'function',
|
|
93
|
+
function: {
|
|
94
|
+
name: 'terminal',
|
|
95
|
+
description: 'Execute a shell command. Use for builds, tests, git, package managers, etc.',
|
|
96
|
+
parameters: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {
|
|
99
|
+
command: { type: 'string', description: 'Command to execute (bash syntax)' },
|
|
100
|
+
timeout: { type: 'integer', description: 'Max seconds to wait', minimum: 1, maximum: 600, default: 180 },
|
|
101
|
+
workdir: { type: 'string', description: 'Working directory (absolute path)' },
|
|
102
|
+
},
|
|
103
|
+
required: ['command'],
|
|
104
|
+
additionalProperties: false,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'function',
|
|
110
|
+
function: {
|
|
111
|
+
name: 'git_diff',
|
|
112
|
+
description: 'Show git diff of working tree or staged changes.',
|
|
113
|
+
parameters: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
staged: { type: 'boolean', description: 'Show staged changes instead of working tree', default: false },
|
|
117
|
+
path: { type: 'string', description: 'Limit to specific file/directory' },
|
|
118
|
+
},
|
|
119
|
+
required: [],
|
|
120
|
+
additionalProperties: false,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'function',
|
|
126
|
+
function: {
|
|
127
|
+
name: 'git_status',
|
|
128
|
+
description: 'Show git repository status (staged, unstaged, untracked files).',
|
|
129
|
+
parameters: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {},
|
|
132
|
+
required: [],
|
|
133
|
+
additionalProperties: false,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'function',
|
|
139
|
+
function: {
|
|
140
|
+
name: 'todo',
|
|
141
|
+
description: 'Manage task list for the current session. Use for planning and tracking.',
|
|
142
|
+
parameters: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
todos: {
|
|
146
|
+
type: 'array',
|
|
147
|
+
description: 'Task items to write',
|
|
148
|
+
items: {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
id: { type: 'string', description: 'Unique item identifier' },
|
|
152
|
+
content: { type: 'string', description: 'Task description' },
|
|
153
|
+
status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'cancelled'], description: 'Current status' },
|
|
154
|
+
},
|
|
155
|
+
required: ['id', 'content', 'status'],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
merge: { type: 'boolean', description: 'Update existing items by id, add new ones', default: false },
|
|
159
|
+
},
|
|
160
|
+
required: ['todos'],
|
|
161
|
+
additionalProperties: false,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: 'function',
|
|
167
|
+
function: {
|
|
168
|
+
name: 'web_search',
|
|
169
|
+
description: 'Search the web for information. Returns top results with snippets.',
|
|
170
|
+
parameters: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
query: { type: 'string', description: 'Search query' },
|
|
174
|
+
limit: { type: 'integer', description: 'Max results', minimum: 1, maximum: 20, default: 10 },
|
|
175
|
+
},
|
|
176
|
+
required: ['query'],
|
|
177
|
+
additionalProperties: false,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: 'function',
|
|
183
|
+
function: {
|
|
184
|
+
name: 'fetch_url',
|
|
185
|
+
description: 'Fetch content from a URL. Returns text content and MIME type.',
|
|
186
|
+
parameters: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
url: { type: 'string', description: 'URL to fetch' },
|
|
190
|
+
timeout: { type: 'integer', description: 'Timeout in seconds', minimum: 1, maximum: 60, default: 30 },
|
|
191
|
+
},
|
|
192
|
+
required: ['url'],
|
|
193
|
+
additionalProperties: false,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
type: 'function',
|
|
199
|
+
function: {
|
|
200
|
+
name: 'delegate_task',
|
|
201
|
+
description: 'Spawn a sub-agent to work on a subtask. Use for parallel workstreams.',
|
|
202
|
+
parameters: {
|
|
203
|
+
type: 'object',
|
|
204
|
+
properties: {
|
|
205
|
+
goal: { type: 'string', description: 'What the sub-agent should accomplish' },
|
|
206
|
+
context: { type: 'string', description: 'Background information the sub-agent needs' },
|
|
207
|
+
role: { type: 'string', description: 'Agent role: coder, reviewer, debugger, researcher, planner', enum: ['coder', 'reviewer', 'debugger', 'researcher', 'planner'] },
|
|
208
|
+
toolsets: { type: 'array', items: { type: 'string' }, description: 'Toolsets to enable for this sub-agent' },
|
|
209
|
+
},
|
|
210
|
+
required: ['goal'],
|
|
211
|
+
additionalProperties: false,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
type: 'function',
|
|
217
|
+
function: {
|
|
218
|
+
name: 'index_codebase',
|
|
219
|
+
description: 'Analyze and index codebase symbols and references.',
|
|
220
|
+
parameters: {
|
|
221
|
+
type: 'object',
|
|
222
|
+
properties: {
|
|
223
|
+
exclude: { type: 'array', items: { type: 'string' }, description: 'Directories to exclude' },
|
|
224
|
+
extensions: { type: 'array', items: { type: 'string' }, description: 'File extensions to index' },
|
|
225
|
+
},
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
type: 'function',
|
|
232
|
+
function: {
|
|
233
|
+
name: 'find_symbol',
|
|
234
|
+
description: 'Fuzzy search code symbols (classes, functions, etc.) in the codebase using FTS5.',
|
|
235
|
+
parameters: {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
query: { type: 'string', description: 'Fuzzy search query term' },
|
|
239
|
+
limit: { type: 'integer', description: 'Max search results', minimum: 1, maximum: 100, default: 30 },
|
|
240
|
+
},
|
|
241
|
+
required: ['query'],
|
|
242
|
+
additionalProperties: false,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
type: 'function',
|
|
248
|
+
function: {
|
|
249
|
+
name: 'get_definition',
|
|
250
|
+
description: 'Retrieve the file path, line range, and signature for a symbol declaration by exact name.',
|
|
251
|
+
parameters: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
name: { type: 'string', description: 'Exact symbol name' },
|
|
255
|
+
},
|
|
256
|
+
required: ['name'],
|
|
257
|
+
additionalProperties: false,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: 'function',
|
|
263
|
+
function: {
|
|
264
|
+
name: 'get_references',
|
|
265
|
+
description: 'Retrieve all caller locations referencing a symbol name.',
|
|
266
|
+
parameters: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
name: { type: 'string', description: 'Symbol name to find calls to' },
|
|
270
|
+
},
|
|
271
|
+
required: ['name'],
|
|
272
|
+
additionalProperties: false,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
// Tool name to implementation function mapping
|
|
278
|
+
export const TOOL_IMPLEMENTATIONS = {
|
|
279
|
+
read_file: 'tools/builtin/files.readFile',
|
|
280
|
+
write_file: 'tools/builtin/files.writeFile',
|
|
281
|
+
patch: 'tools/builtin/files.patchFile',
|
|
282
|
+
search_files: 'tools/builtin/files.searchFiles',
|
|
283
|
+
list_files: 'tools/builtin/files.listFiles',
|
|
284
|
+
terminal: 'tools/builtin/terminal.execute',
|
|
285
|
+
git_diff: 'tools/builtin/git.diff',
|
|
286
|
+
git_status: 'tools/builtin/git.status',
|
|
287
|
+
todo: 'tools/builtin/todo.manage',
|
|
288
|
+
web_search: 'tools/builtin/web.search',
|
|
289
|
+
fetch_url: 'tools/builtin/web.fetchUrl',
|
|
290
|
+
delegate_task: 'tools/builtin/delegation.manage',
|
|
291
|
+
index_codebase: 'tools/builtin/indexing.index_codebase',
|
|
292
|
+
find_symbol: 'tools/builtin/indexing.find_symbol',
|
|
293
|
+
get_definition: 'tools/builtin/indexing.get_definition',
|
|
294
|
+
get_references: 'tools/builtin/indexing.get_references',
|
|
295
|
+
};
|
|
296
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yDAAyD;AAMzD,MAAM,CAAC,MAAM,aAAa,GAAqB;IAC7C;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,0EAA0E;YACvF,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;oBACvE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,kCAAkC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;oBACpG,KAAK,EAAE,EAAE,IAAI,EAAE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E,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;iBAC3D;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;gBAClB,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,0DAA0D;YACvE,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8BAA8B,EAAE;iBACtE;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;gBAClB,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;CACF,CAAC;AAEF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,SAAS,EAAE,8BAA8B;IACzC,UAAU,EAAE,+BAA+B;IAC3C,KAAK,EAAE,+BAA+B;IACtC,YAAY,EAAE,iCAAiC;IAC/C,UAAU,EAAE,+BAA+B;IAC3C,QAAQ,EAAE,gCAAgC;IAC1C,QAAQ,EAAE,wBAAwB;IAClC,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,2BAA2B;IACjC,UAAU,EAAE,0BAA0B;IACtC,SAAS,EAAE,4BAA4B;IACvC,aAAa,EAAE,iCAAiC;IAChD,cAAc,EAAE,uCAAuC;IACvD,WAAW,EAAE,oCAAoC;IACjD,cAAc,EAAE,uCAAuC;IACvD,cAAc,EAAE,uCAAuC;CACxD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ToolContext, ToolResult, ToolCall } from '../types.js';
|
|
2
|
+
export declare function executeToolCall(toolCall: ToolCall, context: ToolContext): Promise<ToolResult>;
|
|
3
|
+
export declare function executeToolCalls(toolCalls: ToolCall[], context: ToolContext): Promise<ToolResult[]>;
|
|
4
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/tools/executor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAoBhE,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAoErB;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,EAAE,CAAC,CAGvB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Tool executor - loads and executes tool implementations
|
|
2
|
+
import { TOOL_IMPLEMENTATIONS } from './definitions.js';
|
|
3
|
+
import { executeMCPTool } from './mcp/tool-executor.js';
|
|
4
|
+
const implementationCache = new Map();
|
|
5
|
+
async function loadImplementation(modulePath) {
|
|
6
|
+
if (implementationCache.has(modulePath)) {
|
|
7
|
+
return implementationCache.get(modulePath);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const mod = await import(modulePath);
|
|
11
|
+
implementationCache.set(modulePath, mod);
|
|
12
|
+
return mod;
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
throw new Error(`Failed to load tool implementation ${modulePath}: ${err.message}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function executeToolCall(toolCall, context) {
|
|
19
|
+
const toolName = toolCall.function.name;
|
|
20
|
+
// Handle MCP tools (prefixed with mcp_)
|
|
21
|
+
if (toolName.startsWith('mcp_')) {
|
|
22
|
+
return executeMCPTool(toolName, JSON.parse(toolCall.function.arguments), context);
|
|
23
|
+
}
|
|
24
|
+
const implPath = TOOL_IMPLEMENTATIONS[toolName];
|
|
25
|
+
if (!implPath) {
|
|
26
|
+
return {
|
|
27
|
+
toolCallId: toolCall.id,
|
|
28
|
+
name: toolName,
|
|
29
|
+
success: false,
|
|
30
|
+
content: '',
|
|
31
|
+
error: `Unknown tool: ${toolName}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
let args;
|
|
35
|
+
try {
|
|
36
|
+
args = JSON.parse(toolCall.function.arguments);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
toolCallId: toolCall.id,
|
|
41
|
+
name: toolName,
|
|
42
|
+
success: false,
|
|
43
|
+
content: '',
|
|
44
|
+
error: `Invalid tool arguments JSON: ${err.message}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const lastDot = implPath.lastIndexOf('.');
|
|
48
|
+
const moduleName = lastDot === -1 ? implPath : implPath.substring(0, lastDot);
|
|
49
|
+
const functionName = lastDot === -1 ? '' : implPath.substring(lastDot + 1);
|
|
50
|
+
// Convert 'tools/builtin/files' to './builtin/files.js'
|
|
51
|
+
let relativePath = moduleName;
|
|
52
|
+
if (relativePath.startsWith('tools/')) {
|
|
53
|
+
relativePath = './' + relativePath.substring(6) + '.js';
|
|
54
|
+
}
|
|
55
|
+
else if (!relativePath.startsWith('.') && !relativePath.startsWith('/')) {
|
|
56
|
+
relativePath = './' + relativePath + '.js';
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const mod = await loadImplementation(relativePath);
|
|
60
|
+
// Find the exported function
|
|
61
|
+
const fn = (functionName ? mod[functionName] : null) ?? mod.default ?? mod[toolName] ?? Object.values(mod)[0];
|
|
62
|
+
if (typeof fn !== 'function') {
|
|
63
|
+
throw new Error(`No executable function found in ${relativePath}`);
|
|
64
|
+
}
|
|
65
|
+
const result = await fn(args, context);
|
|
66
|
+
return {
|
|
67
|
+
...result,
|
|
68
|
+
toolCallId: toolCall.id,
|
|
69
|
+
name: toolName,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
return {
|
|
74
|
+
toolCallId: toolCall.id,
|
|
75
|
+
name: toolName,
|
|
76
|
+
success: false,
|
|
77
|
+
content: '',
|
|
78
|
+
error: `Tool execution failed: ${err.message}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function executeToolCalls(toolCalls, context) {
|
|
83
|
+
// Execute in parallel for independent calls
|
|
84
|
+
return Promise.all(toolCalls.map(tc => executeToolCall(tc, context)));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/tools/executor.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAG1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAe,CAAC;AAEnD,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IAClD,IAAI,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACxC,OAAO,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QACrC,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAkB,EAClB,OAAoB;IAEpB,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IAExC,wCAAwC;IACxC,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;Q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AEpB,4CAA4C;IAC5C,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MCPTransport, MCPServerConfig } from './types.js';
|
|
2
|
+
export declare class HttpTransport implements MCPTransport {
|
|
3
|
+
private config;
|
|
4
|
+
private messageHandler;
|
|
5
|
+
private errorHandler;
|
|
6
|
+
private sseClient;
|
|
7
|
+
private requestId;
|
|
8
|
+
private pendingRequests;
|
|
9
|
+
constructor(config: MCPServerConfig);
|
|
10
|
+
connect(): Promise<void>;
|
|
11
|
+
private nextId;
|
|
12
|
+
private handleMessage;
|
|
13
|
+
private sendPOST;
|
|
14
|
+
send(message: any): Promise<void>;
|
|
15
|
+
sendAndWait(message: any): Promise<any>;
|
|
16
|
+
listTools(): Promise<any[]>;
|
|
17
|
+
callTool(name: string, args: any): Promise<any>;
|
|
18
|
+
onMessage(handler: (message: any) => void): void;
|
|
19
|
+
onClose(_handler: () => void): void;
|
|
20
|
+
onError(handler: (error: Error) => void): void;
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA+E3D,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAA8C;gBAEzD,MAAM,EAAE,eAAe;IAI7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC9B,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,aAAa;YAUP,QAAQ;IAmBhB,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,WAAW,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAiBvC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAQ3B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAYrD,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAIhD,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAInC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAIxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAMlC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// MCP HTTP/SSE Transport
|
|
2
|
+
// Uses native Node.js fetch + ReadableStream for SSE — no EventSource polyfill needed.
|
|
3
|
+
class SSEClient {
|
|
4
|
+
url;
|
|
5
|
+
abortController = new AbortController();
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
_readyState = 0; // 0=connecting, 1=open, 2=closed
|
|
8
|
+
constructor(url) {
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.connect();
|
|
11
|
+
}
|
|
12
|
+
get readyState() { return this._readyState; }
|
|
13
|
+
async connect() {
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(this.url, {
|
|
16
|
+
signal: this.abortController.signal,
|
|
17
|
+
headers: { 'Accept': 'text/event-stream', 'Cache-Control': 'no-cache' },
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok)
|
|
20
|
+
throw new Error(`SSE HTTP ${response.status}`);
|
|
21
|
+
if (!response.body)
|
|
22
|
+
throw new Error('No response body');
|
|
23
|
+
this._readyState = 1;
|
|
24
|
+
const reader = response.body.getReader();
|
|
25
|
+
const decoder = new TextDecoder();
|
|
26
|
+
let buffer = '';
|
|
27
|
+
while (true) {
|
|
28
|
+
const { done, value } = await reader.read();
|
|
29
|
+
if (done)
|
|
30
|
+
break;
|
|
31
|
+
buffer += decoder.decode(value, { stream: true });
|
|
32
|
+
const parts = buffer.split('\n');
|
|
33
|
+
buffer = parts.pop() || '';
|
|
34
|
+
let data = '';
|
|
35
|
+
for (const line of parts) {
|
|
36
|
+
if (line.startsWith('data: ')) {
|
|
37
|
+
data += line.slice(6);
|
|
38
|
+
}
|
|
39
|
+
else if (line === '' && data) {
|
|
40
|
+
this.dispatch('message', { data });
|
|
41
|
+
data = '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (err.name !== 'AbortError') {
|
|
48
|
+
this.dispatch('error', { data: err.message });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
this._readyState = 2;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
dispatch(type, event) {
|
|
56
|
+
const handlers = this.handlers.get(type);
|
|
57
|
+
if (handlers)
|
|
58
|
+
handlers.forEach(h => h(event));
|
|
59
|
+
}
|
|
60
|
+
get onmessage() { return (this.handlers.get('message')?.[0]) ?? null; }
|
|
61
|
+
set onmessage(handler) {
|
|
62
|
+
if (handler)
|
|
63
|
+
this.handlers.set('message', [handler]);
|
|
64
|
+
else
|
|
65
|
+
this.handlers.delete('message');
|
|
66
|
+
}
|
|
67
|
+
get onerror() { return (this.handlers.get('error')?.[0]) ?? null; }
|
|
68
|
+
set onerror(handler) {
|
|
69
|
+
if (handler)
|
|
70
|
+
this.handlers.set('error', [handler]);
|
|
71
|
+
else
|
|
72
|
+
this.handlers.delete('error');
|
|
73
|
+
}
|
|
74
|
+
close() {
|
|
75
|
+
this.abortController.abort();
|
|
76
|
+
this._readyState = 2;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class HttpTransport {
|
|
80
|
+
config;
|
|
81
|
+
messageHandler = null;
|
|
82
|
+
errorHandler = null;
|
|
83
|
+
sseClient = null;
|
|
84
|
+
requestId = 0;
|
|
85
|
+
pendingRequests = new Map();
|
|
86
|
+
constructor(config) {
|
|
87
|
+
this.config = config;
|
|
88
|
+
}
|
|
89
|
+
async connect() {
|
|
90
|
+
if (!this.config.url) {
|
|
91
|
+
throw new Error('HTTP transport requires url');
|
|
92
|
+
}
|
|
93
|
+
this.sseClient = new SSEClient(this.config.url);
|
|
94
|
+
this.sseClient.onmessage = (event) => {
|
|
95
|
+
try {
|
|
96
|
+
const message = JSON.parse(event.data);
|
|
97
|
+
this.handleMessage(message);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
console.error(`[MCP:${this.config.name}] Failed to parse SSE: ${event.data.slice(0, 200)}`);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
this.sseClient.onerror = (event) => {
|
|
104
|
+
this.errorHandler?.(new Error(event.data || 'SSE connection error'));
|
|
105
|
+
};
|
|
106
|
+
await this.sendPOST({
|
|
107
|
+
jsonrpc: '2.0',
|
|
108
|
+
id: this.nextId(),
|
|
109
|
+
method: 'initialize',
|
|
110
|
+
params: {
|
|
111
|
+
protocolVersion: '2024-11-05',
|
|
112
|
+
capabilities: {},
|
|
113
|
+
clientInfo: { name: 'daedalus-cli', version: '0.1.0' },
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
await this.sendPOST({
|
|
117
|
+
jsonrpc: '2.0',
|
|
118
|
+
method: 'notifications/initialized',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
nextId() {
|
|
122
|
+
return ++this.requestId;
|
|
123
|
+
}
|
|
124
|
+
handleMessage(message) {
|
|
125
|
+
if (message.id !== undefined && this.pendingRequests.has(message.id)) {
|
|
126
|
+
const resolver = this.pendingRequests.get(message.id);
|
|
127
|
+
this.pendingRequests.delete(message.id);
|
|
128
|
+
resolver(message);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.messageHandler?.(message);
|
|
132
|
+
}
|
|
133
|
+
async sendPOST(message) {
|
|
134
|
+
if (!this.config.url)
|
|
135
|
+
throw new Error('Not connected');
|
|
136
|
+
const res = await fetch(this.config.url, {
|
|
137
|
+
method: 'POST',
|
|
138
|
+
headers: {
|
|
139
|
+
'Content-Type': 'application/json',
|
|
140
|
+
...this.config.headers,
|
|
141
|
+
},
|
|
142
|
+
body: JSON.stringify(message),
|
|
143
|
+
});
|
|
144
|
+
if (!res.ok) {
|
|
145
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
146
|
+
}
|
|
147
|
+
return res.json();
|
|
148
|
+
}
|
|
149
|
+
async send(message) {
|
|
150
|
+
await this.sendPOST(message);
|
|
151
|
+
}
|
|
152
|
+
async sendAndWait(message) {
|
|
153
|
+
const id = this.nextId();
|
|
154
|
+
const msgWithId = { ...message, id };
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
this.pendingRequests.set(id, resolve);
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
if (this.pendingRequests.has(id)) {
|
|
159
|
+
this.pendingRequests.delete(id);
|
|
160
|
+
reject(new Error('Request timeout'));
|
|
161
|
+
}
|
|
162
|
+
}, 30000);
|
|
163
|
+
this.sendPOST(msgWithId);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async listTools() {
|
|
167
|
+
const response = await this.sendAndWait({
|
|
168
|
+
jsonrpc: '2.0',
|
|
169
|
+
method: 'tools/list',
|
|
170
|
+
});
|
|
171
|
+
return response.result?.tools || [];
|
|
172
|
+
}
|
|
173
|
+
async callTool(name, args) {
|
|
174
|
+
const response = await this.sendAndWait({
|
|
175
|
+
jsonrpc: '2.0',
|
|
176
|
+
method: 'tools/call',
|
|
177
|
+
params: { name, arguments: args },
|
|
178
|
+
});
|
|
179
|
+
if (response.error) {
|
|
180
|
+
throw new Error(response.error.message);
|
|
181
|
+
}
|
|
182
|
+
return response.result;
|
|
183
|
+
}
|
|
184
|
+
onMessage(handler) {
|
|
185
|
+
this.messageHandler = handler;
|
|
186
|
+
}
|
|
187
|
+
onClose(_handler) {
|
|
188
|
+
// SSE auto-reconnects; close detection would need heartbeat
|
|
189
|
+
}
|
|
190
|
+
onError(handler) {
|
|
191
|
+
this.errorHandler = handler;
|
|
192
|
+
}
|
|
193
|
+
async disconnect() {
|
|
194
|
+
if (this.sseClient) {
|
|
195
|
+
this.sseClient.close();
|
|
196
|
+
this.sseClient = null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/tools/mcp/http.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,uFAAuF;AAIvF,MAAM,SAAS;IACL,GAAG,CAAS;IACZ,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,QAAQ,GAAG,IAAI,GAAG,EAAiD,CAAC;IACpE,WAAW,GAAW,CAAC,CAAC,CAAC,iCAAiC;IAElE,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,IAAI,UAAU,KAAK,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAErC,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;gBACrC,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM;gBACnC,OAAO,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE;aACxE,C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