@sema-agent/core 1.411.0 → 1.414.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/roster-store.d.ts.map +1 -1
- package/dist/agents/roster-store.js +6 -5
- package/dist/agents/roster-store.js.map +1 -1
- package/dist/agents/subagent.d.ts.map +1 -1
- package/dist/agents/subagent.js +14 -1
- package/dist/agents/subagent.js.map +1 -1
- package/dist/core/auto-compaction.d.ts +5 -0
- package/dist/core/auto-compaction.d.ts.map +1 -1
- package/dist/core/auto-compaction.js +6 -4
- package/dist/core/auto-compaction.js.map +1 -1
- package/dist/core/exec-output-tail.d.ts.map +1 -1
- package/dist/core/exec-output-tail.js +1 -1
- package/dist/core/exec-output-tail.js.map +1 -1
- package/dist/core/mcp.d.ts.map +1 -1
- package/dist/core/mcp.js +2 -1
- package/dist/core/mcp.js.map +1 -1
- package/dist/core/runner/prepare-task.d.ts.map +1 -1
- package/dist/core/runner/prepare-task.js +18 -3
- package/dist/core/runner/prepare-task.js.map +1 -1
- package/dist/core/runner/runtask.d.ts +1 -0
- package/dist/core/runner/runtask.d.ts.map +1 -1
- package/dist/core/runner/runtask.js +45 -10
- package/dist/core/runner/runtask.js.map +1 -1
- package/dist/core/runner/turn-attachments.js +3 -0
- package/dist/core/runner/turn-attachments.js.map +1 -1
- package/dist/core/task-notification.d.ts +3 -0
- package/dist/core/task-notification.d.ts.map +1 -1
- package/dist/core/task-notification.js +27 -15
- package/dist/core/task-notification.js.map +1 -1
- package/dist/core/task-registry.d.ts.map +1 -1
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-registry.js.map +1 -1
- package/dist/core/tool-policy.d.ts.map +1 -1
- package/dist/core/tool-policy.js +61 -10
- package/dist/core/tool-policy.js.map +1 -1
- package/dist/core/tool-result-budget.d.ts +5 -0
- package/dist/core/tool-result-budget.d.ts.map +1 -1
- package/dist/core/tool-result-budget.js +58 -27
- package/dist/core/tool-result-budget.js.map +1 -1
- package/dist/core/tool-result-store.d.ts +4 -1
- package/dist/core/tool-result-store.d.ts.map +1 -1
- package/dist/core/tool-result-store.js +5 -3
- package/dist/core/tool-result-store.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/untrusted-egress.d.ts.map +1 -1
- package/dist/core/untrusted-egress.js +5 -2
- package/dist/core/untrusted-egress.js.map +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts.map +1 -1
- package/dist/core/untrusted-text.js +12 -3
- package/dist/core/untrusted-text.js.map +1 -1
- package/dist/engine/compaction/utils.d.ts.map +1 -1
- package/dist/engine/compaction/utils.js +2 -1
- package/dist/engine/compaction/utils.js.map +1 -1
- package/dist/engine/harness/types.d.ts +15 -0
- package/dist/engine/harness/types.d.ts.map +1 -1
- package/dist/engine/harness/types.js +31 -0
- package/dist/engine/harness/types.js.map +1 -1
- package/dist/engine/session/import-validate.d.ts +1 -0
- package/dist/engine/session/import-validate.d.ts.map +1 -1
- package/dist/engine/session/import-validate.js +40 -3
- package/dist/engine/session/import-validate.js.map +1 -1
- package/dist/engine/session/log-digest.d.ts +6 -0
- package/dist/engine/session/log-digest.d.ts.map +1 -0
- package/dist/engine/session/log-digest.js +23 -0
- package/dist/engine/session/log-digest.js.map +1 -0
- package/dist/engine/session/session.d.ts.map +1 -1
- package/dist/engine/session/session.js +8 -10
- package/dist/engine/session/session.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/prompt-assembly/assemble.d.ts.map +1 -1
- package/dist/prompt-assembly/assemble.js +7 -6
- package/dist/prompt-assembly/assemble.js.map +1 -1
- package/dist/stores/file/background-agent-store.d.ts +1 -0
- package/dist/stores/file/background-agent-store.d.ts.map +1 -1
- package/dist/stores/file/background-agent-store.js +7 -3
- package/dist/stores/file/background-agent-store.js.map +1 -1
- package/dist/stores/file/checkpoint-store.d.ts +9 -4
- package/dist/stores/file/checkpoint-store.d.ts.map +1 -1
- package/dist/stores/file/checkpoint-store.js +56 -8
- package/dist/stores/file/checkpoint-store.js.map +1 -1
- package/dist/stores/file/fs-atomic.d.ts +1 -0
- package/dist/stores/file/fs-atomic.d.ts.map +1 -1
- package/dist/stores/file/fs-atomic.js +18 -2
- package/dist/stores/file/fs-atomic.js.map +1 -1
- package/dist/stores/file/mailbox-store.d.ts.map +1 -1
- package/dist/stores/file/mailbox-store.js +23 -5
- package/dist/stores/file/mailbox-store.js.map +1 -1
- package/dist/stores/file/memory-store.d.ts +3 -1
- package/dist/stores/file/memory-store.d.ts.map +1 -1
- package/dist/stores/file/memory-store.js +24 -2
- package/dist/stores/file/memory-store.js.map +1 -1
- package/dist/stores/file/session-store.d.ts.map +1 -1
- package/dist/stores/file/session-store.js +7 -21
- package/dist/stores/file/session-store.js.map +1 -1
- package/dist/stores/file/task-list-store.d.ts.map +1 -1
- package/dist/stores/file/task-list-store.js +4 -3
- package/dist/stores/file/task-list-store.js.map +1 -1
- package/dist/stores/file/workflow-run-store.d.ts +1 -0
- package/dist/stores/file/workflow-run-store.d.ts.map +1 -1
- package/dist/stores/file/workflow-run-store.js +7 -3
- package/dist/stores/file/workflow-run-store.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ export declare const DEFAULT_MAX_TURNS = 1000;
|
|
|
9
9
|
export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "sessionId">;
|
|
10
10
|
interface ResumeRun {
|
|
11
11
|
cp: Checkpoint;
|
|
12
|
+
pendingActionStarted?: boolean;
|
|
12
13
|
outcome: Extract<ResumeOutcome, {
|
|
13
14
|
gate: "policy_ask" | "resource_limit" | "dry_run_review" | "plan_review" | "wake";
|
|
14
15
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtask.d.ts","sourceRoot":"","sources":["../../../src/core/runner/runtask.ts"],"names":[],"mappings":"AACA,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= errorCodeOf(err);
|
|
400
|
-
const reopenReason = code === "resume.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
? "tool_unavailable"
|
|
404
|
-
: undefined;
|
|
405
|
-
const reopenable = reopenReason !== undefined;
|
|
400
|
+
const reopenReason = code === "resume.tool_unavailable" ? "tool_unavailable" : "env_failed";
|
|
401
|
+
const reopenable = resume !== undefined && resume.pendingActionStarted !== true && reopenReason !== undefined;
|
|
402
|
+
let reopenCommitted = false;
|
|
406
403
|
if (reopenable && resume?.onEnvRestoreFailed) {
|
|
407
404
|
try {
|
|
408
405
|
await resume.onEnvRestoreFailed(reopenReason);
|
|
406
|
+
reopenCommitted = true;
|
|
409
407
|
}
|
|
410
408
|
catch (reopenErr) {
|
|
411
409
|
this.parentConstraintRegistry.delete(resume.cp.token);
|
|
@@ -418,7 +416,7 @@ export class Runner {
|
|
|
418
416
|
code = "checkpoint.reopen_failed";
|
|
419
417
|
}
|
|
420
418
|
}
|
|
421
|
-
|
|
419
|
+
if (resume && !reopenCommitted) {
|
|
422
420
|
this.parentConstraintRegistry.delete(resume.cp.token);
|
|
423
421
|
try {
|
|
424
422
|
await this.sessions.unpin?.(resume.cp.sessionId);
|
|
@@ -2271,6 +2269,9 @@ export class Runner {
|
|
|
2271
2269
|
compactionBreaker.failures = 0;
|
|
2272
2270
|
}
|
|
2273
2271
|
trimForceBackoff = nextTrimForceBackoff(trimForceBackoff, comp, trimPressure);
|
|
2272
|
+
if (comp.contextUsage) {
|
|
2273
|
+
queue.push({ type: "context_usage", ...comp.contextUsage, ...ident() });
|
|
2274
|
+
}
|
|
2274
2275
|
if (comp.suppressedByFloor) {
|
|
2275
2276
|
const s = comp.suppressedByFloor;
|
|
2276
2277
|
emitTrace(tracer, () => ({
|
|
@@ -2407,7 +2408,12 @@ export class Runner {
|
|
|
2407
2408
|
stampWriteAnchor(attachState, family, cadenceTurns);
|
|
2408
2409
|
if (details !== undefined)
|
|
2409
2410
|
reduceToolEnd(attachState, details);
|
|
2410
|
-
}, (toolCallId) =>
|
|
2411
|
+
}, (toolCallId) => {
|
|
2412
|
+
startedToolCallIds.add(toolCallId);
|
|
2413
|
+
if (resume !== undefined && resume.cp.pendingAction.kind === "tool_approval" && toolCallId === resume.cp.pendingAction.toolCallId) {
|
|
2414
|
+
resume.pendingActionStarted = true;
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2411
2417
|
}
|
|
2412
2418
|
if (walltimeExhaustedResume) {
|
|
2413
2419
|
timeout.fired = true;
|
|
@@ -2705,6 +2711,23 @@ export class Runner {
|
|
|
2705
2711
|
? { token: prepared.reviewRef.token, gate: prepared.reviewRef.gate }
|
|
2706
2712
|
: undefined,
|
|
2707
2713
|
});
|
|
2714
|
+
if (resume !== undefined &&
|
|
2715
|
+
resume.pendingActionStarted !== true &&
|
|
2716
|
+
result.status !== "completed" &&
|
|
2717
|
+
result.status !== "suspended" &&
|
|
2718
|
+
resume.onEnvRestoreFailed !== undefined) {
|
|
2719
|
+
try {
|
|
2720
|
+
await resume.onEnvRestoreFailed("env_failed");
|
|
2721
|
+
const r = result;
|
|
2722
|
+
r.errorCode ??= "resume.reopened_unstarted";
|
|
2723
|
+
r.errorMessage = `${r.errorMessage ?? "the resume leg did not complete"} — the approved action never started, so the checkpoint was REOPENED (pending): the same approval can be resumed again, do not ask for a fresh one`;
|
|
2724
|
+
}
|
|
2725
|
+
catch {
|
|
2726
|
+
const r = result;
|
|
2727
|
+
r.errorCode ??= "resume.reopen_failed_unstarted";
|
|
2728
|
+
r.errorMessage = `${r.errorMessage ?? "the resume leg did not complete"} — the approved action never started, and reopening the checkpoint FAILED: its state is unprovable from here. Re-read it before deciding; do NOT issue a fresh approval on the assumption the old one is dead`;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2708
2731
|
{
|
|
2709
2732
|
const wss = prepared.workspaceStateSettle;
|
|
2710
2733
|
if (wss !== undefined && result.status !== "suspended" && result.status !== "needs_review") {
|
|
@@ -3227,8 +3250,10 @@ export class Runner {
|
|
|
3227
3250
|
this.parentConstraintRegistry.delete(token);
|
|
3228
3251
|
throw new CheckpointError("checkpoint.already_resolved", "checkpoint already resolved or expired — not re-executed (idempotent)");
|
|
3229
3252
|
}
|
|
3253
|
+
let consumeFlipDone = false;
|
|
3230
3254
|
if (internals?.afterCheckpointResolve !== undefined) {
|
|
3231
3255
|
await internals.afterCheckpointResolve();
|
|
3256
|
+
consumeFlipDone = true;
|
|
3232
3257
|
}
|
|
3233
3258
|
const spec = {
|
|
3234
3259
|
...taskConfig,
|
|
@@ -3246,15 +3271,25 @@ export class Runner {
|
|
|
3246
3271
|
}
|
|
3247
3272
|
}
|
|
3248
3273
|
: undefined;
|
|
3274
|
+
if (taskConfig.signal?.aborted === true && consumeFlipDone) {
|
|
3275
|
+
throw new CheckpointError("checkpoint.resume_aborted", "the resume was aborted after its row was already claimed — the checkpoint stays consumed and the caller's rollback settles the outcome-unknown terminal (reopening here would strand a pending approval no redemption path can reach)");
|
|
3276
|
+
}
|
|
3249
3277
|
if (taskConfig.signal?.aborted === true) {
|
|
3278
|
+
let reopenOutcome = "refused";
|
|
3250
3279
|
if (onEnvRestoreFailed !== undefined) {
|
|
3251
3280
|
try {
|
|
3252
3281
|
await onEnvRestoreFailed("env_failed");
|
|
3282
|
+
reopenOutcome = "reopened";
|
|
3253
3283
|
}
|
|
3254
|
-
catch {
|
|
3284
|
+
catch (err) {
|
|
3285
|
+
reopenOutcome = errorCodeOf(err) === "checkpoint.reopen_failed" ? "refused" : "unknown";
|
|
3255
3286
|
}
|
|
3256
3287
|
}
|
|
3257
|
-
throw
|
|
3288
|
+
throw reopenOutcome === "reopened"
|
|
3289
|
+
? new CheckpointError("checkpoint.resume_aborted", "the resume was aborted before the approved action could run — the checkpoint was reopened, so the same approval can be resumed with a live signal")
|
|
3290
|
+
: reopenOutcome === "refused"
|
|
3291
|
+
? new CheckpointError("checkpoint.reopen_failed", "the resume was aborted before the approved action could run AND the store refused to reopen the checkpoint — the approval is terminally consumed and the suspended work was not executed; a retry needs a fresh approval")
|
|
3292
|
+
: new CheckpointError("checkpoint.reopen_failed", "the resume was aborted before the approved action could run and the reopen attempt FAILED IN FLIGHT — the checkpoint's state is unprovable from here: it may already be pending again. Re-read it before deciding; do NOT issue a fresh approval on the assumption the old one is dead (the approved action did NOT run either way)");
|
|
3258
3293
|
}
|
|
3259
3294
|
return this.runTaskStream(spec, { cp, outcome, onEnvRestoreFailed, ...(wakeMessage !== undefined ? { wakeMessage } : {}) }, internals);
|
|
3260
3295
|
}
|