@frontmcp/utils 1.10.15 → 1.11.0-rc.1
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 +1 -0
- package/browser/async-context/browser-async-context.mjs +177 -0
- package/browser/async-context/index.mjs +15 -0
- package/browser/async-context/overlap-error.mjs +10 -0
- package/browser/class-brand/class-brand.mjs +27 -0
- package/browser/class-brand/index.mjs +6 -0
- package/browser/content/content.mjs +151 -0
- package/browser/content/index.mjs +8 -0
- package/browser/crypto/browser.mjs +103 -0
- package/browser/crypto/encrypted-blob.mjs +119 -0
- package/browser/crypto/hmac-signing.mjs +70 -0
- package/browser/crypto/index.mjs +281 -0
- package/browser/crypto/jwt-alg.mjs +40 -0
- package/browser/crypto/key-persistence/factory.mjs +134 -0
- package/browser/crypto/key-persistence/index.mjs +26 -0
- package/browser/crypto/key-persistence/key-persistence.mjs +185 -0
- package/browser/crypto/key-persistence/schemas.mjs +82 -0
- package/browser/crypto/pkce/index.mjs +25 -0
- package/browser/crypto/pkce/pkce.mjs +59 -0
- package/browser/crypto/runtime.mjs +17 -0
- package/browser/crypto/secret-persistence/index.mjs +29 -0
- package/browser/crypto/secret-persistence/persistence.mjs +181 -0
- package/browser/crypto/secret-persistence/schema.mjs +40 -0
- package/browser/crypto/web-rsa.mjs +36 -0
- package/browser/env/browser-env.mjs +56 -0
- package/browser/env/browser-runtime-context.mjs +85 -0
- package/browser/env/build-target.mjs +25 -0
- package/browser/env/edge-scope.mjs +17 -0
- package/browser/env/index.mjs +47 -0
- package/browser/env/provider.mjs +46 -0
- package/browser/escape/escape.mjs +43 -0
- package/browser/escape/index.mjs +9 -0
- package/browser/event-emitter/browser-event-emitter.mjs +49 -0
- package/browser/event-emitter/index.mjs +5 -0
- package/browser/fs/fs.mjs +227 -0
- package/browser/fs/index.mjs +65 -0
- package/browser/http/cookie.mjs +85 -0
- package/browser/http/http.mjs +18 -0
- package/browser/http/index.mjs +11 -0
- package/browser/index.mjs +526 -0
- package/browser/llm/index.mjs +5 -0
- package/browser/llm/llm-tool-handlers.mjs +55 -0
- package/browser/machine-id/index.mjs +7 -0
- package/browser/machine-id/machine-id.mjs +108 -0
- package/browser/naming/index.mjs +10 -0
- package/browser/naming/naming.mjs +68 -0
- package/browser/net/index.mjs +10 -0
- package/browser/net/ip-address.mjs +128 -0
- package/browser/net/redirect.mjs +7 -0
- package/browser/path/browser-path.mjs +47 -0
- package/browser/path/index.mjs +24 -0
- package/browser/path/path.mjs +13 -0
- package/browser/process/child-process.mjs +23 -0
- package/browser/process/index.mjs +15 -0
- package/browser/process/owned-process.mjs +175 -0
- package/browser/process/process-tree.mjs +149 -0
- package/browser/process/process-watch.mjs +48 -0
- package/browser/redaction/index.mjs +6 -0
- package/browser/redaction/redaction.mjs +74 -0
- package/browser/regex/index.mjs +3 -0
- package/browser/regex/patterns.mjs +167 -0
- package/browser/regex/safe-regex.mjs +93 -0
- package/browser/serialization/index.mjs +5 -0
- package/browser/serialization/serialization.mjs +22 -0
- package/browser/stdio-bridge/errors.mjs +27 -0
- package/browser/stdio-bridge/index.mjs +24 -0
- package/browser/stdio-bridge/list-changed.mjs +21 -0
- package/browser/stdio-bridge/state-machine.mjs +211 -0
- package/browser/stdio-bridge/stdio-framer.mjs +91 -0
- package/browser/stdio-bridge/upstream-client.mjs +189 -0
- package/browser/storage/adapters/base.mjs +139 -0
- package/browser/storage/adapters/cloudflare-kv.mjs +149 -0
- package/browser/storage/adapters/filesystem.mjs +279 -0
- package/browser/storage/adapters/index.mjs +23 -0
- package/browser/storage/adapters/indexeddb.mjs +198 -0
- package/browser/storage/adapters/localstorage.mjs +222 -0
- package/browser/storage/adapters/memory.mjs +350 -0
- package/browser/storage/adapters/redis.mjs +497 -0
- package/browser/storage/adapters/upstash.mjs +299 -0
- package/browser/storage/adapters/vercel-kv.mjs +226 -0
- package/browser/storage/change-feed.mjs +189 -0
- package/browser/storage/encrypted-typed-storage.mjs +329 -0
- package/browser/storage/errors.mjs +92 -0
- package/browser/storage/factory.mjs +155 -0
- package/browser/storage/index.mjs +96 -0
- package/browser/storage/namespace.mjs +186 -0
- package/browser/storage/redis-error-listener.mjs +32 -0
- package/browser/storage/redis-url.mjs +66 -0
- package/browser/storage/typed-storage.mjs +171 -0
- package/browser/storage/utils/compare-and-delete.mjs +9 -0
- package/browser/storage/utils/index.mjs +24 -0
- package/browser/storage/utils/pattern.mjs +68 -0
- package/browser/storage/utils/ttl.mjs +48 -0
- package/browser/uri/index.mjs +19 -0
- package/browser/uri/uri-template.mjs +86 -0
- package/browser/uri/uri-validation.mjs +18 -0
- package/content/content.d.ts +8 -0
- package/content/index.d.ts +1 -1
- package/crypto/browser.d.ts +1 -13
- package/crypto/browser.js +1 -1
- package/crypto/node.js +1 -1
- package/crypto/web-rsa.d.ts +13 -0
- package/env/browser-runtime-context.js +1 -1
- package/env/runtime-context.js +1 -1
- package/esm/crypto/browser.mjs +1 -1
- package/esm/crypto/node.mjs +1 -1
- package/esm/env/browser-runtime-context.mjs +1 -1
- package/esm/env/runtime-context.mjs +1 -1
- package/esm/index.mjs +1 -1
- package/fs/fs.d.ts +45 -4
- package/fs/index.d.ts +1 -1
- package/index.d.ts +10 -4
- package/index.js +1 -1
- package/package.json +24 -8
- package/process/child-process.d.ts +2 -0
- package/process/index.d.ts +6 -0
- package/process/owned-process.d.ts +59 -0
- package/process/process-tree.d.ts +78 -0
- package/process/process-watch.d.ts +41 -0
- package/redaction/index.d.ts +2 -0
- package/redaction/redaction.d.ts +24 -0
- package/stdio-bridge/errors.d.ts +23 -0
- package/stdio-bridge/index.d.ts +9 -0
- package/stdio-bridge/list-changed.d.ts +3 -0
- package/stdio-bridge/state-machine.d.ts +61 -0
- package/stdio-bridge/stdio-framer.d.ts +49 -0
- package/stdio-bridge/types.d.ts +10 -0
- package/stdio-bridge/upstream-client.d.ts +66 -0
- package/storage/adapters/base.d.ts +2 -0
- package/storage/adapters/memory.d.ts +1 -0
- package/storage/adapters/redis.d.ts +3 -0
- package/storage/change-feed.d.ts +47 -0
- package/storage/factory.d.ts +6 -0
- package/storage/index.d.ts +3 -1
- package/storage/namespace.d.ts +2 -0
- package/storage/types.d.ts +46 -1
- package/storage/utils/compare-and-delete.d.ts +2 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
// libs/utils/src/index.ts
|
|
2
|
+
import { splitWords, toCase, sepFor, shortHash, ensureMaxLen, idFromString } from "./naming/index.mjs";
|
|
3
|
+
import {
|
|
4
|
+
isValidMcpUri,
|
|
5
|
+
extractUriScheme,
|
|
6
|
+
isValidMcpUriTemplate,
|
|
7
|
+
parseUriTemplate,
|
|
8
|
+
matchUriTemplate,
|
|
9
|
+
expandUriTemplate,
|
|
10
|
+
extractTemplateParams,
|
|
11
|
+
isUriTemplate
|
|
12
|
+
} from "./uri/index.mjs";
|
|
13
|
+
import {
|
|
14
|
+
trimSlashes,
|
|
15
|
+
joinPath,
|
|
16
|
+
pathResolve,
|
|
17
|
+
pathJoin,
|
|
18
|
+
basename,
|
|
19
|
+
dirname,
|
|
20
|
+
extname,
|
|
21
|
+
isAbsolute,
|
|
22
|
+
pathToFileURL,
|
|
23
|
+
sep
|
|
24
|
+
} from "./path/index.mjs";
|
|
25
|
+
import { sanitizeToJson, inferMimeType, findNonFiniteNumber, findDroppedKeys } from "./content/index.mjs";
|
|
26
|
+
import { validateBaseUrl, buildSetCookie, parseCookies, getCookie, isLocalhost, isSecureRequest } from "./http/index.mjs";
|
|
27
|
+
import { classifyIpAddress, expandIpv6, extractEmbeddedIpv4, parseIpv4, isRedirectResponse } from "./net/index.mjs";
|
|
28
|
+
import {
|
|
29
|
+
readFile,
|
|
30
|
+
readFileSync,
|
|
31
|
+
readFileBuffer,
|
|
32
|
+
writeFile,
|
|
33
|
+
appendFile,
|
|
34
|
+
mkdir,
|
|
35
|
+
rename,
|
|
36
|
+
unlink,
|
|
37
|
+
stat,
|
|
38
|
+
lstat,
|
|
39
|
+
chmod,
|
|
40
|
+
copyFile,
|
|
41
|
+
cp,
|
|
42
|
+
readdir,
|
|
43
|
+
readdirSync,
|
|
44
|
+
realpath,
|
|
45
|
+
rm,
|
|
46
|
+
mkdtemp,
|
|
47
|
+
symlink,
|
|
48
|
+
access,
|
|
49
|
+
fileExists,
|
|
50
|
+
fileExistsSync,
|
|
51
|
+
readJSON,
|
|
52
|
+
writeJSON,
|
|
53
|
+
ensureDir,
|
|
54
|
+
ensureDirSync,
|
|
55
|
+
isDirEmpty,
|
|
56
|
+
runCmd,
|
|
57
|
+
watchFile,
|
|
58
|
+
getSpawnFn
|
|
59
|
+
} from "./fs/index.mjs";
|
|
60
|
+
import {
|
|
61
|
+
processTreeSpawnOptions,
|
|
62
|
+
signalProcessTree,
|
|
63
|
+
isProcessTreeAlive,
|
|
64
|
+
stopProcessTree,
|
|
65
|
+
spawnOwned,
|
|
66
|
+
reapOrphans,
|
|
67
|
+
OwnedProcessError,
|
|
68
|
+
watchParent,
|
|
69
|
+
watchPath
|
|
70
|
+
} from "./process/index.mjs";
|
|
71
|
+
import {
|
|
72
|
+
DEV_BUFFER_FULL,
|
|
73
|
+
DEV_ERROR_MESSAGE,
|
|
74
|
+
DEV_RELOAD_DEADLINE,
|
|
75
|
+
DEV_SERVER_UNREACHABLE,
|
|
76
|
+
makeDevError,
|
|
77
|
+
listChangedNotifications,
|
|
78
|
+
createBridgeStateMachine,
|
|
79
|
+
createStdioFramer,
|
|
80
|
+
createHttpUpstream,
|
|
81
|
+
createPipeUpstream
|
|
82
|
+
} from "./stdio-bridge/index.mjs";
|
|
83
|
+
import { redactFields, redactJson } from "./redaction/index.mjs";
|
|
84
|
+
import { escapeHtml, escapeHtmlAttr, escapeJsString, escapeScriptClose, safeJsonForScript } from "./escape/index.mjs";
|
|
85
|
+
import { brandClass, isBrandedInstance } from "./class-brand/index.mjs";
|
|
86
|
+
import { safeStringify } from "./serialization/index.mjs";
|
|
87
|
+
import {
|
|
88
|
+
getCrypto,
|
|
89
|
+
rsaVerify,
|
|
90
|
+
rsaVerifySync,
|
|
91
|
+
pemToPublicJwk,
|
|
92
|
+
generateRsaKeyPair,
|
|
93
|
+
rsaSignBase64Url,
|
|
94
|
+
jwtAlgToNodeAlg,
|
|
95
|
+
isRsaPssAlg,
|
|
96
|
+
randomUUID,
|
|
97
|
+
randomBytes,
|
|
98
|
+
sha256,
|
|
99
|
+
sha256Hex,
|
|
100
|
+
sha256Base64url,
|
|
101
|
+
hmacSha256,
|
|
102
|
+
hkdfSha256,
|
|
103
|
+
encryptAesGcm,
|
|
104
|
+
decryptAesGcm,
|
|
105
|
+
timingSafeEqual,
|
|
106
|
+
bytesToHex,
|
|
107
|
+
base64urlEncode,
|
|
108
|
+
base64urlDecode,
|
|
109
|
+
base64Encode,
|
|
110
|
+
base64Decode,
|
|
111
|
+
isNode,
|
|
112
|
+
isBrowser,
|
|
113
|
+
assertNode,
|
|
114
|
+
EncryptedBlobError,
|
|
115
|
+
encryptValue,
|
|
116
|
+
decryptValue,
|
|
117
|
+
tryDecryptValue,
|
|
118
|
+
serializeBlob,
|
|
119
|
+
deserializeBlob,
|
|
120
|
+
tryDeserializeBlob,
|
|
121
|
+
isValidEncryptedBlob,
|
|
122
|
+
encryptAndSerialize,
|
|
123
|
+
deserializeAndDecrypt,
|
|
124
|
+
tryDeserializeAndDecrypt,
|
|
125
|
+
generateCodeVerifier,
|
|
126
|
+
generateCodeChallenge,
|
|
127
|
+
verifyCodeChallenge,
|
|
128
|
+
generatePkcePair,
|
|
129
|
+
isValidCodeVerifier,
|
|
130
|
+
isValidCodeChallenge,
|
|
131
|
+
MIN_CODE_VERIFIER_LENGTH,
|
|
132
|
+
MAX_CODE_VERIFIER_LENGTH,
|
|
133
|
+
DEFAULT_CODE_VERIFIER_LENGTH,
|
|
134
|
+
PkceError,
|
|
135
|
+
secretDataSchema,
|
|
136
|
+
validateSecretData,
|
|
137
|
+
parseSecretData,
|
|
138
|
+
isSecretPersistenceEnabled,
|
|
139
|
+
resolveSecretPath,
|
|
140
|
+
loadSecret,
|
|
141
|
+
saveSecret,
|
|
142
|
+
deleteSecret,
|
|
143
|
+
generateSecret,
|
|
144
|
+
createSecretData,
|
|
145
|
+
getOrCreateSecret,
|
|
146
|
+
clearCachedSecret,
|
|
147
|
+
isSecretCached,
|
|
148
|
+
signData,
|
|
149
|
+
verifyData,
|
|
150
|
+
isSignedData,
|
|
151
|
+
verifyOrParseData,
|
|
152
|
+
asymmetricAlgSchema,
|
|
153
|
+
secretKeyDataSchema,
|
|
154
|
+
asymmetricKeyDataSchema,
|
|
155
|
+
anyKeyDataSchema,
|
|
156
|
+
validateKeyData,
|
|
157
|
+
parseKeyData,
|
|
158
|
+
isSecretKeyData,
|
|
159
|
+
isAsymmetricKeyData,
|
|
160
|
+
KeyPersistence,
|
|
161
|
+
createKeyPersistence,
|
|
162
|
+
createKeyPersistenceWithStorage
|
|
163
|
+
} from "./crypto/index.mjs";
|
|
164
|
+
import {
|
|
165
|
+
AsyncContextOverlapError,
|
|
166
|
+
AsyncLocalStorage,
|
|
167
|
+
awaitOutsideRequest,
|
|
168
|
+
getAsyncContextMode,
|
|
169
|
+
runRequestExclusive
|
|
170
|
+
} from "./async-context/index.mjs";
|
|
171
|
+
import { EventEmitter } from "./event-emitter/index.mjs";
|
|
172
|
+
import {
|
|
173
|
+
getEnv,
|
|
174
|
+
getNodeEnv,
|
|
175
|
+
getCwd,
|
|
176
|
+
isProduction,
|
|
177
|
+
isDevelopment,
|
|
178
|
+
getEnvFlag,
|
|
179
|
+
isDebug,
|
|
180
|
+
setEnv,
|
|
181
|
+
isEdgeRuntime,
|
|
182
|
+
isServerless,
|
|
183
|
+
supportsAnsi,
|
|
184
|
+
getRuntimeContext,
|
|
185
|
+
resetRuntimeContext,
|
|
186
|
+
detectRuntimeContext,
|
|
187
|
+
isEntryAvailable,
|
|
188
|
+
checkEntryAvailability,
|
|
189
|
+
entryAvailabilitySchema
|
|
190
|
+
} from "./env/index.mjs";
|
|
191
|
+
import {
|
|
192
|
+
analyzePattern,
|
|
193
|
+
isPatternSafe,
|
|
194
|
+
createSafeRegExp,
|
|
195
|
+
safeTest,
|
|
196
|
+
safeMatch,
|
|
197
|
+
safeReplace,
|
|
198
|
+
safeExec,
|
|
199
|
+
isInputLengthSafe,
|
|
200
|
+
DEFAULT_MAX_INPUT_LENGTH,
|
|
201
|
+
REDOS_THRESHOLDS,
|
|
202
|
+
trimLeading,
|
|
203
|
+
trimTrailing,
|
|
204
|
+
trimBoth,
|
|
205
|
+
trimChars,
|
|
206
|
+
extractBracedParams,
|
|
207
|
+
expandTemplate,
|
|
208
|
+
hasTemplatePlaceholders,
|
|
209
|
+
collapseChar,
|
|
210
|
+
collapseWhitespace
|
|
211
|
+
} from "./regex/index.mjs";
|
|
212
|
+
import {
|
|
213
|
+
createStorage,
|
|
214
|
+
createMemoryStorage,
|
|
215
|
+
getDetectedStorageType,
|
|
216
|
+
createChangeFeed,
|
|
217
|
+
DEFAULT_CHANGE_FEED_COALESCE_MS,
|
|
218
|
+
DEFAULT_CHANGE_FEED_POLL_INTERVAL_MS,
|
|
219
|
+
NamespacedStorageImpl,
|
|
220
|
+
createRootStorage,
|
|
221
|
+
createNamespacedStorage,
|
|
222
|
+
buildPrefix,
|
|
223
|
+
NAMESPACE_SEPARATOR,
|
|
224
|
+
StorageError,
|
|
225
|
+
StorageConnectionError,
|
|
226
|
+
StorageOperationError,
|
|
227
|
+
StorageNotSupportedError,
|
|
228
|
+
StorageConfigError,
|
|
229
|
+
StorageTTLError,
|
|
230
|
+
StoragePatternError,
|
|
231
|
+
StorageNotConnectedError,
|
|
232
|
+
EncryptedStorageError,
|
|
233
|
+
BaseStorageAdapter,
|
|
234
|
+
MemoryStorageAdapter,
|
|
235
|
+
RedisStorageAdapter,
|
|
236
|
+
createRedisClient,
|
|
237
|
+
VercelKvStorageAdapter,
|
|
238
|
+
createVercelKvClient,
|
|
239
|
+
UpstashStorageAdapter,
|
|
240
|
+
FileSystemStorageAdapter,
|
|
241
|
+
TypedStorage,
|
|
242
|
+
EncryptedTypedStorage,
|
|
243
|
+
globToRegex,
|
|
244
|
+
matchesPattern,
|
|
245
|
+
validatePattern,
|
|
246
|
+
escapeGlob,
|
|
247
|
+
MAX_TTL_SECONDS,
|
|
248
|
+
validateTTL,
|
|
249
|
+
validateOptionalTTL,
|
|
250
|
+
ttlToExpiresAt,
|
|
251
|
+
expiresAtToTTL,
|
|
252
|
+
isExpired,
|
|
253
|
+
normalizeTTL,
|
|
254
|
+
attachRedisErrorListener,
|
|
255
|
+
DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS,
|
|
256
|
+
mergeRedisUrlFields,
|
|
257
|
+
describeRedisUrlConflicts
|
|
258
|
+
} from "./storage/index.mjs";
|
|
259
|
+
import { processPlatformToolCalls } from "./llm/index.mjs";
|
|
260
|
+
import { getHostname, getMachineId, setMachineIdOverride } from "./machine-id/index.mjs";
|
|
261
|
+
export {
|
|
262
|
+
AsyncContextOverlapError,
|
|
263
|
+
AsyncLocalStorage,
|
|
264
|
+
BaseStorageAdapter,
|
|
265
|
+
DEFAULT_CHANGE_FEED_COALESCE_MS,
|
|
266
|
+
DEFAULT_CHANGE_FEED_POLL_INTERVAL_MS,
|
|
267
|
+
DEFAULT_CODE_VERIFIER_LENGTH,
|
|
268
|
+
DEFAULT_MAX_INPUT_LENGTH,
|
|
269
|
+
DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS,
|
|
270
|
+
DEV_BUFFER_FULL,
|
|
271
|
+
DEV_ERROR_MESSAGE,
|
|
272
|
+
DEV_RELOAD_DEADLINE,
|
|
273
|
+
DEV_SERVER_UNREACHABLE,
|
|
274
|
+
EncryptedBlobError,
|
|
275
|
+
EncryptedStorageError,
|
|
276
|
+
EncryptedTypedStorage,
|
|
277
|
+
EventEmitter,
|
|
278
|
+
FileSystemStorageAdapter,
|
|
279
|
+
KeyPersistence,
|
|
280
|
+
MAX_CODE_VERIFIER_LENGTH,
|
|
281
|
+
MAX_TTL_SECONDS,
|
|
282
|
+
MIN_CODE_VERIFIER_LENGTH,
|
|
283
|
+
MemoryStorageAdapter,
|
|
284
|
+
NAMESPACE_SEPARATOR,
|
|
285
|
+
NamespacedStorageImpl,
|
|
286
|
+
OwnedProcessError,
|
|
287
|
+
PkceError,
|
|
288
|
+
REDOS_THRESHOLDS,
|
|
289
|
+
RedisStorageAdapter,
|
|
290
|
+
StorageConfigError,
|
|
291
|
+
StorageConnectionError,
|
|
292
|
+
StorageError,
|
|
293
|
+
StorageNotConnectedError,
|
|
294
|
+
StorageNotSupportedError,
|
|
295
|
+
StorageOperationError,
|
|
296
|
+
StoragePatternError,
|
|
297
|
+
StorageTTLError,
|
|
298
|
+
TypedStorage,
|
|
299
|
+
UpstashStorageAdapter,
|
|
300
|
+
VercelKvStorageAdapter,
|
|
301
|
+
access,
|
|
302
|
+
analyzePattern,
|
|
303
|
+
anyKeyDataSchema,
|
|
304
|
+
appendFile,
|
|
305
|
+
assertNode,
|
|
306
|
+
asymmetricAlgSchema,
|
|
307
|
+
asymmetricKeyDataSchema,
|
|
308
|
+
attachRedisErrorListener,
|
|
309
|
+
awaitOutsideRequest,
|
|
310
|
+
base64Decode,
|
|
311
|
+
base64Encode,
|
|
312
|
+
base64urlDecode,
|
|
313
|
+
base64urlEncode,
|
|
314
|
+
basename,
|
|
315
|
+
brandClass,
|
|
316
|
+
buildPrefix,
|
|
317
|
+
buildSetCookie,
|
|
318
|
+
bytesToHex,
|
|
319
|
+
checkEntryAvailability,
|
|
320
|
+
chmod,
|
|
321
|
+
classifyIpAddress,
|
|
322
|
+
clearCachedSecret,
|
|
323
|
+
collapseChar,
|
|
324
|
+
collapseWhitespace,
|
|
325
|
+
copyFile,
|
|
326
|
+
cp,
|
|
327
|
+
createBridgeStateMachine,
|
|
328
|
+
createChangeFeed,
|
|
329
|
+
createHttpUpstream,
|
|
330
|
+
createKeyPersistence,
|
|
331
|
+
createKeyPersistenceWithStorage,
|
|
332
|
+
createMemoryStorage,
|
|
333
|
+
createNamespacedStorage,
|
|
334
|
+
createPipeUpstream,
|
|
335
|
+
createRedisClient,
|
|
336
|
+
createRootStorage,
|
|
337
|
+
createSafeRegExp,
|
|
338
|
+
createSecretData,
|
|
339
|
+
createStdioFramer,
|
|
340
|
+
createStorage,
|
|
341
|
+
createVercelKvClient,
|
|
342
|
+
decryptAesGcm,
|
|
343
|
+
decryptValue,
|
|
344
|
+
deleteSecret,
|
|
345
|
+
describeRedisUrlConflicts,
|
|
346
|
+
deserializeAndDecrypt,
|
|
347
|
+
deserializeBlob,
|
|
348
|
+
detectRuntimeContext,
|
|
349
|
+
dirname,
|
|
350
|
+
encryptAesGcm,
|
|
351
|
+
encryptAndSerialize,
|
|
352
|
+
encryptValue,
|
|
353
|
+
ensureDir,
|
|
354
|
+
ensureDirSync,
|
|
355
|
+
ensureMaxLen,
|
|
356
|
+
entryAvailabilitySchema,
|
|
357
|
+
escapeGlob,
|
|
358
|
+
escapeHtml,
|
|
359
|
+
escapeHtmlAttr,
|
|
360
|
+
escapeJsString,
|
|
361
|
+
escapeScriptClose,
|
|
362
|
+
expandIpv6,
|
|
363
|
+
expandTemplate,
|
|
364
|
+
expandUriTemplate,
|
|
365
|
+
expiresAtToTTL,
|
|
366
|
+
extname,
|
|
367
|
+
extractBracedParams,
|
|
368
|
+
extractEmbeddedIpv4,
|
|
369
|
+
extractTemplateParams,
|
|
370
|
+
extractUriScheme,
|
|
371
|
+
fileExists,
|
|
372
|
+
fileExistsSync,
|
|
373
|
+
findDroppedKeys,
|
|
374
|
+
findNonFiniteNumber,
|
|
375
|
+
generateCodeChallenge,
|
|
376
|
+
generateCodeVerifier,
|
|
377
|
+
generatePkcePair,
|
|
378
|
+
generateRsaKeyPair,
|
|
379
|
+
generateSecret,
|
|
380
|
+
getAsyncContextMode,
|
|
381
|
+
getCookie,
|
|
382
|
+
getCrypto,
|
|
383
|
+
getCwd,
|
|
384
|
+
getDetectedStorageType,
|
|
385
|
+
getEnv,
|
|
386
|
+
getEnvFlag,
|
|
387
|
+
getHostname,
|
|
388
|
+
getMachineId,
|
|
389
|
+
getNodeEnv,
|
|
390
|
+
getOrCreateSecret,
|
|
391
|
+
getRuntimeContext,
|
|
392
|
+
getSpawnFn,
|
|
393
|
+
globToRegex,
|
|
394
|
+
hasTemplatePlaceholders,
|
|
395
|
+
hkdfSha256,
|
|
396
|
+
hmacSha256,
|
|
397
|
+
idFromString,
|
|
398
|
+
inferMimeType,
|
|
399
|
+
isAbsolute,
|
|
400
|
+
isAsymmetricKeyData,
|
|
401
|
+
isBrandedInstance,
|
|
402
|
+
isBrowser,
|
|
403
|
+
isDebug,
|
|
404
|
+
isDevelopment,
|
|
405
|
+
isDirEmpty,
|
|
406
|
+
isEdgeRuntime,
|
|
407
|
+
isEntryAvailable,
|
|
408
|
+
isExpired,
|
|
409
|
+
isInputLengthSafe,
|
|
410
|
+
isLocalhost,
|
|
411
|
+
isNode,
|
|
412
|
+
isPatternSafe,
|
|
413
|
+
isProcessTreeAlive,
|
|
414
|
+
isProduction,
|
|
415
|
+
isRedirectResponse,
|
|
416
|
+
isRsaPssAlg,
|
|
417
|
+
isSecretCached,
|
|
418
|
+
isSecretKeyData,
|
|
419
|
+
isSecretPersistenceEnabled,
|
|
420
|
+
isSecureRequest,
|
|
421
|
+
isServerless,
|
|
422
|
+
isSignedData,
|
|
423
|
+
isUriTemplate,
|
|
424
|
+
isValidCodeChallenge,
|
|
425
|
+
isValidCodeVerifier,
|
|
426
|
+
isValidEncryptedBlob,
|
|
427
|
+
isValidMcpUri,
|
|
428
|
+
isValidMcpUriTemplate,
|
|
429
|
+
joinPath,
|
|
430
|
+
jwtAlgToNodeAlg,
|
|
431
|
+
listChangedNotifications,
|
|
432
|
+
loadSecret,
|
|
433
|
+
lstat,
|
|
434
|
+
makeDevError,
|
|
435
|
+
matchUriTemplate,
|
|
436
|
+
matchesPattern,
|
|
437
|
+
mergeRedisUrlFields,
|
|
438
|
+
mkdir,
|
|
439
|
+
mkdtemp,
|
|
440
|
+
normalizeTTL,
|
|
441
|
+
parseCookies,
|
|
442
|
+
parseIpv4,
|
|
443
|
+
parseKeyData,
|
|
444
|
+
parseSecretData,
|
|
445
|
+
parseUriTemplate,
|
|
446
|
+
pathJoin,
|
|
447
|
+
pathResolve,
|
|
448
|
+
pathToFileURL,
|
|
449
|
+
pemToPublicJwk,
|
|
450
|
+
processPlatformToolCalls,
|
|
451
|
+
processTreeSpawnOptions,
|
|
452
|
+
randomBytes,
|
|
453
|
+
randomUUID,
|
|
454
|
+
readFile,
|
|
455
|
+
readFileBuffer,
|
|
456
|
+
readFileSync,
|
|
457
|
+
readJSON,
|
|
458
|
+
readdir,
|
|
459
|
+
readdirSync,
|
|
460
|
+
realpath,
|
|
461
|
+
reapOrphans,
|
|
462
|
+
redactFields,
|
|
463
|
+
redactJson,
|
|
464
|
+
rename,
|
|
465
|
+
resetRuntimeContext,
|
|
466
|
+
resolveSecretPath,
|
|
467
|
+
rm,
|
|
468
|
+
rsaSignBase64Url,
|
|
469
|
+
rsaVerify,
|
|
470
|
+
rsaVerifySync,
|
|
471
|
+
runCmd,
|
|
472
|
+
runRequestExclusive,
|
|
473
|
+
safeExec,
|
|
474
|
+
safeJsonForScript,
|
|
475
|
+
safeMatch,
|
|
476
|
+
safeReplace,
|
|
477
|
+
safeStringify,
|
|
478
|
+
safeTest,
|
|
479
|
+
sanitizeToJson,
|
|
480
|
+
saveSecret,
|
|
481
|
+
secretDataSchema,
|
|
482
|
+
secretKeyDataSchema,
|
|
483
|
+
sep,
|
|
484
|
+
sepFor,
|
|
485
|
+
serializeBlob,
|
|
486
|
+
setEnv,
|
|
487
|
+
setMachineIdOverride,
|
|
488
|
+
sha256,
|
|
489
|
+
sha256Base64url,
|
|
490
|
+
sha256Hex,
|
|
491
|
+
shortHash,
|
|
492
|
+
signData,
|
|
493
|
+
signalProcessTree,
|
|
494
|
+
spawnOwned,
|
|
495
|
+
splitWords,
|
|
496
|
+
stat,
|
|
497
|
+
stopProcessTree,
|
|
498
|
+
supportsAnsi,
|
|
499
|
+
symlink,
|
|
500
|
+
timingSafeEqual,
|
|
501
|
+
toCase,
|
|
502
|
+
trimBoth,
|
|
503
|
+
trimChars,
|
|
504
|
+
trimLeading,
|
|
505
|
+
trimSlashes,
|
|
506
|
+
trimTrailing,
|
|
507
|
+
tryDecryptValue,
|
|
508
|
+
tryDeserializeAndDecrypt,
|
|
509
|
+
tryDeserializeBlob,
|
|
510
|
+
ttlToExpiresAt,
|
|
511
|
+
unlink,
|
|
512
|
+
validateBaseUrl,
|
|
513
|
+
validateKeyData,
|
|
514
|
+
validateOptionalTTL,
|
|
515
|
+
validatePattern,
|
|
516
|
+
validateSecretData,
|
|
517
|
+
validateTTL,
|
|
518
|
+
verifyCodeChallenge,
|
|
519
|
+
verifyData,
|
|
520
|
+
verifyOrParseData,
|
|
521
|
+
watchFile,
|
|
522
|
+
watchParent,
|
|
523
|
+
watchPath,
|
|
524
|
+
writeFile,
|
|
525
|
+
writeJSON
|
|
526
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// libs/utils/src/llm/llm-tool-handlers.ts
|
|
2
|
+
async function processPlatformToolCalls(platform, calls, callTool) {
|
|
3
|
+
switch (platform) {
|
|
4
|
+
case "openai":
|
|
5
|
+
return processOpenAI(calls, callTool);
|
|
6
|
+
case "claude":
|
|
7
|
+
return processClaude(calls, callTool);
|
|
8
|
+
case "vercel-ai":
|
|
9
|
+
return processVercel(calls, callTool);
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function processOpenAI(toolCalls, callTool) {
|
|
15
|
+
return Promise.all(
|
|
16
|
+
toolCalls.map(async (tc) => {
|
|
17
|
+
let args;
|
|
18
|
+
try {
|
|
19
|
+
args = JSON.parse(tc.function.arguments);
|
|
20
|
+
} catch {
|
|
21
|
+
return {
|
|
22
|
+
role: "tool",
|
|
23
|
+
tool_call_id: tc.id,
|
|
24
|
+
content: JSON.stringify({ error: `Invalid JSON in tool call arguments for "${tc.function.name}"` })
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const result = await callTool(tc.function.name, args);
|
|
28
|
+
return {
|
|
29
|
+
role: "tool",
|
|
30
|
+
tool_call_id: tc.id,
|
|
31
|
+
content: typeof result === "string" ? result : JSON.stringify(result)
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
async function processClaude(toolUseBlocks, callTool) {
|
|
37
|
+
return Promise.all(
|
|
38
|
+
toolUseBlocks.map(async (block) => {
|
|
39
|
+
const result = await callTool(block.name, block.input);
|
|
40
|
+
const content = Array.isArray(result) ? result.map((c) => c.text ?? "").join("\n") : typeof result === "string" ? result : JSON.stringify(result);
|
|
41
|
+
return {
|
|
42
|
+
type: "tool_result",
|
|
43
|
+
tool_use_id: block.id,
|
|
44
|
+
content
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
async function processVercel(info, callTool) {
|
|
50
|
+
const args = info.args != null && typeof info.args === "object" && !Array.isArray(info.args) ? info.args : void 0;
|
|
51
|
+
return callTool(info.toolName, args);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
processPlatformToolCalls
|
|
55
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : undefined;
|
|
2
|
+
const require = __frontmcpModule ? __frontmcpModule.createRequire(import.meta.url || 'file:///') : undefined;
|
|
3
|
+
// __frontmcpCreateRequire
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// libs/utils/src/machine-id/machine-id.ts
|
|
12
|
+
import { randomUUID } from "../crypto/index.mjs";
|
|
13
|
+
import { isBrowser, isNode } from "../crypto/runtime.mjs";
|
|
14
|
+
function getEnvDirect(key) {
|
|
15
|
+
return typeof process !== "undefined" ? process.env[key] : void 0;
|
|
16
|
+
}
|
|
17
|
+
function isProductionDirect() {
|
|
18
|
+
return getEnvDirect("NODE_ENV") === "production";
|
|
19
|
+
}
|
|
20
|
+
var DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
|
|
21
|
+
function isDevPersistenceEnabled() {
|
|
22
|
+
if (isBrowser()) return false;
|
|
23
|
+
return !isProductionDirect();
|
|
24
|
+
}
|
|
25
|
+
function resolveMachineIdPath() {
|
|
26
|
+
if (isBrowser()) return DEFAULT_MACHINE_ID_PATH;
|
|
27
|
+
const path = __require("path");
|
|
28
|
+
const machineIdPath = getEnvDirect("MACHINE_ID_PATH") ?? DEFAULT_MACHINE_ID_PATH;
|
|
29
|
+
const cwd = typeof process !== "undefined" ? process.cwd() : ".";
|
|
30
|
+
return path.isAbsolute(machineIdPath) ? machineIdPath : path.resolve(cwd, machineIdPath);
|
|
31
|
+
}
|
|
32
|
+
function loadMachineIdSync() {
|
|
33
|
+
if (!isDevPersistenceEnabled()) return null;
|
|
34
|
+
const machineIdPath = resolveMachineIdPath();
|
|
35
|
+
try {
|
|
36
|
+
const fs = __require("fs");
|
|
37
|
+
const content = fs.readFileSync(machineIdPath, "utf8").trim();
|
|
38
|
+
if (/^[0-9a-f-]{32,36}$/i.test(content)) return content;
|
|
39
|
+
console.warn(`[MachineId] Invalid format at ${machineIdPath}, will regenerate`);
|
|
40
|
+
return null;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error.code !== "ENOENT") {
|
|
43
|
+
console.warn(`[MachineId] Failed to load from ${machineIdPath}: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function saveMachineIdAsync(machineId) {
|
|
49
|
+
if (!isDevPersistenceEnabled()) return;
|
|
50
|
+
const machineIdPath = resolveMachineIdPath();
|
|
51
|
+
const path = __require("path");
|
|
52
|
+
const dir = path.dirname(machineIdPath);
|
|
53
|
+
(async () => {
|
|
54
|
+
try {
|
|
55
|
+
const fsp = __require("fs").promises;
|
|
56
|
+
await fsp.mkdir(dir, { recursive: true, mode: 448 });
|
|
57
|
+
await fsp.writeFile(machineIdPath, machineId, { mode: 384 });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
62
|
+
}
|
|
63
|
+
function getHostname() {
|
|
64
|
+
if (!isNode()) return void 0;
|
|
65
|
+
try {
|
|
66
|
+
return __require("os").hostname();
|
|
67
|
+
} catch {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function computeMachineId() {
|
|
72
|
+
const envMachineId = getEnvDirect("MACHINE_ID");
|
|
73
|
+
if (envMachineId) return envMachineId;
|
|
74
|
+
const deploymentMode = getEnvDirect("FRONTMCP_DEPLOYMENT_MODE");
|
|
75
|
+
if (deploymentMode === "distributed") {
|
|
76
|
+
const hostname = getEnvDirect("HOSTNAME");
|
|
77
|
+
if (hostname) return hostname;
|
|
78
|
+
if (isNode()) {
|
|
79
|
+
const os = __require("os");
|
|
80
|
+
return os.hostname();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (deploymentMode === "serverless") {
|
|
84
|
+
return randomUUID();
|
|
85
|
+
}
|
|
86
|
+
const loadedId = loadMachineIdSync();
|
|
87
|
+
if (loadedId) return loadedId;
|
|
88
|
+
const newId = randomUUID();
|
|
89
|
+
saveMachineIdAsync(newId);
|
|
90
|
+
return newId;
|
|
91
|
+
}
|
|
92
|
+
var cachedMachineId;
|
|
93
|
+
var machineIdOverride;
|
|
94
|
+
function getMachineId() {
|
|
95
|
+
if (machineIdOverride !== void 0) return machineIdOverride;
|
|
96
|
+
if (cachedMachineId === void 0) {
|
|
97
|
+
cachedMachineId = computeMachineId();
|
|
98
|
+
}
|
|
99
|
+
return cachedMachineId;
|
|
100
|
+
}
|
|
101
|
+
function setMachineIdOverride(id) {
|
|
102
|
+
machineIdOverride = id;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
getHostname,
|
|
106
|
+
getMachineId,
|
|
107
|
+
setMachineIdOverride
|
|
108
|
+
};
|