@dexto/core 1.5.2 → 1.5.3
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/dist/agent/DextoAgent.cjs +12 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +12 -1
- package/dist/agent/schemas.d.ts +42 -0
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/approval/manager.cjs +16 -0
- package/dist/approval/manager.d.ts +10 -0
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +16 -0
- package/dist/approval/types.d.ts +11 -0
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/events/index.cjs +3 -1
- package/dist/events/index.d.ts +19 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -1
- package/dist/filesystem/filesystem-service.cjs +18 -15
- package/dist/filesystem/filesystem-service.d.ts +3 -3
- package/dist/filesystem/filesystem-service.d.ts.map +1 -1
- package/dist/filesystem/filesystem-service.js +18 -15
- package/dist/filesystem/path-validator.cjs +16 -7
- package/dist/filesystem/path-validator.d.ts +10 -3
- package/dist/filesystem/path-validator.d.ts.map +1 -1
- package/dist/filesystem/path-validator.js +16 -7
- package/dist/filesystem/types.d.ts +4 -0
- package/dist/filesystem/types.d.ts.map +1 -1
- package/dist/logger/v2/schemas.cjs +4 -0
- package/dist/logger/v2/schemas.d.ts +16 -0
- package/dist/logger/v2/schemas.d.ts.map +1 -1
- package/dist/logger/v2/schemas.js +4 -0
- package/dist/logger/v2/transport-factory.cjs +4 -1
- package/dist/logger/v2/transport-factory.d.ts.map +1 -1
- package/dist/logger/v2/transport-factory.js +4 -1
- package/dist/logger/v2/transports/silent-transport.cjs +33 -0
- package/dist/logger/v2/transports/silent-transport.d.ts +15 -0
- package/dist/logger/v2/transports/silent-transport.d.ts.map +1 -0
- package/dist/logger/v2/transports/silent-transport.js +10 -0
- package/dist/tools/error-codes.cjs +1 -0
- package/dist/tools/error-codes.d.ts +1 -0
- package/dist/tools/error-codes.d.ts.map +1 -1
- package/dist/tools/error-codes.js +1 -0
- package/dist/tools/errors.cjs +17 -0
- package/dist/tools/errors.d.ts +9 -0
- package/dist/tools/errors.d.ts.map +1 -1
- package/dist/tools/errors.js +17 -0
- package/dist/tools/internal-tools/provider.cjs +3 -2
- package/dist/tools/internal-tools/provider.d.ts +1 -1
- package/dist/tools/internal-tools/provider.d.ts.map +1 -1
- package/dist/tools/internal-tools/provider.js +3 -2
- package/dist/tools/tool-manager.cjs +77 -4
- package/dist/tools/tool-manager.d.ts +18 -0
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +78 -5
- package/dist/tools/types.d.ts +5 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ class FileSystemService {
|
|
|
53
53
|
blockedPaths: config.blockedPaths || [".git", "node_modules/.bin", ".env"],
|
|
54
54
|
blockedExtensions: config.blockedExtensions || [".exe", ".dll", ".so"],
|
|
55
55
|
maxFileSize: config.maxFileSize || DEFAULT_MAX_FILE_SIZE,
|
|
56
|
-
enableBackups: config.enableBackups ??
|
|
56
|
+
enableBackups: config.enableBackups ?? false,
|
|
57
57
|
backupPath: config.backupPath,
|
|
58
58
|
// Optional absolute override, defaults handled by getBackupDir()
|
|
59
59
|
backupRetentionDays: config.backupRetentionDays || 7,
|
|
@@ -99,7 +99,7 @@ class FileSystemService {
|
|
|
99
99
|
* @param filePath The file path to check (can be relative or absolute)
|
|
100
100
|
* @returns true if the path is within allowed paths, false otherwise
|
|
101
101
|
*/
|
|
102
|
-
isPathWithinAllowed(filePath) {
|
|
102
|
+
async isPathWithinAllowed(filePath) {
|
|
103
103
|
return this.pathValidator.isPathWithinAllowed(filePath);
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
@@ -137,7 +137,7 @@ class FileSystemService {
|
|
|
137
137
|
if (!this.initialized) {
|
|
138
138
|
throw import_errors.FileSystemError.notInitialized();
|
|
139
139
|
}
|
|
140
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
140
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
141
141
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
142
142
|
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
143
143
|
}
|
|
@@ -216,7 +216,7 @@ class FileSystemService {
|
|
|
216
216
|
});
|
|
217
217
|
const validFiles = [];
|
|
218
218
|
for (const file of files) {
|
|
219
|
-
const validation = this.pathValidator.validatePath(file);
|
|
219
|
+
const validation = await this.pathValidator.validatePath(file);
|
|
220
220
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
221
221
|
this.logger.debug(`Skipping invalid path: ${file}`);
|
|
222
222
|
continue;
|
|
@@ -347,7 +347,7 @@ class FileSystemService {
|
|
|
347
347
|
if (!this.initialized) {
|
|
348
348
|
throw import_errors.FileSystemError.notInitialized();
|
|
349
349
|
}
|
|
350
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
350
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
351
351
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
352
352
|
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
353
353
|
}
|
|
@@ -391,14 +391,14 @@ class FileSystemService {
|
|
|
391
391
|
if (!this.initialized) {
|
|
392
392
|
throw import_errors.FileSystemError.notInitialized();
|
|
393
393
|
}
|
|
394
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
394
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
395
395
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
396
396
|
throw import_errors.FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
397
397
|
}
|
|
398
398
|
const normalizedPath = validation.normalizedPath;
|
|
399
399
|
const fileContent = await this.readFile(normalizedPath);
|
|
400
|
-
|
|
401
|
-
const occurrences = (
|
|
400
|
+
const originalContent = fileContent.content;
|
|
401
|
+
const occurrences = (originalContent.match(
|
|
402
402
|
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g")
|
|
403
403
|
) || []).length;
|
|
404
404
|
if (occurrences === 0) {
|
|
@@ -412,21 +412,24 @@ class FileSystemService {
|
|
|
412
412
|
backupPath = await this.createBackup(normalizedPath);
|
|
413
413
|
}
|
|
414
414
|
try {
|
|
415
|
+
let newContent;
|
|
415
416
|
if (operation.replaceAll) {
|
|
416
|
-
|
|
417
|
+
newContent = originalContent.replace(
|
|
417
418
|
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
|
|
418
419
|
operation.newString
|
|
419
420
|
);
|
|
420
421
|
} else {
|
|
421
|
-
|
|
422
|
+
newContent = originalContent.replace(operation.oldString, operation.newString);
|
|
422
423
|
}
|
|
423
|
-
await fs.writeFile(normalizedPath,
|
|
424
|
+
await fs.writeFile(normalizedPath, newContent, options.encoding || DEFAULT_ENCODING);
|
|
424
425
|
this.logger.debug(`File edited: ${normalizedPath} (${occurrences} replacements)`);
|
|
425
426
|
return {
|
|
426
427
|
success: true,
|
|
427
428
|
path: normalizedPath,
|
|
428
429
|
changesCount: occurrences,
|
|
429
|
-
backupPath
|
|
430
|
+
backupPath,
|
|
431
|
+
originalContent,
|
|
432
|
+
newContent
|
|
430
433
|
};
|
|
431
434
|
} catch (error) {
|
|
432
435
|
throw import_errors.FileSystemError.editFailed(
|
|
@@ -518,10 +521,10 @@ class FileSystemService {
|
|
|
518
521
|
return { ...this.config };
|
|
519
522
|
}
|
|
520
523
|
/**
|
|
521
|
-
* Check if a path is allowed
|
|
524
|
+
* Check if a path is allowed (async for non-blocking symlink resolution)
|
|
522
525
|
*/
|
|
523
|
-
isPathAllowed(filePath) {
|
|
524
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
526
|
+
async isPathAllowed(filePath) {
|
|
527
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
525
528
|
return validation.isValid;
|
|
526
529
|
}
|
|
527
530
|
}
|
|
@@ -34,7 +34,7 @@ export declare class FileSystemService {
|
|
|
34
34
|
* @param filePath The file path to check (can be relative or absolute)
|
|
35
35
|
* @returns true if the path is within allowed paths, false otherwise
|
|
36
36
|
*/
|
|
37
|
-
isPathWithinAllowed(filePath: string): boolean
|
|
37
|
+
isPathWithinAllowed(filePath: string): Promise<boolean>;
|
|
38
38
|
/**
|
|
39
39
|
* Get the list of configured allowed paths.
|
|
40
40
|
* Useful for displaying to users when directory approval is needed.
|
|
@@ -90,8 +90,8 @@ export declare class FileSystemService {
|
|
|
90
90
|
*/
|
|
91
91
|
getConfig(): Readonly<FileSystemConfig>;
|
|
92
92
|
/**
|
|
93
|
-
* Check if a path is allowed
|
|
93
|
+
* Check if a path is allowed (async for non-blocking symlink resolution)
|
|
94
94
|
*/
|
|
95
|
-
isPathAllowed(filePath: string): boolean
|
|
95
|
+
isPathAllowed(filePath: string): Promise<boolean>;
|
|
96
96
|
}
|
|
97
97
|
//# sourceMappingURL=filesystem-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-service.d.ts","sourceRoot":"","sources":["../../src/filesystem/filesystem-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EAEZ,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EAGhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAiB,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQ1D;;;;GAIG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAe;gBA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CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IA+ErF;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwEhF;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAqGtF;;OAEG;IACG,SAAS,CACX,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC/B,OAAO,CAAC,WAAW,CAAC;IA0DvB;;OAEG;IACG,QAAQ,CACV,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,aAAa,EACxB,OAAO,GAAE,eAAoB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAuEtB;;OAEG;YACW,YAAY;IA0B1B;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IA6D1C;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,gBAAgB,CAAC;IAIvC;;OAEG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI1D"}
|
|
@@ -21,7 +21,7 @@ class FileSystemService {
|
|
|
21
21
|
blockedPaths: config.blockedPaths || [".git", "node_modules/.bin", ".env"],
|
|
22
22
|
blockedExtensions: config.blockedExtensions || [".exe", ".dll", ".so"],
|
|
23
23
|
maxFileSize: config.maxFileSize || DEFAULT_MAX_FILE_SIZE,
|
|
24
|
-
enableBackups: config.enableBackups ??
|
|
24
|
+
enableBackups: config.enableBackups ?? false,
|
|
25
25
|
backupPath: config.backupPath,
|
|
26
26
|
// Optional absolute override, defaults handled by getBackupDir()
|
|
27
27
|
backupRetentionDays: config.backupRetentionDays || 7,
|
|
@@ -67,7 +67,7 @@ class FileSystemService {
|
|
|
67
67
|
* @param filePath The file path to check (can be relative or absolute)
|
|
68
68
|
* @returns true if the path is within allowed paths, false otherwise
|
|
69
69
|
*/
|
|
70
|
-
isPathWithinAllowed(filePath) {
|
|
70
|
+
async isPathWithinAllowed(filePath) {
|
|
71
71
|
return this.pathValidator.isPathWithinAllowed(filePath);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
@@ -105,7 +105,7 @@ class FileSystemService {
|
|
|
105
105
|
if (!this.initialized) {
|
|
106
106
|
throw FileSystemError.notInitialized();
|
|
107
107
|
}
|
|
108
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
108
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
109
109
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
110
110
|
throw FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
111
111
|
}
|
|
@@ -184,7 +184,7 @@ class FileSystemService {
|
|
|
184
184
|
});
|
|
185
185
|
const validFiles = [];
|
|
186
186
|
for (const file of files) {
|
|
187
|
-
const validation = this.pathValidator.validatePath(file);
|
|
187
|
+
const validation = await this.pathValidator.validatePath(file);
|
|
188
188
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
189
189
|
this.logger.debug(`Skipping invalid path: ${file}`);
|
|
190
190
|
continue;
|
|
@@ -315,7 +315,7 @@ class FileSystemService {
|
|
|
315
315
|
if (!this.initialized) {
|
|
316
316
|
throw FileSystemError.notInitialized();
|
|
317
317
|
}
|
|
318
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
318
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
319
319
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
320
320
|
throw FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
321
321
|
}
|
|
@@ -359,14 +359,14 @@ class FileSystemService {
|
|
|
359
359
|
if (!this.initialized) {
|
|
360
360
|
throw FileSystemError.notInitialized();
|
|
361
361
|
}
|
|
362
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
362
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
363
363
|
if (!validation.isValid || !validation.normalizedPath) {
|
|
364
364
|
throw FileSystemError.invalidPath(filePath, validation.error || "Unknown error");
|
|
365
365
|
}
|
|
366
366
|
const normalizedPath = validation.normalizedPath;
|
|
367
367
|
const fileContent = await this.readFile(normalizedPath);
|
|
368
|
-
|
|
369
|
-
const occurrences = (
|
|
368
|
+
const originalContent = fileContent.content;
|
|
369
|
+
const occurrences = (originalContent.match(
|
|
370
370
|
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g")
|
|
371
371
|
) || []).length;
|
|
372
372
|
if (occurrences === 0) {
|
|
@@ -380,21 +380,24 @@ class FileSystemService {
|
|
|
380
380
|
backupPath = await this.createBackup(normalizedPath);
|
|
381
381
|
}
|
|
382
382
|
try {
|
|
383
|
+
let newContent;
|
|
383
384
|
if (operation.replaceAll) {
|
|
384
|
-
|
|
385
|
+
newContent = originalContent.replace(
|
|
385
386
|
new RegExp(operation.oldString.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
|
|
386
387
|
operation.newString
|
|
387
388
|
);
|
|
388
389
|
} else {
|
|
389
|
-
|
|
390
|
+
newContent = originalContent.replace(operation.oldString, operation.newString);
|
|
390
391
|
}
|
|
391
|
-
await fs.writeFile(normalizedPath,
|
|
392
|
+
await fs.writeFile(normalizedPath, newContent, options.encoding || DEFAULT_ENCODING);
|
|
392
393
|
this.logger.debug(`File edited: ${normalizedPath} (${occurrences} replacements)`);
|
|
393
394
|
return {
|
|
394
395
|
success: true,
|
|
395
396
|
path: normalizedPath,
|
|
396
397
|
changesCount: occurrences,
|
|
397
|
-
backupPath
|
|
398
|
+
backupPath,
|
|
399
|
+
originalContent,
|
|
400
|
+
newContent
|
|
398
401
|
};
|
|
399
402
|
} catch (error) {
|
|
400
403
|
throw FileSystemError.editFailed(
|
|
@@ -486,10 +489,10 @@ class FileSystemService {
|
|
|
486
489
|
return { ...this.config };
|
|
487
490
|
}
|
|
488
491
|
/**
|
|
489
|
-
* Check if a path is allowed
|
|
492
|
+
* Check if a path is allowed (async for non-blocking symlink resolution)
|
|
490
493
|
*/
|
|
491
|
-
isPathAllowed(filePath) {
|
|
492
|
-
const validation = this.pathValidator.validatePath(filePath);
|
|
494
|
+
async isPathAllowed(filePath) {
|
|
495
|
+
const validation = await this.pathValidator.validatePath(filePath);
|
|
493
496
|
return validation.isValid;
|
|
494
497
|
}
|
|
495
498
|
}
|
|
@@ -32,7 +32,7 @@ __export(path_validator_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(path_validator_exports);
|
|
34
34
|
var path = __toESM(require("node:path"), 1);
|
|
35
|
-
var
|
|
35
|
+
var fs = __toESM(require("node:fs/promises"), 1);
|
|
36
36
|
class PathValidator {
|
|
37
37
|
config;
|
|
38
38
|
normalizedAllowedPaths;
|
|
@@ -67,7 +67,7 @@ class PathValidator {
|
|
|
67
67
|
/**
|
|
68
68
|
* Validate a file path for security and policy compliance
|
|
69
69
|
*/
|
|
70
|
-
validatePath(filePath) {
|
|
70
|
+
async validatePath(filePath) {
|
|
71
71
|
if (!filePath || filePath.trim() === "") {
|
|
72
72
|
return {
|
|
73
73
|
isValid: false,
|
|
@@ -79,7 +79,7 @@ class PathValidator {
|
|
|
79
79
|
try {
|
|
80
80
|
normalizedPath = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(workingDir, filePath);
|
|
81
81
|
try {
|
|
82
|
-
normalizedPath =
|
|
82
|
+
normalizedPath = await fs.realpath(normalizedPath);
|
|
83
83
|
} catch {
|
|
84
84
|
}
|
|
85
85
|
} catch (error) {
|
|
@@ -135,8 +135,16 @@ class PathValidator {
|
|
|
135
135
|
/**
|
|
136
136
|
* Check if path is within allowed paths (whitelist check)
|
|
137
137
|
* Also consults the directory approval checker if configured.
|
|
138
|
+
* Uses the sync version since the path is already normalized at this point.
|
|
138
139
|
*/
|
|
139
140
|
isPathAllowed(normalizedPath) {
|
|
141
|
+
return this.isPathAllowedSync(normalizedPath);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Synchronous path allowed check (for already-normalized paths)
|
|
145
|
+
* This is used internally when we already have a canonicalized path
|
|
146
|
+
*/
|
|
147
|
+
isPathAllowedSync(normalizedPath) {
|
|
140
148
|
if (this.normalizedAllowedPaths.length === 0) {
|
|
141
149
|
return true;
|
|
142
150
|
}
|
|
@@ -169,9 +177,10 @@ class PathValidator {
|
|
|
169
177
|
}
|
|
170
178
|
/**
|
|
171
179
|
* Quick check if a path is allowed (for internal use)
|
|
180
|
+
* Note: This assumes the path is already normalized/canonicalized
|
|
172
181
|
*/
|
|
173
182
|
isPathAllowedQuick(normalizedPath) {
|
|
174
|
-
return this.
|
|
183
|
+
return this.isPathAllowedSync(normalizedPath) && !this.isPathBlocked(normalizedPath);
|
|
175
184
|
}
|
|
176
185
|
/**
|
|
177
186
|
* Check if a file path is within the configured allowed paths (from config only).
|
|
@@ -187,12 +196,12 @@ class PathValidator {
|
|
|
187
196
|
* @example
|
|
188
197
|
* ```typescript
|
|
189
198
|
* // Check if path needs directory approval
|
|
190
|
-
* if (!pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
199
|
+
* if (!await pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
191
200
|
* // Request directory access approval
|
|
192
201
|
* }
|
|
193
202
|
* ```
|
|
194
203
|
*/
|
|
195
|
-
isPathWithinAllowed(filePath) {
|
|
204
|
+
async isPathWithinAllowed(filePath) {
|
|
196
205
|
if (!filePath || filePath.trim() === "") {
|
|
197
206
|
return false;
|
|
198
207
|
}
|
|
@@ -201,7 +210,7 @@ class PathValidator {
|
|
|
201
210
|
try {
|
|
202
211
|
normalizedPath = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(workingDir, filePath);
|
|
203
212
|
try {
|
|
204
|
-
normalizedPath =
|
|
213
|
+
normalizedPath = await fs.realpath(normalizedPath);
|
|
205
214
|
} catch {
|
|
206
215
|
}
|
|
207
216
|
} catch {
|
|
@@ -41,7 +41,7 @@ export declare class PathValidator {
|
|
|
41
41
|
/**
|
|
42
42
|
* Validate a file path for security and policy compliance
|
|
43
43
|
*/
|
|
44
|
-
validatePath(filePath: string): PathValidation
|
|
44
|
+
validatePath(filePath: string): Promise<PathValidation>;
|
|
45
45
|
/**
|
|
46
46
|
* Check if path contains traversal attempts
|
|
47
47
|
*/
|
|
@@ -49,14 +49,21 @@ export declare class PathValidator {
|
|
|
49
49
|
/**
|
|
50
50
|
* Check if path is within allowed paths (whitelist check)
|
|
51
51
|
* Also consults the directory approval checker if configured.
|
|
52
|
+
* Uses the sync version since the path is already normalized at this point.
|
|
52
53
|
*/
|
|
53
54
|
private isPathAllowed;
|
|
55
|
+
/**
|
|
56
|
+
* Synchronous path allowed check (for already-normalized paths)
|
|
57
|
+
* This is used internally when we already have a canonicalized path
|
|
58
|
+
*/
|
|
59
|
+
private isPathAllowedSync;
|
|
54
60
|
/**
|
|
55
61
|
* Check if path matches blocked patterns (blacklist check)
|
|
56
62
|
*/
|
|
57
63
|
private isPathBlocked;
|
|
58
64
|
/**
|
|
59
65
|
* Quick check if a path is allowed (for internal use)
|
|
66
|
+
* Note: This assumes the path is already normalized/canonicalized
|
|
60
67
|
*/
|
|
61
68
|
isPathAllowedQuick(normalizedPath: string): boolean;
|
|
62
69
|
/**
|
|
@@ -73,12 +80,12 @@ export declare class PathValidator {
|
|
|
73
80
|
* @example
|
|
74
81
|
* ```typescript
|
|
75
82
|
* // Check if path needs directory approval
|
|
76
|
-
* if (!pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
83
|
+
* if (!await pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
77
84
|
* // Request directory access approval
|
|
78
85
|
* }
|
|
79
86
|
* ```
|
|
80
87
|
*/
|
|
81
|
-
isPathWithinAllowed(filePath: string): boolean
|
|
88
|
+
isPathWithinAllowed(filePath: string): Promise<boolean>;
|
|
82
89
|
/**
|
|
83
90
|
* Check if path is within config-allowed paths only (no approval checker).
|
|
84
91
|
* Used for prompting decisions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-validator.d.ts","sourceRoot":"","sources":["../../src/filesystem/path-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,sBAAsB,CAAW;IACzC,OAAO,CAAC,sBAAsB,CAAW;IACzC,OAAO,CAAC,2BAA2B,CAAW;IAC9C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,wBAAwB,CAAuC;gBAE3D,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY;IAsB1D;;;;;OAKG;IACH,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;IAKpE;;OAEG;
|
|
1
|
+
{"version":3,"file":"path-validator.d.ts","sourceRoot":"","sources":["../../src/filesystem/path-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,sBAAsB,CAAW;IACzC,OAAO,CAAC,sBAAsB,CAAW;IACzC,OAAO,CAAC,2BAA2B,CAAW;IAC9C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,wBAAwB,CAAuC;gBAE3D,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY;IAsB1D;;;;;OAKG;IACH,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;IAKpE;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAyE7D;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAyBzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAyBrB;;;OAGG;IACH,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO;IAInD;;;;;;;;;;;;;;;;;;OAkBG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B7D;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACH,eAAe,IAAI,MAAM,EAAE;IAI3B;;OAEG;IACH,eAAe,IAAI,MAAM,EAAE;CAG9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
4
|
class PathValidator {
|
|
5
5
|
config;
|
|
6
6
|
normalizedAllowedPaths;
|
|
@@ -35,7 +35,7 @@ class PathValidator {
|
|
|
35
35
|
/**
|
|
36
36
|
* Validate a file path for security and policy compliance
|
|
37
37
|
*/
|
|
38
|
-
validatePath(filePath) {
|
|
38
|
+
async validatePath(filePath) {
|
|
39
39
|
if (!filePath || filePath.trim() === "") {
|
|
40
40
|
return {
|
|
41
41
|
isValid: false,
|
|
@@ -47,7 +47,7 @@ class PathValidator {
|
|
|
47
47
|
try {
|
|
48
48
|
normalizedPath = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(workingDir, filePath);
|
|
49
49
|
try {
|
|
50
|
-
normalizedPath =
|
|
50
|
+
normalizedPath = await fs.realpath(normalizedPath);
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
53
|
} catch (error) {
|
|
@@ -103,8 +103,16 @@ class PathValidator {
|
|
|
103
103
|
/**
|
|
104
104
|
* Check if path is within allowed paths (whitelist check)
|
|
105
105
|
* Also consults the directory approval checker if configured.
|
|
106
|
+
* Uses the sync version since the path is already normalized at this point.
|
|
106
107
|
*/
|
|
107
108
|
isPathAllowed(normalizedPath) {
|
|
109
|
+
return this.isPathAllowedSync(normalizedPath);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Synchronous path allowed check (for already-normalized paths)
|
|
113
|
+
* This is used internally when we already have a canonicalized path
|
|
114
|
+
*/
|
|
115
|
+
isPathAllowedSync(normalizedPath) {
|
|
108
116
|
if (this.normalizedAllowedPaths.length === 0) {
|
|
109
117
|
return true;
|
|
110
118
|
}
|
|
@@ -137,9 +145,10 @@ class PathValidator {
|
|
|
137
145
|
}
|
|
138
146
|
/**
|
|
139
147
|
* Quick check if a path is allowed (for internal use)
|
|
148
|
+
* Note: This assumes the path is already normalized/canonicalized
|
|
140
149
|
*/
|
|
141
150
|
isPathAllowedQuick(normalizedPath) {
|
|
142
|
-
return this.
|
|
151
|
+
return this.isPathAllowedSync(normalizedPath) && !this.isPathBlocked(normalizedPath);
|
|
143
152
|
}
|
|
144
153
|
/**
|
|
145
154
|
* Check if a file path is within the configured allowed paths (from config only).
|
|
@@ -155,12 +164,12 @@ class PathValidator {
|
|
|
155
164
|
* @example
|
|
156
165
|
* ```typescript
|
|
157
166
|
* // Check if path needs directory approval
|
|
158
|
-
* if (!pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
167
|
+
* if (!await pathValidator.isPathWithinAllowed('/external/project/file.ts')) {
|
|
159
168
|
* // Request directory access approval
|
|
160
169
|
* }
|
|
161
170
|
* ```
|
|
162
171
|
*/
|
|
163
|
-
isPathWithinAllowed(filePath) {
|
|
172
|
+
async isPathWithinAllowed(filePath) {
|
|
164
173
|
if (!filePath || filePath.trim() === "") {
|
|
165
174
|
return false;
|
|
166
175
|
}
|
|
@@ -169,7 +178,7 @@ class PathValidator {
|
|
|
169
178
|
try {
|
|
170
179
|
normalizedPath = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(workingDir, filePath);
|
|
171
180
|
try {
|
|
172
|
-
normalizedPath =
|
|
181
|
+
normalizedPath = await fs.realpath(normalizedPath);
|
|
173
182
|
} catch {
|
|
174
183
|
}
|
|
175
184
|
} catch {
|
|
@@ -138,6 +138,10 @@ export interface EditResult {
|
|
|
138
138
|
path: string;
|
|
139
139
|
changesCount: number;
|
|
140
140
|
backupPath?: string | undefined;
|
|
141
|
+
/** Original content before edit (for diff generation) */
|
|
142
|
+
originalContent: string;
|
|
143
|
+
/** New content after edit (for diff generation) */
|
|
144
|
+
newContent: string;
|
|
141
145
|
}
|
|
142
146
|
/**
|
|
143
147
|
* Path validation result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/filesystem/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,cAAc,GACpB,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,KAAK,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,sC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_exports);
|
|
25
25
|
var import_zod = require("zod");
|
|
26
|
+
const SilentTransportSchema = import_zod.z.object({
|
|
27
|
+
type: import_zod.z.literal("silent")
|
|
28
|
+
}).strict().describe("Silent transport that discards all logs (useful for sub-agents)");
|
|
26
29
|
const ConsoleTransportSchema = import_zod.z.object({
|
|
27
30
|
type: import_zod.z.literal("console"),
|
|
28
31
|
colorize: import_zod.z.boolean().default(true).describe("Enable colored output")
|
|
@@ -42,6 +45,7 @@ const UpstashTransportSchema = import_zod.z.object({
|
|
|
42
45
|
batchSize: import_zod.z.number().int().positive().default(100).describe("Number of log entries to batch before sending (default: 100)")
|
|
43
46
|
}).strict().describe("Upstash Redis transport for remote logging");
|
|
44
47
|
const LoggerTransportSchema = import_zod.z.discriminatedUnion("type", [
|
|
48
|
+
SilentTransportSchema,
|
|
45
49
|
ConsoleTransportSchema,
|
|
46
50
|
FileTransportSchema,
|
|
47
51
|
UpstashTransportSchema
|
|
@@ -9,6 +9,12 @@ import { z } from 'zod';
|
|
|
9
9
|
* Transport configuration (discriminated union)
|
|
10
10
|
*/
|
|
11
11
|
export declare const LoggerTransportSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"silent">;
|
|
13
|
+
}, "strict", z.ZodTypeAny, {
|
|
14
|
+
type: "silent";
|
|
15
|
+
}, {
|
|
16
|
+
type: "silent";
|
|
17
|
+
}>, z.ZodObject<{
|
|
12
18
|
type: z.ZodLiteral<"console">;
|
|
13
19
|
colorize: z.ZodDefault<z.ZodBoolean>;
|
|
14
20
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -61,6 +67,12 @@ export type LoggerTransportConfig = z.output<typeof LoggerTransportSchema>;
|
|
|
61
67
|
export declare const LoggerConfigSchema: z.ZodObject<{
|
|
62
68
|
level: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error", "silly"]>>;
|
|
63
69
|
transports: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
70
|
+
type: z.ZodLiteral<"silent">;
|
|
71
|
+
}, "strict", z.ZodTypeAny, {
|
|
72
|
+
type: "silent";
|
|
73
|
+
}, {
|
|
74
|
+
type: "silent";
|
|
75
|
+
}>, z.ZodObject<{
|
|
64
76
|
type: z.ZodLiteral<"console">;
|
|
65
77
|
colorize: z.ZodDefault<z.ZodBoolean>;
|
|
66
78
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -109,6 +121,8 @@ export declare const LoggerConfigSchema: z.ZodObject<{
|
|
|
109
121
|
}, "strict", z.ZodTypeAny, {
|
|
110
122
|
level: "debug" | "info" | "warn" | "error" | "silly";
|
|
111
123
|
transports: ({
|
|
124
|
+
type: "silent";
|
|
125
|
+
} | {
|
|
112
126
|
type: "console";
|
|
113
127
|
colorize: boolean;
|
|
114
128
|
} | {
|
|
@@ -127,6 +141,8 @@ export declare const LoggerConfigSchema: z.ZodObject<{
|
|
|
127
141
|
}, {
|
|
128
142
|
level?: "debug" | "info" | "warn" | "error" | "silly" | undefined;
|
|
129
143
|
transports?: ({
|
|
144
|
+
type: "silent";
|
|
145
|
+
} | {
|
|
130
146
|
type: "console";
|
|
131
147
|
colorize?: boolean | undefined;
|
|
132
148
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsExB;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKhC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAamC,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import "../../chunk-PTJYTZNU.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
const SilentTransportSchema = z.object({
|
|
4
|
+
type: z.literal("silent")
|
|
5
|
+
}).strict().describe("Silent transport that discards all logs (useful for sub-agents)");
|
|
3
6
|
const ConsoleTransportSchema = z.object({
|
|
4
7
|
type: z.literal("console"),
|
|
5
8
|
colorize: z.boolean().default(true).describe("Enable colored output")
|
|
@@ -19,6 +22,7 @@ const UpstashTransportSchema = z.object({
|
|
|
19
22
|
batchSize: z.number().int().positive().default(100).describe("Number of log entries to batch before sending (default: 100)")
|
|
20
23
|
}).strict().describe("Upstash Redis transport for remote logging");
|
|
21
24
|
const LoggerTransportSchema = z.discriminatedUnion("type", [
|
|
25
|
+
SilentTransportSchema,
|
|
22
26
|
ConsoleTransportSchema,
|
|
23
27
|
FileTransportSchema,
|
|
24
28
|
UpstashTransportSchema
|
|
@@ -22,11 +22,14 @@ __export(transport_factory_exports, {
|
|
|
22
22
|
createTransports: () => createTransports
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(transport_factory_exports);
|
|
25
|
+
var import_silent_transport = require("./transports/silent-transport.js");
|
|
25
26
|
var import_console_transport = require("./transports/console-transport.js");
|
|
26
27
|
var import_file_transport = require("./transports/file-transport.js");
|
|
27
28
|
var import_errors = require("./errors.js");
|
|
28
29
|
function createTransport(config) {
|
|
29
30
|
switch (config.type) {
|
|
31
|
+
case "silent":
|
|
32
|
+
return new import_silent_transport.SilentTransport();
|
|
30
33
|
case "console":
|
|
31
34
|
return new import_console_transport.ConsoleTransport({
|
|
32
35
|
colorize: config.colorize
|
|
@@ -38,7 +41,7 @@ function createTransport(config) {
|
|
|
38
41
|
maxFiles: config.maxFiles
|
|
39
42
|
});
|
|
40
43
|
case "upstash":
|
|
41
|
-
throw import_errors.LoggerError.transportNotImplemented("upstash", ["console", "file"]);
|
|
44
|
+
throw import_errors.LoggerError.transportNotImplemented("upstash", ["silent", "console", "file"]);
|
|
42
45
|
default:
|
|
43
46
|
throw import_errors.LoggerError.unknownTransportType(config.type);
|
|
44
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-factory.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/transport-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"transport-factory.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/transport-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAM1D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,gBAAgB,CAwB/E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,gBAAgB,EAAE,CAErF"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import "../../chunk-PTJYTZNU.js";
|
|
2
|
+
import { SilentTransport } from "./transports/silent-transport.js";
|
|
2
3
|
import { ConsoleTransport } from "./transports/console-transport.js";
|
|
3
4
|
import { FileTransport } from "./transports/file-transport.js";
|
|
4
5
|
import { LoggerError } from "./errors.js";
|
|
5
6
|
function createTransport(config) {
|
|
6
7
|
switch (config.type) {
|
|
8
|
+
case "silent":
|
|
9
|
+
return new SilentTransport();
|
|
7
10
|
case "console":
|
|
8
11
|
return new ConsoleTransport({
|
|
9
12
|
colorize: config.colorize
|
|
@@ -15,7 +18,7 @@ function createTransport(config) {
|
|
|
15
18
|
maxFiles: config.maxFiles
|
|
16
19
|
});
|
|
17
20
|
case "upstash":
|
|
18
|
-
throw LoggerError.transportNotImplemented("upstash", ["console", "file"]);
|
|
21
|
+
throw LoggerError.transportNotImplemented("upstash", ["silent", "console", "file"]);
|
|
19
22
|
default:
|
|
20
23
|
throw LoggerError.unknownTransportType(config.type);
|
|
21
24
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var silent_transport_exports = {};
|
|
20
|
+
__export(silent_transport_exports, {
|
|
21
|
+
SilentTransport: () => SilentTransport
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(silent_transport_exports);
|
|
24
|
+
class SilentTransport {
|
|
25
|
+
write(_entry) {
|
|
26
|
+
}
|
|
27
|
+
destroy() {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
SilentTransport
|
|
33
|
+
});
|