@sema-agent/core 1.312.0 → 1.314.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 +8 -0
- package/dist/agents/subagent.js.map +1 -1
- package/dist/core/checkpoint-store.d.ts +5 -1
- package/dist/core/checkpoint-store.d.ts.map +1 -1
- package/dist/core/checkpoint-store.js +8 -1
- package/dist/core/checkpoint-store.js.map +1 -1
- package/dist/core/runner/prepare-task.d.ts +2 -0
- package/dist/core/runner/prepare-task.d.ts.map +1 -1
- package/dist/core/runner/prepare-task.js +30 -7
- 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 +32 -10
- package/dist/core/runner/runtask.js.map +1 -1
- package/dist/core/runner/tool-disclosure.d.ts +1 -0
- package/dist/core/runner/tool-disclosure.d.ts.map +1 -1
- package/dist/core/runner/tool-disclosure.js +2 -0
- package/dist/core/runner/tool-disclosure.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +2 -0
- package/dist/orchestration/run-workflow-tool.d.ts.map +1 -1
- package/dist/orchestration/run-workflow-tool.js +19 -1
- package/dist/orchestration/run-workflow-tool.js.map +1 -1
- package/dist/prompt-assembly/explain.d.ts +14 -0
- package/dist/prompt-assembly/explain.d.ts.map +1 -1
- package/dist/prompt-assembly/explain.js +17 -0
- package/dist/prompt-assembly/explain.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtask.d.ts","sourceRoot":"","sources":["../../../src/core/runner/runtask.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,KAAK,EAAE,MAAM,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AC,qBAAqB;IAwD7B,OAAO,CAAC,qBAAqB;YAKf,MAAM;YAoHN,gBAAgB;CAc/B;AAGD,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAE7E;AA0DD,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentHarness, DEFAULT_COMPACTION_SETTINGS, uuidv7 } from "../../internal/harness.js";
|
|
2
|
-
import { CheckpointError, BINDING_CHECKPOINT_VERSION, checkpointVersionOf, MAX_SUPPORTED_CHECKPOINT_VERSION, remainingBudgetMicroUsd, validatePendingSteer, winnerFromOutcome, } from "../checkpoint-store.js";
|
|
2
|
+
import { CheckpointError, BINDING_CHECKPOINT_VERSION, checkpointVersionOf, MAX_SUPPORTED_CHECKPOINT_VERSION, remainingBudgetMicroUsd, remainingWalltimeMs, validatePendingSteer, winnerFromOutcome, } from "../checkpoint-store.js";
|
|
3
3
|
import { effectiveCushionMs, estimateCycleMs, hasRealContent, minLiveWriteoutWindowMs, recordCallSample, recordToolCycleSample, recordToolSample, recordTtftSample, softExecDeadlineMs, writeoutCushionMs } from "./call-cap.js";
|
|
4
4
|
import { engineVersion } from "../version.js";
|
|
5
5
|
import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
|
|
@@ -705,7 +705,7 @@ export class Runner {
|
|
|
705
705
|
}
|
|
706
706
|
onReady({ harness: prepared.harness, abortController: prepared.abortController });
|
|
707
707
|
const stats = { turns: 0, tokens: 0, toolCalls: 0, promptTokens: 0, cachedTokens: 0, cacheWriteTokens: 0, cacheWriteTokensLong: 0, outputTokens: 0, costUsd: 0, costMicroUsd: 0 };
|
|
708
|
-
prepared.liveSpendRef.get = () => ({ costMicroUsd: stats.costMicroUsd, tokens: stats.tokens, turns: stats.turns });
|
|
708
|
+
prepared.liveSpendRef.get = () => ({ costMicroUsd: stats.costMicroUsd, tokens: stats.tokens, turns: stats.turns, walltimeMs: Math.round(performance.now() - taskStartMonotonic) });
|
|
709
709
|
if (resume &&
|
|
710
710
|
resume.cp.suspendedAt !== undefined &&
|
|
711
711
|
(resume.cp.gate.kind === "human" ||
|
|
@@ -972,13 +972,22 @@ export class Runner {
|
|
|
972
972
|
};
|
|
973
973
|
});
|
|
974
974
|
}
|
|
975
|
-
const
|
|
976
|
-
const
|
|
975
|
+
const sliceWindowWalltimeMs = spec.limits?.timeoutSec ? spec.limits.timeoutSec * 1000 : undefined;
|
|
976
|
+
const remainingWalltimeBudgetMs = prepared.resourceLedger?.totalWalltimeSec !== undefined
|
|
977
|
+
? remainingWalltimeMs(prepared.resourceLedger)
|
|
978
|
+
: spec.resourceSuspend?.totalWalltimeSec !== undefined
|
|
979
|
+
? Math.max(0, spec.resourceSuspend.totalWalltimeSec * 1000 - (prepared.resourceLedger?.spentWalltimeMs ?? 0))
|
|
980
|
+
: undefined;
|
|
981
|
+
const effectiveTimeoutMs = sliceWindowWalltimeMs !== undefined && remainingWalltimeBudgetMs !== undefined
|
|
982
|
+
? Math.min(sliceWindowWalltimeMs, remainingWalltimeBudgetMs)
|
|
983
|
+
: (sliceWindowWalltimeMs ?? remainingWalltimeBudgetMs);
|
|
984
|
+
const walltimeDeadlineMs = effectiveTimeoutMs !== undefined ? taskStart + effectiveTimeoutMs : undefined;
|
|
985
|
+
const walltimeMonotonicDeadline = effectiveTimeoutMs !== undefined ? taskStartMonotonic + effectiveTimeoutMs : undefined;
|
|
977
986
|
if (prepared.callCapRef && prepared.suspendForResource === undefined && walltimeDeadlineMs !== undefined) {
|
|
978
987
|
prepared.callCapRef.deadlineMs = walltimeDeadlineMs;
|
|
979
988
|
if (spec.limits?.gracefulFinalize !== false) {
|
|
980
|
-
prepared.callCapRef.cushionMs = writeoutCushionMs(
|
|
981
|
-
prepared.callCapRef.budgetMs =
|
|
989
|
+
prepared.callCapRef.cushionMs = writeoutCushionMs(effectiveTimeoutMs);
|
|
990
|
+
prepared.callCapRef.budgetMs = effectiveTimeoutMs;
|
|
982
991
|
}
|
|
983
992
|
}
|
|
984
993
|
let finalizeInjected = false;
|
|
@@ -986,7 +995,7 @@ export class Runner {
|
|
|
986
995
|
const nudgeSchedule = [];
|
|
987
996
|
{
|
|
988
997
|
const conf = spec.limits?.deadlineNudge;
|
|
989
|
-
const budgetSec =
|
|
998
|
+
const budgetSec = effectiveTimeoutMs !== undefined ? effectiveTimeoutMs / 1000 : undefined;
|
|
990
999
|
if (conf !== false && budgetSec && budgetSec > 0) {
|
|
991
1000
|
const [a, b] = conf?.at ?? [0.8, 0.95];
|
|
992
1001
|
if (a > 0 && a < 1) {
|
|
@@ -1802,7 +1811,7 @@ export class Runner {
|
|
|
1802
1811
|
: walltimeHit
|
|
1803
1812
|
? "walltime"
|
|
1804
1813
|
: "turns";
|
|
1805
|
-
const sliceSpend = { costMicroUsd: stats.costMicroUsd, tokens: stats.tokens, turns: stats.turns };
|
|
1814
|
+
const sliceSpend = { costMicroUsd: stats.costMicroUsd, tokens: stats.tokens, turns: stats.turns, walltimeMs: Math.round(performance.now() - taskStartMonotonic) };
|
|
1806
1815
|
if (await prepared.suspendForResource(reason, sliceSpend)) {
|
|
1807
1816
|
turnsExceeded = false;
|
|
1808
1817
|
budgetHit = undefined;
|
|
@@ -2254,7 +2263,8 @@ export class Runner {
|
|
|
2254
2263
|
throw e;
|
|
2255
2264
|
}
|
|
2256
2265
|
if (resume) {
|
|
2257
|
-
|
|
2266
|
+
const walltimeExhaustedResume = effectiveTimeoutMs !== undefined && effectiveTimeoutMs <= 0;
|
|
2267
|
+
if (!walltimeExhaustedResume && resume.outcome.gate !== "wake") {
|
|
2258
2268
|
await this.applyResumeDecision(prepared, resume, (e) => queue.push(e), emitCommitted, (toolName, details) => {
|
|
2259
2269
|
if (attachState === undefined)
|
|
2260
2270
|
return;
|
|
@@ -2265,7 +2275,13 @@ export class Runner {
|
|
|
2265
2275
|
reduceToolEnd(attachState, details);
|
|
2266
2276
|
}, (toolCallId) => startedToolCallIds.add(toolCallId));
|
|
2267
2277
|
}
|
|
2268
|
-
if (
|
|
2278
|
+
if (walltimeExhaustedResume) {
|
|
2279
|
+
timeout.fired = true;
|
|
2280
|
+
timeout.clear();
|
|
2281
|
+
void prepared.harness.abort();
|
|
2282
|
+
prepared.abortController.abort();
|
|
2283
|
+
}
|
|
2284
|
+
else if (maxCostMicroUsd !== undefined && maxCostMicroUsd <= 0) {
|
|
2269
2285
|
budgetHit = "exceeded";
|
|
2270
2286
|
}
|
|
2271
2287
|
else {
|
|
@@ -2358,6 +2374,12 @@ export class Runner {
|
|
|
2358
2374
|
else if (precallCeilingMicroUsd !== undefined && precallMicroUsd > precallCeilingMicroUsd) {
|
|
2359
2375
|
budgetHit = "precall";
|
|
2360
2376
|
}
|
|
2377
|
+
else if (effectiveTimeoutMs !== undefined && effectiveTimeoutMs <= 0) {
|
|
2378
|
+
timeout.fired = true;
|
|
2379
|
+
timeout.clear();
|
|
2380
|
+
void prepared.harness.abort();
|
|
2381
|
+
prepared.abortController.abort();
|
|
2382
|
+
}
|
|
2361
2383
|
else {
|
|
2362
2384
|
const images = spec.images
|
|
2363
2385
|
? await Promise.all(spec.images.map((img) => toImageContent(img, this.deps.allowImageUrl)))
|