@sema-agent/core 1.295.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/bin/sema-tb.d.ts +20 -0
- package/dist/bin/sema-tb.d.ts.map +1 -1
- package/dist/bin/sema-tb.js +64 -21
- package/dist/bin/sema-tb.js.map +1 -1
- package/dist/brain/anthropic.d.ts.map +1 -1
- package/dist/brain/anthropic.js +8 -0
- package/dist/brain/anthropic.js.map +1 -1
- package/dist/brain/openai.d.ts.map +1 -1
- package/dist/brain/openai.js +8 -0
- 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/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 +28 -8
- 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 +13 -1
- package/dist/core/runner/runtask.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 +2 -0
- package/dist/core/types.d.ts.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/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/internal/llm.d.ts +1 -1
- package/dist/internal/llm.d.ts.map +1 -1
- package/dist/tools/fs/index.d.ts +4 -0
- package/dist/tools/fs/index.d.ts.map +1 -1
- package/dist/tools/fs/index.js +33 -10
- package/dist/tools/fs/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,8 @@ import { Session, isSessionConflict, hasSessionFork } from "../session.js";
|
|
|
19
19
|
import { createAgentTranscriptTool, createSendMessageTool, createSubagentWorktreeHelper, forkGovernanceDenial, AGENT_TRANSCRIPT_TOOL_NAME, SEND_MESSAGE_TOOL_NAME, SubagentRetainLedger } from "../../agents/subagent.js";
|
|
20
20
|
import { combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, resolveAsk } from "../tool-policy.js";
|
|
21
21
|
import { ActiveSkillScope, createActiveSkillScopePolicy } from "./active-skill-scope.js";
|
|
22
|
-
import { computeCallCap, createCallCapRef, softExecDeadlineMs, toolCutDeadlineMs } from "./call-cap.js";
|
|
22
|
+
import { computeCallCap, createCallCapRef, softExecDeadlineMs, toolCutDeadlineMs, WALLTIME_STALL_CONNECT_MS, WALLTIME_STALL_FIRST_TOKEN_MS, WALLTIME_STALL_IDLE_MS } from "./call-cap.js";
|
|
23
|
+
import { createCutKillRegistry } from "./cut-kill.js";
|
|
23
24
|
import { CHANGED_FILES_MTIME_EPS_MS } from "./turn-attachments.js";
|
|
24
25
|
import { emitTrace } from "../trace.js";
|
|
25
26
|
import { createSessionRulePolicy } from "./session-rule-policy.js";
|
|
@@ -630,10 +631,13 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
630
631
|
if (!(spec.tools ?? []).some((t) => t.name === REPORT_FINDINGS_TOOL_NAME || t.aliases?.includes(REPORT_FINDINGS_TOOL_NAME))) {
|
|
631
632
|
tools.push(makeReportFindingsTool());
|
|
632
633
|
}
|
|
633
|
-
if (spec.enablePlanMode === true) {
|
|
634
|
-
|
|
635
|
-
if (
|
|
636
|
-
tools.push(defineTool(
|
|
634
|
+
if (spec.enablePlanMode === true && spec.interactiveTools !== false) {
|
|
635
|
+
const planReviewFace = (spec.checkpointStore ?? deps.checkpointStore) !== undefined;
|
|
636
|
+
if (spec.interactiveTools === true || planReviewFace) {
|
|
637
|
+
tools.push(defineTool(createPresentPlanTool(requestReview)));
|
|
638
|
+
if (planReviewFace) {
|
|
639
|
+
tools.push(defineTool(createEnterPlanModeTool(enterPlanMode)));
|
|
640
|
+
}
|
|
637
641
|
}
|
|
638
642
|
}
|
|
639
643
|
let runtimeCaps;
|
|
@@ -818,12 +822,15 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
818
822
|
? spec.limits.maxOutputTokens
|
|
819
823
|
: model.maxTokens;
|
|
820
824
|
}
|
|
825
|
+
const cutKills = callCapRef ? createCutKillRegistry() : undefined;
|
|
826
|
+
const callIssuedAtRef = {};
|
|
821
827
|
const execClamp = callCapRef
|
|
822
828
|
? {
|
|
823
829
|
deadlineMs: () => softExecDeadlineMs(callCapRef),
|
|
824
830
|
onClamp: () => {
|
|
825
831
|
callCapRef.toolClamps = (callCapRef.toolClamps ?? 0) + 1;
|
|
826
832
|
},
|
|
833
|
+
...(cutKills ? { registerKillHandle: cutKills.register } : {}),
|
|
827
834
|
}
|
|
828
835
|
: undefined;
|
|
829
836
|
const memoryWriteGateRef = {};
|
|
@@ -961,7 +968,9 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
961
968
|
if (offloadStore)
|
|
962
969
|
tools.push(makeReadToolResultTool(offloadStore));
|
|
963
970
|
const onQuestion = spec.onQuestion ?? deps.onQuestion;
|
|
964
|
-
|
|
971
|
+
const durableQuestionFace = (spec.checkpointStore ?? deps.checkpointStore) !== undefined &&
|
|
972
|
+
(spec.durableApproval !== undefined || runtimeCaps?.forceDurableGate === true);
|
|
973
|
+
if (spec.interactiveTools === true || (spec.interactiveTools !== false && (onQuestion !== undefined || durableQuestionFace)))
|
|
965
974
|
tools.push(createAskUserQuestionTool(onQuestion, { principal: spec.principal, sourceTaskId: sessionId }));
|
|
966
975
|
if (spec.handsReadOnly !== true) {
|
|
967
976
|
const schedScope = sessionId ?? spec.principal ?? spec.taskId ?? "default";
|
|
@@ -1542,7 +1551,15 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
1542
1551
|
}
|
|
1543
1552
|
: {}),
|
|
1544
1553
|
...(callCapRef !== undefined
|
|
1545
|
-
? {
|
|
1554
|
+
? {
|
|
1555
|
+
callDeadlineMsPerCall: () => {
|
|
1556
|
+
callIssuedAtRef.current = Date.now();
|
|
1557
|
+
return softExecDeadlineMs(callCapRef);
|
|
1558
|
+
},
|
|
1559
|
+
stallTimeoutsPerCall: () => softExecDeadlineMs(callCapRef) !== undefined
|
|
1560
|
+
? { connectMs: WALLTIME_STALL_CONNECT_MS, firstTokenMs: WALLTIME_STALL_FIRST_TOKEN_MS, idleMs: WALLTIME_STALL_IDLE_MS }
|
|
1561
|
+
: undefined,
|
|
1562
|
+
}
|
|
1546
1563
|
: {}),
|
|
1547
1564
|
...(callCapRef !== undefined
|
|
1548
1565
|
? {
|
|
@@ -1550,6 +1567,9 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
1550
1567
|
deadlineMs: () => toolCutDeadlineMs(callCapRef, Date.now()),
|
|
1551
1568
|
onCut: (info) => {
|
|
1552
1569
|
callCapRef.toolCuts = (callCapRef.toolCuts ?? 0) + 1;
|
|
1570
|
+
if (callCapRef.finalizeMode === true && cutKills !== undefined) {
|
|
1571
|
+
cutKills.killFor(info.toolCallId);
|
|
1572
|
+
}
|
|
1553
1573
|
callCapRef.pendingCutTools = (callCapRef.pendingCutTools ?? 0) + 1;
|
|
1554
1574
|
void info.settled.then(() => {
|
|
1555
1575
|
callCapRef.pendingCutTools = (callCapRef.pendingCutTools ?? 0) - 1;
|
|
@@ -2486,7 +2506,7 @@ export async function prepareTask(spec, deps, sessions, resume, _memorySelector,
|
|
|
2486
2506
|
.list({ owner: hostTaskId, scope: taskScope, sessionId })
|
|
2487
2507
|
.filter((t) => t.status === "pending" || t.status === "running")
|
|
2488
2508
|
.map((t) => ({ id: t.task_id, ...(t.description !== undefined ? { description: t.description } : {}), status: t.status }));
|
|
2489
|
-
return { harness, session, sessionId, taskRootPath, model, thinking, compModel, mcp, blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, nestedStats, cwdRef: handsCwdRef, denyNarrowingPolicy, releaseSignal, cacheBreakDetector, cacheFingerprint, promptManifest, activeTools, ownedEnv, suspendRef, reviewRef, reviewRequestRef, suspendLoopRef, suspendForResource, ...(callCapRef ? { callCapRef } : {}), suspendForReview, resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolEffects, promptOverheadTokens, readTaskFile, recentlyReadFiles, compactionReuseRef, trimPressureRef, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit } } : {}), planModeRef, ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(agentListing ? { agentListing } : {}), listBackgroundTasks };
|
|
2509
|
+
return { harness, session, sessionId, taskRootPath, model, thinking, compModel, mcp, blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, nestedStats, cwdRef: handsCwdRef, denyNarrowingPolicy, releaseSignal, cacheBreakDetector, cacheFingerprint, promptManifest, activeTools, ownedEnv, suspendRef, reviewRef, reviewRequestRef, suspendLoopRef, suspendForResource, ...(callCapRef ? { callCapRef } : {}), ...(cutKills ? { cutKills } : {}), ...(callCapRef ? { callIssuedAtRef } : {}), suspendForReview, resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolEffects, promptOverheadTokens, readTaskFile, recentlyReadFiles, compactionReuseRef, trimPressureRef, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit } } : {}), planModeRef, ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(agentListing ? { agentListing } : {}), listBackgroundTasks };
|
|
2490
2510
|
}
|
|
2491
2511
|
catch (prepareErr) {
|
|
2492
2512
|
if (mcp) {
|