@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
|
@@ -1103,6 +1103,9 @@ export class Runner {
|
|
|
1103
1103
|
turnUsage.cacheWriteTokens += u.cacheWrite || 0;
|
|
1104
1104
|
turnUsage.costMicroUsd += turnCostMicroUsd;
|
|
1105
1105
|
const callEndAt = Date.now();
|
|
1106
|
+
const callIssuedAt = prepared.callIssuedAtRef?.current;
|
|
1107
|
+
if (prepared.callIssuedAtRef)
|
|
1108
|
+
prepared.callIssuedAtRef.current = undefined;
|
|
1106
1109
|
const capLast = prepared.callCapRef?.state.last;
|
|
1107
1110
|
if (prepared.callCapRef) {
|
|
1108
1111
|
recordCallSample(prepared.callCapRef.state, u.output || 0, callStartAt !== undefined ? callEndAt - callStartAt : 0);
|
|
@@ -1123,6 +1126,7 @@ export class Runner {
|
|
|
1123
1126
|
cacheWrite: u.cacheWrite || 0,
|
|
1124
1127
|
latencyMs: callStartAt !== undefined ? callEndAt - callStartAt : 0,
|
|
1125
1128
|
firstTokenMs: callStartAt !== undefined && firstTokenAt !== undefined ? firstTokenAt - callStartAt : undefined,
|
|
1129
|
+
...(callIssuedAt !== undefined ? { callStartedAt: callIssuedAt } : {}),
|
|
1126
1130
|
costMicroUsd: turnCostMicroUsd,
|
|
1127
1131
|
...(capLast !== undefined ? { callCap: capLast.cap, capThinkingSkipped: capLast.thinkingSkipped } : {}),
|
|
1128
1132
|
...(m.role === "assistant" && typeof m.stopReason === "string"
|
|
@@ -1224,7 +1228,8 @@ export class Runner {
|
|
|
1224
1228
|
const batchArgs = postToolBatchHook ? new Map() : undefined;
|
|
1225
1229
|
let toolBatch = [];
|
|
1226
1230
|
const onToolStart = (event) => {
|
|
1227
|
-
|
|
1231
|
+
const startAt = Date.now();
|
|
1232
|
+
toolStartAt.set(event.toolCallId, startAt);
|
|
1228
1233
|
startedToolCallIds.add(event.toolCallId);
|
|
1229
1234
|
batchArgs?.set(event.toolCallId, event.args);
|
|
1230
1235
|
stats.toolCalls += 1;
|
|
@@ -1235,7 +1240,7 @@ export class Runner {
|
|
|
1235
1240
|
groundingSignalPostR9 = true;
|
|
1236
1241
|
}
|
|
1237
1242
|
const activityArg = primaryActivityArg(event.args);
|
|
1238
|
-
internals?.onActivity?.({ phase: "start", toolCallId: event.toolCallId, toolName: event.toolName, ...(activityArg !== undefined ? { arg: activityArg } : {}) });
|
|
1243
|
+
internals?.onActivity?.({ phase: "start", toolCallId: event.toolCallId, toolName: event.toolName, at: startAt, ...(activityArg !== undefined ? { arg: activityArg } : {}) });
|
|
1239
1244
|
pushContent({
|
|
1240
1245
|
type: "tool_start",
|
|
1241
1246
|
toolCallId: event.toolCallId,
|
|
@@ -1285,7 +1290,7 @@ export class Runner {
|
|
|
1285
1290
|
ok: !event.isError,
|
|
1286
1291
|
ts: toolNow,
|
|
1287
1292
|
}));
|
|
1288
|
-
internals?.onActivity?.({ phase: "end", toolCallId: event.toolCallId, toolName: event.toolName, isError: event.isError });
|
|
1293
|
+
internals?.onActivity?.({ phase: "end", toolCallId: event.toolCallId, toolName: event.toolName, isError: event.isError, at: toolNow });
|
|
1289
1294
|
if (prepared.lspDiagnostics && !event.isError) {
|
|
1290
1295
|
const name = canonicalToolName(event.toolName);
|
|
1291
1296
|
if (name === "Edit" || name === "Write" || name === "NotebookEdit") {
|
|
@@ -2316,7 +2321,8 @@ export class Runner {
|
|
|
2316
2321
|
const toolClamps = prepared.callCapRef?.toolClamps ?? 0;
|
|
2317
2322
|
const toolCuts = prepared.callCapRef?.toolCuts ?? 0;
|
|
2318
2323
|
const pendingCutTools = prepared.callCapRef?.pendingCutTools ?? 0;
|
|
2319
|
-
|
|
2324
|
+
const toolCutKills = prepared.cutKills?.kills ?? 0;
|
|
2325
|
+
if (finalizeInjected || nudgesSent > 0 || capShrinks > 0 || callCutoffs > 0 || toolClamps > 0 || toolCuts > 0 || toolCutKills > 0 || pendingCutTools > 0 || finalVerifyInjections > 0 || attachmentsInjected > 0 || repetitionCuts > 0 || repetitionSpared > 0) {
|
|
2320
2326
|
stats.mechanisms = {
|
|
2321
2327
|
...(finalizeInjected ? { finalizeInjected: true } : {}),
|
|
2322
2328
|
...(nudgesSent > 0 ? { nudgesSent } : {}),
|
|
@@ -2324,6 +2330,7 @@ export class Runner {
|
|
|
2324
2330
|
...(callCutoffs > 0 ? { callCutoffs } : {}),
|
|
2325
2331
|
...(toolClamps > 0 ? { toolClamps } : {}),
|
|
2326
2332
|
...(toolCuts > 0 ? { toolCuts } : {}),
|
|
2333
|
+
...(toolCutKills > 0 ? { toolCutKills } : {}),
|
|
2327
2334
|
...(pendingCutTools > 0 ? { pendingCutTools } : {}),
|
|
2328
2335
|
...(finalVerifyInjections > 0 ? { finalVerifyInjected: true } : {}),
|
|
2329
2336
|
...(finalVerifyInjections > 0 ? { finalVerifyInjections } : {}),
|
|
@@ -2424,6 +2431,9 @@ export class Runner {
|
|
|
2424
2431
|
...(stats.mechanisms !== undefined
|
|
2425
2432
|
? { mechanisms: (({ repetitionEvents: _events, ...scalars }) => scalars)(stats.mechanisms) }
|
|
2426
2433
|
: {}),
|
|
2434
|
+
...(timeout.latenessMs !== undefined && timeout.latenessMs > TIMER_LATENESS_REPORT_MS
|
|
2435
|
+
? { timerLatenessMs: timeout.latenessMs }
|
|
2436
|
+
: {}),
|
|
2427
2437
|
ts: Date.now(),
|
|
2428
2438
|
}));
|
|
2429
2439
|
setResult(result);
|
|
@@ -2446,7 +2456,7 @@ export class Runner {
|
|
|
2446
2456
|
prepared.suspendRef.token === undefined &&
|
|
2447
2457
|
prepared.reviewRef.token === undefined;
|
|
2448
2458
|
try {
|
|
2449
|
-
await defaultTaskRegistry.settleKilledForOwner({ owner: spec.taskId ?? prepared.sessionId, scope: spec.principal ?? "default" }, {
|
|
2459
|
+
await defaultTaskRegistry.settleKilledForOwner({ owner: spec.taskId ?? prepared.sessionId, scope: spec.principal ?? "default", sessionId: prepared.sessionId }, {
|
|
2450
2460
|
source: abortedLive &&
|
|
2451
2461
|
!timeout.fired &&
|
|
2452
2462
|
!turnsExceeded &&
|
|
@@ -2457,6 +2467,7 @@ export class Runner {
|
|
|
2457
2467
|
: "parent",
|
|
2458
2468
|
skipSessionScoped: true,
|
|
2459
2469
|
envDying: ownedEnvDying,
|
|
2470
|
+
retainProcesses: spec.retainBackgroundProcesses === true,
|
|
2460
2471
|
});
|
|
2461
2472
|
}
|
|
2462
2473
|
catch (e) {
|
|
@@ -2467,13 +2478,15 @@ export class Runner {
|
|
|
2467
2478
|
}
|
|
2468
2479
|
}
|
|
2469
2480
|
const bgEnv = prepared.ownedEnv ?? this.deps.executionEnv;
|
|
2470
|
-
|
|
2481
|
+
const retainBgBySpec = spec.retainBackgroundProcesses === true && !ownedEnvDying;
|
|
2482
|
+
if (bgEnv && hasBackgroundShell(bgEnv) && !retainBgBySpec) {
|
|
2471
2483
|
try {
|
|
2472
2484
|
const keepAlive = ownedEnvDying && bgEnv === prepared.ownedEnv
|
|
2473
2485
|
? []
|
|
2474
2486
|
: [
|
|
2475
2487
|
...defaultTaskRegistry.sessionResidentShellIds(prepared.sessionId, bgEnv),
|
|
2476
2488
|
...defaultTaskRegistry.timeoutResidentShellIds(bgEnv),
|
|
2489
|
+
...defaultTaskRegistry.retainedShellIds(bgEnv),
|
|
2477
2490
|
];
|
|
2478
2491
|
await bgEnv.disposeBackgroundShells(keepAlive.length > 0 ? { except: keepAlive } : undefined);
|
|
2479
2492
|
}
|
|
@@ -3098,12 +3111,15 @@ export function runTask(spec, deps) {
|
|
|
3098
3111
|
return new Runner(deps).runTask(spec);
|
|
3099
3112
|
}
|
|
3100
3113
|
const WALLTIME_SUSPEND_GRACE_SEC = 120;
|
|
3114
|
+
const TIMER_LATENESS_REPORT_MS = 5_000;
|
|
3101
3115
|
function startTimeout(harness, abortController, timeoutSec, softSuspendable = false) {
|
|
3102
3116
|
const state = { fired: false, clear: () => { } };
|
|
3103
3117
|
if (timeoutSec && timeoutSec > 0) {
|
|
3104
3118
|
const hardSec = softSuspendable ? timeoutSec + WALLTIME_SUSPEND_GRACE_SEC : timeoutSec;
|
|
3119
|
+
const scheduledAtMs = Date.now() + hardSec * 1000;
|
|
3105
3120
|
const timer = setTimeout(() => {
|
|
3106
3121
|
state.fired = true;
|
|
3122
|
+
state.latenessMs = Math.max(0, Date.now() - scheduledAtMs);
|
|
3107
3123
|
abortController.abort();
|
|
3108
3124
|
void harness.abort();
|
|
3109
3125
|
}, hardSec * 1000);
|