@frontmcp/utils 1.9.3 → 1.9.5
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/class-brand/class-brand.d.ts +37 -0
- package/class-brand/index.d.ts +1 -0
- package/esm/index.mjs +51 -7
- package/fs/fs.d.ts +24 -1
- package/fs/index.d.ts +1 -1
- package/index.d.ts +3 -2
- package/index.js +55 -7
- package/machine-id/index.d.ts +1 -1
- package/machine-id/machine-id.d.ts +2 -0
- package/package.json +2 -2
- package/storage/factory.d.ts +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class identity shared by every copy of a package loaded in one process.
|
|
3
|
+
*
|
|
4
|
+
* A process can hold two copies of a FrontMCP package: in an ES-module project `@frontmcp/sdk`'s ESM
|
|
5
|
+
* build loads `@frontmcp/observability` with `require()`, which resolves observability's CommonJS
|
|
6
|
+
* build, which in turn loads the CommonJS builds of the SDK and of its dependencies. Each copy has its
|
|
7
|
+
* own classes, so a plain `instanceof` in one copy does not recognise an instance made by the other:
|
|
8
|
+
* an error the client was answered with as a `PublicMcpError` was recorded as an internal error with
|
|
9
|
+
* a new id (#802).
|
|
10
|
+
*
|
|
11
|
+
* A branded class answers `instanceof` for its own instances as usual, and also for an instance of
|
|
12
|
+
* the class with the same brand from another copy. The brand is an own property of the class, so a
|
|
13
|
+
* subclass is recognised only through a brand of its own: an unbranded subclass keeps the plain
|
|
14
|
+
* check, and never matches a different subclass that happens to share a branded parent.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* export class GuardError extends Error {
|
|
19
|
+
* static override [Symbol.hasInstance](value: unknown): boolean {
|
|
20
|
+
* return isBrandedInstance(this, value);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* brandClass(GuardError, '@frontmcp/guard:GuardError');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Give `klass` a process-wide brand. The same class in another copy of its package carries the same
|
|
28
|
+
* brand, so each recognises the other's instances through {@link isBrandedInstance}. Namespace the
|
|
29
|
+
* brand with the package name (`'@frontmcp/sdk:McpError'`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function brandClass(klass: object, brand: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* `value instanceof klass`, also true when `value` is an instance of the class that carries `klass`'s
|
|
34
|
+
* own brand in another copy of the package. Meant as the `static [Symbol.hasInstance]` of a branded
|
|
35
|
+
* class (subclasses inherit it, and match through their own brand or the plain check).
|
|
36
|
+
*/
|
|
37
|
+
export declare function isBrandedInstance(klass: object, value: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { brandClass, isBrandedInstance } from './class-brand';
|
package/esm/index.mjs
CHANGED
|
@@ -117,6 +117,9 @@ async function fileExists(p) {
|
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
function fileExistsSync(p) {
|
|
121
|
+
return getFs().existsSync(p);
|
|
122
|
+
}
|
|
120
123
|
async function readJSON(jsonPath) {
|
|
121
124
|
try {
|
|
122
125
|
const fsp = getFsp();
|
|
@@ -4883,6 +4886,30 @@ function safeJsonForScript(value) {
|
|
|
4883
4886
|
}
|
|
4884
4887
|
}
|
|
4885
4888
|
|
|
4889
|
+
// libs/utils/src/class-brand/class-brand.ts
|
|
4890
|
+
var CLASS_BRAND = /* @__PURE__ */ Symbol.for("@frontmcp/class-brand");
|
|
4891
|
+
var ordinaryHasInstance = Function.prototype[Symbol.hasInstance];
|
|
4892
|
+
function ownBrandOf(klass) {
|
|
4893
|
+
if (typeof klass !== "function" || !Object.prototype.hasOwnProperty.call(klass, CLASS_BRAND)) return void 0;
|
|
4894
|
+
return klass[CLASS_BRAND];
|
|
4895
|
+
}
|
|
4896
|
+
function classOfPrototype(proto) {
|
|
4897
|
+
return Object.getOwnPropertyDescriptor(proto, "constructor")?.value;
|
|
4898
|
+
}
|
|
4899
|
+
function brandClass(klass, brand) {
|
|
4900
|
+
Object.defineProperty(klass, CLASS_BRAND, { value: brand, enumerable: false, writable: false, configurable: false });
|
|
4901
|
+
}
|
|
4902
|
+
function isBrandedInstance(klass, value) {
|
|
4903
|
+
if (ordinaryHasInstance.call(klass, value)) return true;
|
|
4904
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4905
|
+
const brand = ownBrandOf(klass);
|
|
4906
|
+
if (brand === void 0) return false;
|
|
4907
|
+
for (let proto = Object.getPrototypeOf(value); proto !== null; proto = Object.getPrototypeOf(proto)) {
|
|
4908
|
+
if (ownBrandOf(classOfPrototype(proto)) === brand) return true;
|
|
4909
|
+
}
|
|
4910
|
+
return false;
|
|
4911
|
+
}
|
|
4912
|
+
|
|
4886
4913
|
// libs/utils/src/serialization/serialization.ts
|
|
4887
4914
|
function safeStringify(value, space) {
|
|
4888
4915
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
@@ -4942,7 +4969,10 @@ import {
|
|
|
4942
4969
|
} from "#runtime-context";
|
|
4943
4970
|
|
|
4944
4971
|
// libs/utils/src/storage/factory.ts
|
|
4972
|
+
init_memory();
|
|
4945
4973
|
init_errors();
|
|
4974
|
+
import { getEnv as getEnv3, isProduction as isProduction2 } from "#env";
|
|
4975
|
+
import { getRuntimeContext as getRuntimeContext2 } from "#runtime-context";
|
|
4946
4976
|
|
|
4947
4977
|
// libs/utils/src/storage/namespace.ts
|
|
4948
4978
|
init_errors();
|
|
@@ -5110,8 +5140,14 @@ function createNamespacedStorage(adapter, prefix) {
|
|
|
5110
5140
|
}
|
|
5111
5141
|
|
|
5112
5142
|
// libs/utils/src/storage/factory.ts
|
|
5113
|
-
|
|
5114
|
-
|
|
5143
|
+
var noDistributedStorageWarned = false;
|
|
5144
|
+
function warnNoDistributedStorage() {
|
|
5145
|
+
if (noDistributedStorageWarned || getRuntimeContext2().runtime === "browser") return;
|
|
5146
|
+
noDistributedStorageWarned = true;
|
|
5147
|
+
console.warn(
|
|
5148
|
+
"[storage] Warning: No distributed storage backend detected in production. Using in-memory storage. Set REDIS_URL, UPSTASH_REDIS_REST_URL, or KV_REST_API_URL."
|
|
5149
|
+
);
|
|
5150
|
+
}
|
|
5115
5151
|
function detectStorageType() {
|
|
5116
5152
|
if (getEnv3("UPSTASH_REDIS_REST_URL") && getEnv3("UPSTASH_REDIS_REST_TOKEN")) {
|
|
5117
5153
|
return "upstash";
|
|
@@ -5162,11 +5198,7 @@ async function createStorage(config = {}) {
|
|
|
5162
5198
|
const fallback = config.fallback ?? (isProduction2() ? "error" : "memory");
|
|
5163
5199
|
if (type === "auto") {
|
|
5164
5200
|
type = detectStorageType();
|
|
5165
|
-
if (type === "memory" && isProduction2())
|
|
5166
|
-
console.warn(
|
|
5167
|
-
"[storage] Warning: No distributed storage backend detected in production. Using in-memory storage. Set REDIS_URL, UPSTASH_REDIS_REST_URL, or KV_REST_API_URL."
|
|
5168
|
-
);
|
|
5169
|
-
}
|
|
5201
|
+
if (type === "memory" && isProduction2()) warnNoDistributedStorage();
|
|
5170
5202
|
}
|
|
5171
5203
|
let adapter;
|
|
5172
5204
|
try {
|
|
@@ -5828,6 +5860,14 @@ function saveMachineIdAsync(machineId) {
|
|
|
5828
5860
|
}
|
|
5829
5861
|
})();
|
|
5830
5862
|
}
|
|
5863
|
+
function getHostname() {
|
|
5864
|
+
if (!isNode()) return void 0;
|
|
5865
|
+
try {
|
|
5866
|
+
return __require("os").hostname();
|
|
5867
|
+
} catch {
|
|
5868
|
+
return void 0;
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5831
5871
|
function computeMachineId() {
|
|
5832
5872
|
const envMachineId = getEnvDirect("MACHINE_ID");
|
|
5833
5873
|
if (envMachineId) return envMachineId;
|
|
@@ -5907,6 +5947,7 @@ export {
|
|
|
5907
5947
|
base64urlDecode,
|
|
5908
5948
|
base64urlEncode,
|
|
5909
5949
|
basename,
|
|
5950
|
+
brandClass,
|
|
5910
5951
|
buildPrefix,
|
|
5911
5952
|
buildSetCookie,
|
|
5912
5953
|
bytesToHex,
|
|
@@ -5957,6 +5998,7 @@ export {
|
|
|
5957
5998
|
extractTemplateParams,
|
|
5958
5999
|
extractUriScheme,
|
|
5959
6000
|
fileExists,
|
|
6001
|
+
fileExistsSync,
|
|
5960
6002
|
findNonFiniteNumber,
|
|
5961
6003
|
generateCodeChallenge,
|
|
5962
6004
|
generateCodeVerifier,
|
|
@@ -5970,6 +6012,7 @@ export {
|
|
|
5970
6012
|
getDetectedStorageType,
|
|
5971
6013
|
getEnv2 as getEnv,
|
|
5972
6014
|
getEnvFlag,
|
|
6015
|
+
getHostname,
|
|
5973
6016
|
getMachineId,
|
|
5974
6017
|
getNodeEnv,
|
|
5975
6018
|
getOrCreateSecret,
|
|
@@ -5983,6 +6026,7 @@ export {
|
|
|
5983
6026
|
inferMimeType,
|
|
5984
6027
|
isAbsolute,
|
|
5985
6028
|
isAsymmetricKeyData,
|
|
6029
|
+
isBrandedInstance,
|
|
5986
6030
|
isBrowser,
|
|
5987
6031
|
isDebug,
|
|
5988
6032
|
isDevelopment,
|
package/fs/fs.d.ts
CHANGED
|
@@ -137,6 +137,21 @@ export declare function unlink(p: string): Promise<void>;
|
|
|
137
137
|
* await fileExists('/path/to/file.txt') // true or false
|
|
138
138
|
*/
|
|
139
139
|
export declare function fileExists(p: string): Promise<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* Check whether a file or directory exists, synchronously.
|
|
142
|
+
*
|
|
143
|
+
* **Node.js only** - throws an error if called in browser.
|
|
144
|
+
*
|
|
145
|
+
* Use this only where async is not possible (e.g. resolving a command line
|
|
146
|
+
* before a synchronous `spawn`). Prefer {@link fileExists} otherwise.
|
|
147
|
+
*
|
|
148
|
+
* @param p - Path to check
|
|
149
|
+
* @returns true if the path exists, false otherwise
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* fileExistsSync('/path/to/file.txt') // true or false
|
|
153
|
+
*/
|
|
154
|
+
export declare function fileExistsSync(p: string): boolean;
|
|
140
155
|
/**
|
|
141
156
|
* Read and parse a JSON file.
|
|
142
157
|
*
|
|
@@ -239,13 +254,16 @@ export declare function copyFile(src: string, dest: string): Promise<void>;
|
|
|
239
254
|
*
|
|
240
255
|
* @param src - Source path
|
|
241
256
|
* @param dest - Destination path
|
|
242
|
-
* @param options - Copy options
|
|
257
|
+
* @param options - Copy options; `dereference` copies the files symlinks point to instead of the links,
|
|
258
|
+
* and `filter` returns false for a path to leave it (and, for a folder, its contents) out
|
|
243
259
|
*
|
|
244
260
|
* @example
|
|
245
261
|
* await cp('/path/to/src', '/path/to/dest', { recursive: true });
|
|
246
262
|
*/
|
|
247
263
|
export declare function cp(src: string, dest: string, options?: {
|
|
248
264
|
recursive?: boolean;
|
|
265
|
+
dereference?: boolean;
|
|
266
|
+
filter?: (source: string, destination: string) => boolean | Promise<boolean>;
|
|
249
267
|
}): Promise<void>;
|
|
250
268
|
/**
|
|
251
269
|
* List directory contents.
|
|
@@ -343,6 +361,11 @@ export declare function access(p: string, mode?: number): Promise<void>;
|
|
|
343
361
|
export declare function runCmd(cmd: string, args: string[], opts?: {
|
|
344
362
|
cwd?: string;
|
|
345
363
|
env?: NodeJS.ProcessEnv;
|
|
364
|
+
/**
|
|
365
|
+
* Pass `args` to the child unquoted (Windows only). Set it when the arguments
|
|
366
|
+
* are already quoted for `cmd.exe /d /s /c`; ignored on other platforms.
|
|
367
|
+
*/
|
|
368
|
+
windowsVerbatimArguments?: boolean;
|
|
346
369
|
}): Promise<void>;
|
|
347
370
|
/**
|
|
348
371
|
* Handle returned by {@link watchFile}. `close()` stops the watch and is safe
|
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, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
|
|
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';
|
|
2
2
|
export type { FileWatcherHandle, SymlinkType } from './fs';
|
package/index.d.ts
CHANGED
|
@@ -15,9 +15,10 @@ export { validateBaseUrl, buildSetCookie, parseCookies, getCookie, isLocalhost,
|
|
|
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, readJSON, writeJSON, ensureDir, ensureDirSync, isDirEmpty, runCmd, watchFile, getSpawnFn, } from './fs';
|
|
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';
|
|
19
19
|
export type { FileWatcherHandle } from './fs';
|
|
20
20
|
export { escapeHtml, escapeHtmlAttr, escapeJsString, escapeScriptClose, safeJsonForScript } from './escape';
|
|
21
|
+
export { brandClass, isBrandedInstance } from './class-brand';
|
|
21
22
|
export { safeStringify } from './serialization';
|
|
22
23
|
export { getCrypto, rsaVerify, rsaVerifySync, pemToPublicJwk, generateRsaKeyPair, rsaSignBase64Url, type RsaJwk, type RsaKeyPair, jwtAlgToNodeAlg, isRsaPssAlg, randomUUID, randomBytes, sha256, sha256Hex, sha256Base64url, hmacSha256, hkdfSha256, encryptAesGcm, decryptAesGcm, timingSafeEqual, bytesToHex, base64urlEncode, base64urlDecode, base64Encode, base64Decode, isNode, isBrowser, assertNode, EncryptedBlobError, encryptValue, decryptValue, tryDecryptValue, serializeBlob, deserializeBlob, tryDeserializeBlob, isValidEncryptedBlob, encryptAndSerialize, deserializeAndDecrypt, tryDeserializeAndDecrypt, generateCodeVerifier, generateCodeChallenge, verifyCodeChallenge, generatePkcePair, isValidCodeVerifier, isValidCodeChallenge, MIN_CODE_VERIFIER_LENGTH, MAX_CODE_VERIFIER_LENGTH, DEFAULT_CODE_VERIFIER_LENGTH, PkceError, type PkcePair, type SecretData, type SecretPersistenceOptions, type SecretValidationResult, secretDataSchema, validateSecretData, parseSecretData, isSecretPersistenceEnabled, resolveSecretPath, loadSecret, saveSecret, deleteSecret, generateSecret, createSecretData, getOrCreateSecret, clearCachedSecret, isSecretCached, type SignedData, type HmacSigningConfig, signData, verifyData, isSignedData, verifyOrParseData, type BaseKeyData, type SecretKeyData, type AsymmetricKeyData, type AnyKeyData, type KeyPersistenceOptions, type CreateKeyPersistenceOptions, type CreateSecretOptions, type CreateAsymmetricOptions, type KeyValidationResult, asymmetricAlgSchema, secretKeyDataSchema, asymmetricKeyDataSchema, anyKeyDataSchema, validateKeyData, parseKeyData, isSecretKeyData, isAsymmetricKeyData, KeyPersistence, createKeyPersistence, createKeyPersistenceWithStorage, } from './crypto';
|
|
23
24
|
export type { CryptoProvider, EncBlob, EncryptedBlob } from './crypto';
|
|
@@ -30,4 +31,4 @@ export { createStorage, createMemoryStorage, getDetectedStorageType, NamespacedS
|
|
|
30
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';
|
|
31
32
|
export { processPlatformToolCalls } from './llm';
|
|
32
33
|
export type { CallToolFn, OpenAIToolCallItem, OpenAIToolResponse, ClaudeToolUseBlock, ClaudeToolResultBlock, VercelToolCallInfo, PlatformToolCallsInput, PlatformToolCallsOutput, SupportedPlatform, } from './llm';
|
|
33
|
-
export { getMachineId, setMachineIdOverride } from './machine-id';
|
|
34
|
+
export { getHostname, getMachineId, setMachineIdOverride } from './machine-id';
|
package/index.js
CHANGED
|
@@ -119,6 +119,9 @@ async function fileExists(p) {
|
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
function fileExistsSync(p) {
|
|
123
|
+
return getFs().existsSync(p);
|
|
124
|
+
}
|
|
122
125
|
async function readJSON(jsonPath) {
|
|
123
126
|
try {
|
|
124
127
|
const fsp = getFsp();
|
|
@@ -4134,6 +4137,7 @@ __export(index_exports, {
|
|
|
4134
4137
|
base64urlDecode: () => base64urlDecode,
|
|
4135
4138
|
base64urlEncode: () => base64urlEncode,
|
|
4136
4139
|
basename: () => import_path2.basename,
|
|
4140
|
+
brandClass: () => brandClass,
|
|
4137
4141
|
buildPrefix: () => buildPrefix,
|
|
4138
4142
|
buildSetCookie: () => buildSetCookie,
|
|
4139
4143
|
bytesToHex: () => bytesToHex,
|
|
@@ -4184,6 +4188,7 @@ __export(index_exports, {
|
|
|
4184
4188
|
extractTemplateParams: () => extractTemplateParams,
|
|
4185
4189
|
extractUriScheme: () => extractUriScheme,
|
|
4186
4190
|
fileExists: () => fileExists,
|
|
4191
|
+
fileExistsSync: () => fileExistsSync,
|
|
4187
4192
|
findNonFiniteNumber: () => findNonFiniteNumber,
|
|
4188
4193
|
generateCodeChallenge: () => generateCodeChallenge,
|
|
4189
4194
|
generateCodeVerifier: () => generateCodeVerifier,
|
|
@@ -4197,6 +4202,7 @@ __export(index_exports, {
|
|
|
4197
4202
|
getDetectedStorageType: () => getDetectedStorageType,
|
|
4198
4203
|
getEnv: () => import_env2.getEnv,
|
|
4199
4204
|
getEnvFlag: () => import_env2.getEnvFlag,
|
|
4205
|
+
getHostname: () => getHostname,
|
|
4200
4206
|
getMachineId: () => getMachineId,
|
|
4201
4207
|
getNodeEnv: () => import_env2.getNodeEnv,
|
|
4202
4208
|
getOrCreateSecret: () => getOrCreateSecret,
|
|
@@ -4210,6 +4216,7 @@ __export(index_exports, {
|
|
|
4210
4216
|
inferMimeType: () => inferMimeType,
|
|
4211
4217
|
isAbsolute: () => import_path2.isAbsolute,
|
|
4212
4218
|
isAsymmetricKeyData: () => isAsymmetricKeyData,
|
|
4219
|
+
isBrandedInstance: () => isBrandedInstance,
|
|
4213
4220
|
isBrowser: () => isBrowser,
|
|
4214
4221
|
isDebug: () => import_env2.isDebug,
|
|
4215
4222
|
isDevelopment: () => import_env2.isDevelopment,
|
|
@@ -5114,6 +5121,30 @@ function safeJsonForScript(value) {
|
|
|
5114
5121
|
}
|
|
5115
5122
|
}
|
|
5116
5123
|
|
|
5124
|
+
// libs/utils/src/class-brand/class-brand.ts
|
|
5125
|
+
var CLASS_BRAND = /* @__PURE__ */ Symbol.for("@frontmcp/class-brand");
|
|
5126
|
+
var ordinaryHasInstance = Function.prototype[Symbol.hasInstance];
|
|
5127
|
+
function ownBrandOf(klass) {
|
|
5128
|
+
if (typeof klass !== "function" || !Object.prototype.hasOwnProperty.call(klass, CLASS_BRAND)) return void 0;
|
|
5129
|
+
return klass[CLASS_BRAND];
|
|
5130
|
+
}
|
|
5131
|
+
function classOfPrototype(proto) {
|
|
5132
|
+
return Object.getOwnPropertyDescriptor(proto, "constructor")?.value;
|
|
5133
|
+
}
|
|
5134
|
+
function brandClass(klass, brand) {
|
|
5135
|
+
Object.defineProperty(klass, CLASS_BRAND, { value: brand, enumerable: false, writable: false, configurable: false });
|
|
5136
|
+
}
|
|
5137
|
+
function isBrandedInstance(klass, value) {
|
|
5138
|
+
if (ordinaryHasInstance.call(klass, value)) return true;
|
|
5139
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5140
|
+
const brand = ownBrandOf(klass);
|
|
5141
|
+
if (brand === void 0) return false;
|
|
5142
|
+
for (let proto = Object.getPrototypeOf(value); proto !== null; proto = Object.getPrototypeOf(proto)) {
|
|
5143
|
+
if (ownBrandOf(classOfPrototype(proto)) === brand) return true;
|
|
5144
|
+
}
|
|
5145
|
+
return false;
|
|
5146
|
+
}
|
|
5147
|
+
|
|
5117
5148
|
// libs/utils/src/serialization/serialization.ts
|
|
5118
5149
|
function safeStringify(value, space) {
|
|
5119
5150
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
@@ -5148,6 +5179,9 @@ var import_env2 = require("#env");
|
|
|
5148
5179
|
var import_runtime_context = require("#runtime-context");
|
|
5149
5180
|
|
|
5150
5181
|
// libs/utils/src/storage/factory.ts
|
|
5182
|
+
var import_env3 = require("#env");
|
|
5183
|
+
var import_runtime_context2 = require("#runtime-context");
|
|
5184
|
+
init_memory();
|
|
5151
5185
|
init_errors();
|
|
5152
5186
|
|
|
5153
5187
|
// libs/utils/src/storage/namespace.ts
|
|
@@ -5316,8 +5350,14 @@ function createNamespacedStorage(adapter, prefix) {
|
|
|
5316
5350
|
}
|
|
5317
5351
|
|
|
5318
5352
|
// libs/utils/src/storage/factory.ts
|
|
5319
|
-
|
|
5320
|
-
|
|
5353
|
+
var noDistributedStorageWarned = false;
|
|
5354
|
+
function warnNoDistributedStorage() {
|
|
5355
|
+
if (noDistributedStorageWarned || (0, import_runtime_context2.getRuntimeContext)().runtime === "browser") return;
|
|
5356
|
+
noDistributedStorageWarned = true;
|
|
5357
|
+
console.warn(
|
|
5358
|
+
"[storage] Warning: No distributed storage backend detected in production. Using in-memory storage. Set REDIS_URL, UPSTASH_REDIS_REST_URL, or KV_REST_API_URL."
|
|
5359
|
+
);
|
|
5360
|
+
}
|
|
5321
5361
|
function detectStorageType() {
|
|
5322
5362
|
if ((0, import_env3.getEnv)("UPSTASH_REDIS_REST_URL") && (0, import_env3.getEnv)("UPSTASH_REDIS_REST_TOKEN")) {
|
|
5323
5363
|
return "upstash";
|
|
@@ -5368,11 +5408,7 @@ async function createStorage(config = {}) {
|
|
|
5368
5408
|
const fallback = config.fallback ?? ((0, import_env3.isProduction)() ? "error" : "memory");
|
|
5369
5409
|
if (type === "auto") {
|
|
5370
5410
|
type = detectStorageType();
|
|
5371
|
-
if (type === "memory" && (0, import_env3.isProduction)())
|
|
5372
|
-
console.warn(
|
|
5373
|
-
"[storage] Warning: No distributed storage backend detected in production. Using in-memory storage. Set REDIS_URL, UPSTASH_REDIS_REST_URL, or KV_REST_API_URL."
|
|
5374
|
-
);
|
|
5375
|
-
}
|
|
5411
|
+
if (type === "memory" && (0, import_env3.isProduction)()) warnNoDistributedStorage();
|
|
5376
5412
|
}
|
|
5377
5413
|
let adapter;
|
|
5378
5414
|
try {
|
|
@@ -6034,6 +6070,14 @@ function saveMachineIdAsync(machineId) {
|
|
|
6034
6070
|
}
|
|
6035
6071
|
})();
|
|
6036
6072
|
}
|
|
6073
|
+
function getHostname() {
|
|
6074
|
+
if (!isNode()) return void 0;
|
|
6075
|
+
try {
|
|
6076
|
+
return require("os").hostname();
|
|
6077
|
+
} catch {
|
|
6078
|
+
return void 0;
|
|
6079
|
+
}
|
|
6080
|
+
}
|
|
6037
6081
|
function computeMachineId() {
|
|
6038
6082
|
const envMachineId = getEnvDirect("MACHINE_ID");
|
|
6039
6083
|
if (envMachineId) return envMachineId;
|
|
@@ -6114,6 +6158,7 @@ function setMachineIdOverride(id) {
|
|
|
6114
6158
|
base64urlDecode,
|
|
6115
6159
|
base64urlEncode,
|
|
6116
6160
|
basename,
|
|
6161
|
+
brandClass,
|
|
6117
6162
|
buildPrefix,
|
|
6118
6163
|
buildSetCookie,
|
|
6119
6164
|
bytesToHex,
|
|
@@ -6164,6 +6209,7 @@ function setMachineIdOverride(id) {
|
|
|
6164
6209
|
extractTemplateParams,
|
|
6165
6210
|
extractUriScheme,
|
|
6166
6211
|
fileExists,
|
|
6212
|
+
fileExistsSync,
|
|
6167
6213
|
findNonFiniteNumber,
|
|
6168
6214
|
generateCodeChallenge,
|
|
6169
6215
|
generateCodeVerifier,
|
|
@@ -6177,6 +6223,7 @@ function setMachineIdOverride(id) {
|
|
|
6177
6223
|
getDetectedStorageType,
|
|
6178
6224
|
getEnv,
|
|
6179
6225
|
getEnvFlag,
|
|
6226
|
+
getHostname,
|
|
6180
6227
|
getMachineId,
|
|
6181
6228
|
getNodeEnv,
|
|
6182
6229
|
getOrCreateSecret,
|
|
@@ -6190,6 +6237,7 @@ function setMachineIdOverride(id) {
|
|
|
6190
6237
|
inferMimeType,
|
|
6191
6238
|
isAbsolute,
|
|
6192
6239
|
isAsymmetricKeyData,
|
|
6240
|
+
isBrandedInstance,
|
|
6193
6241
|
isBrowser,
|
|
6194
6242
|
isDebug,
|
|
6195
6243
|
isDevelopment,
|
package/machine-id/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getMachineId, setMachineIdOverride } from './machine-id';
|
|
1
|
+
export { getHostname, getMachineId, setMachineIdOverride } from './machine-id';
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
* 2. File persistence at `.frontmcp/machine-id` (dev mode)
|
|
21
21
|
* 3. Random UUID (production)
|
|
22
22
|
*/
|
|
23
|
+
/** This host's name (`os.hostname()`), read when called; `undefined` outside Node. */
|
|
24
|
+
export declare function getHostname(): string | undefined;
|
|
23
25
|
/**
|
|
24
26
|
* Get the current machine ID.
|
|
25
27
|
* Returns the override (if set via `setMachineIdOverride`) or the lazily
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/utils",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"description": "Shared utility functions for FrontMCP - string manipulation, URI handling, path utilities, and more",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@noble/hashes": "^2.0.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@frontmcp/lazy-zod": "1.9.
|
|
35
|
+
"@frontmcp/lazy-zod": "1.9.5",
|
|
36
36
|
"@upstash/redis": "^1.34.0",
|
|
37
37
|
"@vercel/kv": "^2.0.0 || ^3.0.0",
|
|
38
38
|
"ioredis": "^5.0.0"
|
package/storage/factory.d.ts
CHANGED