


















@@ -1,4 +1,8 @@
11import { randomUUID } from "node:crypto";
2+import {
3+isFutureDateTimestampMs,
4+resolveExpiresAtMsFromDurationMs,
5+} from "../shared/number-coercion.js";
26import { normalizeOptionalString } from "../shared/string-coerce.js";
37import type { ExecElevatedDefaults } from "./bash-tools.exec-types.js";
48@@ -56,7 +60,7 @@ function cloneExecApprovalFollowupRuntimeHandoff(
56605761function pruneExpiredExecApprovalFollowupRuntimeHandoffs(nowMs: number): void {
5862for (const [handoffId, entry] of execApprovalFollowupRuntimeHandoffs) {
59-if (entry.expiresAtMs <= nowMs) {
63+if (!isFutureDateTimestampMs(entry.expiresAtMs, { nowMs })) {
6064execApprovalFollowupRuntimeHandoffs.delete(handoffId);
6165}
6266}
@@ -94,6 +98,13 @@ export function registerExecApprovalFollowupRuntimeHandoff(params: {
9498}
9599const nowMs = params.nowMs ?? Date.now();
96100pruneExpiredExecApprovalFollowupRuntimeHandoffs(nowMs);
101+const expiresAtMs = resolveExpiresAtMsFromDurationMs(
102+EXEC_APPROVAL_FOLLOWUP_RUNTIME_HANDOFF_TTL_MS,
103+{ nowMs },
104+);
105+if (expiresAtMs === undefined) {
106+return undefined;
107+}
97108const handoffId = randomUUID();
98109const idempotencyKey = buildExecApprovalFollowupIdempotencyKey({
99110 approvalId,
@@ -105,7 +116,7 @@ export function registerExecApprovalFollowupRuntimeHandoff(params: {
105116 sessionKey,
106117 idempotencyKey,
107118bashElevated: cloneExecElevatedDefaults(params.bashElevated),
108-expiresAtMs: nowMs + EXEC_APPROVAL_FOLLOWUP_RUNTIME_HANDOFF_TTL_MS,
119+ expiresAtMs,
109120});
110121return { handoffId, idempotencyKey };
111122}
@@ -129,7 +140,7 @@ export function consumeExecApprovalFollowupRuntimeHandoff(params: {
129140if (!entry) {
130141return undefined;
131142}
132-if (entry.expiresAtMs <= nowMs) {
143+if (!isFutureDateTimestampMs(entry.expiresAtMs, { nowMs })) {
133144execApprovalFollowupRuntimeHandoffs.delete(handoffId);
134145return undefined;
135146}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。