@sema-agent/core 2.8.0 → 2.9.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/send-message-tool.js +37 -29
- package/dist/agents/subagent.js +15 -3
- package/dist/brain/circuit-breaker.js +18 -8
- package/dist/brain/retry.d.ts +1 -0
- package/dist/brain/retry.js +29 -7
- package/dist/brain/stream-engine.d.ts +1 -0
- package/dist/brain/stream-engine.js +74 -12
- package/dist/core/auto-compaction.js +9 -1
- package/dist/core/background-agent-store.d.ts +2 -0
- package/dist/core/background-agent-store.js +20 -0
- package/dist/core/mcp.js +8 -5
- package/dist/core/runner/prepare-task.js +24 -8
- package/dist/core/runner/runtask.js +20 -7
- package/dist/core/runner/tool-disclosure.d.ts +8 -3
- package/dist/core/runner/tool-disclosure.js +22 -8
- package/dist/core/skills-directory.d.ts +1 -1
- package/dist/core/skills-directory.js +257 -28
- package/dist/core/task-registry-agent.d.ts +2 -1
- package/dist/core/task-registry-agent.js +47 -54
- package/dist/core/task-registry.d.ts +1 -0
- package/dist/core/task-registry.js +1 -1
- package/dist/core/types.d.ts +5 -1
- package/dist/engine/compaction/compaction.js +71 -20
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.js +4 -1
- package/dist/orchestration/workflow.d.ts +1 -1
- package/dist/orchestration/workflow.js +2 -2
- package/dist/tools/fs/bash-readonly-classifier.js +83 -17
- package/dist/tools/fs/fs-bash.js +17 -11
- package/dist/tools/fs/fs-shared.d.ts +1 -0
- package/dist/tools/fs/fs-shared.js +44 -2
- package/package.json +1 -1
|
@@ -52,7 +52,10 @@ export const BASH_MAX_TIMEOUT_SEC = 600;
|
|
|
52
52
|
export const BASH_DEFAULT_TIMEOUT_MS = BASH_DEFAULT_TIMEOUT_SEC * 1000;
|
|
53
53
|
export const BASH_MAX_TIMEOUT_MS = BASH_MAX_TIMEOUT_SEC * 1000;
|
|
54
54
|
function validTimeoutMs(n) {
|
|
55
|
-
|
|
55
|
+
if (n === undefined || !Number.isFinite(n))
|
|
56
|
+
return undefined;
|
|
57
|
+
const floored = Math.floor(n);
|
|
58
|
+
return floored >= 1 ? floored : undefined;
|
|
56
59
|
}
|
|
57
60
|
export function resolveBashTimeoutCaps(opts) {
|
|
58
61
|
const defaultMs = validTimeoutMs(opts?.bashDefaultTimeoutMs) ??
|
|
@@ -80,7 +83,7 @@ export function clipShellOutput(s) {
|
|
|
80
83
|
return clipWithFilePointer(s, bashMaxOutputChars());
|
|
81
84
|
}
|
|
82
85
|
export async function writeShellOverflowFile(env, stdout, stderr) {
|
|
83
|
-
const tf = await env.createTempFile({ prefix:
|
|
86
|
+
const tf = await env.createTempFile({ prefix: SHELL_OVERFLOW_FILE_PREFIX, suffix: SHELL_OVERFLOW_FILE_SUFFIX });
|
|
84
87
|
if (!tf.ok)
|
|
85
88
|
return undefined;
|
|
86
89
|
const body = stderr.length > 0 ? `${stdout}${stdout.length > 0 && !stdout.endsWith("\n") ? "\n" : ""}--- stderr ---\n${stderr}` : stdout;
|
|
@@ -90,6 +93,45 @@ export async function writeShellOverflowFile(env, stdout, stderr) {
|
|
|
90
93
|
const canon = await env.canonicalPath(tf.value);
|
|
91
94
|
return canon.ok ? canon.value : tf.value;
|
|
92
95
|
}
|
|
96
|
+
const SHELL_OVERFLOW_FILE_PREFIX = "bash-output-";
|
|
97
|
+
const SHELL_OVERFLOW_FILE_SUFFIX = ".log";
|
|
98
|
+
function toPosixPathKey(p) {
|
|
99
|
+
return p.replace(/\\/g, "/").replace(/(.)\/+$/, "$1");
|
|
100
|
+
}
|
|
101
|
+
function isShellOverflowFileName(base) {
|
|
102
|
+
if (!base.startsWith(SHELL_OVERFLOW_FILE_PREFIX) || !base.endsWith(SHELL_OVERFLOW_FILE_SUFFIX))
|
|
103
|
+
return false;
|
|
104
|
+
const middle = base.slice(SHELL_OVERFLOW_FILE_PREFIX.length, base.length - SHELL_OVERFLOW_FILE_SUFFIX.length);
|
|
105
|
+
return /^[0-9A-Za-z][0-9A-Za-z._-]*$/.test(middle);
|
|
106
|
+
}
|
|
107
|
+
export function createShellOverflowSpoolFence(env) {
|
|
108
|
+
let tempArea;
|
|
109
|
+
const learnTempArea = async () => {
|
|
110
|
+
const probe = await env.createTempDir();
|
|
111
|
+
if (!probe.ok)
|
|
112
|
+
return undefined;
|
|
113
|
+
const canon = await env.canonicalPath(probe.value);
|
|
114
|
+
const resolved = toPosixPathKey(canon.ok ? canon.value : probe.value);
|
|
115
|
+
await env.remove(probe.value, { recursive: true, force: true });
|
|
116
|
+
const cut = resolved.lastIndexOf("/");
|
|
117
|
+
return cut > 0 ? resolved.slice(0, cut) : undefined;
|
|
118
|
+
};
|
|
119
|
+
return async (path) => {
|
|
120
|
+
const target = toPosixPathKey(path);
|
|
121
|
+
const cut = target.lastIndexOf("/");
|
|
122
|
+
if (cut <= 0 || !isShellOverflowFileName(target.slice(cut + 1)))
|
|
123
|
+
return false;
|
|
124
|
+
tempArea ??= learnTempArea();
|
|
125
|
+
const area = await tempArea;
|
|
126
|
+
if (area === undefined)
|
|
127
|
+
return false;
|
|
128
|
+
const parent = target.slice(0, cut);
|
|
129
|
+
if (parent === area)
|
|
130
|
+
return true;
|
|
131
|
+
const up = parent.lastIndexOf("/");
|
|
132
|
+
return up > 0 && parent.slice(0, up) === area;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
93
135
|
export function shellRecoveryHint(path, readOnly) {
|
|
94
136
|
const quoted = shellQuote(path);
|
|
95
137
|
const example = readOnly ? `tail -c 50000 ${quoted}` : `sed -n 'START,ENDp' ${quoted}`;
|