@frontmcp/utils 1.10.16 → 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/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 +20 -4
- package/fs/index.d.ts +1 -1
- package/index.d.ts +9 -3
- 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
package/storage/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Unified storage abstraction with pluggable backends.
|
|
5
5
|
* Supports Memory (dev), Redis (prod), Vercel KV (edge), and Upstash (edge + pub/sub).
|
|
6
6
|
*/
|
|
7
|
-
export type { StorageAdapter, NamespacedStorage, RootStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe, MemoryAdapterOptions, RedisAdapterOptions, RedisHostConnectionConfig, RedisUrlConnectionConfig, RedisUrlFillInConfig, VercelKvAdapterOptions, UpstashAdapterOptions, StorageType, StorageConfig, } from './types';
|
|
7
|
+
export type { StorageAdapter, NamespacedStorage, RootStorage, SetOptions, SetEntry, MessageHandler, Unsubscribe, MemoryAdapterOptions, RedisAdapterOptions, RedisHostConnectionConfig, RedisUrlConnectionConfig, RedisUrlFillInConfig, VercelKvAdapterOptions, UpstashAdapterOptions, SqliteAdapterOptions, StorageType, StorageConfig, } from './types';
|
|
8
8
|
export { createStorage, createMemoryStorage, getDetectedStorageType } from './factory';
|
|
9
|
+
export { createChangeFeed, DEFAULT_CHANGE_FEED_COALESCE_MS, DEFAULT_CHANGE_FEED_POLL_INTERVAL_MS } from './change-feed';
|
|
10
|
+
export type { ChangeFeed, ChangeFeedKind, ChangeFeedOptions } from './change-feed';
|
|
9
11
|
export { attachRedisErrorListener, DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS } from './redis-error-listener';
|
|
10
12
|
export type { RedisErrorListenerOptions, ErrorEmitterClient } from './redis-error-listener';
|
|
11
13
|
export { mergeRedisUrlFields, describeRedisUrlConflicts } from './redis-url';
|
package/storage/namespace.d.ts
CHANGED
|
@@ -68,8 +68,10 @@ export declare class NamespacedStorageImpl implements NamespacedStorage {
|
|
|
68
68
|
incrBy(key: string, amount: number): Promise<number>;
|
|
69
69
|
deleteIfEquals(key: string, expectedValue: string): Promise<boolean>;
|
|
70
70
|
expireIfEquals(key: string, expectedValue: string, ttlSeconds: number): Promise<boolean>;
|
|
71
|
+
setIfEquals(key: string, expectedValue: string, value: string): Promise<boolean>;
|
|
71
72
|
publish(channel: string, message: string): Promise<number>;
|
|
72
73
|
subscribe(channel: string, handler: MessageHandler): Promise<Unsubscribe>;
|
|
74
|
+
onPubSubReconnect(listener: () => void): () => void;
|
|
73
75
|
supportsPubSub(): boolean;
|
|
74
76
|
}
|
|
75
77
|
/**
|
package/storage/types.d.ts
CHANGED
|
@@ -224,6 +224,22 @@ export interface StorageAdapter {
|
|
|
224
224
|
* @throws StorageNotSupportedError if the backend has no atomic compare-and-expire
|
|
225
225
|
*/
|
|
226
226
|
expireIfEquals?(key: string, expectedValue: string, ttlSeconds: number): Promise<boolean>;
|
|
227
|
+
/**
|
|
228
|
+
* Atomically replace a key's value only while it still holds `expectedValue` (compare-and-set).
|
|
229
|
+
* Like a plain `set(key, value)`, the key has no TTL afterwards.
|
|
230
|
+
*
|
|
231
|
+
* @param key - Storage key
|
|
232
|
+
* @param expectedValue - The exact value the key must hold
|
|
233
|
+
* @param value - The value to store
|
|
234
|
+
* @returns true if this call stored `value`, false if the key was missing or held another value
|
|
235
|
+
* @throws StorageNotSupportedError if the backend has no atomic compare-and-set
|
|
236
|
+
*/
|
|
237
|
+
setIfEquals?(key: string, expectedValue: string, value: string): Promise<boolean>;
|
|
238
|
+
/**
|
|
239
|
+
* A number that changes whenever another connection commits a write (SQLite's `PRAGMA data_version`),
|
|
240
|
+
* so a change feed can tell cheaply that another process wrote. Only the SQLite adapter has it.
|
|
241
|
+
*/
|
|
242
|
+
dataVersion?(): Promise<number>;
|
|
227
243
|
/**
|
|
228
244
|
* Publish a message to a channel.
|
|
229
245
|
* Not all adapters support pub/sub (e.g., Vercel KV doesn't).
|
|
@@ -244,6 +260,13 @@ export interface StorageAdapter {
|
|
|
244
260
|
* @throws StorageNotSupportedError if adapter doesn't support pub/sub
|
|
245
261
|
*/
|
|
246
262
|
subscribe(channel: string, handler: MessageHandler): Promise<Unsubscribe>;
|
|
263
|
+
/**
|
|
264
|
+
* Call `listener` each time the pub/sub connection is back after it was lost. The messages published while it
|
|
265
|
+
* was down were missed, so a subscriber that must not miss a change re-reads the state. Only Redis has it.
|
|
266
|
+
*
|
|
267
|
+
* @returns The function that stops calling `listener`
|
|
268
|
+
*/
|
|
269
|
+
onPubSubReconnect?(listener: () => void): () => void;
|
|
247
270
|
/**
|
|
248
271
|
* Check if this adapter supports pub/sub.
|
|
249
272
|
*
|
|
@@ -290,6 +313,8 @@ export interface NamespacedStorage extends StorageAdapter {
|
|
|
290
313
|
deleteIfEquals(key: string, expectedValue: string): Promise<boolean>;
|
|
291
314
|
/** {@link StorageAdapter.expireIfEquals}; throws StorageNotSupportedError when the adapter has none. */
|
|
292
315
|
expireIfEquals(key: string, expectedValue: string, ttlSeconds: number): Promise<boolean>;
|
|
316
|
+
/** {@link StorageAdapter.setIfEquals}; throws StorageNotSupportedError when the adapter has none. */
|
|
317
|
+
setIfEquals(key: string, expectedValue: string, value: string): Promise<boolean>;
|
|
293
318
|
/**
|
|
294
319
|
* Get the underlying root adapter (for advanced use).
|
|
295
320
|
* Use with caution - operations bypass namespace prefixing.
|
|
@@ -457,10 +482,25 @@ export interface CloudflareKvAdapterOptions {
|
|
|
457
482
|
/** Key prefix applied to all keys. @default '' */
|
|
458
483
|
keyPrefix?: string;
|
|
459
484
|
}
|
|
485
|
+
/** SQLite adapter options (type 'sqlite', from `@frontmcp/storage-sqlite`): processes on one file share its keys. */
|
|
486
|
+
export interface SqliteAdapterOptions {
|
|
487
|
+
/** Path to the database file; its directory is created if missing. */
|
|
488
|
+
path: string;
|
|
489
|
+
/** Write-ahead log: readers don't wait for the writer. Needs a local filesystem. @default true */
|
|
490
|
+
walMode?: boolean;
|
|
491
|
+
/** How long an operation waits for another process's lock before failing with `SQLITE_BUSY`. @default 5000 */
|
|
492
|
+
busyTimeoutMs?: number;
|
|
493
|
+
/** How often expired keys are purged, in milliseconds; 0 turns the sweep off. @default 60000 */
|
|
494
|
+
ttlCleanupIntervalMs?: number;
|
|
495
|
+
/** Encrypt values at rest with AES-256-GCM, from a key derived with HKDF-SHA256. */
|
|
496
|
+
encryption?: {
|
|
497
|
+
secret: string;
|
|
498
|
+
};
|
|
499
|
+
}
|
|
460
500
|
/**
|
|
461
501
|
* Storage backend type.
|
|
462
502
|
*/
|
|
463
|
-
export type StorageType = 'memory' | 'redis' | 'vercel-kv' | 'upstash' | 'cloudflare-kv' | 'auto';
|
|
503
|
+
export type StorageType = 'memory' | 'redis' | 'vercel-kv' | 'upstash' | 'cloudflare-kv' | 'sqlite' | 'auto';
|
|
464
504
|
/**
|
|
465
505
|
* Configuration for createStorage factory.
|
|
466
506
|
*/
|
|
@@ -471,6 +511,7 @@ export interface StorageConfig {
|
|
|
471
511
|
* - 'redis': Redis (production)
|
|
472
512
|
* - 'vercel-kv': Vercel KV (edge deployment, no pub/sub)
|
|
473
513
|
* - 'upstash': Upstash Redis (edge deployment, with pub/sub)
|
|
514
|
+
* - 'sqlite': A local SQLite file, shared by the processes on one machine (no pub/sub)
|
|
474
515
|
* - 'auto': Auto-detect based on environment variables
|
|
475
516
|
* @default 'auto'
|
|
476
517
|
*/
|
|
@@ -495,6 +536,10 @@ export interface StorageConfig {
|
|
|
495
536
|
* Upstash adapter options (when type='upstash').
|
|
496
537
|
*/
|
|
497
538
|
upstash?: UpstashAdapterOptions;
|
|
539
|
+
/**
|
|
540
|
+
* SQLite adapter options (when type='sqlite').
|
|
541
|
+
*/
|
|
542
|
+
sqlite?: SqliteAdapterOptions;
|
|
498
543
|
/**
|
|
499
544
|
* Root namespace prefix for all keys.
|
|
500
545
|
* Applied on top of any adapter-specific prefix.
|
|
@@ -2,3 +2,5 @@
|
|
|
2
2
|
export declare const COMPARE_AND_DELETE_SCRIPT = "if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) end return 0";
|
|
3
3
|
/** Redis Lua script for `expireIfEquals`: sets KEYS[1]'s TTL to ARGV[2] seconds only while it holds ARGV[1]. */
|
|
4
4
|
export declare const COMPARE_AND_EXPIRE_SCRIPT = "if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('EXPIRE', KEYS[1], ARGV[2]) end return 0";
|
|
5
|
+
/** Redis Lua script for `setIfEquals`: sets KEYS[1] to ARGV[2] only while it holds ARGV[1], returning 1 or 0. */
|
|
6
|
+
export declare const COMPARE_AND_SET_SCRIPT = "if redis.call('GET', KEYS[1]) == ARGV[1] then redis.call('SET', KEYS[1], ARGV[2]) return 1 end return 0";
|