@yeaft/webchat-agent 1.0.542 → 1.0.544
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/connection/message-router.js +14 -1
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +155 -103
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
- package/workbench/file-reference-resolver.js +14 -4
|
Binary file
|
package/package.json
CHANGED
|
@@ -6,10 +6,19 @@ import { resolveAndValidatePath } from './utils.js';
|
|
|
6
6
|
import { sendWorkbenchResult } from './request-routing.js';
|
|
7
7
|
|
|
8
8
|
const MAX_REFERENCES = 32;
|
|
9
|
+
const MAX_REFERENCE_LENGTH = 4096;
|
|
9
10
|
const MAX_SCANNED_ENTRIES = 5000;
|
|
10
11
|
const MAX_DEPTH = 10;
|
|
12
|
+
const URI_SCHEME = /^[A-Za-z][A-Za-z\d+.-]*:/;
|
|
13
|
+
const WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/;
|
|
11
14
|
const SKIP_DIRS = new Set(['.git', 'node_modules', '__pycache__', '.next', '.nuxt', 'dist', 'build', '.cache', 'bin', 'obj']);
|
|
12
15
|
|
|
16
|
+
function isFilesystemReference(value) {
|
|
17
|
+
return value.length <= MAX_REFERENCE_LENGTH
|
|
18
|
+
&& !value.includes('\0')
|
|
19
|
+
&& (!URI_SCHEME.test(value) || WINDOWS_ABSOLUTE_PATH.test(value));
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
function comparable(value) {
|
|
14
23
|
const normalized = String(value || '').replaceAll('\\', '/');
|
|
15
24
|
return platform() === 'win32' ? normalized.toLowerCase() : normalized;
|
|
@@ -79,21 +88,22 @@ async function findUniqueBasenames(workDir, requestedPaths, {
|
|
|
79
88
|
export async function resolveFileReferences(references, workDir, scanOptions) {
|
|
80
89
|
const unique = [...new Set((Array.isArray(references) ? references : [])
|
|
81
90
|
.map(value => typeof value === 'string' ? value.trim() : '')
|
|
82
|
-
.filter(
|
|
91
|
+
.filter(value => value && isFilesystemReference(value)))].slice(0, MAX_REFERENCES);
|
|
83
92
|
const root = resolve(workDir);
|
|
84
93
|
const canonicalRoot = await realpath(root);
|
|
85
94
|
const exactCandidates = unique.map(requestedPath => resolveAndValidatePath(requestedPath, root));
|
|
86
95
|
const exactMatches = await Promise.all(exactCandidates.map(exactPath => (
|
|
87
96
|
canonicalWorkspaceFile(exactPath, canonicalRoot)
|
|
88
97
|
)));
|
|
89
|
-
const
|
|
90
|
-
!exactMatches[index] && isInsideWorkspace(root,
|
|
98
|
+
const fallbackEligible = exactCandidates.map((exactPath, index) => (
|
|
99
|
+
!exactMatches[index] && isInsideWorkspace(root, exactPath)
|
|
91
100
|
));
|
|
101
|
+
const unresolved = unique.filter((_path, index) => fallbackEligible[index]);
|
|
92
102
|
const basenameScan = await findUniqueBasenames(root, unresolved, scanOptions);
|
|
93
103
|
|
|
94
104
|
const resolvedEntries = await Promise.all(unique.map(async (requestedPath, index) => {
|
|
95
105
|
const matches = basenameScan.matches.get(comparable(basename(requestedPath))) || [];
|
|
96
|
-
const fallbackPath = basenameScan.complete && matches.length === 1
|
|
106
|
+
const fallbackPath = fallbackEligible[index] && basenameScan.complete && matches.length === 1
|
|
97
107
|
? await canonicalWorkspaceFile(matches[0], canonicalRoot)
|
|
98
108
|
: null;
|
|
99
109
|
const matchedPath = exactMatches[index] || fallbackPath;
|