@sema-agent/core 1.407.0 → 1.410.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.
Files changed (98) hide show
  1. package/dist/agents/roster-store.d.ts.map +1 -1
  2. package/dist/agents/roster-store.js +2 -1
  3. package/dist/agents/roster-store.js.map +1 -1
  4. package/dist/agents/subagent.d.ts.map +1 -1
  5. package/dist/agents/subagent.js +14 -4
  6. package/dist/agents/subagent.js.map +1 -1
  7. package/dist/core/background-agent-store.d.ts.map +1 -1
  8. package/dist/core/background-agent-store.js +3 -3
  9. package/dist/core/background-agent-store.js.map +1 -1
  10. package/dist/core/canonical-json.js +10 -2
  11. package/dist/core/canonical-json.js.map +1 -1
  12. package/dist/core/checkpoint-store.d.ts +3 -3
  13. package/dist/core/checkpoint-store.d.ts.map +1 -1
  14. package/dist/core/checkpoint-store.js +10 -1
  15. package/dist/core/checkpoint-store.js.map +1 -1
  16. package/dist/core/hooks.d.ts.map +1 -1
  17. package/dist/core/hooks.js +3 -3
  18. package/dist/core/hooks.js.map +1 -1
  19. package/dist/core/mailbox-store.d.ts.map +1 -1
  20. package/dist/core/mailbox-store.js +4 -3
  21. package/dist/core/mailbox-store.js.map +1 -1
  22. package/dist/core/mcp.d.ts.map +1 -1
  23. package/dist/core/mcp.js +16 -2
  24. package/dist/core/mcp.js.map +1 -1
  25. package/dist/core/runner/prepare-task.d.ts +1 -0
  26. package/dist/core/runner/prepare-task.d.ts.map +1 -1
  27. package/dist/core/runner/prepare-task.js +19 -9
  28. package/dist/core/runner/prepare-task.js.map +1 -1
  29. package/dist/core/runner/runtask.d.ts.map +1 -1
  30. package/dist/core/runner/runtask.js +27 -1
  31. package/dist/core/runner/runtask.js.map +1 -1
  32. package/dist/core/session-reconcile.d.ts.map +1 -1
  33. package/dist/core/session-reconcile.js +27 -11
  34. package/dist/core/session-reconcile.js.map +1 -1
  35. package/dist/core/task-notification.d.ts +1 -0
  36. package/dist/core/task-notification.d.ts.map +1 -1
  37. package/dist/core/task-notification.js +26 -1
  38. package/dist/core/task-notification.js.map +1 -1
  39. package/dist/core/task-registry.d.ts +1 -1
  40. package/dist/core/task-registry.d.ts.map +1 -1
  41. package/dist/core/task-registry.js +9 -5
  42. package/dist/core/task-registry.js.map +1 -1
  43. package/dist/core/tighten-task-spec.d.ts.map +1 -1
  44. package/dist/core/tighten-task-spec.js +7 -0
  45. package/dist/core/tighten-task-spec.js.map +1 -1
  46. package/dist/core/tool-policy.d.ts.map +1 -1
  47. package/dist/core/tool-policy.js +24 -8
  48. package/dist/core/tool-policy.js.map +1 -1
  49. package/dist/{stores/pg.d.ts → examples/adapters/pg-adapter.d.ts} +5 -5
  50. package/dist/examples/adapters/pg-adapter.d.ts.map +1 -0
  51. package/dist/{stores/pg.js → examples/adapters/pg-adapter.js} +11 -6
  52. package/dist/examples/adapters/pg-adapter.js.map +1 -0
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +2 -2
  56. package/dist/index.js.map +1 -1
  57. package/dist/stores/cc/mailbox-store.d.ts.map +1 -1
  58. package/dist/stores/cc/mailbox-store.js +3 -2
  59. package/dist/stores/cc/mailbox-store.js.map +1 -1
  60. package/dist/stores/cc/sidecar-transcript.d.ts.map +1 -1
  61. package/dist/stores/cc/sidecar-transcript.js +25 -3
  62. package/dist/stores/cc/sidecar-transcript.js.map +1 -1
  63. package/dist/stores/cc/task-list-store.d.ts.map +1 -1
  64. package/dist/stores/cc/task-list-store.js +26 -12
  65. package/dist/stores/cc/task-list-store.js.map +1 -1
  66. package/dist/stores/file/background-agent-store.d.ts +8 -4
  67. package/dist/stores/file/background-agent-store.d.ts.map +1 -1
  68. package/dist/stores/file/background-agent-store.js +41 -6
  69. package/dist/stores/file/background-agent-store.js.map +1 -1
  70. package/dist/stores/file/checkpoint-store.d.ts.map +1 -1
  71. package/dist/stores/file/checkpoint-store.js +3 -2
  72. package/dist/stores/file/checkpoint-store.js.map +1 -1
  73. package/dist/stores/file/fs-atomic.d.ts.map +1 -1
  74. package/dist/stores/file/fs-atomic.js +8 -2
  75. package/dist/stores/file/fs-atomic.js.map +1 -1
  76. package/dist/stores/file/mailbox-store.d.ts.map +1 -1
  77. package/dist/stores/file/mailbox-store.js +19 -9
  78. package/dist/stores/file/mailbox-store.js.map +1 -1
  79. package/dist/stores/file/session-store.d.ts.map +1 -1
  80. package/dist/stores/file/session-store.js +35 -6
  81. package/dist/stores/file/session-store.js.map +1 -1
  82. package/dist/stores/file/task-list-store.d.ts.map +1 -1
  83. package/dist/stores/file/task-list-store.js +36 -4
  84. package/dist/stores/file/task-list-store.js.map +1 -1
  85. package/dist/stores/file/workflow-journal-store.d.ts +1 -1
  86. package/dist/stores/file/workflow-journal-store.d.ts.map +1 -1
  87. package/dist/stores/file/workflow-journal-store.js +15 -16
  88. package/dist/stores/file/workflow-journal-store.js.map +1 -1
  89. package/dist/stores/file/workflow-run-store.d.ts +8 -4
  90. package/dist/stores/file/workflow-run-store.d.ts.map +1 -1
  91. package/dist/stores/file/workflow-run-store.js +39 -5
  92. package/dist/stores/file/workflow-run-store.js.map +1 -1
  93. package/dist/tools/fs/index.d.ts.map +1 -1
  94. package/dist/tools/fs/index.js +26 -1
  95. package/dist/tools/fs/index.js.map +1 -1
  96. package/package.json +1 -1
  97. package/dist/stores/pg.d.ts.map +0 -1
  98. package/dist/stores/pg.js.map +0 -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,uBAAuB,CAAC;AACrE,OAAO,EASL,KAAK,UAAU,EAEf,KAAK,eAAe,EACpB,KAAK,YAAY,EAGjB,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAgC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASpF,OAAO,EAAmB,KAAK,WAAW,EAAE,MA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AE,gBAAgB,EAoB5B,SAAS,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,UAAU,CAAC;YAmcR,mBAAmB;YA4GnB,kBAAkB;IAmKhC,OAAO,CAAC,sBAAsB;YA6BhB,kBAAkB;IAkDhC,OAAO,CAAC,qBAAqB;IAwD7B,OAAO,CAAC,qBAAqB;YAKf,MAAM;YA0HN,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"}
@@ -397,7 +397,7 @@ export class Runner {
397
397
  })();
398
398
  const settled = run.catch(async (err) => {
399
399
  let code = errorCodeOf(err);
400
- const reopenReason = code === "resume.env_failed"
400
+ const reopenReason = code === "resume.env_failed" || code === "resume.session_not_found"
401
401
  ? "env_failed"
402
402
  : code === "resume.tool_unavailable"
403
403
  ? "tool_unavailable"
@@ -3157,6 +3157,19 @@ export class Runner {
3157
3157
  sanitizeUntrustedText(outcome.editedPlan) !== outcome.editedPlan) {
3158
3158
  throw new CheckpointError("checkpoint.invalid_outcome", "resume editedPlan must not contain a </system-reminder> tag");
3159
3159
  }
3160
+ if ((outcome.gate === "plan_review" || outcome.gate === "dry_run_review") && cp.reopenReason === "env_failed") {
3161
+ const winner = cp.resolvedOutcome;
3162
+ if (winner === undefined) {
3163
+ throw new CheckpointError("checkpoint.reopen_revote", "review checkpoint was reopened after an env-restore failure (env_failed) but carries no persisted winner to replay — refusing to resume (inconsistent row, fail-closed)");
3164
+ }
3165
+ if (winner.decision !== outcome.decision) {
3166
+ throw new CheckpointError("checkpoint.reopen_revote", `an env_failed reopen replays the ALREADY-RECORDED review decision ("${winner.decision}") — refusing a re-vote with a different decision ("${outcome.decision}")`);
3167
+ }
3168
+ const replayedPlan = outcome.gate === "plan_review" ? outcome.editedPlan : undefined;
3169
+ if (winner.updatedInput !== replayedPlan) {
3170
+ throw new CheckpointError("checkpoint.reopen_revote", "an env_failed reopen replays the ALREADY-RECORDED review decision — refusing a re-vote whose edited plan differs from the recorded one");
3171
+ }
3172
+ }
3160
3173
  if (outcome.gate === "policy_ask") {
3161
3174
  const boundTo = cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolCallId : undefined;
3162
3175
  if (outcome.boundCallId !== boundTo) {
@@ -3184,6 +3197,9 @@ export class Runner {
3184
3197
  if (checkpointVersionOf(cp) > MAX_SUPPORTED_CHECKPOINT_VERSION) {
3185
3198
  throw new CheckpointError("checkpoint.unsupported_version", `checkpoint version ${checkpointVersionOf(cp)} is newer than this worker supports (max ${MAX_SUPPORTED_CHECKPOINT_VERSION})`);
3186
3199
  }
3200
+ if (taskConfig.signal?.aborted === true) {
3201
+ throw new CheckpointError("checkpoint.resume_aborted", "the resume was handed an ALREADY-ABORTED signal — refusing to consume the approval on a leg that cannot run it (the checkpoint stays pending and is resumable with a live signal)");
3202
+ }
3187
3203
  if (cp.state.workspaceHandle !== undefined && this.deps.executionEnvFactory === undefined) {
3188
3204
  throw new CheckpointError("checkpoint.unsupported_version", "checkpoint has a remote workspaceHandle but no RunnerDeps.executionEnvFactory is wired to rebuild the env");
3189
3205
  }
@@ -3218,6 +3234,7 @@ export class Runner {
3218
3234
  ...taskConfig,
3219
3235
  objective: "",
3220
3236
  sessionId: cp.sessionId,
3237
+ requireExistingSession: true,
3221
3238
  preemptSignal: taskConfig.preemptSignal?.aborted ? undefined : taskConfig.preemptSignal,
3222
3239
  };
3223
3240
  const reopenFn = store.reopen?.bind(store);
@@ -3288,6 +3305,15 @@ export class Runner {
3288
3305
  emitCommitted(eid, "toolResult", pendingAction.toolCallId);
3289
3306
  return;
3290
3307
  }
3308
+ if (outcome.decision === "allow" && outcome.updatedInput !== undefined && prepared.basePolicyForResumeEdit) {
3309
+ const rechecked = await prepared.basePolicyForResumeEdit.check({ toolName: pendingAction.toolName, args: resolvedArgs, toolCallId: pendingAction.toolCallId }, prepared.abortController.signal);
3310
+ if (rechecked.action === "deny") {
3311
+ emitEnd(true);
3312
+ const eid = await prepared.session.appendMessage(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, formatHookFeedback(`The approver EDITED this call's input; the edited call is denied by the deployment's tool policy and was not executed${rechecked.reason ? `: ${rechecked.reason}` : ""}.`), true));
3313
+ emitCommitted(eid, "toolResult", pendingAction.toolCallId);
3314
+ return;
3315
+ }
3316
+ }
3291
3317
  if (prepared.denyNarrowingPolicy) {
3292
3318
  const narrowed = await prepared.denyNarrowingPolicy.check({ toolName: pendingAction.toolName, args: resolvedArgs, toolCallId: pendingAction.toolCallId }, prepared.abortController.signal);
3293
3319
  if (narrowed.action === "deny") {