@qmediat.io/gemini-code-context-mcp 1.23.1 → 1.25.0
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 +161 -1
- package/README.md +1 -1
- package/dist/cache/ttl-watcher.d.ts +29 -0
- package/dist/cache/ttl-watcher.d.ts.map +1 -1
- package/dist/cache/ttl-watcher.js +104 -43
- package/dist/cache/ttl-watcher.js.map +1 -1
- package/dist/gemini/client.d.ts +7 -0
- package/dist/gemini/client.d.ts.map +1 -1
- package/dist/gemini/client.js +8 -1
- package/dist/gemini/client.js.map +1 -1
- package/dist/gemini/long-decode.d.ts +153 -0
- package/dist/gemini/long-decode.d.ts.map +1 -0
- package/dist/gemini/long-decode.js +178 -0
- package/dist/gemini/long-decode.js.map +1 -0
- package/dist/gemini/model-registry.d.ts +2 -0
- package/dist/gemini/model-registry.d.ts.map +1 -1
- package/dist/gemini/model-registry.js +5 -2
- package/dist/gemini/model-registry.js.map +1 -1
- package/dist/gemini/models.d.ts.map +1 -1
- package/dist/gemini/models.js +1 -0
- package/dist/gemini/models.js.map +1 -1
- package/dist/gemini/retry.d.ts +8 -0
- package/dist/gemini/retry.d.ts.map +1 -1
- package/dist/gemini/retry.js +33 -1
- package/dist/gemini/retry.js.map +1 -1
- package/dist/tools/agentic/dispatch.d.ts +68 -0
- package/dist/tools/agentic/dispatch.d.ts.map +1 -0
- package/dist/tools/agentic/dispatch.js +167 -0
- package/dist/tools/agentic/dispatch.js.map +1 -0
- package/dist/tools/agentic/input.d.ts +28 -0
- package/dist/tools/agentic/input.d.ts.map +1 -0
- package/dist/tools/agentic/input.js +66 -0
- package/dist/tools/agentic/input.js.map +1 -0
- package/dist/tools/agentic/instructions.d.ts +46 -0
- package/dist/tools/agentic/instructions.d.ts.map +1 -0
- package/dist/tools/agentic/instructions.js +170 -0
- package/dist/tools/agentic/instructions.js.map +1 -0
- package/dist/tools/agentic/iteration.d.ts +81 -0
- package/dist/tools/agentic/iteration.d.ts.map +1 -0
- package/dist/tools/agentic/iteration.js +317 -0
- package/dist/tools/agentic/iteration.js.map +1 -0
- package/dist/tools/agentic/ledger.d.ts +64 -0
- package/dist/tools/agentic/ledger.d.ts.map +1 -0
- package/dist/tools/agentic/ledger.js +110 -0
- package/dist/tools/agentic/ledger.js.map +1 -0
- package/dist/tools/agentic/loop.d.ts +10 -0
- package/dist/tools/agentic/loop.d.ts.map +1 -0
- package/dist/tools/agentic/loop.js +179 -0
- package/dist/tools/agentic/loop.js.map +1 -0
- package/dist/tools/agentic/no-progress.d.ts +90 -0
- package/dist/tools/agentic/no-progress.d.ts.map +1 -0
- package/dist/tools/agentic/no-progress.js +107 -0
- package/dist/tools/agentic/no-progress.js.map +1 -0
- package/dist/tools/agentic/pass-clock.d.ts +85 -0
- package/dist/tools/agentic/pass-clock.d.ts.map +1 -0
- package/dist/tools/agentic/pass-clock.js +162 -0
- package/dist/tools/agentic/pass-clock.js.map +1 -0
- package/dist/tools/agentic/phase-defaults.d.ts +29 -0
- package/dist/tools/agentic/phase-defaults.d.ts.map +1 -0
- package/dist/tools/agentic/phase-defaults.js +23 -0
- package/dist/tools/agentic/phase-defaults.js.map +1 -0
- package/dist/tools/agentic/rescue.d.ts +69 -0
- package/dist/tools/agentic/rescue.d.ts.map +1 -0
- package/dist/tools/agentic/rescue.js +203 -0
- package/dist/tools/agentic/rescue.js.map +1 -0
- package/dist/tools/agentic/response.d.ts +16 -0
- package/dist/tools/agentic/response.d.ts.map +1 -0
- package/dist/tools/agentic/response.js +25 -0
- package/dist/tools/agentic/response.js.map +1 -0
- package/dist/tools/agentic/results.d.ts +76 -0
- package/dist/tools/agentic/results.d.ts.map +1 -0
- package/dist/tools/agentic/results.js +228 -0
- package/dist/tools/agentic/results.js.map +1 -0
- package/dist/tools/agentic/run.d.ts +130 -0
- package/dist/tools/agentic/run.d.ts.map +1 -0
- package/dist/tools/agentic/run.js +131 -0
- package/dist/tools/agentic/run.js.map +1 -0
- package/dist/tools/agentic/sandbox.d.ts +13 -2
- package/dist/tools/agentic/sandbox.d.ts.map +1 -1
- package/dist/tools/agentic/sandbox.js +127 -111
- package/dist/tools/agentic/sandbox.js.map +1 -1
- package/dist/tools/agentic/workspace-tools.d.ts +30 -27
- package/dist/tools/agentic/workspace-tools.d.ts.map +1 -1
- package/dist/tools/agentic/workspace-tools.js +324 -385
- package/dist/tools/agentic/workspace-tools.js.map +1 -1
- package/dist/tools/ask-agentic-fallback.d.ts +33 -0
- package/dist/tools/ask-agentic-fallback.d.ts.map +1 -0
- package/dist/tools/ask-agentic-fallback.js +113 -0
- package/dist/tools/ask-agentic-fallback.js.map +1 -0
- package/dist/tools/ask-agentic.tool.d.ts +11 -44
- package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.js +143 -1618
- package/dist/tools/ask-agentic.tool.js.map +1 -1
- package/dist/tools/ask.tool.d.ts.map +1 -1
- package/dist/tools/ask.tool.js +195 -555
- package/dist/tools/ask.tool.js.map +1 -1
- package/dist/tools/code.tool.d.ts +6 -0
- package/dist/tools/code.tool.d.ts.map +1 -1
- package/dist/tools/code.tool.js +155 -306
- package/dist/tools/code.tool.js.map +1 -1
- package/dist/tools/shared/abort-timeout.d.ts +48 -4
- package/dist/tools/shared/abort-timeout.d.ts.map +1 -1
- package/dist/tools/shared/abort-timeout.js +116 -95
- package/dist/tools/shared/abort-timeout.js.map +1 -1
- package/dist/tools/shared/call-ledger.d.ts +88 -0
- package/dist/tools/shared/call-ledger.d.ts.map +1 -0
- package/dist/tools/shared/call-ledger.js +133 -0
- package/dist/tools/shared/call-ledger.js.map +1 -0
- package/dist/tools/shared/context-decode.d.ts +77 -0
- package/dist/tools/shared/context-decode.d.ts.map +1 -0
- package/dist/tools/shared/context-decode.js +125 -0
- package/dist/tools/shared/context-decode.js.map +1 -0
- package/dist/tools/shared/continuation.d.ts +124 -0
- package/dist/tools/shared/continuation.d.ts.map +1 -0
- package/dist/tools/shared/continuation.js +302 -0
- package/dist/tools/shared/continuation.js.map +1 -0
- package/dist/tools/shared/dispatch-throttle.d.ts +43 -0
- package/dist/tools/shared/dispatch-throttle.d.ts.map +1 -0
- package/dist/tools/shared/dispatch-throttle.js +65 -0
- package/dist/tools/shared/dispatch-throttle.js.map +1 -0
- package/dist/tools/shared/question-fields.d.ts +10 -0
- package/dist/tools/shared/question-fields.d.ts.map +1 -0
- package/dist/tools/shared/question-fields.js +13 -0
- package/dist/tools/shared/question-fields.js.map +1 -0
- package/dist/tools/shared/settle-call.d.ts +68 -0
- package/dist/tools/shared/settle-call.d.ts.map +1 -0
- package/dist/tools/shared/settle-call.js +59 -0
- package/dist/tools/shared/settle-call.js.map +1 -0
- package/dist/tools/shared/stream-collector.d.ts +7 -0
- package/dist/tools/shared/stream-collector.d.ts.map +1 -1
- package/dist/tools/shared/stream-collector.js +5 -1
- package/dist/tools/shared/stream-collector.js.map +1 -1
- package/dist/tools/shared/thinking.d.ts +41 -11
- package/dist/tools/shared/thinking.d.ts.map +1 -1
- package/dist/tools/shared/thinking.js +62 -9
- package/dist/tools/shared/thinking.js.map +1 -1
- package/dist/tools/shared/throttle.d.ts +7 -0
- package/dist/tools/shared/throttle.d.ts.map +1 -1
- package/dist/tools/shared/throttle.js +18 -0
- package/dist/tools/shared/throttle.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cost-estimator.d.ts +17 -0
- package/dist/utils/cost-estimator.d.ts.map +1 -1
- package/dist/utils/cost-estimator.js +15 -2
- package/dist/utils/cost-estimator.js.map +1 -1
- package/package.json +4 -3
|
@@ -69,6 +69,17 @@ const AGENTIC_SECRET_EXTENSIONS = [
|
|
|
69
69
|
'.ppk',
|
|
70
70
|
'.ovpn',
|
|
71
71
|
];
|
|
72
|
+
/**
|
|
73
|
+
* The list of the secret denylist `fileName` (a basename) is on, case-insensitively, or `null` when it is on neither.
|
|
74
|
+
* The one test of the denylist: `read_file` refuses such a file (`resolveInsideWorkspace`), `list_directory` hides it,
|
|
75
|
+
* and the walk of `find_files` and `grep` never visits it — its name, size and content stay out of every response.
|
|
76
|
+
*/
|
|
77
|
+
export function secretListOf(fileName) {
|
|
78
|
+
const lowerBase = fileName.toLowerCase();
|
|
79
|
+
if (AGENTIC_SECRET_BASENAMES_LOWER.has(lowerBase))
|
|
80
|
+
return 'basename';
|
|
81
|
+
return AGENTIC_SECRET_EXTENSIONS.some((ext) => lowerBase.endsWith(ext)) ? 'extension' : null;
|
|
82
|
+
}
|
|
72
83
|
// ---------------------------------------------------------------------------
|
|
73
84
|
// Path-compare helpers (declared at the top of the file so no function is
|
|
74
85
|
// referenced before its declaration in source order — a defensive tidy-up
|
|
@@ -109,142 +120,147 @@ export async function resolveWorkspaceRoot(rootInput) {
|
|
|
109
120
|
throw new SandboxError('NOT_FOUND', `workspace root does not exist or is unreadable: ${rootInput} (${String(err)})`, rootInput);
|
|
110
121
|
}
|
|
111
122
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
* `SandboxError` if it escapes the workspace or matches a denylist.
|
|
115
|
-
*
|
|
116
|
-
* Returns both the resolved absolute path and the POSIX relative path —
|
|
117
|
-
* callers need the absolute for FS operations and the relative for logging
|
|
118
|
-
* and response payloads. Relative path is always forward-slash form
|
|
119
|
-
* regardless of host OS.
|
|
120
|
-
*
|
|
121
|
-
* Missing-file policy: when the target path doesn't exist on disk, we
|
|
122
|
-
* still enforce the structural jail on the PARENT of the missing leaf so
|
|
123
|
-
* a request like `read_file(".ssh/id_ed25519")` fails with `PATH_TRAVERSAL`
|
|
124
|
-
* even if that specific file is absent. Without walking to a real parent
|
|
125
|
-
* we'd leak a `NOT_FOUND` error that confirms the path shape to an
|
|
126
|
-
* attacker — indirect enumeration signal. Acceptable trade-off: the
|
|
127
|
-
* missing-file error for a valid path inside the root still surfaces as
|
|
128
|
-
* `NOT_FOUND` once the parent resolves.
|
|
129
|
-
*/
|
|
130
|
-
export async function resolveInsideWorkspace(workspaceRoot, relOrAbs) {
|
|
123
|
+
/** The argument trimmed; an empty, non-string or whitespace-only argument is refused before any file system call. */
|
|
124
|
+
function cleanedPathArgument(relOrAbs) {
|
|
131
125
|
if (typeof relOrAbs !== 'string' || relOrAbs.length === 0) {
|
|
132
126
|
throw new SandboxError('PATH_TRAVERSAL', 'path argument is empty', relOrAbs);
|
|
133
127
|
}
|
|
134
|
-
// Empty after normalisation (only whitespace) → reject.
|
|
135
128
|
const cleaned = relOrAbs.trim();
|
|
136
129
|
if (cleaned.length === 0) {
|
|
137
130
|
throw new SandboxError('PATH_TRAVERSAL', 'path argument is whitespace only', relOrAbs);
|
|
138
131
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
return cleaned;
|
|
133
|
+
}
|
|
134
|
+
/** The real path of the nearest ancestor of `candidate` that exists, or `null` when none does up to the file system
|
|
135
|
+
* root. `candidate` itself is not tried: the caller's `realpath` of it has already failed. */
|
|
136
|
+
async function nearestExistingAncestor(candidate) {
|
|
137
|
+
let parent = candidate;
|
|
138
|
+
while (true) {
|
|
139
|
+
const next = resolve(parent, '..');
|
|
140
|
+
if (next === parent)
|
|
141
|
+
return null; // hit filesystem root
|
|
142
|
+
parent = next;
|
|
143
|
+
try {
|
|
144
|
+
return await realpath(parent);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
/* keep walking */
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The refusal of a target that does not exist. The structural jail still holds on its nearest existing ancestor, so a
|
|
153
|
+
* path that is structurally illegal is refused as traversal and never answered with "file not found": an ancestor
|
|
154
|
+
* inside the jail means the leaf is legitimately absent in the workspace (`NOT_FOUND`); one outside means the request
|
|
155
|
+
* tried to escape through a path whose leaf does not exist (`PATH_TRAVERSAL`).
|
|
156
|
+
*/
|
|
157
|
+
async function refuseMissingPath(workspaceRoot, candidate, relOrAbs) {
|
|
158
|
+
const existingAncestor = await nearestExistingAncestor(candidate);
|
|
159
|
+
if (existingAncestor === null) {
|
|
160
|
+
throw new SandboxError('NOT_FOUND', `path has no existing ancestor: ${relOrAbs}`, relOrAbs);
|
|
161
|
+
}
|
|
162
|
+
if (!isInside(workspaceRoot, existingAncestor)) {
|
|
163
|
+
throw new SandboxError('PATH_TRAVERSAL', `path escapes workspace root: ${relOrAbs}`, relOrAbs);
|
|
164
|
+
}
|
|
165
|
+
throw new SandboxError('NOT_FOUND', `path does not exist: ${relOrAbs}`, relOrAbs);
|
|
166
|
+
}
|
|
167
|
+
/** The canonical (symlink-resolved) form of `candidate`, inside the jail. The jail is enforced on the RESOLVED path,
|
|
168
|
+
* so a symlink inside the root that points outside it is caught. */
|
|
169
|
+
async function realpathInsideRoot(workspaceRoot, candidate, relOrAbs) {
|
|
144
170
|
let resolved;
|
|
145
171
|
try {
|
|
146
172
|
resolved = await realpath(candidate);
|
|
147
173
|
}
|
|
148
174
|
catch {
|
|
149
|
-
|
|
150
|
-
// can still assert "the parent is inside the workspace". This avoids
|
|
151
|
-
// leaking "file not found" for paths that are structurally illegal.
|
|
152
|
-
let parent = candidate;
|
|
153
|
-
let existingAncestor = null;
|
|
154
|
-
while (true) {
|
|
155
|
-
const next = resolve(parent, '..');
|
|
156
|
-
if (next === parent)
|
|
157
|
-
break; // hit filesystem root
|
|
158
|
-
parent = next;
|
|
159
|
-
try {
|
|
160
|
-
existingAncestor = await realpath(parent);
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
/* keep walking */
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (existingAncestor === null) {
|
|
168
|
-
throw new SandboxError('NOT_FOUND', `path has no existing ancestor: ${relOrAbs}`, relOrAbs);
|
|
169
|
-
}
|
|
170
|
-
// Assert the existing ancestor is inside the jail. If YES, the missing
|
|
171
|
-
// leaf is legitimately absent inside the workspace; we return a
|
|
172
|
-
// `NOT_FOUND`. If NO, the request was trying to escape via a path
|
|
173
|
-
// whose leaf doesn't exist — treat as traversal.
|
|
174
|
-
if (!isInside(workspaceRoot, existingAncestor)) {
|
|
175
|
-
throw new SandboxError('PATH_TRAVERSAL', `path escapes workspace root: ${relOrAbs}`, relOrAbs);
|
|
176
|
-
}
|
|
177
|
-
throw new SandboxError('NOT_FOUND', `path does not exist: ${relOrAbs}`, relOrAbs);
|
|
175
|
+
return refuseMissingPath(workspaceRoot, candidate, relOrAbs);
|
|
178
176
|
}
|
|
179
|
-
// realpath succeeded — enforce jail on the RESOLVED path so symlinks are caught.
|
|
180
177
|
if (!isInside(workspaceRoot, resolved)) {
|
|
181
178
|
throw new SandboxError('PATH_TRAVERSAL', `path escapes workspace root (symlink or absolute outside): ${relOrAbs}`, relOrAbs);
|
|
182
179
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const base = basename(resolved);
|
|
192
|
-
const lowerBase = base.toLowerCase();
|
|
193
|
-
if (AGENTIC_SECRET_BASENAMES_LOWER.has(lowerBase)) {
|
|
194
|
-
throw new SandboxError('SECRET_DENYLIST', `filename on secret-basename denylist: ${base}`, relOrAbs);
|
|
180
|
+
return resolved;
|
|
181
|
+
}
|
|
182
|
+
/** Content denylist: secrets by basename or extension, case-insensitively — macOS/APFS and Windows/NTFS are
|
|
183
|
+
* case-insensitive by default, so `.ENV` (or `.Env.Local`, `CREDENTIALS`, …) is the same file as `.env`. */
|
|
184
|
+
function refuseSecretFile(base, relOrAbs) {
|
|
185
|
+
const secretList = secretListOf(base);
|
|
186
|
+
if (secretList !== null) {
|
|
187
|
+
throw new SandboxError('SECRET_DENYLIST', `filename on secret-${secretList} denylist: ${base}`, relOrAbs);
|
|
195
188
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The refusal of a path that `pathHitsDir` placed in the excluded directory `dir`. `SECRET_EXCLUDE_DIRS` wins over
|
|
192
|
+
* the generic list, so `.ssh/id_ed25519` yields `SECRET_DENYLIST` (not `EXCLUDED_DIR`) — "user tried to exfiltrate"
|
|
193
|
+
* stays distinct from "this dir is just boring build output" in observability; functionally both are blocked. The
|
|
194
|
+
* message says whether the path is inside the directory, is the directory, or is a file named like it.
|
|
195
|
+
*/
|
|
196
|
+
function excludedDirError(dir, relLower, kind, relOrAbs) {
|
|
197
|
+
const dirLower = dir.toLowerCase();
|
|
198
|
+
if (SECRET_EXCLUDE_DIRS.has(dirLower)) {
|
|
199
|
+
return new SandboxError('SECRET_DENYLIST', `path is inside a secret-bearing directory: ${dir}`, relOrAbs);
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
const namesTheDir = relLower === dirLower || relLower.endsWith(`/${dirLower}`);
|
|
202
|
+
if (!namesTheDir) {
|
|
203
|
+
return new SandboxError('EXCLUDED_DIR', `path is inside excluded directory: ${dir}`, relOrAbs);
|
|
204
|
+
}
|
|
205
|
+
const detail = kind === 'dir'
|
|
206
|
+
? `path is an excluded directory: ${dir}`
|
|
207
|
+
: `path is a file named like an excluded directory: ${dir}`;
|
|
208
|
+
return new SandboxError('EXCLUDED_DIR', detail, relOrAbs);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The default excludes, in this order: the excluded directories, the excluded file names, .NET build output.
|
|
212
|
+
*
|
|
213
|
+
* Excluded-dir check: the POSIX relative path sitting under any entry of `DEFAULT_EXCLUDE_DIRS` is refused. Same
|
|
214
|
+
* semantics as `globs.ts#isPathExcluded`, but it reuses the table rather than the function to skip the MatchConfig
|
|
215
|
+
* plumbing (the path is already inside the jail, so only dir-name matching matters). The comparison is on the
|
|
216
|
+
* lowercased path and entries, so on a case-insensitive file system `NODE_MODULES/foo.js` does not slip past.
|
|
217
|
+
*
|
|
218
|
+
* `DEFAULT_EXCLUDE_FILE_NAMES` (lockfiles, `tsconfig.tsbuildinfo`, …) are matched through their lowercased `Set`, so
|
|
219
|
+
* mis-cased files (`PACKAGE-LOCK.JSON`) match too; their code `EXCLUDED_FILENAME` is distinct from `EXCLUDED_DIR` so
|
|
220
|
+
* the calling model can tell a refused file name from a refused directory in the `functionResponse.error` payload.
|
|
221
|
+
*/
|
|
222
|
+
function refuseDefaultExcluded(base, relLower, kind, relOrAbs) {
|
|
218
223
|
for (const dir of DEFAULT_EXCLUDE_DIRS) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const code = SECRET_EXCLUDE_DIRS.has(dirLower)
|
|
223
|
-
? 'SECRET_DENYLIST'
|
|
224
|
-
: 'EXCLUDED_DIR';
|
|
225
|
-
const detail = code === 'SECRET_DENYLIST'
|
|
226
|
-
? `path is inside a secret-bearing directory: ${dir}`
|
|
227
|
-
: !(relLower === dirLower || relLower.endsWith(`/${dirLower}`))
|
|
228
|
-
? `path is inside excluded directory: ${dir}`
|
|
229
|
-
: kind === 'dir'
|
|
230
|
-
? `path is an excluded directory: ${dir}`
|
|
231
|
-
: `path is a file named like an excluded directory: ${dir}`;
|
|
232
|
-
throw new SandboxError(code, detail, relOrAbs);
|
|
224
|
+
if (pathHitsDir(relLower, dir.toLowerCase(), kind)) {
|
|
225
|
+
throw excludedDirError(dir, relLower, kind, relOrAbs);
|
|
226
|
+
}
|
|
233
227
|
}
|
|
234
|
-
|
|
235
|
-
// tsconfig.tsbuildinfo, etc. — they were uninteresting even in the
|
|
236
|
-
// eager path, and definitely shouldn't cost agentic iterations.
|
|
237
|
-
// Uses the lowercased `Set` so mis-cased files (e.g. `PACKAGE-LOCK.JSON`
|
|
238
|
-
// on case-insensitive FS) still match. Uses `EXCLUDED_FILENAME`
|
|
239
|
-
// (distinct from `EXCLUDED_DIR`) so the calling model can tell
|
|
240
|
-
// "this is a blacklisted filename" from "this is a blacklisted
|
|
241
|
-
// directory" in the `functionResponse.error` payload.
|
|
242
|
-
if (DEFAULT_EXCLUDE_FILE_NAMES_LOWER.has(lowerBase)) {
|
|
228
|
+
if (DEFAULT_EXCLUDE_FILE_NAMES_LOWER.has(base.toLowerCase())) {
|
|
243
229
|
throw new SandboxError('EXCLUDED_FILENAME', `filename on default exclude list: ${base}`, relOrAbs);
|
|
244
230
|
}
|
|
245
231
|
if (isDotnetBuildOutput(relLower, kind)) {
|
|
246
232
|
throw new SandboxError('EXCLUDED_DIR', 'path is .NET build output (bin/…/Debug or Release)', relOrAbs);
|
|
247
233
|
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Resolve `relOrAbs` to a real (symlink-resolved) absolute path, or throw
|
|
237
|
+
* `SandboxError` if it escapes the workspace or matches a denylist.
|
|
238
|
+
*
|
|
239
|
+
* Returns both the resolved absolute path and the POSIX relative path —
|
|
240
|
+
* callers need the absolute for FS operations and the relative for logging
|
|
241
|
+
* and response payloads. Relative path is always forward-slash form
|
|
242
|
+
* regardless of host OS.
|
|
243
|
+
*
|
|
244
|
+
* Missing-file policy: when the target path doesn't exist on disk, we
|
|
245
|
+
* still enforce the structural jail on the PARENT of the missing leaf so
|
|
246
|
+
* a request like `read_file(".ssh/id_ed25519")` fails with `PATH_TRAVERSAL`
|
|
247
|
+
* even if that specific file is absent. Without walking to a real parent
|
|
248
|
+
* we'd leak a `NOT_FOUND` error that confirms the path shape to an
|
|
249
|
+
* attacker — indirect enumeration signal. Acceptable trade-off: the
|
|
250
|
+
* missing-file error for a valid path inside the root still surfaces as
|
|
251
|
+
* `NOT_FOUND` once the parent resolves.
|
|
252
|
+
*
|
|
253
|
+
* The steps run in this order and each refuses with its own code: the argument, the jail, the secret denylist (before
|
|
254
|
+
* the `stat` of the target), the default excludes.
|
|
255
|
+
*/
|
|
256
|
+
export async function resolveInsideWorkspace(workspaceRoot, relOrAbs) {
|
|
257
|
+
const candidate = resolve(workspaceRoot, cleanedPathArgument(relOrAbs));
|
|
258
|
+
const resolved = await realpathInsideRoot(workspaceRoot, candidate, relOrAbs);
|
|
259
|
+
const rel = toPosix(relative(workspaceRoot, resolved));
|
|
260
|
+
const base = basename(resolved);
|
|
261
|
+
refuseSecretFile(base, relOrAbs);
|
|
262
|
+
const kind = await kindOf(resolved, relOrAbs);
|
|
263
|
+
refuseDefaultExcluded(base, rel.toLowerCase(), kind, relOrAbs);
|
|
248
264
|
return { absolutePath: resolved, relpath: rel, kind };
|
|
249
265
|
}
|
|
250
266
|
async function kindOf(resolved, relOrAbs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../src/tools/agentic/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAEhC,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;4DAO4D;AAC5D,MAAM,wBAAwB,GAAsB;IAClD,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,iBAAiB;IACjB,WAAW;IACX,cAAc;IACd,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,kBAAkB;IAClB,WAAW;IACX,aAAa;IACb,kBAAkB;IAClB,cAAc;IACd,cAAc;IACd,aAAa;IACb,sBAAsB;CACvB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CACjE,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CACrD,CAAC;AAEF;gFACgF;AAChF,MAAM,yBAAyB,GAAsB;IACnD,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,WAAW;IACX,MAAM;IACN,MAAM;IACN,OAAO;CACR,CAAC;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../src/tools/agentic/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAEhC,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;4DAO4D;AAC5D,MAAM,wBAAwB,GAAsB;IAClD,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,iBAAiB;IACjB,WAAW;IACX,cAAc;IACd,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,kBAAkB;IAClB,WAAW;IACX,aAAa;IACb,kBAAkB;IAClB,cAAc;IACd,cAAc;IACd,aAAa;IACb,sBAAsB;CACvB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CACjE,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CACrD,CAAC;AAEF;gFACgF;AAChF,MAAM,yBAAyB,GAAsB;IACnD,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;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CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,wBAAwB,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpF,CAAC;AACH,CAAC"}
|
|
@@ -19,6 +19,18 @@
|
|
|
19
19
|
* minified bundle or a massive listing burning output tokens on one call.
|
|
20
20
|
*/
|
|
21
21
|
import { type MatchConfig } from '../../indexer/globs.js';
|
|
22
|
+
/** What an executor reports to, and is stopped by: the pass that runs it. */
|
|
23
|
+
export interface ToolWatch {
|
|
24
|
+
/** Fires when a bound of the pass fired: the executor then rejects with its reason at its next checkpoint. */
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
/** Called at every checkpoint the executor passes: progress, which defers the tools phase's bound on silence. */
|
|
27
|
+
readonly onProgress?: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A checkpoint of an executor's work — every place it reads the signal: rejects with the signal's reason once it
|
|
31
|
+
* fired, else reports progress. Reading the signal and reporting progress are one call, so they cannot drift apart.
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkpoint(watch: ToolWatch | undefined): void;
|
|
22
34
|
export interface DirEntry {
|
|
23
35
|
relpath: string;
|
|
24
36
|
type: 'file' | 'dir';
|
|
@@ -31,11 +43,12 @@ export interface ListDirectoryResult {
|
|
|
31
43
|
totalEntries: number;
|
|
32
44
|
}
|
|
33
45
|
/**
|
|
34
|
-
* List immediate children of `relPath` (non-recursive). Default-excluded
|
|
35
|
-
*
|
|
36
|
-
*
|
|
46
|
+
* List immediate children of `relPath` (non-recursive). Default-excluded dirs and denylisted filenames are omitted; the
|
|
47
|
+
* model sees only paths it is allowed to ask for via `read_file` / `grep`. The requested directory itself is checked
|
|
48
|
+
* against the caller's `excludeGlobs` first — with a message that names no path, so success vs `NOT_FOUND` is no oracle
|
|
49
|
+
* for an excluded directory's existence. A checkpoint (`watch`) precedes the read and each entry.
|
|
37
50
|
*/
|
|
38
|
-
export declare function listDirectoryExecutor(workspaceRoot: string, relPath: string, matchConfig?: MatchConfig): Promise<ListDirectoryResult>;
|
|
51
|
+
export declare function listDirectoryExecutor(workspaceRoot: string, relPath: string, matchConfig?: MatchConfig, watch?: ToolWatch): Promise<ListDirectoryResult>;
|
|
39
52
|
export interface FindFilesResult {
|
|
40
53
|
pattern: string;
|
|
41
54
|
matches: string[];
|
|
@@ -43,12 +56,10 @@ export interface FindFilesResult {
|
|
|
43
56
|
totalMatches: number;
|
|
44
57
|
}
|
|
45
58
|
/**
|
|
46
|
-
* Recursive glob search inside the workspace. Respects default excludes
|
|
47
|
-
*
|
|
48
|
-
* sees paths it couldn't `read_file` on anyway — avoids a foot-gun where
|
|
49
|
-
* the model tries to open a secret it saw in a `find_files` response).
|
|
59
|
+
* Recursive glob search inside the workspace. Respects default excludes, the secret denylist and extension gating, so
|
|
60
|
+
* the model never sees paths it could not `read_file` on anyway.
|
|
50
61
|
*/
|
|
51
|
-
export declare function findFilesExecutor(workspaceRoot: string, pattern: string, matchConfig?: MatchConfig): Promise<FindFilesResult>;
|
|
62
|
+
export declare function findFilesExecutor(workspaceRoot: string, pattern: string, matchConfig?: MatchConfig, watch?: ToolWatch): Promise<FindFilesResult>;
|
|
52
63
|
export interface ReadFileResult {
|
|
53
64
|
relpath: string;
|
|
54
65
|
content: string;
|
|
@@ -60,16 +71,12 @@ export interface ReadFileResult {
|
|
|
60
71
|
totalBytes: number;
|
|
61
72
|
}
|
|
62
73
|
/**
|
|
63
|
-
* Read a file with bounded bytes + lines. Every response includes enough
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* Slicing semantics:
|
|
68
|
-
* - `startLine` / `endLine` are 1-indexed inclusive ranges when given.
|
|
69
|
-
* - Omit both → return the first `DEFAULT_READ_LINE_LIMIT` lines, up to
|
|
70
|
-
* `MAX_READ_BYTES`, whichever hits first.
|
|
74
|
+
* Read a file with bounded bytes + lines. Every response includes enough metadata (`totalLines`, `totalBytes`,
|
|
75
|
+
* `truncated`, `truncationReason`) for the model to request the next slice intelligently. `startLine` / `endLine` are
|
|
76
|
+
* 1-indexed inclusive; omit both → the first `DEFAULT_READ_LINE_LIMIT` lines, up to `MAX_READ_BYTES`, whichever hits
|
|
77
|
+
* first. A checkpoint (`watch`) precedes the read and follows it; the signal aborts the read itself.
|
|
71
78
|
*/
|
|
72
|
-
export declare function readFileExecutor(workspaceRoot: string, relPath: string, startLine?: number, endLine?: number, matchConfig?: MatchConfig): Promise<ReadFileResult>;
|
|
79
|
+
export declare function readFileExecutor(workspaceRoot: string, relPath: string, startLine?: number, endLine?: number, matchConfig?: MatchConfig, watch?: ToolWatch): Promise<ReadFileResult>;
|
|
73
80
|
export interface GrepMatch {
|
|
74
81
|
relpath: string;
|
|
75
82
|
line: number;
|
|
@@ -83,16 +90,12 @@ export interface GrepResult {
|
|
|
83
90
|
totalMatches: number;
|
|
84
91
|
}
|
|
85
92
|
/**
|
|
86
|
-
* Recursive regex search. Supports a basic anchored `pathPrefix` so the
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* Hard caps:
|
|
91
|
-
* - `MAX_GREP_MATCHES` matches returned
|
|
92
|
-
* - each match line truncated to 500 chars (guard against minified
|
|
93
|
-
* lines flooding the payload)
|
|
93
|
+
* Recursive regex search. Supports a basic anchored `pathPrefix` so the model can scope to a subtree. Pattern is
|
|
94
|
+
* compiled as JS RegExp — the model can use standard metacharacters. Hard caps: `MAX_GREP_MATCHES` matches returned,
|
|
95
|
+
* each match line truncated to 500 chars, the walk ends once the response reaches `MAX_RESPONSE_BYTES`. The walk
|
|
96
|
+
* honours the caller's directory excludes, so a regex like `password|secret` reads no file in an excluded directory.
|
|
94
97
|
*/
|
|
95
|
-
export declare function grepExecutor(workspaceRoot: string, pattern: string, pathPrefix?: string, matchConfig?: MatchConfig): Promise<GrepResult>;
|
|
98
|
+
export declare function grepExecutor(workspaceRoot: string, pattern: string, pathPrefix?: string, matchConfig?: MatchConfig, watch?: ToolWatch): Promise<GrepResult>;
|
|
96
99
|
/** Export knobs for tests to reference without re-declaring numeric values. */
|
|
97
100
|
export declare const AGENTIC_LIMITS: Readonly<{
|
|
98
101
|
readonly MAX_READ_BYTES: 200000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/workspace-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"workspace-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/workspace-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,wBAAwB,CAAC;AAuB9F,6EAA6E;AAC7E,MAAM,WAAW,SAAS;IACxB,8GAA8G;IAC9G,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,iHAAiH;IACjH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAG7D;AAqHD,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AA+ED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,WAAW,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