@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.
Files changed (137) hide show
  1. package/README.md +1 -0
  2. package/browser/async-context/browser-async-context.mjs +177 -0
  3. package/browser/async-context/index.mjs +15 -0
  4. package/browser/async-context/overlap-error.mjs +10 -0
  5. package/browser/class-brand/class-brand.mjs +27 -0
  6. package/browser/class-brand/index.mjs +6 -0
  7. package/browser/content/content.mjs +151 -0
  8. package/browser/content/index.mjs +8 -0
  9. package/browser/crypto/browser.mjs +103 -0
  10. package/browser/crypto/encrypted-blob.mjs +119 -0
  11. package/browser/crypto/hmac-signing.mjs +70 -0
  12. package/browser/crypto/index.mjs +281 -0
  13. package/browser/crypto/jwt-alg.mjs +40 -0
  14. package/browser/crypto/key-persistence/factory.mjs +134 -0
  15. package/browser/crypto/key-persistence/index.mjs +26 -0
  16. package/browser/crypto/key-persistence/key-persistence.mjs +185 -0
  17. package/browser/crypto/key-persistence/schemas.mjs +82 -0
  18. package/browser/crypto/pkce/index.mjs +25 -0
  19. package/browser/crypto/pkce/pkce.mjs +59 -0
  20. package/browser/crypto/runtime.mjs +17 -0
  21. package/browser/crypto/secret-persistence/index.mjs +29 -0
  22. package/browser/crypto/secret-persistence/persistence.mjs +181 -0
  23. package/browser/crypto/secret-persistence/schema.mjs +40 -0
  24. package/browser/crypto/web-rsa.mjs +36 -0
  25. package/browser/env/browser-env.mjs +56 -0
  26. package/browser/env/browser-runtime-context.mjs +85 -0
  27. package/browser/env/build-target.mjs +25 -0
  28. package/browser/env/edge-scope.mjs +17 -0
  29. package/browser/env/index.mjs +47 -0
  30. package/browser/env/provider.mjs +46 -0
  31. package/browser/escape/escape.mjs +43 -0
  32. package/browser/escape/index.mjs +9 -0
  33. package/browser/event-emitter/browser-event-emitter.mjs +49 -0
  34. package/browser/event-emitter/index.mjs +5 -0
  35. package/browser/fs/fs.mjs +227 -0
  36. package/browser/fs/index.mjs +65 -0
  37. package/browser/http/cookie.mjs +85 -0
  38. package/browser/http/http.mjs +18 -0
  39. package/browser/http/index.mjs +11 -0
  40. package/browser/index.mjs +526 -0
  41. package/browser/llm/index.mjs +5 -0
  42. package/browser/llm/llm-tool-handlers.mjs +55 -0
  43. package/browser/machine-id/index.mjs +7 -0
  44. package/browser/machine-id/machine-id.mjs +108 -0
  45. package/browser/naming/index.mjs +10 -0
  46. package/browser/naming/naming.mjs +68 -0
  47. package/browser/net/index.mjs +10 -0
  48. package/browser/net/ip-address.mjs +128 -0
  49. package/browser/net/redirect.mjs +7 -0
  50. package/browser/path/browser-path.mjs +47 -0
  51. package/browser/path/index.mjs +24 -0
  52. package/browser/path/path.mjs +13 -0
  53. package/browser/process/child-process.mjs +23 -0
  54. package/browser/process/index.mjs +15 -0
  55. package/browser/process/owned-process.mjs +175 -0
  56. package/browser/process/process-tree.mjs +149 -0
  57. package/browser/process/process-watch.mjs +48 -0
  58. package/browser/redaction/index.mjs +6 -0
  59. package/browser/redaction/redaction.mjs +74 -0
  60. package/browser/regex/index.mjs +3 -0
  61. package/browser/regex/patterns.mjs +167 -0
  62. package/browser/regex/safe-regex.mjs +93 -0
  63. package/browser/serialization/index.mjs +5 -0
  64. package/browser/serialization/serialization.mjs +22 -0
  65. package/browser/stdio-bridge/errors.mjs +27 -0
  66. package/browser/stdio-bridge/index.mjs +24 -0
  67. package/browser/stdio-bridge/list-changed.mjs +21 -0
  68. package/browser/stdio-bridge/state-machine.mjs +211 -0
  69. package/browser/stdio-bridge/stdio-framer.mjs +91 -0
  70. package/browser/stdio-bridge/upstream-client.mjs +189 -0
  71. package/browser/storage/adapters/base.mjs +139 -0
  72. package/browser/storage/adapters/cloudflare-kv.mjs +149 -0
  73. package/browser/storage/adapters/filesystem.mjs +279 -0
  74. package/browser/storage/adapters/index.mjs +23 -0
  75. package/browser/storage/adapters/indexeddb.mjs +198 -0
  76. package/browser/storage/adapters/localstorage.mjs +222 -0
  77. package/browser/storage/adapters/memory.mjs +350 -0
  78. package/browser/storage/adapters/redis.mjs +497 -0
  79. package/browser/storage/adapters/upstash.mjs +299 -0
  80. package/browser/storage/adapters/vercel-kv.mjs +226 -0
  81. package/browser/storage/change-feed.mjs +189 -0
  82. package/browser/storage/encrypted-typed-storage.mjs +329 -0
  83. package/browser/storage/errors.mjs +92 -0
  84. package/browser/storage/factory.mjs +155 -0
  85. package/browser/storage/index.mjs +96 -0
  86. package/browser/storage/namespace.mjs +186 -0
  87. package/browser/storage/redis-error-listener.mjs +32 -0
  88. package/browser/storage/redis-url.mjs +66 -0
  89. package/browser/storage/typed-storage.mjs +171 -0
  90. package/browser/storage/utils/compare-and-delete.mjs +9 -0
  91. package/browser/storage/utils/index.mjs +24 -0
  92. package/browser/storage/utils/pattern.mjs +68 -0
  93. package/browser/storage/utils/ttl.mjs +48 -0
  94. package/browser/uri/index.mjs +19 -0
  95. package/browser/uri/uri-template.mjs +86 -0
  96. package/browser/uri/uri-validation.mjs +18 -0
  97. package/content/content.d.ts +8 -0
  98. package/content/index.d.ts +1 -1
  99. package/crypto/browser.d.ts +1 -13
  100. package/crypto/browser.js +1 -1
  101. package/crypto/node.js +1 -1
  102. package/crypto/web-rsa.d.ts +13 -0
  103. package/env/browser-runtime-context.js +1 -1
  104. package/env/runtime-context.js +1 -1
  105. package/esm/crypto/browser.mjs +1 -1
  106. package/esm/crypto/node.mjs +1 -1
  107. package/esm/env/browser-runtime-context.mjs +1 -1
  108. package/esm/env/runtime-context.mjs +1 -1
  109. package/esm/index.mjs +1 -1
  110. package/fs/fs.d.ts +45 -4
  111. package/fs/index.d.ts +1 -1
  112. package/index.d.ts +10 -4
  113. package/index.js +1 -1
  114. package/package.json +24 -8
  115. package/process/child-process.d.ts +2 -0
  116. package/process/index.d.ts +6 -0
  117. package/process/owned-process.d.ts +59 -0
  118. package/process/process-tree.d.ts +78 -0
  119. package/process/process-watch.d.ts +41 -0
  120. package/redaction/index.d.ts +2 -0
  121. package/redaction/redaction.d.ts +24 -0
  122. package/stdio-bridge/errors.d.ts +23 -0
  123. package/stdio-bridge/index.d.ts +9 -0
  124. package/stdio-bridge/list-changed.d.ts +3 -0
  125. package/stdio-bridge/state-machine.d.ts +61 -0
  126. package/stdio-bridge/stdio-framer.d.ts +49 -0
  127. package/stdio-bridge/types.d.ts +10 -0
  128. package/stdio-bridge/upstream-client.d.ts +66 -0
  129. package/storage/adapters/base.d.ts +2 -0
  130. package/storage/adapters/memory.d.ts +1 -0
  131. package/storage/adapters/redis.d.ts +3 -0
  132. package/storage/change-feed.d.ts +47 -0
  133. package/storage/factory.d.ts +6 -0
  134. package/storage/index.d.ts +3 -1
  135. package/storage/namespace.d.ts +2 -0
  136. package/storage/types.d.ts +46 -1
  137. package/storage/utils/compare-and-delete.d.ts +2 -0
package/fs/fs.d.ts CHANGED
@@ -11,9 +11,10 @@
11
11
  * detached worker (CLI task runners, dev-server supervisors, etc.). Throws
12
12
  * via `assertNode` on non-Node runtimes.
13
13
  *
14
- * **Node.js only.** Exposed because consumers (e.g. `CliTaskRunner` in the
15
- * SDK) need a single place to reach `spawn` without a top-level
16
- * `import 'node:child_process'` that V8 isolates would choke on.
14
+ * **Node.js only.** Exposed so consumers have a single place to reach `spawn`
15
+ * without a top-level `import 'node:child_process'` that V8 isolates would
16
+ * choke on. A worker that should be reapable once its owner dies is spawned
17
+ * with `spawnOwned` instead (as `CliTaskRunner` in the SDK does).
17
18
  */
18
19
  export declare function getSpawnFn(): typeof import('child_process').spawn;
19
20
  /**
@@ -64,13 +65,26 @@ export declare function readFileBuffer(p: string): Promise<Buffer>;
64
65
  *
65
66
  * @param p - Path to write to
66
67
  * @param content - Content to write
67
- * @param options - Optional mode (permissions)
68
+ * @param options - Optional mode (permissions, applied when the file is created) and flag (e.g. `'a'` to append)
68
69
  *
69
70
  * @example
70
71
  * await writeFile('/path/to/file.txt', 'hello', { mode: 0o600 });
71
72
  */
72
73
  export declare function writeFile(p: string, content: string, options?: {
73
74
  mode?: number;
75
+ flag?: string;
76
+ }): Promise<void>;
77
+ /**
78
+ * Append content to a file, creating the file when it is missing.
79
+ *
80
+ * **Node.js only** - throws an error if called in browser.
81
+ *
82
+ * @param p - Path to append to
83
+ * @param content - Content to append
84
+ * @param options - The mode (permissions) a file created here gets, e.g. 0o600
85
+ */
86
+ export declare function appendFile(p: string, content: string, options?: {
87
+ mode?: number;
74
88
  }): Promise<void>;
75
89
  /**
76
90
  * Create a directory with optional mode (permissions).
@@ -152,6 +166,8 @@ export declare function fileExists(p: string): Promise<boolean>;
152
166
  * fileExistsSync('/path/to/file.txt') // true or false
153
167
  */
154
168
  export declare function fileExistsSync(p: string): boolean;
169
+ /** Whether `p` is known to be missing: a check that fails another way (no access, a timeout) can't tell. */
170
+ export declare function isMissingSync(p: string): boolean;
155
171
  /**
156
172
  * Read and parse a JSON file.
157
173
  *
@@ -200,6 +216,31 @@ export declare function ensureDir(p: string): Promise<void>;
200
216
  * if (stats.isDirectory()) { ... }
201
217
  */
202
218
  export declare function stat(p: string): Promise<import('fs').Stats>;
219
+ /**
220
+ * Get file/directory stats without following a symlink.
221
+ *
222
+ * **Node.js only** - throws an error if called in browser.
223
+ *
224
+ * @param p - Path to file, directory, socket or symlink
225
+ * @returns Stats of the entry itself (isSocket(), isSymbolicLink(), mode, uid, ...)
226
+ *
227
+ * @example
228
+ * const stats = await lstat('/tmp/app.sock');
229
+ * if (stats.isSocket()) { ... }
230
+ */
231
+ export declare function lstat(p: string): Promise<import('fs').Stats>;
232
+ /**
233
+ * Change the permission bits of a file or directory.
234
+ *
235
+ * **Node.js only** - throws an error if called in browser.
236
+ *
237
+ * @param p - Path to file or directory
238
+ * @param mode - Permission bits, e.g. 0o600
239
+ *
240
+ * @example
241
+ * await chmod('/tmp/app.sock', 0o600);
242
+ */
243
+ export declare function chmod(p: string, mode: number): Promise<void>;
203
244
  /** Link type accepted by {@link symlink}; only meaningful on Windows. */
204
245
  export type SymlinkType = 'dir' | 'file' | 'junction';
205
246
  /**
package/fs/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { readFile, readFileSync, readFileBuffer, writeFile, mkdir, rename, unlink, stat, copyFile, cp, readdir, readdirSync, realpath, rm, mkdtemp, symlink, access, fileExists, fileExistsSync, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
1
+ export { readFile, readFileSync, readFileBuffer, writeFile, appendFile, mkdir, rename, unlink, stat, lstat, chmod, copyFile, cp, readdir, readdirSync, realpath, rm, mkdtemp, symlink, access, fileExists, fileExistsSync, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
2
2
  export type { FileWatcherHandle, SymlinkType } from './fs';
package/index.d.ts CHANGED
@@ -10,13 +10,19 @@ export type { NameCase } from './naming';
10
10
  export { isValidMcpUri, extractUriScheme, isValidMcpUriTemplate, parseUriTemplate, matchUriTemplate, expandUriTemplate, extractTemplateParams, isUriTemplate, } from './uri';
11
11
  export type { ParsedUriTemplate } from './uri';
12
12
  export { trimSlashes, joinPath, pathResolve, pathJoin, basename, dirname, extname, isAbsolute, pathToFileURL, sep, } from './path';
13
- export { sanitizeToJson, inferMimeType, findNonFiniteNumber } from './content';
13
+ export { sanitizeToJson, inferMimeType, findNonFiniteNumber, findDroppedKeys } from './content';
14
14
  export { validateBaseUrl, buildSetCookie, parseCookies, getCookie, isLocalhost, isSecureRequest } from './http';
15
15
  export type { CookieOptions, SecureDetectionRequest } from './http';
16
16
  export { classifyIpAddress, expandIpv6, extractEmbeddedIpv4, parseIpv4, isRedirectResponse } from './net';
17
17
  export type { IpAddressClassification, IpAddressRange, SpecialPurposeIpRange, RedirectCandidate } from './net';
18
- export { readFile, readFileSync, readFileBuffer, writeFile, mkdir, rename, unlink, stat, copyFile, cp, readdir, readdirSync, realpath, rm, mkdtemp, symlink, access, fileExists, fileExistsSync, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
18
+ export { readFile, readFileSync, readFileBuffer, writeFile, appendFile, mkdir, rename, unlink, stat, lstat, chmod, copyFile, cp, readdir, readdirSync, realpath, rm, mkdtemp, symlink, access, fileExists, fileExistsSync, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
19
19
  export type { FileWatcherHandle } from './fs';
20
+ export { processTreeSpawnOptions, signalProcessTree, isProcessTreeAlive, stopProcessTree, spawnOwned, reapOrphans, OwnedProcessError, watchParent, watchPath, } from './process';
21
+ export type { ProcessTreeDeps, SpawnOwnedOptions, OwnedProcess, ReapOrphansOptions, ParentGoneReason, ProcessWatcher, WatchParentOptions, WatchPathOptions, } from './process';
22
+ export { DEV_BUFFER_FULL, DEV_ERROR_MESSAGE, DEV_RELOAD_DEADLINE, DEV_SERVER_UNREACHABLE, makeDevError, listChangedNotifications, createBridgeStateMachine, createStdioFramer, createHttpUpstream, createPipeUpstream, } from './stdio-bridge';
23
+ export type { BridgeState, BridgeStateMachine, BridgeStateMachineOptions, InflightRequest, JsonRpcFrame, StdioFramer, StdioFramerOptions, BridgeLogger, HttpUpstreamClient, HttpUpstreamOptions, PipeUpstreamOptions, UpstreamClient, UpstreamClientOptions, } from './stdio-bridge';
24
+ export { redactFields, redactJson } from './redaction';
25
+ export type { RedactedFields } from './redaction';
20
26
  export { escapeHtml, escapeHtmlAttr, escapeJsString, escapeScriptClose, safeJsonForScript } from './escape';
21
27
  export { brandClass, isBrandedInstance } from './class-brand';
22
28
  export { safeStringify } from './serialization';
@@ -27,8 +33,8 @@ export { EventEmitter } from './event-emitter';
27
33
  export { getEnv, getNodeEnv, getCwd, isProduction, isDevelopment, getEnvFlag, isDebug, setEnv, isEdgeRuntime, isServerless, supportsAnsi, getRuntimeContext, resetRuntimeContext, detectRuntimeContext, isEntryAvailable, checkEntryAvailability, entryAvailabilitySchema, } from './env';
28
34
  export type { RuntimeContext, EntryAvailability } from './env';
29
35
  export { analyzePattern, isPatternSafe, createSafeRegExp, safeTest, safeMatch, safeReplace, safeExec, isInputLengthSafe, DEFAULT_MAX_INPUT_LENGTH, REDOS_THRESHOLDS, trimLeading, trimTrailing, trimBoth, trimChars, extractBracedParams, expandTemplate, hasTemplatePlaceholders, collapseChar, collapseWhitespace, type SafeRegexOptions, type PatternAnalysisResult, } from './regex';
30
- export { createStorage, createMemoryStorage, getDetectedStorageType, NamespacedStorageImpl, createRootStorage, createNamespacedStorage, buildPrefix, NAMESPACE_SEPARATOR, StorageError, StorageConnectionError, StorageOperationError, StorageNotSupportedError, StorageConfigError, StorageTTLError, StoragePatternError, StorageNotConnectedError, EncryptedStorageError, BaseStorageAdapter, MemoryStorageAdapter, RedisStorageAdapter, createRedisClient, VercelKvStorageAdapter, createVercelKvClient, type VercelKvConnection, UpstashStorageAdapter, FileSystemStorageAdapter, type FileSystemAdapterOptions, TypedStorage, type TypedStorageOptions, type TypedSetOptions, type TypedSetEntry, EncryptedTypedStorage, type EncryptedTypedStorageOptions, type EncryptedSetOptions, type EncryptedSetEntry, type EncryptionKey, type StoredEncryptedBlob, type ClientKeyBinding, globToRegex, matchesPattern, validatePattern, escapeGlob, MAX_TTL_SECONDS, validateTTL, validateOptionalTTL, ttlToExpiresAt, expiresAtToTTL, isExpired, normalizeTTL, attachRedisErrorListener, DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS, mergeRedisUrlFields, describeRedisUrlConflicts, } from './storage';
31
- export type { StorageAdapter, NamespacedStorage, RootStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe, MemoryAdapterOptions, RedisAdapterOptions, RedisHostConnectionConfig, RedisUrlConnectionConfig, RedisUrlFillInConfig, VercelKvAdapterOptions, UpstashAdapterOptions, StorageType, StorageConfig, RedisErrorListenerOptions, RedisUrlConnection, RedisUrlMerge, RedisUrlSiblingFields, CreateRedisClientOptions, ErrorEmitterClient, } from './storage';
36
+ export { createStorage, createMemoryStorage, getDetectedStorageType, createChangeFeed, DEFAULT_CHANGE_FEED_COALESCE_MS, DEFAULT_CHANGE_FEED_POLL_INTERVAL_MS, NamespacedStorageImpl, createRootStorage, createNamespacedStorage, buildPrefix, NAMESPACE_SEPARATOR, StorageError, StorageConnectionError, StorageOperationError, StorageNotSupportedError, StorageConfigError, StorageTTLError, StoragePatternError, StorageNotConnectedError, EncryptedStorageError, BaseStorageAdapter, MemoryStorageAdapter, RedisStorageAdapter, createRedisClient, VercelKvStorageAdapter, createVercelKvClient, type VercelKvConnection, UpstashStorageAdapter, FileSystemStorageAdapter, type FileSystemAdapterOptions, TypedStorage, type TypedStorageOptions, type TypedSetOptions, type TypedSetEntry, EncryptedTypedStorage, type EncryptedTypedStorageOptions, type EncryptedSetOptions, type EncryptedSetEntry, type EncryptionKey, type StoredEncryptedBlob, type ClientKeyBinding, globToRegex, matchesPattern, validatePattern, escapeGlob, MAX_TTL_SECONDS, validateTTL, validateOptionalTTL, ttlToExpiresAt, expiresAtToTTL, isExpired, normalizeTTL, attachRedisErrorListener, DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS, mergeRedisUrlFields, describeRedisUrlConflicts, } from './storage';
37
+ export type { StorageAdapter, NamespacedStorage, RootStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe, MemoryAdapterOptions, RedisAdapterOptions, RedisHostConnectionConfig, RedisUrlConnectionConfig, RedisUrlFillInConfig, VercelKvAdapterOptions, UpstashAdapterOptions, SqliteAdapterOptions, StorageType, StorageConfig, RedisErrorListenerOptions, RedisUrlConnection, RedisUrlMerge, RedisUrlSiblingFields, CreateRedisClientOptions, ErrorEmitterClient, ChangeFeed, ChangeFeedKind, ChangeFeedOptions, } from './storage';
32
38
  export { processPlatformToolCalls } from './llm';
33
39
  export type { CallToolFn, OpenAIToolCallItem, OpenAIToolResponse, ClaudeToolUseBlock, ClaudeToolResultBlock, VercelToolCallInfo, PlatformToolCallsInput, PlatformToolCallsOutput, SupportedPlatform, } from './llm';
34
40
  export { getHostname, getMachineId, setMachineIdOverride } from './machine-id';