@sema-agent/core 1.448.1 → 1.450.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/dist/core/tools.js
CHANGED
|
@@ -6,6 +6,14 @@ function normalizeContent(ret) {
|
|
|
6
6
|
return { content: [{ type: "text", text: ret }], details: undefined, terminate: false, isError: false };
|
|
7
7
|
}
|
|
8
8
|
const raw = ret.content;
|
|
9
|
+
if (typeof raw !== "string" && !Array.isArray(raw)) {
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: "text", text: "Tool error: content must be a string or an array of content blocks." }],
|
|
12
|
+
details: undefined,
|
|
13
|
+
terminate: false,
|
|
14
|
+
isError: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
9
17
|
const content = typeof raw === "string" ? [{ type: "text", text: raw }] : raw;
|
|
10
18
|
return { content, details: ret.details, terminate: ret.terminate ?? false, isError: ret.isError === true };
|
|
11
19
|
}
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -586,7 +586,14 @@ export function makeReadFileTool(env, state, rootCanonical, cwdRef, additionalRo
|
|
|
586
586
|
if (total > 0 && prev && prev.hash === hash && prev.view && prev.view.start === start && prev.view.end === end) {
|
|
587
587
|
return `[${path}: unchanged since you last read it (lines ${start}-${end} of ${total}); content omitted to save context]`;
|
|
588
588
|
}
|
|
589
|
-
state.set(r.key, {
|
|
589
|
+
state.set(r.key, {
|
|
590
|
+
hash,
|
|
591
|
+
totalLines: countLines(content),
|
|
592
|
+
truncated,
|
|
593
|
+
...(pageMarker !== undefined ? { isPartialView: true } : {}),
|
|
594
|
+
view: { start, end },
|
|
595
|
+
lastReadAt: Date.now(),
|
|
596
|
+
});
|
|
590
597
|
if (total === 0)
|
|
591
598
|
return `<system-reminder>Warning: the file exists but is shorter than the provided offset (${start}). The file has 1 lines.</system-reminder>`;
|
|
592
599
|
const header = pageMarker ?? (truncated ? `[${path}: lines ${start}-${end} of ${total}${end < total ? " — use offset to see more" : ""}]\n` : "");
|
|
@@ -1021,7 +1028,7 @@ export function makeGrepTool(env, rootCanonical, additionalRoots) {
|
|
|
1021
1028
|
'- Filter with `glob` (e.g. "**/*.tsx") or `type` (e.g. "js", "py", "rust").\n' +
|
|
1022
1029
|
'- `output_mode`: "content" (matching lines), "files_with_matches" (paths only, default), or "count".\n' +
|
|
1023
1030
|
"- `multiline: true` for patterns that span lines.\n" +
|
|
1024
|
-
"- Uses ripgrep when available (respects .gitignore, skips binary
|
|
1031
|
+
"- Uses ripgrep when available (respects .gitignore, skips binary files and VCS directories), otherwise a JS fallback that skips node_modules/build/… and parses .gitignore. Hidden files/directories ARE searched.\n" +
|
|
1025
1032
|
"- Use Agent tool for open-ended searches requiring multiple rounds",
|
|
1026
1033
|
parameters: Type.Object({
|
|
1027
1034
|
pattern: Type.String({ description: "The regular expression pattern to search for in file contents" }),
|
package/dist/tools/fs/safety.js
CHANGED
|
@@ -228,7 +228,8 @@ export function violationText(toolName, v) {
|
|
|
228
228
|
return `Error (${toolName}): ${v.message}`;
|
|
229
229
|
}
|
|
230
230
|
export function requireRead(state, key) {
|
|
231
|
-
|
|
231
|
+
const entry = state.get(key);
|
|
232
|
+
if (entry === undefined || entry.isPartialView) {
|
|
232
233
|
return { code: "not_read", message: "File has not been read yet. Read it first before writing to it." };
|
|
233
234
|
}
|
|
234
235
|
return undefined;
|
package/dist/tools/fs/search.js
CHANGED
|
@@ -5,10 +5,11 @@ const WALK_MAX_DEPTH = 32;
|
|
|
5
5
|
const GREP_DEFAULT_CAP = 250;
|
|
6
6
|
const FILE_MAX_BYTES = 5 * 1024 * 1024;
|
|
7
7
|
export const DEFAULT_IGNORE_DIRS = new Set([
|
|
8
|
-
"node_modules", ".git", ".hg", ".svn", "
|
|
9
|
-
".next", ".nuxt", ".gradle", ".idea", ".vscode", "Pods", ".venv", "venv",
|
|
10
|
-
".pytest_cache", "coverage", ".turbo", ".cache", "vendor",
|
|
8
|
+
"node_modules", ".git", ".hg", ".svn", ".bzr", ".jj", ".sl", "build", "dist", "out", "target",
|
|
9
|
+
".dart_tool", ".pub-cache", ".next", ".nuxt", ".gradle", ".idea", ".vscode", "Pods", ".venv", "venv",
|
|
10
|
+
"__pycache__", ".mypy_cache", ".pytest_cache", "coverage", ".turbo", ".cache", "vendor",
|
|
11
11
|
]);
|
|
12
|
+
const VCS_DIRS = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
12
13
|
const TYPE_GLOBS = {
|
|
13
14
|
js: "*.{js,jsx,mjs,cjs}",
|
|
14
15
|
ts: "*.{ts,tsx,mts,cts}",
|
|
@@ -152,8 +153,6 @@ export async function buildIgnore(env, root, signal) {
|
|
|
152
153
|
const base = basename(rel);
|
|
153
154
|
if (isDir && DEFAULT_IGNORE_DIRS.has(base))
|
|
154
155
|
return true;
|
|
155
|
-
if (base.startsWith(".") && base !== ".")
|
|
156
|
-
return true;
|
|
157
156
|
if (gi && gi(rel, isDir))
|
|
158
157
|
return true;
|
|
159
158
|
return false;
|
|
@@ -945,7 +944,9 @@ async function jsGrepFallback(env, root, p, signal, reason) {
|
|
|
945
944
|
}
|
|
946
945
|
export async function rgGrepDetailed(env, root, p, signal) {
|
|
947
946
|
const mode = p.output_mode ?? "files_with_matches";
|
|
948
|
-
const flags = ["--no-messages", "--no-require-git"];
|
|
947
|
+
const flags = ["--no-messages", "--no-require-git", "--hidden"];
|
|
948
|
+
for (const d of VCS_DIRS)
|
|
949
|
+
flags.push("--glob", `!${d}`);
|
|
949
950
|
flags.push("--max-columns", "500", "--max-columns-preview");
|
|
950
951
|
if (p.ignore_case)
|
|
951
952
|
flags.push("-i");
|