@sema-agent/core 1.294.0 → 1.296.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/agents/subagent.d.ts.map +1 -1
- package/dist/agents/subagent.js +24 -3
- package/dist/agents/subagent.js.map +1 -1
- package/dist/bin/sema-tb.d.ts +20 -0
- package/dist/bin/sema-tb.d.ts.map +1 -1
- package/dist/bin/sema-tb.js +71 -23
- package/dist/bin/sema-tb.js.map +1 -1
- package/dist/brain/anthropic.d.ts.map +1 -1
- package/dist/brain/anthropic.js +17 -3
- package/dist/brain/anthropic.js.map +1 -1
- package/dist/brain/openai.d.ts +1 -0
- package/dist/brain/openai.d.ts.map +1 -1
- package/dist/brain/openai.js +328 -298
- package/dist/brain/openai.js.map +1 -1
- package/dist/brain/stream-engine.d.ts +7 -0
- package/dist/brain/stream-engine.d.ts.map +1 -1
- package/dist/brain/stream-engine.js +44 -11
- package/dist/brain/stream-engine.js.map +1 -1
- package/dist/brain/timeout.d.ts +2 -1
- package/dist/brain/timeout.d.ts.map +1 -1
- package/dist/brain/timeout.js +14 -1
- package/dist/brain/timeout.js.map +1 -1
- package/dist/core/ask-question.d.ts.map +1 -1
- package/dist/core/ask-question.js.map +1 -1
- package/dist/core/hooks.d.ts +3 -3
- package/dist/core/hooks.d.ts.map +1 -1
- package/dist/core/hooks.js +11 -4
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/present-plan-tool.d.ts.map +1 -1
- package/dist/core/present-plan-tool.js +12 -13
- package/dist/core/present-plan-tool.js.map +1 -1
- package/dist/core/runner/assemble-result.d.ts +1 -0
- package/dist/core/runner/assemble-result.d.ts.map +1 -1
- package/dist/core/runner/assemble-result.js.map +1 -1
- package/dist/core/runner/call-cap.d.ts +4 -1
- package/dist/core/runner/call-cap.d.ts.map +1 -1
- package/dist/core/runner/call-cap.js +4 -1
- package/dist/core/runner/call-cap.js.map +1 -1
- package/dist/core/runner/cut-kill.d.ts +11 -0
- package/dist/core/runner/cut-kill.d.ts.map +1 -0
- package/dist/core/runner/cut-kill.js +38 -0
- package/dist/core/runner/cut-kill.js.map +1 -0
- package/dist/core/runner/prepare-task.d.ts +5 -0
- package/dist/core/runner/prepare-task.d.ts.map +1 -1
- package/dist/core/runner/prepare-task.js +70 -23
- package/dist/core/runner/prepare-task.js.map +1 -1
- package/dist/core/runner/runtask.d.ts.map +1 -1
- package/dist/core/runner/runtask.js +22 -6
- package/dist/core/runner/runtask.js.map +1 -1
- package/dist/core/sensitive-path-policy.d.ts +2 -1
- package/dist/core/sensitive-path-policy.d.ts.map +1 -1
- package/dist/core/sensitive-path-policy.js +22 -0
- package/dist/core/sensitive-path-policy.js.map +1 -1
- package/dist/core/task-registry.d.ts +4 -0
- package/dist/core/task-registry.d.ts.map +1 -1
- package/dist/core/task-registry.js +83 -15
- package/dist/core/task-registry.js.map +1 -1
- package/dist/core/tool-policy.d.ts +5 -2
- package/dist/core/tool-policy.d.ts.map +1 -1
- package/dist/core/tool-policy.js +9 -0
- package/dist/core/tool-policy.js.map +1 -1
- package/dist/core/trace.d.ts +3 -0
- package/dist/core/trace.d.ts.map +1 -1
- package/dist/core/trace.js.map +1 -1
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/engine/compaction/utils.d.ts.map +1 -1
- package/dist/engine/compaction/utils.js +3 -1
- package/dist/engine/compaction/utils.js.map +1 -1
- package/dist/engine/execution-env/kill-tree.d.ts +1 -0
- package/dist/engine/execution-env/kill-tree.d.ts.map +1 -1
- package/dist/engine/execution-env/kill-tree.js +18 -2
- package/dist/engine/execution-env/kill-tree.js.map +1 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +5 -0
- package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -1
- package/dist/engine/execution-env/node-execution-env.js +19 -0
- package/dist/engine/execution-env/node-execution-env.js.map +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -0
- package/dist/engine/harness/agent-harness.d.ts.map +1 -1
- package/dist/engine/harness/agent-harness.js +4 -0
- package/dist/engine/harness/agent-harness.js.map +1 -1
- package/dist/engine/harness/messages.d.ts +2 -0
- package/dist/engine/harness/messages.d.ts.map +1 -1
- package/dist/engine/harness/messages.js +52 -3
- package/dist/engine/harness/messages.js.map +1 -1
- package/dist/engine/harness/types.d.ts +7 -0
- package/dist/engine/harness/types.d.ts.map +1 -1
- package/dist/engine/harness/types.js.map +1 -1
- package/dist/engine/llm/types.d.ts +6 -0
- package/dist/engine/llm/types.d.ts.map +1 -1
- package/dist/engine/loop/agent-loop.js +3 -0
- package/dist/engine/loop/agent-loop.js.map +1 -1
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/loop/types.d.ts.map +1 -1
- package/dist/engine/session/import-validate.d.ts.map +1 -1
- package/dist/engine/session/import-validate.js +64 -0
- package/dist/engine/session/import-validate.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/llm.d.ts +1 -1
- package/dist/internal/llm.d.ts.map +1 -1
- package/dist/scenarios/full-body.d.ts.map +1 -1
- package/dist/scenarios/full-body.js +3 -2
- package/dist/scenarios/full-body.js.map +1 -1
- package/dist/tools/fs/index.d.ts +8 -1
- package/dist/tools/fs/index.d.ts.map +1 -1
- package/dist/tools/fs/index.js +92 -30
- package/dist/tools/fs/index.js.map +1 -1
- package/dist/tools/fs/safety.d.ts +1 -1
- package/dist/tools/fs/safety.d.ts.map +1 -1
- package/dist/tools/fs/safety.js +3 -1
- package/dist/tools/fs/safety.js.map +1 -1
- package/dist/tools/fs/search.d.ts +7 -2
- package/dist/tools/fs/search.d.ts.map +1 -1
- package/dist/tools/fs/search.js +465 -57
- package/dist/tools/fs/search.js.map +1 -1
- package/dist/tools/monitor.d.ts.map +1 -1
- package/dist/tools/monitor.js +12 -1
- package/dist/tools/monitor.js.map +1 -1
- package/dist/tools/task-list.d.ts.map +1 -1
- package/dist/tools/task-list.js.map +1 -1
- package/dist/tools/worktree.d.ts.map +1 -1
- package/dist/tools/worktree.js +15 -2
- package/dist/tools/worktree.js.map +1 -1
- package/package.json +1 -1
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -14,7 +14,10 @@ export declare function seedReadFileStateFromContext(state: ReadFileState, key:
|
|
|
14
14
|
export interface CwdRef {
|
|
15
15
|
current: string;
|
|
16
16
|
}
|
|
17
|
-
export declare function makeReadFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: string, cwdRef?: CwdRef, additionalRoots?: readonly string[], imageDownsampler?: ReadImageDownsamplerOption, pdfCapabilities?: PdfModelCapabilities
|
|
17
|
+
export declare function makeReadFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: string, cwdRef?: CwdRef, additionalRoots?: readonly string[], imageDownsampler?: ReadImageDownsamplerOption, pdfCapabilities?: PdfModelCapabilities, bgOutputReadExemption?: (canonicalKey: string, ctx: {
|
|
18
|
+
taskId?: string;
|
|
19
|
+
principal?: string;
|
|
20
|
+
}) => boolean): AgentTool;
|
|
18
21
|
export type { BeforeWriteRequest, BeforeWriteResult, BeforeWriteHook } from "../../core/types.js";
|
|
19
22
|
export declare function makeEditFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: string, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook): AgentTool;
|
|
20
23
|
export declare function makeWriteFileTool(env: ExecutionEnv, state: ReadFileState, rootCanonical: string, cwdRef?: CwdRef, additionalRoots?: readonly string[], beforeWrite?: BeforeWriteHook): AgentTool;
|
|
@@ -34,6 +37,10 @@ export declare function bashReversibilityProbe(allow?: readonly string[]): (args
|
|
|
34
37
|
export interface ExecClampOption {
|
|
35
38
|
deadlineMs: () => number | undefined;
|
|
36
39
|
onClamp?: (requestedSec: number, clampedSec: number) => void;
|
|
40
|
+
registerKillHandle?: (toolCallId: string, handle: {
|
|
41
|
+
pid: number;
|
|
42
|
+
kill: () => void;
|
|
43
|
+
}) => () => void;
|
|
37
44
|
}
|
|
38
45
|
export declare function bashExitOneInterpretation(command: string): string | undefined;
|
|
39
46
|
export declare function makeBashTool(env: ExecutionEnv, rootCanonical: string, coAuthor?: string | false, cwdRef?: CwdRef, taskOpts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fs/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAyC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAiE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG/H,OAAO,EACL,KAAK,aAAa,EAmBnB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAAsE,KAAK,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAIpJ,OAAO,EAWL,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAuB7E,eAAO,MAAM,qBAAqB,QAAmB,CAAC;AA+BtD,MAAM,MAAM,0BAA0B,GAAG,gBAAgB,GAAG,KAAK,GAAG,SAAS,CAAC;AAwD9E,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AAIjF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGpE;AA4BD,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAUD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAErG;AAqCD,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AA6TD,wBAAgB,gBAAgB,
|
|
1
|
+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CAAC,EAAE,eAAe,CAAC;IAG5B,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;IAKlD,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAG5C,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AASD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE,mBAAwB,GAC7B,SAAS,EAAE,CA4Eb"}
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -324,7 +324,7 @@ async function readPdfFile(env, path, key, pages, signal, downsamplerOpt, cwd, p
|
|
|
324
324
|
},
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
|
-
export function makeReadFileTool(env, state, rootCanonical, cwdRef, additionalRoots, imageDownsampler, pdfCapabilities) {
|
|
327
|
+
export function makeReadFileTool(env, state, rootCanonical, cwdRef, additionalRoots, imageDownsampler, pdfCapabilities, bgOutputReadExemption) {
|
|
328
328
|
return defineTool({
|
|
329
329
|
name: "Read",
|
|
330
330
|
description: "Reads a file from the local filesystem.\n" +
|
|
@@ -352,7 +352,7 @@ export function makeReadFileTool(env, state, rootCanonical, cwdRef, additionalRo
|
|
|
352
352
|
const path = fileArgPath(args);
|
|
353
353
|
if (path === undefined)
|
|
354
354
|
return `Error (Read): file_path is required.`;
|
|
355
|
-
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots);
|
|
355
|
+
const r = await resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, additionalRoots, bgOutputReadExemption === undefined ? undefined : (key) => bgOutputReadExemption(key, ctx));
|
|
356
356
|
if (!r.ok)
|
|
357
357
|
return violationText("Read", r.violation);
|
|
358
358
|
const imageMime = imageMimeForRead(r.key);
|
|
@@ -937,21 +937,20 @@ export function makeNotebookEditTool(env, state, rootCanonical, cwdRef, addition
|
|
|
937
937
|
export function makeGrepTool(env, rootCanonical, additionalRoots) {
|
|
938
938
|
return defineTool({
|
|
939
939
|
name: "Grep",
|
|
940
|
-
description: "
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
"
|
|
945
|
-
"
|
|
946
|
-
"requiring multiple rounds
|
|
940
|
+
description: "Content search built on ripgrep. Prefer this over `grep`/`rg` via Bash — results integrate with the permission UI and file links.\n" +
|
|
941
|
+
'- Full regex syntax (e.g. "log.*Error", "function\\s+\\w+"). Ripgrep, not grep — escape literal braces (`interface\\{\\}`).\n' +
|
|
942
|
+
'- Filter with `glob` (e.g. "**/*.tsx") or `type` (e.g. "js", "py", "rust").\n' +
|
|
943
|
+
'- `output_mode`: "content" (matching lines), "files_with_matches" (paths only, default), or "count".\n' +
|
|
944
|
+
"- `multiline: true` for patterns that span lines.\n" +
|
|
945
|
+
"- Uses ripgrep when available (respects .gitignore, skips binary/hidden files), otherwise a JS fallback that skips node_modules/build/… and parses .gitignore.\n" +
|
|
946
|
+
"- Use Agent tool for open-ended searches requiring multiple rounds",
|
|
947
947
|
parameters: Type.Object({
|
|
948
|
-
pattern: Type.String({ description: "
|
|
949
|
-
regex: Type.Optional(Type.Boolean({ description: "Treat pattern as a regex (default false = literal)." })),
|
|
948
|
+
pattern: Type.String({ description: "The regular expression pattern to search for in file contents" }),
|
|
950
949
|
path: Type.Optional(Type.String({ description: "Restrict to a sub-directory (relative to root)." })),
|
|
951
950
|
glob: Type.Optional(Type.String({ description: 'Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}")' })),
|
|
952
951
|
type: Type.Optional(Type.String({ description: 'File type to search (rg --type): "js", "py", "rust", "go", "java", etc. More efficient than glob for standard file types.' })),
|
|
953
952
|
output_mode: Type.Optional(Type.Union([Type.Literal("content"), Type.Literal("files_with_matches"), Type.Literal("count")], {
|
|
954
|
-
description: "content (
|
|
953
|
+
description: '"content" (matching lines), "files_with_matches" (paths only), or "count" (match counts). Defaults to "files_with_matches".',
|
|
955
954
|
})),
|
|
956
955
|
context: Type.Optional(Type.Number({ description: "Lines of context around each match (content mode). CC alias: -C." })),
|
|
957
956
|
"-C": Type.Optional(Type.Number({ description: "Number of lines to show before and after each match (content mode only)." })),
|
|
@@ -964,7 +963,9 @@ export function makeGrepTool(env, rootCanonical, additionalRoots) {
|
|
|
964
963
|
})),
|
|
965
964
|
"-n": Type.Optional(Type.Boolean({ description: "Show line numbers (accepted for CC compatibility; content mode always includes line numbers)." })),
|
|
966
965
|
multiline: Type.Optional(Type.Boolean({ description: "Match across line boundaries." })),
|
|
967
|
-
head_limit: Type.Optional(Type.Number({
|
|
966
|
+
head_limit: Type.Optional(Type.Number({
|
|
967
|
+
description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 250 when unspecified. Pass 0 for unlimited (use sparingly — large result sets waste context).',
|
|
968
|
+
})),
|
|
968
969
|
offset: Type.Optional(Type.Number({ description: "Skip the first N output lines (pagination partner of head_limit)." })),
|
|
969
970
|
max_results: Type.Optional(Type.Number({ description: "Deprecated alias for head_limit." })),
|
|
970
971
|
}),
|
|
@@ -989,7 +990,9 @@ export function makeGrepTool(env, rootCanonical, additionalRoots) {
|
|
|
989
990
|
only_matching: a.only_matching ?? a["-o"],
|
|
990
991
|
}, ctx.signal);
|
|
991
992
|
const text = grepRun.text;
|
|
992
|
-
|
|
993
|
+
if (text.startsWith("Error (grep)") || text.startsWith("Error (Grep)"))
|
|
994
|
+
return text;
|
|
995
|
+
const mode = a.output_mode ?? "files_with_matches";
|
|
993
996
|
const rows = text.startsWith("No matches.")
|
|
994
997
|
? []
|
|
995
998
|
: text
|
|
@@ -1045,7 +1048,9 @@ export function makeGlobTool(env, rootCanonical, additionalRoots) {
|
|
|
1045
1048
|
name: "Glob",
|
|
1046
1049
|
description: "- Fast file pattern matching tool that works with any codebase size\n" +
|
|
1047
1050
|
'- Supports glob patterns like "**/*.js" or "src/**/*.ts"\n' +
|
|
1048
|
-
"- Returns matching
|
|
1051
|
+
"- Returns matching file paths sorted by modification time\n" +
|
|
1052
|
+
"- On environments that do not report modification times, results fall back to alphabetical order\n" +
|
|
1053
|
+
"- Paths are RELATIVE to the root; ignored trees (node_modules/build/.gitignore) are skipped\n" +
|
|
1049
1054
|
"- Use this tool when you need to find files by name patterns; use `path` to scope to a sub-directory\n" +
|
|
1050
1055
|
"- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead",
|
|
1051
1056
|
parameters: Type.Object({
|
|
@@ -1219,7 +1224,7 @@ async function diagnoseDeadCwd(env, toolName, effectiveCwd, root, cwdRef) {
|
|
|
1219
1224
|
`It was likely deleted by a previous command (e.g. rm -rf on the current directory). There is no directory to reset to; ` +
|
|
1220
1225
|
`this task cannot recover its working tree.`);
|
|
1221
1226
|
}
|
|
1222
|
-
async function runShell(env, cwd, toolName, command, timeoutSec, signal, cwdRef, detach, execClamp) {
|
|
1227
|
+
async function runShell(env, cwd, toolName, command, timeoutSec, signal, cwdRef, detach, execClamp, toolCallId) {
|
|
1223
1228
|
let timeout = Math.min(BASH_MAX_TIMEOUT_SEC, Math.max(1, Math.floor(timeoutSec ?? BASH_DEFAULT_TIMEOUT_SEC)));
|
|
1224
1229
|
const requestedSec = timeout;
|
|
1225
1230
|
let clampedByDeadline = false;
|
|
@@ -1242,13 +1247,36 @@ async function runShell(env, cwd, toolName, command, timeoutSec, signal, cwdRef,
|
|
|
1242
1247
|
? `${command}\n__cc_rc=$?; printf '%s%s%s' '${CWD_SENTINEL}' "$(pwd)" '${CWD_SENTINEL}' 1>&2; exit $__cc_rc`
|
|
1243
1248
|
: command;
|
|
1244
1249
|
const execEnv = cwdRef ? { env: { PWD: effectiveCwd } } : undefined;
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1250
|
+
let deregisterKill;
|
|
1251
|
+
const registerKillHandle = execClamp?.registerKillHandle;
|
|
1252
|
+
let res;
|
|
1253
|
+
try {
|
|
1254
|
+
res = await env.exec(toRun, {
|
|
1255
|
+
cwd: effectiveCwd,
|
|
1256
|
+
timeout,
|
|
1257
|
+
abortSignal: signal,
|
|
1258
|
+
...execEnv,
|
|
1259
|
+
...(detach
|
|
1260
|
+
? {
|
|
1261
|
+
detachSignal: detach.signal,
|
|
1262
|
+
onDetachAdopted: () => {
|
|
1263
|
+
deregisterKill?.();
|
|
1264
|
+
deregisterKill = undefined;
|
|
1265
|
+
},
|
|
1266
|
+
}
|
|
1267
|
+
: {}),
|
|
1268
|
+
...(registerKillHandle !== undefined && toolCallId !== undefined
|
|
1269
|
+
? {
|
|
1270
|
+
onSpawn: (handle) => {
|
|
1271
|
+
deregisterKill = registerKillHandle(toolCallId, handle);
|
|
1272
|
+
},
|
|
1273
|
+
}
|
|
1274
|
+
: {}),
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
finally {
|
|
1278
|
+
deregisterKill?.();
|
|
1279
|
+
}
|
|
1252
1280
|
if (!res.ok) {
|
|
1253
1281
|
if (res.error.code === "spawn_error" || res.error.code === "shell_unavailable") {
|
|
1254
1282
|
const diagnosis = await diagnoseDeadCwd(env, toolName, effectiveCwd, cwd, cwdRef);
|
|
@@ -1423,6 +1451,14 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1423
1451
|
const owner = sessionScoped ? taskOpts.sessionId : (ctx.taskId ?? taskOpts.taskOwner);
|
|
1424
1452
|
const scope = ctx.principal ?? taskOpts.taskScope;
|
|
1425
1453
|
const onNotify = taskOpts.onTaskNotification;
|
|
1454
|
+
let outputFile;
|
|
1455
|
+
if (onNotify !== undefined) {
|
|
1456
|
+
const tf = await env.createTempFile({ prefix: "bash-task-", suffix: ".output" });
|
|
1457
|
+
if (tf.ok) {
|
|
1458
|
+
const tfCanon = await env.canonicalPath(tf.value);
|
|
1459
|
+
outputFile = tfCanon.ok ? tfCanon.value : tf.value;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1426
1462
|
let taskId;
|
|
1427
1463
|
try {
|
|
1428
1464
|
taskId = taskOpts.taskRegistry.registerBackgroundBash({
|
|
@@ -1433,6 +1469,7 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1433
1469
|
...(owner !== undefined ? { owner } : {}),
|
|
1434
1470
|
...(scope !== undefined ? { scope } : {}),
|
|
1435
1471
|
...(sessionScoped ? { sessionScoped: true } : {}),
|
|
1472
|
+
...(outputFile !== undefined ? { outputFile } : {}),
|
|
1436
1473
|
...(onNotify !== undefined ? { onTerminal: (n) => onNotify(n, { priority: "next" }) } : {}),
|
|
1437
1474
|
});
|
|
1438
1475
|
}
|
|
@@ -1456,9 +1493,12 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1456
1493
|
details: { type: "bash", registerFailed: true, killFailed: true },
|
|
1457
1494
|
};
|
|
1458
1495
|
}
|
|
1496
|
+
const interimNote = outputFile !== undefined
|
|
1497
|
+
? ` Output file: ${outputFile} (full output is appended there — Read it any time).`
|
|
1498
|
+
: ` Use TaskOutput("${taskId}") to check interim output.`;
|
|
1459
1499
|
return onNotify !== undefined
|
|
1460
|
-
? `Command running in background; task_id=${taskId}
|
|
1461
|
-
`end your turn if nothing else is pending.
|
|
1500
|
+
? `Command running in background; task_id=${taskId}.${interimNote} You will be notified when it completes — do not poll; ` +
|
|
1501
|
+
`end your turn if nothing else is pending. TaskStop("${taskId}") to stop.` +
|
|
1462
1502
|
budgetNote
|
|
1463
1503
|
: `Started in background; task_id=${taskId}. ` +
|
|
1464
1504
|
`Use TaskOutput("${taskId}") to read output (poll until status is no longer "running"); ` +
|
|
@@ -1478,6 +1518,14 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1478
1518
|
const owner = sessionScoped ? taskOpts.sessionId : (ctx.taskId ?? taskOpts.taskOwner);
|
|
1479
1519
|
const scope = ctx.principal ?? taskOpts.taskScope;
|
|
1480
1520
|
const onNotify = taskOpts.onTaskNotification;
|
|
1521
|
+
let outputFile;
|
|
1522
|
+
if (onNotify !== undefined) {
|
|
1523
|
+
const tf = await env.createTempFile({ prefix: "bash-task-", suffix: ".output" });
|
|
1524
|
+
if (tf.ok) {
|
|
1525
|
+
const tfCanon = await env.canonicalPath(tf.value);
|
|
1526
|
+
outputFile = tfCanon.ok ? tfCanon.value : tf.value;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1481
1529
|
let taskId;
|
|
1482
1530
|
try {
|
|
1483
1531
|
taskId = taskOpts.taskRegistry.registerBackgroundBash({
|
|
@@ -1488,6 +1536,7 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1488
1536
|
...(owner !== undefined ? { owner } : {}),
|
|
1489
1537
|
...(scope !== undefined ? { scope } : {}),
|
|
1490
1538
|
...(sessionScoped ? { sessionScoped: true } : {}),
|
|
1539
|
+
...(outputFile !== undefined ? { outputFile } : {}),
|
|
1491
1540
|
...(onNotify !== undefined ? { onTerminal: (n) => onNotify(n, { priority: "next" }) } : {}),
|
|
1492
1541
|
});
|
|
1493
1542
|
}
|
|
@@ -1529,20 +1578,23 @@ export function makeBashTool(env, rootCanonical, coAuthor = DEFAULT_COMMIT_COAUT
|
|
|
1529
1578
|
: "";
|
|
1530
1579
|
return {
|
|
1531
1580
|
content: `Command moved to background; task_id=${taskId}. ` +
|
|
1532
|
-
|
|
1581
|
+
(outputFile !== undefined
|
|
1582
|
+
? `Output file: ${outputFile} (full output is appended there — Read it any time). `
|
|
1583
|
+
: `Use TaskOutput("${taskId}") to read its output. `) +
|
|
1584
|
+
`TaskStop("${taskId}") to stop it. ` +
|
|
1533
1585
|
(onNotify !== undefined
|
|
1534
1586
|
? `You will be notified when it completes — do not poll.`
|
|
1535
1587
|
: `Poll TaskOutput until its status is no longer "running".`) +
|
|
1536
1588
|
adoptBudgetNote +
|
|
1537
1589
|
(tail ? `\n--- output so far (tail) ---\n${tail}` : ""),
|
|
1538
|
-
details: { type: "bash", detached: true, task_id: taskId, ...(description !== undefined ? { description } : {}) },
|
|
1590
|
+
details: { type: "bash", detached: true, task_id: taskId, ...(description !== undefined ? { description } : {}), ...(outputFile !== undefined ? { output_file: outputFile } : {}) },
|
|
1539
1591
|
};
|
|
1540
1592
|
},
|
|
1541
1593
|
}
|
|
1542
1594
|
: undefined;
|
|
1543
1595
|
let res;
|
|
1544
1596
|
try {
|
|
1545
|
-
res = await runShell(env, rootCanonical, "Bash", command, msTimeoutToSec(timeout), ctx.signal, cwdRef, detachChain, taskOpts.execClamp);
|
|
1597
|
+
res = await runShell(env, rootCanonical, "Bash", command, msTimeoutToSec(timeout), ctx.signal, cwdRef, detachChain, taskOpts.execClamp, ctx.toolCallId);
|
|
1546
1598
|
}
|
|
1547
1599
|
finally {
|
|
1548
1600
|
taskOpts.detachHub?.gc(ctx.toolCallId);
|
|
@@ -1576,7 +1628,7 @@ export function makeBashReadonlyTool(env, rootCanonical, allow, execClamp) {
|
|
|
1576
1628
|
const reason = coarseReadonlyCheck(command, allow);
|
|
1577
1629
|
if (reason)
|
|
1578
1630
|
return `Error (Bash): ${reason}`;
|
|
1579
|
-
return runShell(env, rootCanonical, "Bash", command, msTimeoutToSec(timeout), ctx.signal, undefined, undefined, execClamp);
|
|
1631
|
+
return runShell(env, rootCanonical, "Bash", command, msTimeoutToSec(timeout), ctx.signal, undefined, undefined, execClamp, ctx.toolCallId);
|
|
1580
1632
|
},
|
|
1581
1633
|
});
|
|
1582
1634
|
}
|
|
@@ -1658,7 +1710,17 @@ export function makeKillShellTool(env, registry = defaultTaskRegistry) {
|
|
|
1658
1710
|
export function createHandsToolkit(env, readFileState, rootCanonical, opts = {}) {
|
|
1659
1711
|
const { includeShell = false, readOnly = false, bashReadonlyAllow, commitCoAuthor = DEFAULT_COMMIT_COAUTHOR, mountBackgroundTaskTools = true, additionalRoots, } = opts;
|
|
1660
1712
|
const cwdRef = opts.cwdRef ?? { current: rootCanonical };
|
|
1661
|
-
const
|
|
1713
|
+
const bgReadRegistry = opts.taskRegistry;
|
|
1714
|
+
const bgOutputReadExemption = bgReadRegistry === undefined
|
|
1715
|
+
? undefined
|
|
1716
|
+
: (canonicalKey, c) => bgReadRegistry.isBackgroundOutputFile(canonicalKey, {
|
|
1717
|
+
owner: c.taskId ?? opts.taskOwner,
|
|
1718
|
+
scope: c.principal ?? opts.taskScope,
|
|
1719
|
+
...(opts.sessionId !== undefined ? { sessionId: opts.sessionId } : {}),
|
|
1720
|
+
}, env);
|
|
1721
|
+
const tools = [
|
|
1722
|
+
makeReadFileTool(env, readFileState, rootCanonical, readOnly ? undefined : cwdRef, additionalRoots, opts.readImageDownsampler, opts.pdfModelCapabilities, bgOutputReadExemption),
|
|
1723
|
+
];
|
|
1662
1724
|
if (!readOnly) {
|
|
1663
1725
|
tools.push(makeEditFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite), makeWriteFileTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite), makeNotebookEditTool(env, readFileState, rootCanonical, cwdRef, additionalRoots, opts.beforeWrite));
|
|
1664
1726
|
}
|