@semalt-ai/code 1.8.0 → 1.8.3

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.
@@ -0,0 +1,499 @@
1
+ 'use strict';
2
+
3
+ // TOOL_SPECS — parameter source of truth for every 'tool'-type tag in
4
+ // TAG_REGISTRY (see lib/constants.js). Each entry is an OpenAI-format
5
+ // JSON Schema describing the tool's arguments. This file exists so that:
6
+ //
7
+ // 1. A native function-calling `tools` array can be generated verbatim.
8
+ // 2. The non-native system prompt (lib/prompts.js) can render clean tag
9
+ // documentation from a single source.
10
+ // 3. Tool call arguments can eventually be validated before execution.
11
+ //
12
+ // Parameter names, required flags, and types were reverse-engineered from
13
+ // lib/tools.js — specifically the `agentExecFile` / `agentExecShell`
14
+ // branches and the `mapInvokeToCall` name→positional-args mapping. If
15
+ // those change, this file must change in lockstep.
16
+ //
17
+ // Wrappers (minimax:tool_call, qwen:tool_call, tool_call, function_call,
18
+ // function) carry `wrapper: true`. They are not tools themselves — they
19
+ // are XML envelopes the StreamParser recognises so raw tool-call markup
20
+ // does not leak into the rendered transcript. They should NOT be emitted
21
+ // as tools in a native function-calling request.
22
+
23
+ const TOOL_SPECS = {
24
+ exec: {
25
+ description: 'Run a shell command and return its stdout, stderr, and exit code.',
26
+ parameters: {
27
+ type: 'object',
28
+ properties: {
29
+ command: {
30
+ type: 'string',
31
+ description: 'Shell command to execute; runs through the default system shell',
32
+ },
33
+ },
34
+ required: ['command'],
35
+ },
36
+ },
37
+
38
+ shell: {
39
+ description: 'Run a shell command and return its stdout, stderr, and exit code.',
40
+ parameters: {
41
+ type: 'object',
42
+ properties: {
43
+ command: {
44
+ type: 'string',
45
+ description: 'Shell command to execute; runs through the default system shell',
46
+ },
47
+ },
48
+ required: ['command'],
49
+ },
50
+ },
51
+
52
+ read_file: {
53
+ description: 'Read a UTF-8 text file and return its full contents.',
54
+ parameters: {
55
+ type: 'object',
56
+ properties: {
57
+ path: {
58
+ type: 'string',
59
+ description: 'Absolute or relative path to the file to read',
60
+ },
61
+ },
62
+ required: ['path'],
63
+ },
64
+ },
65
+
66
+ write_file: {
67
+ description: 'Write a file, creating it and any missing parent directories; overwrites existing content.',
68
+ parameters: {
69
+ type: 'object',
70
+ properties: {
71
+ path: {
72
+ type: 'string',
73
+ description: 'Absolute or relative path to the file to write',
74
+ },
75
+ content: {
76
+ type: 'string',
77
+ description: 'Full UTF-8 text to write as the new file contents',
78
+ },
79
+ },
80
+ required: ['path', 'content'],
81
+ },
82
+ },
83
+
84
+ create_file: {
85
+ description: 'Create a new file with the given contents; identical behavior to write_file (creates parents, overwrites if present).',
86
+ parameters: {
87
+ type: 'object',
88
+ properties: {
89
+ path: {
90
+ type: 'string',
91
+ description: 'Absolute or relative path where the file should be created',
92
+ },
93
+ content: {
94
+ type: 'string',
95
+ description: 'Full UTF-8 text to write as the initial file contents',
96
+ },
97
+ },
98
+ required: ['path', 'content'],
99
+ },
100
+ },
101
+
102
+ append_file: {
103
+ description: 'Append text to the end of a file, creating it and any missing parent directories if needed.',
104
+ parameters: {
105
+ type: 'object',
106
+ properties: {
107
+ path: {
108
+ type: 'string',
109
+ description: 'Absolute or relative path to the file to append to',
110
+ },
111
+ content: {
112
+ type: 'string',
113
+ description: 'UTF-8 text to append to the end of the file',
114
+ },
115
+ },
116
+ required: ['path', 'content'],
117
+ },
118
+ },
119
+
120
+ delete_file: {
121
+ description: 'Delete a single file at the given path.',
122
+ parameters: {
123
+ type: 'object',
124
+ properties: {
125
+ path: {
126
+ type: 'string',
127
+ description: 'Absolute or relative path to the file to delete',
128
+ },
129
+ },
130
+ required: ['path'],
131
+ },
132
+ },
133
+
134
+ list_dir: {
135
+ description: 'List the entries of a directory, tagging each as file, directory, or symlink.',
136
+ parameters: {
137
+ type: 'object',
138
+ properties: {
139
+ path: {
140
+ type: 'string',
141
+ description: 'Absolute or relative path to the directory to list; defaults to the current working directory',
142
+ default: '.',
143
+ },
144
+ },
145
+ required: [],
146
+ },
147
+ },
148
+
149
+ make_dir: {
150
+ description: 'Create a directory, including any missing parent directories.',
151
+ parameters: {
152
+ type: 'object',
153
+ properties: {
154
+ path: {
155
+ type: 'string',
156
+ description: 'Absolute or relative path of the directory to create',
157
+ },
158
+ },
159
+ required: ['path'],
160
+ },
161
+ },
162
+
163
+ remove_dir: {
164
+ description: 'Recursively remove a directory and all of its contents.',
165
+ parameters: {
166
+ type: 'object',
167
+ properties: {
168
+ path: {
169
+ type: 'string',
170
+ description: 'Absolute or relative path of the directory to remove',
171
+ },
172
+ },
173
+ required: ['path'],
174
+ },
175
+ },
176
+
177
+ move_file: {
178
+ description: 'Move or rename a file or directory; falls back to copy-then-delete across filesystems.',
179
+ parameters: {
180
+ type: 'object',
181
+ properties: {
182
+ src: {
183
+ type: 'string',
184
+ description: 'Current absolute or relative path of the file or directory to move',
185
+ },
186
+ dst: {
187
+ type: 'string',
188
+ description: 'Destination absolute or relative path; parent directories are created if missing',
189
+ },
190
+ },
191
+ required: ['src', 'dst'],
192
+ },
193
+ },
194
+
195
+ copy_file: {
196
+ description: 'Copy a file or directory recursively to a new location.',
197
+ parameters: {
198
+ type: 'object',
199
+ properties: {
200
+ src: {
201
+ type: 'string',
202
+ description: 'Absolute or relative path of the source file or directory',
203
+ },
204
+ dst: {
205
+ type: 'string',
206
+ description: 'Destination absolute or relative path; parent directories are created if missing',
207
+ },
208
+ },
209
+ required: ['src', 'dst'],
210
+ },
211
+ },
212
+
213
+ file_stat: {
214
+ description: 'Return metadata for a path: size in KB, modification time, type (file/directory/symlink), and mode.',
215
+ parameters: {
216
+ type: 'object',
217
+ properties: {
218
+ path: {
219
+ type: 'string',
220
+ description: 'Absolute or relative path of the file or directory to inspect',
221
+ },
222
+ },
223
+ required: ['path'],
224
+ },
225
+ },
226
+
227
+ edit_file: {
228
+ description: 'Replace the contents of a single line in a file, identified by 1-based line number.',
229
+ parameters: {
230
+ type: 'object',
231
+ properties: {
232
+ path: {
233
+ type: 'string',
234
+ description: 'Absolute or relative path of the file to edit',
235
+ },
236
+ line: {
237
+ type: 'integer',
238
+ description: '1-based line number of the line to replace',
239
+ minimum: 1,
240
+ },
241
+ content: {
242
+ type: 'string',
243
+ description: 'New text for the target line; trailing newline is added automatically when the file is rejoined',
244
+ },
245
+ },
246
+ required: ['path', 'line', 'content'],
247
+ },
248
+ },
249
+
250
+ search_files: {
251
+ description: 'Recursively find files whose name or relative path matches a glob pattern.',
252
+ parameters: {
253
+ type: 'object',
254
+ properties: {
255
+ pattern: {
256
+ type: 'string',
257
+ description: 'Glob pattern such as "*.ts" or "src/**/*.js"; matches against the basename when the pattern contains no slash, otherwise against the relative path',
258
+ },
259
+ dir: {
260
+ type: 'string',
261
+ description: 'Root directory to search from; defaults to the current working directory',
262
+ default: '.',
263
+ },
264
+ },
265
+ required: ['pattern'],
266
+ },
267
+ },
268
+
269
+ search_in_file: {
270
+ description: 'Search for a regular-expression pattern inside a file and return each matching line with its 1-based line number.',
271
+ parameters: {
272
+ type: 'object',
273
+ properties: {
274
+ path: {
275
+ type: 'string',
276
+ description: 'Absolute or relative path of the file to search',
277
+ },
278
+ pattern: {
279
+ type: 'string',
280
+ description: 'JavaScript-style regular expression to match against each line',
281
+ },
282
+ },
283
+ required: ['path', 'pattern'],
284
+ },
285
+ },
286
+
287
+ replace_in_file: {
288
+ description: 'Regex-replace occurrences of a pattern in a file; returns the number of replacements made.',
289
+ parameters: {
290
+ type: 'object',
291
+ properties: {
292
+ path: {
293
+ type: 'string',
294
+ description: 'Absolute or relative path of the file to modify',
295
+ },
296
+ search: {
297
+ type: 'string',
298
+ description: 'JavaScript regular-expression pattern to search for',
299
+ },
300
+ replace: {
301
+ type: 'string',
302
+ description: 'Replacement string; supports the standard $1, $2, $& back-references',
303
+ },
304
+ flags: {
305
+ type: 'string',
306
+ description: 'Regex flags, any combination of g/i/m/s/u/y; the "g" flag is added automatically if omitted',
307
+ default: '',
308
+ },
309
+ },
310
+ required: ['path', 'search', 'replace'],
311
+ },
312
+ },
313
+
314
+ get_env: {
315
+ description: 'Read a single environment variable from the current process and return its value (or null if unset).',
316
+ parameters: {
317
+ type: 'object',
318
+ properties: {
319
+ name: {
320
+ type: 'string',
321
+ description: 'Name of the environment variable to read',
322
+ },
323
+ },
324
+ required: ['name'],
325
+ },
326
+ },
327
+
328
+ set_env: {
329
+ description: 'Set an environment variable for the current agent process; does not affect the parent shell.',
330
+ parameters: {
331
+ type: 'object',
332
+ properties: {
333
+ name: {
334
+ type: 'string',
335
+ description: 'Name of the environment variable to set',
336
+ },
337
+ value: {
338
+ type: 'string',
339
+ description: 'Value to assign to the environment variable; defaults to an empty string',
340
+ default: '',
341
+ },
342
+ },
343
+ required: ['name'],
344
+ },
345
+ },
346
+
347
+ download: {
348
+ description: 'Download a URL over HTTP(S) and save it to a file in the current working directory, following redirects.',
349
+ parameters: {
350
+ type: 'object',
351
+ properties: {
352
+ url: {
353
+ type: 'string',
354
+ description: 'HTTP or HTTPS URL to download',
355
+ },
356
+ },
357
+ required: ['url'],
358
+ },
359
+ },
360
+
361
+ upload: {
362
+ description: 'Write base64-encoded content to a local file, creating any missing parent directories.',
363
+ parameters: {
364
+ type: 'object',
365
+ properties: {
366
+ path: {
367
+ type: 'string',
368
+ description: 'Absolute or relative path of the destination file',
369
+ },
370
+ content: {
371
+ type: 'string',
372
+ description: 'Base64-encoded payload to decode and write as the file contents',
373
+ },
374
+ },
375
+ required: ['path', 'content'],
376
+ },
377
+ },
378
+
379
+ http_get: {
380
+ description: 'Perform an HTTP GET and return the response status code and body, truncated to a configured byte cap.',
381
+ parameters: {
382
+ type: 'object',
383
+ properties: {
384
+ url: {
385
+ type: 'string',
386
+ description: 'HTTP or HTTPS URL to fetch',
387
+ },
388
+ },
389
+ required: ['url'],
390
+ },
391
+ },
392
+
393
+ ask_user: {
394
+ description: 'Prompt the interactive user for input and return their answer; auto-answers "y" in non-TTY mode.',
395
+ parameters: {
396
+ type: 'object',
397
+ properties: {
398
+ question: {
399
+ type: 'string',
400
+ description: 'Question text to show the user; if the text contains a numbered list, it renders as a selectable menu',
401
+ },
402
+ },
403
+ required: ['question'],
404
+ },
405
+ },
406
+
407
+ store_memory: {
408
+ description: 'Persist a key/value pair to the agent\'s local memory store at ~/.semalt-ai/memory.json.',
409
+ parameters: {
410
+ type: 'object',
411
+ properties: {
412
+ key: {
413
+ type: 'string',
414
+ description: 'Memory key under which to store the value',
415
+ },
416
+ value: {
417
+ type: 'string',
418
+ description: 'Value to associate with the key; defaults to an empty string',
419
+ default: '',
420
+ },
421
+ },
422
+ required: ['key'],
423
+ },
424
+ },
425
+
426
+ recall_memory: {
427
+ description: 'Read a previously stored value from the local memory store by key.',
428
+ parameters: {
429
+ type: 'object',
430
+ properties: {
431
+ key: {
432
+ type: 'string',
433
+ description: 'Memory key to look up',
434
+ },
435
+ },
436
+ required: ['key'],
437
+ },
438
+ },
439
+
440
+ list_memories: {
441
+ description: 'List all keys currently present in the local memory store.',
442
+ parameters: {
443
+ type: 'object',
444
+ properties: {},
445
+ required: [],
446
+ },
447
+ },
448
+
449
+ system_info: {
450
+ description: 'Return information about the host: platform, arch, hostname, total/free memory, Node version, and current working directory.',
451
+ parameters: {
452
+ type: 'object',
453
+ properties: {},
454
+ required: [],
455
+ },
456
+ },
457
+
458
+ // ──────────────────────────────────────────────────────────────────
459
+ // Parser-wrapper tags. These are XML envelopes that carry other tool
460
+ // calls; they are not invocable tools themselves. Entries exist only
461
+ // so the TAG_REGISTRY ↔ TOOL_SPECS parity assertion in constants.js
462
+ // passes. Generators producing a native `tools` array MUST filter on
463
+ // `wrapper === true` and skip these.
464
+ // ──────────────────────────────────────────────────────────────────
465
+
466
+ 'minimax:tool_call': {
467
+ wrapper: true,
468
+ description: 'Parser envelope for MiniMax-M2 native tool calls; contains one or more <invoke name="…"> children. Not a callable tool.',
469
+ parameters: { type: 'object', properties: {}, required: [] },
470
+ },
471
+
472
+ 'qwen:tool_call': {
473
+ wrapper: true,
474
+ description: 'Parser envelope for Qwen-family native tool calls; contains an <invoke> child or a JSON {name, arguments} body. Not a callable tool.',
475
+ parameters: { type: 'object', properties: {}, required: [] },
476
+ },
477
+
478
+ tool_call: {
479
+ wrapper: true,
480
+ description: 'Parser envelope for Hermes/Qwen JSON tool calls of the form {"name":"…","arguments":{…}}. Not a callable tool.',
481
+ parameters: { type: 'object', properties: {}, required: [] },
482
+ },
483
+
484
+ function_call: {
485
+ wrapper: true,
486
+ description: 'Alternate spelling of <tool_call> used by some Qwen finetunes; same JSON body shape. Not a callable tool.',
487
+ parameters: { type: 'object', properties: {}, required: [] },
488
+ },
489
+
490
+ function: {
491
+ wrapper: true,
492
+ description: 'Parser envelope for the Qwen3-Coder XML tool-call format <function=tool_name>…</function>. The tool name travels as an =suffix on the opening tag. Not a callable tool.',
493
+ parameters: { type: 'object', properties: {}, required: [] },
494
+ },
495
+ };
496
+
497
+ module.exports = {
498
+ TOOL_SPECS,
499
+ };