@swifty.js/swifty 0.0.30 → 0.0.31
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 +14 -0
- package/dist/agent-O6C4FCQY.js +4 -0
- package/dist/anthropic-CFM2DXMB.js +4 -0
- package/dist/checker-A6PGACKZ.js +4 -0
- package/dist/chunk-4ABFUBO4.js +601 -0
- package/dist/{chunk-K5ZK27BX.js → chunk-AGJYBJ5M.js} +1 -1
- package/dist/chunk-MVVSONAE.js +4 -0
- package/dist/chunk-OQCEP2F5.js +4 -0
- package/dist/{chunk-QFSCPD63.js → chunk-TCQ4EB4G.js} +1 -1
- package/dist/chunk-Y2UUXOQA.js +4 -0
- package/dist/chunk-YAXZ2OUD.js +150 -0
- package/dist/lib/agent-YRTROHXU.js +10 -0
- package/dist/lib/{anthropic-CL5IK7KN.js → anthropic-R6DMXE7U.js} +3 -4
- package/dist/lib/{checker-BS4MK3O6.js → checker-M7RKMKJQ.js} +2 -3
- package/dist/lib/{chunk-IYPTOY3Y.js → chunk-4MDCRPVV.js} +35 -26
- package/dist/lib/{chunk-RMB3J46W.js → chunk-A4MXZA5Q.js} +197 -36
- package/dist/lib/{chunk-7QPDFSQE.js → chunk-EWE5IWZE.js} +20 -10
- package/dist/lib/{chunk-KG4MJGKQ.js → chunk-FZ4Y6MBN.js} +1 -4
- package/dist/lib/{chunk-OOSNCCI7.js → chunk-J6AV7SIF.js} +143 -148
- package/dist/lib/{chunk-I7OPU4K2.js → chunk-OEPCNATU.js} +192 -32
- package/dist/lib/{chunk-PIL7M52F.js → chunk-XT67KGWE.js} +16 -3
- package/dist/lib/index.d.ts +856 -778
- package/dist/lib/index.js +2261 -749
- package/dist/lib/{openai-LH4E7ZQS.js → openai-5N42ZYIJ.js} +1 -1
- package/dist/lib/{tool-filter-CS6W2GMU.js → tool-filter-XG2GXFVN.js} +3 -2
- package/dist/main.js +140 -140
- package/dist/openai-NQYARTT6.js +34 -0
- package/dist/{server-IVIRQTO7.js → server-BNT2IIKB.js} +17 -17
- package/dist/tool-filter-5NDJMSTD.js +4 -0
- package/package.json +1 -1
- package/dist/agent-TCNIRVHD.js +0 -4
- package/dist/anthropic-7RIVSEDF.js +0 -4
- package/dist/checker-3LHDOATB.js +0 -4
- package/dist/chunk-2IBMB3ZM.js +0 -150
- package/dist/chunk-E55KH72M.js +0 -4
- package/dist/chunk-FA26MQ7K.js +0 -257
- package/dist/chunk-QCKJLO6X.js +0 -4
- package/dist/chunk-TKADLB2Q.js +0 -4
- package/dist/chunk-VA64DJNN.js +0 -4
- package/dist/lib/agent-IRY7KR5D.js +0 -11
- package/dist/lib/chunk-GHF2PSEW.js +0 -8
- package/dist/openai-RZLCY55V.js +0 -34
- package/dist/tool-filter-CG3KGQQW.js +0 -4
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpCallPermissionContent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FZ4Y6MBN.js";
|
|
4
4
|
import {
|
|
5
5
|
createChildLogger,
|
|
6
|
+
isRecord,
|
|
6
7
|
strArg
|
|
7
8
|
} from "./chunk-EY7HE52Q.js";
|
|
8
|
-
import {
|
|
9
|
-
MCP_CALL_TOOL_NAME
|
|
10
|
-
} from "./chunk-GHF2PSEW.js";
|
|
11
9
|
|
|
12
10
|
// src/permissions/checker.ts
|
|
13
11
|
import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
|
|
@@ -47,40 +45,193 @@ function isPathWithin(root, path) {
|
|
|
47
45
|
var log = createChildLogger({ module: "permissions" });
|
|
48
46
|
var DANGEROUS_PATTERNS = [];
|
|
49
47
|
var SAFE_PREFIXES = [
|
|
50
|
-
"
|
|
51
|
-
"pwd",
|
|
52
|
-
"echo",
|
|
48
|
+
"basename",
|
|
53
49
|
"cat",
|
|
50
|
+
"cksum",
|
|
51
|
+
"cmp",
|
|
52
|
+
"column",
|
|
53
|
+
"comm",
|
|
54
|
+
"cut",
|
|
55
|
+
"df",
|
|
56
|
+
"dirname",
|
|
57
|
+
"du",
|
|
58
|
+
"echo",
|
|
59
|
+
"expr",
|
|
60
|
+
"false",
|
|
61
|
+
"fold",
|
|
62
|
+
"fmt",
|
|
63
|
+
"grep",
|
|
64
|
+
"groups",
|
|
54
65
|
"head",
|
|
66
|
+
"id",
|
|
67
|
+
"jq",
|
|
68
|
+
"locate",
|
|
69
|
+
"ls",
|
|
70
|
+
"md5",
|
|
71
|
+
"md5sum",
|
|
72
|
+
"nl",
|
|
73
|
+
"od",
|
|
74
|
+
"paste",
|
|
75
|
+
"pgrep",
|
|
76
|
+
"printenv",
|
|
77
|
+
"printf",
|
|
78
|
+
"ps",
|
|
79
|
+
"pwd",
|
|
80
|
+
"readlink",
|
|
81
|
+
"realpath",
|
|
82
|
+
"sha1sum",
|
|
83
|
+
"sha224sum",
|
|
84
|
+
"sha256sum",
|
|
85
|
+
"sha384sum",
|
|
86
|
+
"sha512sum",
|
|
87
|
+
"shasum",
|
|
88
|
+
"stat",
|
|
89
|
+
"strings",
|
|
90
|
+
"tac",
|
|
55
91
|
"tail",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
92
|
+
"tr",
|
|
93
|
+
"true",
|
|
94
|
+
"tty",
|
|
95
|
+
"type",
|
|
59
96
|
"uname",
|
|
60
|
-
"
|
|
97
|
+
"uptime",
|
|
98
|
+
"w",
|
|
99
|
+
"wc",
|
|
100
|
+
"whereis",
|
|
61
101
|
"which",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
102
|
+
"who",
|
|
103
|
+
"whoami",
|
|
104
|
+
"ack",
|
|
105
|
+
"ag",
|
|
106
|
+
"alias",
|
|
107
|
+
"arch",
|
|
108
|
+
"base64",
|
|
109
|
+
"bat",
|
|
110
|
+
"bzcat",
|
|
111
|
+
"cal",
|
|
112
|
+
"col",
|
|
113
|
+
"cloc",
|
|
114
|
+
"diff",
|
|
115
|
+
"diff3",
|
|
116
|
+
"dig",
|
|
117
|
+
"dmesg",
|
|
118
|
+
"expand",
|
|
119
|
+
"factor",
|
|
120
|
+
"free",
|
|
121
|
+
"help",
|
|
122
|
+
"hexdump",
|
|
123
|
+
"host",
|
|
124
|
+
"iconv",
|
|
125
|
+
"info",
|
|
126
|
+
"locale",
|
|
127
|
+
"lscpu",
|
|
128
|
+
"lsblk",
|
|
129
|
+
"lsof",
|
|
130
|
+
"lspci",
|
|
131
|
+
"lsusb",
|
|
132
|
+
"man",
|
|
133
|
+
"mdfind",
|
|
134
|
+
"mdls",
|
|
135
|
+
"ncal",
|
|
136
|
+
"netstat",
|
|
137
|
+
"nproc",
|
|
138
|
+
"nslookup",
|
|
139
|
+
"objdump",
|
|
140
|
+
"otool",
|
|
141
|
+
"pbpaste",
|
|
142
|
+
"ping",
|
|
143
|
+
"readelf",
|
|
144
|
+
"rev",
|
|
145
|
+
"sdiff",
|
|
146
|
+
"seq",
|
|
147
|
+
"sum",
|
|
148
|
+
"sw_vers",
|
|
149
|
+
"tldr",
|
|
150
|
+
"traceroute",
|
|
151
|
+
"unexpand",
|
|
152
|
+
"vm_stat",
|
|
153
|
+
"whois",
|
|
154
|
+
"xxd",
|
|
155
|
+
"xzcat",
|
|
156
|
+
"zcat",
|
|
157
|
+
"zgrep",
|
|
158
|
+
"zipinfo",
|
|
159
|
+
/^command\s+(?:-v|-V)\s+\S+(?:\s+\S+)*$/,
|
|
160
|
+
/^date(?!.*\s(?:-s|--set)(?:=|\s|$))(?:\s.*)?$/,
|
|
161
|
+
/^file(?!.*(?:\s--compile(?:=|\s|$)|\s-[^-\s]*C))(?:\s.*)?$/,
|
|
162
|
+
/^find(?!.*\s(?:-delete|-exec(?:dir)?|-ok(?:dir)?|-fls|-fprint(?:0)?|-fprintf)(?:\s|$))(?:\s.*)?$/,
|
|
163
|
+
/^fd(?!.*\s(?:-x|-X|--exec|--exec-batch)(?:=|\s|$))(?:\s.*)?$/,
|
|
164
|
+
/^hostname(?:\s+(?:-[adfFiIsyVh]|--(?:alias|all-fqdns|all-ip-addresses|domain|fqdn|help|ip-address|long|nis|short|version|yp)))*$/,
|
|
165
|
+
/^rg(?!.*\s(?:--pre|--pre-glob|--hostname-bin)(?:=|\s|$))(?:\s.*)?$/,
|
|
166
|
+
/^sort(?!.*\s(?:-o|--output|--compress-program)(?:=|\s|$))(?:\s.*)?$/,
|
|
167
|
+
/^ss(?!.*\s(?:--kill|-[^-\s]*K)(?:\s|$))(?:\s.*)?$/,
|
|
168
|
+
/^tree(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,
|
|
169
|
+
/^git\s+(?:--version|version)$/,
|
|
170
|
+
/^git\s+(?:blame|cat-file|count-objects|describe|for-each-ref|ls-files|ls-tree|merge-base|name-rev|rev-parse|shortlog|show-ref|status|verify-pack)(?:\s.*)?$/,
|
|
171
|
+
/^git\s+(?:diff|log|show)(?!.*\s(?:--ext-diff|--output)(?:=|\s|$))(?:\s.*)?$/,
|
|
172
|
+
/^git\s+branch$/,
|
|
173
|
+
/^git\s+branch(?=.*\s(?:-a|--all|-r|--remotes|--list|--show-current|--contains|--no-contains|--merged|--no-merged)(?:=|\s|$))(?!.*\s(?:-[dDmMcCf]|--(?:copy|create-reflog|delete|edit-description|move|set-upstream-to|unset-upstream))(?:=|\s|$))(?:\s.*)?$/,
|
|
174
|
+
/^git\s+config(?:\s+(?:--blob(?:=|\s)\S+|--file(?:=|\s)\S+|--fixed-value|--global|--local|--null|--show-names|--show-origin|--show-scope|--system|--worktree|-z))*\s+(?:--get|--get-all|--get-regexp|--get-urlmatch|--list|-l)(?:\s.*)?$/,
|
|
175
|
+
/^git\s+notes\s+(?:list|show)(?:\s.*)?$/,
|
|
176
|
+
/^git\s+reflog\s+show(?:\s.*)?$/,
|
|
177
|
+
/^git\s+remote(?:\s+-v)?$/,
|
|
178
|
+
/^git\s+remote\s+get-url(?:\s+(?:--all|--push))*\s+\S+$/,
|
|
179
|
+
/^git\s+remote\s+show(?:\s+-n)?(?:\s+\S+)?$/,
|
|
180
|
+
/^git\s+stash\s+(?:list|show)(?:\s.*)?$/,
|
|
181
|
+
/^git\s+submodule\s+(?:status|summary)(?:\s.*)?$/,
|
|
182
|
+
/^git\s+tag(?:\s+(?:-l|--list)(?:\s.*)?)?$/,
|
|
183
|
+
/^git\s+worktree\s+list(?:\s.*)?$/,
|
|
184
|
+
/^(?:bun|npm|pnpm|yarn)\s+(?:explain|help|info|list|ls|outdated|prefix|query|root|search|show|view|why)(?:\s.*)?$/,
|
|
185
|
+
/^(?:npm|pnpm|yarn)\s+config\s+(?:get|list)(?:\s.*)?$/,
|
|
186
|
+
/^npm\s+pkg\s+get(?:\s.*)?$/,
|
|
187
|
+
/^bun\s+pm\s+ls(?:\s.*)?$/,
|
|
188
|
+
/^(?:bun|cargo|clang|cmake|composer|deno|gcc|gem|node|npm|php|pip|pip3|pnpm|python|python3|ruby|rustc|swift|yarn)\s+(?:--version|-V)$/,
|
|
189
|
+
/^(?:go|helm|kubectl|podman|terraform)\s+version(?:\s.*)?$/,
|
|
190
|
+
/^(?:java|javac)\s+-version$/,
|
|
191
|
+
/^dotnet\s+(?:--info|--list-runtimes|--list-sdks|--version)$/,
|
|
192
|
+
/^(?:docker|podman)\s+(?:diff|events|images|info|inspect|logs|port|ps|stats|top|version)(?:\s.*)?$/,
|
|
193
|
+
/^(?:docker|podman)\s+(?:container|image|network|volume)\s+(?:inspect|ls)(?:\s.*)?$/,
|
|
194
|
+
/^docker\s+compose\s+(?:config|images|logs|ps|top|version)(?:\s.*)?$/,
|
|
195
|
+
/^kubectl\s+(?:api-resources|api-versions|cluster-info|describe|explain|get|logs|top|version)(?:\s.*)?$/,
|
|
196
|
+
/^kubectl\s+config\s+(?:current-context|get-contexts|view)(?:\s.*)?$/,
|
|
197
|
+
/^helm\s+(?:env|get|history|list|search|show|status|version)(?:\s.*)?$/,
|
|
198
|
+
/^terraform\s+(?:output|providers|show|version)(?:\s.*)?$/,
|
|
199
|
+
/^terraform\s+workspace\s+(?:list|show)(?:\s.*)?$/,
|
|
200
|
+
/^systemctl\s+(?:is-active|is-enabled|is-failed|list-dependencies|list-jobs|list-sockets|list-timers|list-unit-files|list-units|show|show-environment|status)(?:\s.*)?$/,
|
|
201
|
+
/^launchctl\s+(?:error|hostinfo|list|managername|managerpid|manageruid|print|print-cache|procinfo|variant|version)(?:\s.*)?$/,
|
|
202
|
+
/^journalctl(?!.*\s--(?:rotate|vacuum|flush|sync))(?:\s.*)?$/,
|
|
203
|
+
/^defaults\s+read(?:\s.*)?$/,
|
|
204
|
+
/^ifconfig$/,
|
|
205
|
+
/^ipconfig(?:\s+\/(?:all|allcompartments|displaydns))?\s*$/,
|
|
206
|
+
/^ip\s+(?:addr(?:ess)?|route)$/,
|
|
207
|
+
/^ip\s+(?:addr(?:ess)?|link|route|neigh(?:bor)?)\s+(?:show|list)\b(?:\s.*)?$/,
|
|
208
|
+
/^tar\s+(?:--list\b|-[a-zA-Z]*t[a-zA-Z]*)(?:\s.*)?$/,
|
|
209
|
+
/^unzip\s+-[a-zA-Z]*l(?:\s.*)?$/,
|
|
210
|
+
/^git\s+(?:grep|fsck|rev-list|whatchanged|help|diff-tree|diff-index|diff-files|ls-remote|verify-tag|verify-commit)(?:\s.*)?$/,
|
|
211
|
+
/^git\s+archive(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,
|
|
212
|
+
/^svn\s+(?:status|stat|st|diff|di|log|info|list|ls|cat|blame|ann|annotate|proplist|propget|pg)(?:\s.*)?$/,
|
|
213
|
+
/^hg\s+(?:status|st|log|diff|summary|id|identify|branches|tags|manifest|cat|files|locate|heads|tip|parents|paths|root)(?:\s.*)?$/,
|
|
214
|
+
/^cargo\s+(?:tree|search|locate-project|verify-project|config\s+get)(?:\s.*)?$/,
|
|
215
|
+
/^gem\s+(?:list|search|info|env|dependency|contents|specification|sources\s+(?:-l|--list))(?:\s.*)?$/,
|
|
216
|
+
/^brew\s+(?:--version|-v|list|info|search|outdated|deps|uses|config|leaves|doctor)(?:\s.*)?$/,
|
|
217
|
+
/^choco\s+(?:--version|list|info|search|outdated)(?:\s.*)?$/,
|
|
218
|
+
/^apt(?:-get)?\s+list(?:\s.*)?$/,
|
|
219
|
+
/^apt-cache\s+(?:search|show|showpkg|policy|depends|rdepends|pkgnames)(?:\s.*)?$/,
|
|
220
|
+
/^dpkg\s+(?:-l|-L|-s|-S|--list|--listfiles|--status|--search)\b(?:\s.*)?$/,
|
|
221
|
+
/^rpm\s+-q[a-zA-Z]*(?:\s.*)?$/,
|
|
222
|
+
/^(?:aws|gh|gcloud|az)\s+--version$/,
|
|
223
|
+
/^aws\s+(?:\S+\s+)?(?:describe|list|get|wait)-\S+(?:\s.*)?$/,
|
|
224
|
+
/^aws\s+s3\s+ls(?:\s.*)?$/,
|
|
225
|
+
/^gcloud\s+\S+(?:\s+\S+)*\s+(?:list|describe)(?:\s.*)?$/,
|
|
226
|
+
/^az\s+\S+(?:\s+\S+)*\s+(?:list|show)(?:\s.*)?$/,
|
|
227
|
+
/^gh\s+(?:pr|issue|repo|run|release|gist)\s+(?:view|list|status|checks|diff)(?:\s.*)?$/,
|
|
228
|
+
/^(?:docker|podman)\s+(?:system\s+(?:df|info)|history|context\s+(?:ls|list|show|inspect))(?:\s.*)?$/,
|
|
229
|
+
/^(?:Get-(?:Acl|Alias|AuthenticodeSignature|ChildItem|CimInstance|Clipboard|Command|ComputerInfo|Content|Counter|Culture|Date|DnsClientCache|EventLog|ExecutionPolicy|FileHash|Help|History|Host|HotFix|Item|ItemProperty|Location|Member|Module|NetAdapter|NetIPAddress|NetNeighbor|NetIPConfiguration|NetRoute|NetTCPConnection|NetUDPEndpoint|Package|PackageProvider|PnpDevice|Printer|Process|PSDrive|PSProvider|PSRepository|PSSnapin|ScheduledTask|Service|TimeZone|UICulture|Variable|Verb|WinEvent|WmiObject)|Compare-Object|Format-(?:Custom|Hex|List|Table|Wide)|Group-Object|Measure-Object|Out-String|Resolve-Path|Select-Object|Select-String|Sort-Object|Test-Path|Where-Object|Write-(?:Debug|Error|Host|Information|Output|Progress|Verbose|Warning))(?:\s.*)?$/i
|
|
80
230
|
];
|
|
81
231
|
var CONTENT_FIELDS = {
|
|
82
232
|
Bash: "command",
|
|
83
233
|
PowerShell: "command",
|
|
234
|
+
ComputerUse: "action",
|
|
84
235
|
ReadFile: "file_path",
|
|
85
236
|
WriteFile: "file_path",
|
|
86
237
|
EditFile: "file_path",
|
|
@@ -88,9 +239,9 @@ var CONTENT_FIELDS = {
|
|
|
88
239
|
Grep: "pattern",
|
|
89
240
|
InstallSkill: "source"
|
|
90
241
|
};
|
|
91
|
-
var DEFAULT_DENY_WRITE = [
|
|
242
|
+
var DEFAULT_DENY_WRITE = [];
|
|
92
243
|
function extractContent(toolName, args) {
|
|
93
|
-
if (toolName ===
|
|
244
|
+
if (toolName === "McpCall") {
|
|
94
245
|
return mcpCallPermissionContent(strArg(args, "server", ""), strArg(args, "tool", ""));
|
|
95
246
|
}
|
|
96
247
|
const field = CONTENT_FIELDS[toolName];
|
|
@@ -98,7 +249,13 @@ function extractContent(toolName, args) {
|
|
|
98
249
|
return "";
|
|
99
250
|
}
|
|
100
251
|
const v = args[field];
|
|
101
|
-
|
|
252
|
+
if (typeof v === "string") {
|
|
253
|
+
return v;
|
|
254
|
+
}
|
|
255
|
+
if (toolName === "ComputerUse" && Array.isArray(args.actions)) {
|
|
256
|
+
return args.actions.map((item) => isRecord(item) ? strArg(item, "type") : "").filter(Boolean).join(",");
|
|
257
|
+
}
|
|
258
|
+
return "";
|
|
102
259
|
}
|
|
103
260
|
var PathSandbox = class {
|
|
104
261
|
allowedRoots;
|
|
@@ -280,12 +437,16 @@ function detectDangerous(command) {
|
|
|
280
437
|
}
|
|
281
438
|
function isSafeCommand(command) {
|
|
282
439
|
const trimmed = command.trim();
|
|
283
|
-
if (
|
|
440
|
+
if (/[\r\n&|;<>`(){}[\]]/.test(trimmed)) {
|
|
284
441
|
return false;
|
|
285
442
|
}
|
|
286
|
-
return SAFE_PREFIXES.some(
|
|
287
|
-
(prefix
|
|
288
|
-
|
|
443
|
+
return SAFE_PREFIXES.some((prefix) => {
|
|
444
|
+
if (typeof prefix === "string") {
|
|
445
|
+
return trimmed === prefix || trimmed.startsWith(prefix + " ") || trimmed.startsWith(prefix + " ");
|
|
446
|
+
}
|
|
447
|
+
prefix.lastIndex = 0;
|
|
448
|
+
return prefix.test(trimmed);
|
|
449
|
+
});
|
|
289
450
|
}
|
|
290
451
|
function modeDecide(mode, category) {
|
|
291
452
|
switch (mode) {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MCP_CALL_TOOL_NAME,
|
|
3
|
-
TOOL_SEARCH_TOOL_NAME
|
|
4
|
-
} from "./chunk-GHF2PSEW.js";
|
|
5
|
-
|
|
6
1
|
// src/tools/registry.ts
|
|
7
2
|
var ToolRegistry = class {
|
|
8
3
|
tools = /* @__PURE__ */ new Map();
|
|
@@ -32,20 +27,29 @@ var ToolRegistry = class {
|
|
|
32
27
|
listTools() {
|
|
33
28
|
return [...this.tools.values()];
|
|
34
29
|
}
|
|
35
|
-
getAllSchemas(protocol
|
|
36
|
-
const
|
|
30
|
+
getAllSchemas(protocol, filter) {
|
|
31
|
+
const resolvedProtocol = protocol ?? "anthropic";
|
|
32
|
+
const isOpenAI = resolvedProtocol === "openai" || resolvedProtocol === "openai-compat";
|
|
37
33
|
const native = this.mcpLoadingMode === "native" && !isOpenAI;
|
|
38
34
|
const schemas = [];
|
|
39
35
|
for (const tool of this.tools.values()) {
|
|
40
|
-
if (
|
|
36
|
+
if (filter && !filter(tool.name)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (tool.name === "ToolSearch" && !this.exposeToolSearch || tool.name === "McpCall" && !this.exposeMcpCall) {
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
const deferred = Boolean(tool.deferred) && !this.discovered.has(tool.name);
|
|
44
43
|
if (deferred && !native) {
|
|
45
44
|
continue;
|
|
46
45
|
}
|
|
46
|
+
const providerSchema = protocol ? tool.providerSchema?.(resolvedProtocol) : void 0;
|
|
47
|
+
if (providerSchema) {
|
|
48
|
+
schemas.push(providerSchema);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
47
51
|
const s = tool.schema();
|
|
48
|
-
if (
|
|
52
|
+
if (resolvedProtocol === "openai") {
|
|
49
53
|
schemas.push({
|
|
50
54
|
strict: s.strict ?? false,
|
|
51
55
|
type: "function",
|
|
@@ -53,7 +57,7 @@ var ToolRegistry = class {
|
|
|
53
57
|
description: s.description,
|
|
54
58
|
parameters: s.input_schema
|
|
55
59
|
});
|
|
56
|
-
} else if (
|
|
60
|
+
} else if (resolvedProtocol === "openai-compat") {
|
|
57
61
|
schemas.push({
|
|
58
62
|
type: "function",
|
|
59
63
|
function: {
|
|
@@ -120,11 +124,13 @@ var ToolRegistry = class {
|
|
|
120
124
|
};
|
|
121
125
|
|
|
122
126
|
// src/subagent/tool-filter.ts
|
|
127
|
+
var MAIN_AGENT_ONLY_TOOLS = /* @__PURE__ */ new Set(["ComputerUse"]);
|
|
123
128
|
var SUBAGENT_DISALLOWED_TOOLS = /* @__PURE__ */ new Set([
|
|
124
129
|
"ExitPlanMode",
|
|
125
130
|
"Agent",
|
|
126
131
|
// Prevents recursive spawning of subagents
|
|
127
132
|
"AskUserQuestion",
|
|
133
|
+
...MAIN_AGENT_ONLY_TOOLS,
|
|
128
134
|
"TaskStop"
|
|
129
135
|
]);
|
|
130
136
|
var TEAMMATE_DISALLOWED_TOOLS = /* @__PURE__ */ new Set(["TeamCreate", "TeamDelete"]);
|
|
@@ -193,6 +199,9 @@ function cloneRegistryForFork(registry) {
|
|
|
193
199
|
const forked = new ToolRegistry();
|
|
194
200
|
forked.mcpLoadingMode = registry.mcpLoadingMode;
|
|
195
201
|
for (const tool of registry.listTools()) {
|
|
202
|
+
if (MAIN_AGENT_ONLY_TOOLS.has(tool.name)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
196
205
|
if (tool.name === "Agent" && "querySource" in tool) {
|
|
197
206
|
const clone = Object.create(
|
|
198
207
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -210,6 +219,7 @@ function cloneRegistryForFork(registry) {
|
|
|
210
219
|
|
|
211
220
|
export {
|
|
212
221
|
ToolRegistry,
|
|
222
|
+
MAIN_AGENT_ONLY_TOOLS,
|
|
213
223
|
SUBAGENT_DISALLOWED_TOOLS,
|
|
214
224
|
TEAMMATE_DISALLOWED_TOOLS,
|
|
215
225
|
CUSTOM_AGENT_DISALLOWED_TOOLS,
|
|
@@ -4,9 +4,6 @@ import {
|
|
|
4
4
|
createChildLogger,
|
|
5
5
|
strArg
|
|
6
6
|
} from "./chunk-EY7HE52Q.js";
|
|
7
|
-
import {
|
|
8
|
-
MCP_CALL_TOOL_NAME
|
|
9
|
-
} from "./chunk-GHF2PSEW.js";
|
|
10
7
|
|
|
11
8
|
// src/mcp/tool-wrapper.ts
|
|
12
9
|
var log = createChildLogger({ module: "mcp" });
|
|
@@ -148,7 +145,7 @@ var McpCallTool = class {
|
|
|
148
145
|
this.registry = registry;
|
|
149
146
|
}
|
|
150
147
|
registry;
|
|
151
|
-
name =
|
|
148
|
+
name = "McpCall";
|
|
152
149
|
description = "Invoke a tool on a connected MCP server. Call ToolSearch first to load the tool's schema, then pass its arguments here exactly as that schema requires, using the same JSON types.";
|
|
153
150
|
category = "command";
|
|
154
151
|
// This tool must stay in tools[] itself, otherwise the model has no entry point
|