@agent-api/sdk 1.4.5 → 1.4.7
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/CHANGELOG.md +16 -0
- package/dist/local/context.d.ts +3 -1
- package/dist/local/context.js +4 -1
- package/dist/local/core.d.ts +13 -0
- package/dist/local/core.js +56 -13
- package/dist/local/tools.js +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/dist-cjs/local/context.js +4 -1
- package/dist-cjs/local/core.js +56 -13
- package/dist-cjs/local/tools.js +1 -0
- package/dist-cjs/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog — @agent-api/sdk
|
|
2
2
|
|
|
3
|
+
## 1.4.7
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added warning-aware low-level local workdir listing via `listWithWarnings()`.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Made local context packages use bounded recursive scans and expose `scan_warnings` for skipped child paths.
|
|
12
|
+
|
|
13
|
+
## 1.4.6
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Made local workdir scans skip inaccessible or broken child entries with structured `scan_warnings` instead of failing an otherwise valid workdir.
|
|
18
|
+
|
|
3
19
|
## 1.4.5
|
|
4
20
|
|
|
5
21
|
### Fixed
|
package/dist/local/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LocalFileDeliver, type LocalGrepResponse, type LocalPathSensitivity, type LocalPathSensitivityInfo, type LocalSummary, type LocalWorkdir, type LocalWorkdirSnapshotFile } from "./core.js";
|
|
1
|
+
import { type LocalFileDeliver, type LocalGrepResponse, type LocalPathSensitivity, type LocalPathSensitivityInfo, type LocalScanWarning, type LocalSummary, type LocalWorkdir, type LocalWorkdirSnapshotFile } from "./core.js";
|
|
2
2
|
export interface LocalContextPackageParams {
|
|
3
3
|
path?: string;
|
|
4
4
|
include?: string[];
|
|
@@ -7,6 +7,7 @@ export interface LocalContextPackageParams {
|
|
|
7
7
|
maxFiles?: number;
|
|
8
8
|
maxBytes?: number;
|
|
9
9
|
maxBytesPerFile?: number;
|
|
10
|
+
maxDepth?: number;
|
|
10
11
|
previewBytes?: number;
|
|
11
12
|
includeContent?: boolean;
|
|
12
13
|
includeHashes?: boolean;
|
|
@@ -38,6 +39,7 @@ export interface LocalContextManifest {
|
|
|
38
39
|
included_bytes: number;
|
|
39
40
|
truncated: boolean;
|
|
40
41
|
files: LocalContextFile[];
|
|
42
|
+
scan_warnings?: LocalScanWarning[];
|
|
41
43
|
summary?: LocalSummary;
|
|
42
44
|
search?: LocalGrepResponse;
|
|
43
45
|
}
|
package/dist/local/context.js
CHANGED
|
@@ -6,13 +6,14 @@ export async function createLocalContextPackage(workdir, params = {}) {
|
|
|
6
6
|
const maxFiles = positiveInt(params.maxFiles, 80);
|
|
7
7
|
const maxBytes = positiveInt(params.maxBytes, 256 * 1024);
|
|
8
8
|
const maxBytesPerFile = positiveInt(params.maxBytesPerFile, 32 * 1024);
|
|
9
|
+
const maxDepth = positiveInt(params.maxDepth, 3);
|
|
9
10
|
const previewBytes = positiveInt(params.previewBytes, maxBytesPerFile);
|
|
10
11
|
const includeContent = params.includeContent ?? true;
|
|
11
12
|
const includeHashes = params.includeHashes ?? true;
|
|
12
13
|
const includeSummary = params.includeSummary ?? true;
|
|
13
14
|
const includeSearch = Boolean(params.includeSearch && params.query?.trim());
|
|
14
15
|
const includeSecrets = params.includeSecrets ?? false;
|
|
15
|
-
const stats = await workdir.
|
|
16
|
+
const { stats, warnings } = await workdir.listWithWarnings(basePath, { recursive: true, maxDepth });
|
|
16
17
|
const fileStats = stats
|
|
17
18
|
.filter((item) => item.type === "file")
|
|
18
19
|
.filter((item) => matchesPathFilters(item.path, params.include, params.exclude))
|
|
@@ -75,6 +76,7 @@ export async function createLocalContextPackage(workdir, params = {}) {
|
|
|
75
76
|
? await workdir.summarize({
|
|
76
77
|
path: basePath,
|
|
77
78
|
maxFiles,
|
|
79
|
+
maxDepth,
|
|
78
80
|
previewBytes,
|
|
79
81
|
ignore: params.exclude,
|
|
80
82
|
})
|
|
@@ -99,6 +101,7 @@ export async function createLocalContextPackage(workdir, params = {}) {
|
|
|
99
101
|
included_bytes: includedBytes,
|
|
100
102
|
truncated,
|
|
101
103
|
files,
|
|
104
|
+
scan_warnings: warnings.length ? warnings : undefined,
|
|
102
105
|
summary,
|
|
103
106
|
search,
|
|
104
107
|
};
|
package/dist/local/core.d.ts
CHANGED
|
@@ -66,6 +66,16 @@ export interface LocalEntry {
|
|
|
66
66
|
export interface LocalEntryList {
|
|
67
67
|
object: "list";
|
|
68
68
|
entries: LocalEntry[];
|
|
69
|
+
scan_warnings?: LocalScanWarning[];
|
|
70
|
+
}
|
|
71
|
+
export interface LocalFileStatList {
|
|
72
|
+
stats: LocalFileStat[];
|
|
73
|
+
warnings: LocalScanWarning[];
|
|
74
|
+
}
|
|
75
|
+
export interface LocalScanWarning {
|
|
76
|
+
path: string;
|
|
77
|
+
code?: string;
|
|
78
|
+
message: string;
|
|
69
79
|
}
|
|
70
80
|
export interface LocalSearchEntriesParams {
|
|
71
81
|
query: string;
|
|
@@ -174,6 +184,7 @@ export interface LocalSummary {
|
|
|
174
184
|
text_previews: LocalSummaryPreview[];
|
|
175
185
|
generated_at_unix: number;
|
|
176
186
|
scan_truncated: boolean;
|
|
187
|
+
scan_warnings?: LocalScanWarning[];
|
|
177
188
|
}
|
|
178
189
|
export interface LocalWorkdirOptions {
|
|
179
190
|
name?: string;
|
|
@@ -279,6 +290,7 @@ export declare class LocalFileStore {
|
|
|
279
290
|
stat(relativePath?: string): Promise<LocalFileStat>;
|
|
280
291
|
mkdir(relativePath?: string): Promise<string>;
|
|
281
292
|
list(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStat[]>;
|
|
293
|
+
listWithWarnings(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStatList>;
|
|
282
294
|
listEntries(relativePath?: string, options?: LocalListOptions): Promise<LocalEntryList>;
|
|
283
295
|
searchEntries(params: LocalSearchEntriesParams): Promise<LocalEntryList>;
|
|
284
296
|
readText(relativePath: string): Promise<string>;
|
|
@@ -340,6 +352,7 @@ export declare class LocalWorkdir {
|
|
|
340
352
|
child(relativePath: string, options?: LocalWorkdirOptions): LocalWorkdir;
|
|
341
353
|
resolvePath(relativePath?: string): string;
|
|
342
354
|
list(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStat[]>;
|
|
355
|
+
listWithWarnings(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStatList>;
|
|
343
356
|
listEntries(relativePath?: string, options?: LocalListOptions): Promise<LocalEntryList>;
|
|
344
357
|
searchEntries(params: LocalSearchEntriesParams): Promise<LocalEntryList>;
|
|
345
358
|
readFile(relativePath: string, params: LocalReadFileRawParams): Promise<LocalFileRaw>;
|
package/dist/local/core.js
CHANGED
|
@@ -139,15 +139,19 @@ export class LocalFileStore {
|
|
|
139
139
|
return fullPath;
|
|
140
140
|
}
|
|
141
141
|
async list(relativePath = ".", options = {}) {
|
|
142
|
+
return (await this.listWithWarnings(relativePath, options)).stats;
|
|
143
|
+
}
|
|
144
|
+
async listWithWarnings(relativePath = ".", options = {}) {
|
|
142
145
|
const base = this.resolvePath(relativePath);
|
|
143
146
|
const maxDepth = options.recursive ? options.maxDepth ?? Number.POSITIVE_INFINITY : 1;
|
|
144
147
|
const out = [];
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
const warnings = [];
|
|
149
|
+
await this.walk(this.root, base, base, out, maxDepth, options, warnings);
|
|
150
|
+
return { stats: out.sort((a, b) => a.path.localeCompare(b.path)), warnings };
|
|
147
151
|
}
|
|
148
152
|
async listEntries(relativePath = ".", options = {}) {
|
|
149
|
-
const stats = await this.
|
|
150
|
-
return { object: "list", entries: stats.map(localEntryFromStat) };
|
|
153
|
+
const { stats, warnings } = await this.listWithWarnings(relativePath, { ...options, includeDirectories: options.includeDirectories ?? true });
|
|
154
|
+
return withScanWarnings({ object: "list", entries: stats.map(localEntryFromStat) }, warnings);
|
|
151
155
|
}
|
|
152
156
|
async searchEntries(params) {
|
|
153
157
|
const query = params.query.trim().toLowerCase();
|
|
@@ -374,7 +378,7 @@ export class LocalFileStore {
|
|
|
374
378
|
const maxPreviews = positiveInt(params.maxPreviews, 20);
|
|
375
379
|
const previewBytes = positiveInt(params.previewBytes, 4096);
|
|
376
380
|
const topPaths = positiveInt(params.topPaths, 20);
|
|
377
|
-
const stats = await this.
|
|
381
|
+
const { stats, warnings } = await this.listWithWarnings(params.path ?? ".", { recursive: true, maxDepth: params.maxDepth, ignore: params.ignore });
|
|
378
382
|
const files = stats.filter((item) => item.type === "file").slice(0, maxFiles);
|
|
379
383
|
const scanTruncated = stats.filter((item) => item.type === "file").length > files.length;
|
|
380
384
|
const totalBytes = files.reduce((sum, item) => sum + item.size, 0);
|
|
@@ -402,7 +406,7 @@ export class LocalFileStore {
|
|
|
402
406
|
preview_truncated: truncated || undefined,
|
|
403
407
|
});
|
|
404
408
|
}
|
|
405
|
-
return {
|
|
409
|
+
return withScanWarnings({
|
|
406
410
|
summary_path: "",
|
|
407
411
|
file_count: files.length,
|
|
408
412
|
total_bytes: totalBytes,
|
|
@@ -410,17 +414,26 @@ export class LocalFileStore {
|
|
|
410
414
|
text_previews: previews,
|
|
411
415
|
generated_at_unix: Math.floor(Date.now() / 1000),
|
|
412
416
|
scan_truncated: scanTruncated,
|
|
413
|
-
};
|
|
417
|
+
}, warnings);
|
|
414
418
|
}
|
|
415
|
-
async walk(storeRoot, scanRoot, dir, out, maxDepth, options) {
|
|
416
|
-
|
|
419
|
+
async walk(storeRoot, scanRoot, dir, out, maxDepth, options, warnings) {
|
|
420
|
+
let entries;
|
|
421
|
+
try {
|
|
422
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
if (dir !== scanRoot && recordScanWarning(warnings, toPortablePath(path.relative(storeRoot, dir)), error)) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
417
430
|
for (const entry of entries) {
|
|
418
431
|
const fullPath = path.join(dir, entry.name);
|
|
419
432
|
const relativePath = toPortablePath(path.relative(storeRoot, fullPath));
|
|
420
433
|
if (ignored(relativePath, options.ignore)) {
|
|
421
434
|
continue;
|
|
422
435
|
}
|
|
423
|
-
const info = await lstatOptional(fullPath);
|
|
436
|
+
const info = await lstatOptional(fullPath, relativePath, warnings);
|
|
424
437
|
if (!info) {
|
|
425
438
|
continue;
|
|
426
439
|
}
|
|
@@ -437,7 +450,7 @@ export class LocalFileStore {
|
|
|
437
450
|
}
|
|
438
451
|
const depth = toPortablePath(path.relative(scanRoot, fullPath)).split("/").filter(Boolean).length;
|
|
439
452
|
if (depth < maxDepth) {
|
|
440
|
-
await this.walk(storeRoot, scanRoot, fullPath, out, maxDepth, options);
|
|
453
|
+
await this.walk(storeRoot, scanRoot, fullPath, out, maxDepth, options, warnings);
|
|
441
454
|
}
|
|
442
455
|
continue;
|
|
443
456
|
}
|
|
@@ -549,6 +562,9 @@ export class LocalWorkdir {
|
|
|
549
562
|
async list(relativePath = ".", options = {}) {
|
|
550
563
|
return await this.files.list(relativePath, this.scopedListOptions(options));
|
|
551
564
|
}
|
|
565
|
+
async listWithWarnings(relativePath = ".", options = {}) {
|
|
566
|
+
return await this.files.listWithWarnings(relativePath, this.scopedListOptions(options));
|
|
567
|
+
}
|
|
552
568
|
async listEntries(relativePath = ".", options = {}) {
|
|
553
569
|
return await this.files.listEntries(relativePath, this.scopedListOptions(options));
|
|
554
570
|
}
|
|
@@ -847,11 +863,38 @@ async function fileExists(fullPath) {
|
|
|
847
863
|
return false;
|
|
848
864
|
}
|
|
849
865
|
}
|
|
850
|
-
|
|
866
|
+
const maxScanWarnings = 20;
|
|
867
|
+
const ignorableScanErrorCodes = new Set(["ENOENT", "ENOTDIR", "EACCES", "EPERM", "ENOTCONN", "ELOOP", "EINVAL"]);
|
|
868
|
+
function withScanWarnings(value, warnings) {
|
|
869
|
+
const out = value;
|
|
870
|
+
if (warnings.length > 0) {
|
|
871
|
+
out.scan_warnings = warnings;
|
|
872
|
+
}
|
|
873
|
+
return out;
|
|
874
|
+
}
|
|
875
|
+
function recordScanWarning(warnings, relativePath, error) {
|
|
876
|
+
const scanError = error;
|
|
877
|
+
const code = typeof scanError?.code === "string" ? scanError.code : undefined;
|
|
878
|
+
if (!code || !ignorableScanErrorCodes.has(code)) {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
if (warnings.length < maxScanWarnings) {
|
|
882
|
+
warnings.push({
|
|
883
|
+
path: relativePath || ".",
|
|
884
|
+
code,
|
|
885
|
+
message: typeof scanError.message === "string" ? scanError.message : code,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
async function lstatOptional(fullPath, relativePath, warnings) {
|
|
851
891
|
try {
|
|
852
892
|
return await lstat(fullPath);
|
|
853
893
|
}
|
|
854
894
|
catch (error) {
|
|
895
|
+
if (warnings && relativePath && recordScanWarning(warnings, relativePath, error)) {
|
|
896
|
+
return null;
|
|
897
|
+
}
|
|
855
898
|
if (error?.code === "ENOENT" || error?.code === "ENOTDIR") {
|
|
856
899
|
return null;
|
|
857
900
|
}
|
|
@@ -863,7 +906,7 @@ async function readOptionalFile(fullPath) {
|
|
|
863
906
|
return await readFile(fullPath);
|
|
864
907
|
}
|
|
865
908
|
catch (error) {
|
|
866
|
-
if (error?.code === "ENOENT" || error?.code === "ENOTDIR" || error?.code === "EISDIR") {
|
|
909
|
+
if (error?.code === "ENOENT" || error?.code === "ENOTDIR" || error?.code === "EISDIR" || error?.code === "ENOTCONN") {
|
|
867
910
|
return null;
|
|
868
911
|
}
|
|
869
912
|
throw error;
|
package/dist/local/tools.js
CHANGED
|
@@ -255,6 +255,7 @@ function contextPackageArgs(args) {
|
|
|
255
255
|
maxFiles: optionalNumberArg(args, "maxFiles", "max_files"),
|
|
256
256
|
maxBytes: optionalNumberArg(args, "maxBytes", "max_bytes"),
|
|
257
257
|
maxBytesPerFile: optionalNumberArg(args, "maxBytesPerFile", "max_bytes_per_file"),
|
|
258
|
+
maxDepth: optionalNumberArg(args, "maxDepth", "max_depth"),
|
|
258
259
|
includeContent: optionalBooleanArg(args, "includeContent", "include_content"),
|
|
259
260
|
includeSummary: optionalBooleanArg(args, "includeSummary", "include_summary"),
|
|
260
261
|
includeSearch: optionalBooleanArg(args, "includeSearch", "include_search"),
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.4.
|
|
2
|
-
export declare const USER_AGENT = "@agent-api/sdk/1.4.
|
|
1
|
+
export declare const VERSION = "1.4.7";
|
|
2
|
+
export declare const USER_AGENT = "@agent-api/sdk/1.4.7";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "1.4.
|
|
1
|
+
export const VERSION = "1.4.7";
|
|
2
2
|
export const USER_AGENT = `@agent-api/sdk/${VERSION}`;
|
|
@@ -10,13 +10,14 @@ async function createLocalContextPackage(workdir, params = {}) {
|
|
|
10
10
|
const maxFiles = positiveInt(params.maxFiles, 80);
|
|
11
11
|
const maxBytes = positiveInt(params.maxBytes, 256 * 1024);
|
|
12
12
|
const maxBytesPerFile = positiveInt(params.maxBytesPerFile, 32 * 1024);
|
|
13
|
+
const maxDepth = positiveInt(params.maxDepth, 3);
|
|
13
14
|
const previewBytes = positiveInt(params.previewBytes, maxBytesPerFile);
|
|
14
15
|
const includeContent = params.includeContent ?? true;
|
|
15
16
|
const includeHashes = params.includeHashes ?? true;
|
|
16
17
|
const includeSummary = params.includeSummary ?? true;
|
|
17
18
|
const includeSearch = Boolean(params.includeSearch && params.query?.trim());
|
|
18
19
|
const includeSecrets = params.includeSecrets ?? false;
|
|
19
|
-
const stats = await workdir.
|
|
20
|
+
const { stats, warnings } = await workdir.listWithWarnings(basePath, { recursive: true, maxDepth });
|
|
20
21
|
const fileStats = stats
|
|
21
22
|
.filter((item) => item.type === "file")
|
|
22
23
|
.filter((item) => matchesPathFilters(item.path, params.include, params.exclude))
|
|
@@ -79,6 +80,7 @@ async function createLocalContextPackage(workdir, params = {}) {
|
|
|
79
80
|
? await workdir.summarize({
|
|
80
81
|
path: basePath,
|
|
81
82
|
maxFiles,
|
|
83
|
+
maxDepth,
|
|
82
84
|
previewBytes,
|
|
83
85
|
ignore: params.exclude,
|
|
84
86
|
})
|
|
@@ -103,6 +105,7 @@ async function createLocalContextPackage(workdir, params = {}) {
|
|
|
103
105
|
included_bytes: includedBytes,
|
|
104
106
|
truncated,
|
|
105
107
|
files,
|
|
108
|
+
scan_warnings: warnings.length ? warnings : undefined,
|
|
106
109
|
summary,
|
|
107
110
|
search,
|
|
108
111
|
};
|
package/dist-cjs/local/core.js
CHANGED
|
@@ -154,15 +154,19 @@ class LocalFileStore {
|
|
|
154
154
|
return fullPath;
|
|
155
155
|
}
|
|
156
156
|
async list(relativePath = ".", options = {}) {
|
|
157
|
+
return (await this.listWithWarnings(relativePath, options)).stats;
|
|
158
|
+
}
|
|
159
|
+
async listWithWarnings(relativePath = ".", options = {}) {
|
|
157
160
|
const base = this.resolvePath(relativePath);
|
|
158
161
|
const maxDepth = options.recursive ? options.maxDepth ?? Number.POSITIVE_INFINITY : 1;
|
|
159
162
|
const out = [];
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
const warnings = [];
|
|
164
|
+
await this.walk(this.root, base, base, out, maxDepth, options, warnings);
|
|
165
|
+
return { stats: out.sort((a, b) => a.path.localeCompare(b.path)), warnings };
|
|
162
166
|
}
|
|
163
167
|
async listEntries(relativePath = ".", options = {}) {
|
|
164
|
-
const stats = await this.
|
|
165
|
-
return { object: "list", entries: stats.map(localEntryFromStat) };
|
|
168
|
+
const { stats, warnings } = await this.listWithWarnings(relativePath, { ...options, includeDirectories: options.includeDirectories ?? true });
|
|
169
|
+
return withScanWarnings({ object: "list", entries: stats.map(localEntryFromStat) }, warnings);
|
|
166
170
|
}
|
|
167
171
|
async searchEntries(params) {
|
|
168
172
|
const query = params.query.trim().toLowerCase();
|
|
@@ -389,7 +393,7 @@ class LocalFileStore {
|
|
|
389
393
|
const maxPreviews = positiveInt(params.maxPreviews, 20);
|
|
390
394
|
const previewBytes = positiveInt(params.previewBytes, 4096);
|
|
391
395
|
const topPaths = positiveInt(params.topPaths, 20);
|
|
392
|
-
const stats = await this.
|
|
396
|
+
const { stats, warnings } = await this.listWithWarnings(params.path ?? ".", { recursive: true, maxDepth: params.maxDepth, ignore: params.ignore });
|
|
393
397
|
const files = stats.filter((item) => item.type === "file").slice(0, maxFiles);
|
|
394
398
|
const scanTruncated = stats.filter((item) => item.type === "file").length > files.length;
|
|
395
399
|
const totalBytes = files.reduce((sum, item) => sum + item.size, 0);
|
|
@@ -417,7 +421,7 @@ class LocalFileStore {
|
|
|
417
421
|
preview_truncated: truncated || undefined,
|
|
418
422
|
});
|
|
419
423
|
}
|
|
420
|
-
return {
|
|
424
|
+
return withScanWarnings({
|
|
421
425
|
summary_path: "",
|
|
422
426
|
file_count: files.length,
|
|
423
427
|
total_bytes: totalBytes,
|
|
@@ -425,17 +429,26 @@ class LocalFileStore {
|
|
|
425
429
|
text_previews: previews,
|
|
426
430
|
generated_at_unix: Math.floor(Date.now() / 1000),
|
|
427
431
|
scan_truncated: scanTruncated,
|
|
428
|
-
};
|
|
432
|
+
}, warnings);
|
|
429
433
|
}
|
|
430
|
-
async walk(storeRoot, scanRoot, dir, out, maxDepth, options) {
|
|
431
|
-
|
|
434
|
+
async walk(storeRoot, scanRoot, dir, out, maxDepth, options, warnings) {
|
|
435
|
+
let entries;
|
|
436
|
+
try {
|
|
437
|
+
entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
if (dir !== scanRoot && recordScanWarning(warnings, toPortablePath(node_path_1.default.relative(storeRoot, dir)), error)) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
throw error;
|
|
444
|
+
}
|
|
432
445
|
for (const entry of entries) {
|
|
433
446
|
const fullPath = node_path_1.default.join(dir, entry.name);
|
|
434
447
|
const relativePath = toPortablePath(node_path_1.default.relative(storeRoot, fullPath));
|
|
435
448
|
if (ignored(relativePath, options.ignore)) {
|
|
436
449
|
continue;
|
|
437
450
|
}
|
|
438
|
-
const info = await lstatOptional(fullPath);
|
|
451
|
+
const info = await lstatOptional(fullPath, relativePath, warnings);
|
|
439
452
|
if (!info) {
|
|
440
453
|
continue;
|
|
441
454
|
}
|
|
@@ -452,7 +465,7 @@ class LocalFileStore {
|
|
|
452
465
|
}
|
|
453
466
|
const depth = toPortablePath(node_path_1.default.relative(scanRoot, fullPath)).split("/").filter(Boolean).length;
|
|
454
467
|
if (depth < maxDepth) {
|
|
455
|
-
await this.walk(storeRoot, scanRoot, fullPath, out, maxDepth, options);
|
|
468
|
+
await this.walk(storeRoot, scanRoot, fullPath, out, maxDepth, options, warnings);
|
|
456
469
|
}
|
|
457
470
|
continue;
|
|
458
471
|
}
|
|
@@ -567,6 +580,9 @@ class LocalWorkdir {
|
|
|
567
580
|
async list(relativePath = ".", options = {}) {
|
|
568
581
|
return await this.files.list(relativePath, this.scopedListOptions(options));
|
|
569
582
|
}
|
|
583
|
+
async listWithWarnings(relativePath = ".", options = {}) {
|
|
584
|
+
return await this.files.listWithWarnings(relativePath, this.scopedListOptions(options));
|
|
585
|
+
}
|
|
570
586
|
async listEntries(relativePath = ".", options = {}) {
|
|
571
587
|
return await this.files.listEntries(relativePath, this.scopedListOptions(options));
|
|
572
588
|
}
|
|
@@ -867,11 +883,38 @@ async function fileExists(fullPath) {
|
|
|
867
883
|
return false;
|
|
868
884
|
}
|
|
869
885
|
}
|
|
870
|
-
|
|
886
|
+
const maxScanWarnings = 20;
|
|
887
|
+
const ignorableScanErrorCodes = new Set(["ENOENT", "ENOTDIR", "EACCES", "EPERM", "ENOTCONN", "ELOOP", "EINVAL"]);
|
|
888
|
+
function withScanWarnings(value, warnings) {
|
|
889
|
+
const out = value;
|
|
890
|
+
if (warnings.length > 0) {
|
|
891
|
+
out.scan_warnings = warnings;
|
|
892
|
+
}
|
|
893
|
+
return out;
|
|
894
|
+
}
|
|
895
|
+
function recordScanWarning(warnings, relativePath, error) {
|
|
896
|
+
const scanError = error;
|
|
897
|
+
const code = typeof scanError?.code === "string" ? scanError.code : undefined;
|
|
898
|
+
if (!code || !ignorableScanErrorCodes.has(code)) {
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
if (warnings.length < maxScanWarnings) {
|
|
902
|
+
warnings.push({
|
|
903
|
+
path: relativePath || ".",
|
|
904
|
+
code,
|
|
905
|
+
message: typeof scanError.message === "string" ? scanError.message : code,
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
910
|
+
async function lstatOptional(fullPath, relativePath, warnings) {
|
|
871
911
|
try {
|
|
872
912
|
return await (0, promises_1.lstat)(fullPath);
|
|
873
913
|
}
|
|
874
914
|
catch (error) {
|
|
915
|
+
if (warnings && relativePath && recordScanWarning(warnings, relativePath, error)) {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
875
918
|
if (error?.code === "ENOENT" || error?.code === "ENOTDIR") {
|
|
876
919
|
return null;
|
|
877
920
|
}
|
|
@@ -883,7 +926,7 @@ async function readOptionalFile(fullPath) {
|
|
|
883
926
|
return await (0, promises_1.readFile)(fullPath);
|
|
884
927
|
}
|
|
885
928
|
catch (error) {
|
|
886
|
-
if (error?.code === "ENOENT" || error?.code === "ENOTDIR" || error?.code === "EISDIR") {
|
|
929
|
+
if (error?.code === "ENOENT" || error?.code === "ENOTDIR" || error?.code === "EISDIR" || error?.code === "ENOTCONN") {
|
|
887
930
|
return null;
|
|
888
931
|
}
|
|
889
932
|
throw error;
|
package/dist-cjs/local/tools.js
CHANGED
|
@@ -262,6 +262,7 @@ function contextPackageArgs(args) {
|
|
|
262
262
|
maxFiles: optionalNumberArg(args, "maxFiles", "max_files"),
|
|
263
263
|
maxBytes: optionalNumberArg(args, "maxBytes", "max_bytes"),
|
|
264
264
|
maxBytesPerFile: optionalNumberArg(args, "maxBytesPerFile", "max_bytes_per_file"),
|
|
265
|
+
maxDepth: optionalNumberArg(args, "maxDepth", "max_depth"),
|
|
265
266
|
includeContent: optionalBooleanArg(args, "includeContent", "include_content"),
|
|
266
267
|
includeSummary: optionalBooleanArg(args, "includeSummary", "include_summary"),
|
|
267
268
|
includeSearch: optionalBooleanArg(args, "includeSearch", "include_search"),
|
package/dist-cjs/version.js
CHANGED