deepagents 1.12.0 → 1.12.1

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.
@@ -342,11 +342,32 @@ function validatePath$1(path) {
342
342
  return normalized;
343
343
  }
344
344
  /**
345
+ * Resolve the files under `path` for grep/glob search.
346
+ *
347
+ * If `path` exactly names a file that exists in `files`, only that file is
348
+ * returned (exact match) — this lets grep/glob target a specific file
349
+ * directly instead of only matching directories. Otherwise `path` is treated
350
+ * as a directory and files are filtered by the normalized directory prefix.
351
+ *
352
+ * @returns Filtered files map, or null if `path` is invalid (e.g. whitespace-only).
353
+ */
354
+ function filterFilesByPath(files, path) {
355
+ const exactPath = path ? path.startsWith("/") ? path : "/" + path : "/";
356
+ if (Object.prototype.hasOwnProperty.call(files, exactPath)) return { [exactPath]: files[exactPath] };
357
+ try {
358
+ const normalizedPath = validatePath$1(path);
359
+ return Object.fromEntries(Object.entries(files).filter(([fp]) => fp.startsWith(normalizedPath)));
360
+ } catch {
361
+ return null;
362
+ }
363
+ }
364
+ /**
345
365
  * Search files dict for paths matching glob pattern.
346
366
  *
347
367
  * @param files - Dictionary of file paths to FileData
348
368
  * @param pattern - Glob pattern (e.g., `*.py`, `**\/*.ts`)
349
- * @param path - Base path to search from
369
+ * @param path - Base path to search from. If `path` names an exact file, only
370
+ * that file is considered.
350
371
  * @returns Newline-separated file paths, sorted by modification time (most recent first).
351
372
  * Returns "No files found" if no matches.
352
373
  *
@@ -358,13 +379,9 @@ function validatePath$1(path) {
358
379
  * ```
359
380
  */
360
381
  function globSearchFiles(files, pattern, path = "/") {
361
- let normalizedPath;
362
- try {
363
- normalizedPath = validatePath$1(path);
364
- } catch {
365
- return "No files found";
366
- }
367
- const filtered = Object.fromEntries(Object.entries(files).filter(([fp]) => fp.startsWith(normalizedPath)));
382
+ const filtered = filterFilesByPath(files, path);
383
+ if (filtered === null) return "No files found";
384
+ const normalizedPath = validatePath$1(path);
368
385
  const effectivePattern = pattern;
369
386
  const matches = [];
370
387
  for (const [filePath, fileData] of Object.entries(filtered)) {
@@ -387,16 +404,12 @@ function globSearchFiles(files, pattern, path = "/") {
387
404
  * Return structured grep matches from an in-memory files mapping.
388
405
  *
389
406
  * Performs literal text search (not regex). Binary files are skipped.
407
+ * If `path` names an exact file, only that file is considered.
390
408
  * Returns an empty array when no matches are found or on invalid input.
391
409
  */
392
410
  function grepMatchesFromFiles(files, pattern, path = null, glob = null) {
393
- let normalizedPath;
394
- try {
395
- normalizedPath = validatePath$1(path);
396
- } catch {
397
- return [];
398
- }
399
- let filtered = Object.fromEntries(Object.entries(files).filter(([fp]) => fp.startsWith(normalizedPath)));
411
+ let filtered = filterFilesByPath(files, path);
412
+ if (filtered === null) return [];
400
413
  if (glob) filtered = Object.fromEntries(Object.entries(filtered).filter(([fp]) => micromatch.isMatch(basename(fp), glob, {
401
414
  dot: true,
402
415
  nobrace: false
@@ -7447,4 +7460,4 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
7447
7460
  //#endregion
7448
7461
  export { filesValue as A, StateBackend as B, createSummarizationMiddleware as C, MAX_SKILL_NAME_LENGTH as D, MAX_SKILL_FILE_SIZE as E, SUBAGENT_RESPONSE_FORMAT_CONFIG_KEY as F, adaptBackendProtocol as G, isSandboxBackend as H, createSubAgent as I, getMimeType as J, adaptSandboxProtocol as K, createSubAgentMiddleware as L, DEFAULT_GENERAL_PURPOSE_DESCRIPTION as M, DEFAULT_SUBAGENT_PROMPT as N, createSkillsMiddleware as O, GENERAL_PURPOSE_SUBAGENT as P, createFilesystemMiddleware as R, computeSummarizationDefaults as S, MAX_SKILL_DESCRIPTION_LENGTH as T, isSandboxProtocol as U, SandboxError as V, resolveBackend as W, performStringReplacement as X, isTextMimeType as Y, createHarnessProfile as _, ASYNC_TASK_SYSTEM_PROMPT as a, createAsyncSubAgentMiddleware as b, TASK_SYSTEM_PROMPT as c, registerHarnessProfile as d, generalPurposeSubagentConfigSchema as f, EMPTY_HARNESS_PROFILE as g, serializeProfile as h, StoreBackend as i, createPatchToolCallsMiddleware as j, createMemoryMiddleware as k, createDeepAgent as l, parseHarnessProfileConfig as m, BaseSandbox as n, BASE_AGENT_PROMPT as o, harnessProfileConfigSchema as p, checkEmptyContent as q, ContextHubBackend as r, EXECUTION_SYSTEM_PROMPT as s, LangSmithSandbox as t, getHarnessProfile as u, REQUIRED_MIDDLEWARE_NAMES as v, createCompletionCallbackMiddleware as w, isAsyncSubAgent as x, ConfigurationError as y, CompositeBackend as z };
7449
7462
 
7450
- //# sourceMappingURL=langsmith-hz83LfzA.js.map
7463
+ //# sourceMappingURL=langsmith-DgbmWtWj.js.map