@@ -13,6 +13,10 @@ import type { CronJob } from "../../cron/types.js";
1313import { requestHeartbeat } from "../../infra/heartbeat-wake.js" ;
1414import { enqueueSystemEvent } from "../../infra/system-events.js" ;
1515import type { createSubsystemLogger } from "../../logging/subsystem.js" ;
16+ import {
17+ resolveDateTimestampMs ,
18+ resolveTimestampMsToIsoString ,
19+ } from "../../shared/number-coercion.js" ;
1620import { normalizeOptionalString } from "../../shared/string-coerce.js" ;
1721import { type HookAgentDispatchPayload , type HooksConfigResolved } from "../hooks.js" ;
1822import { createHooksRequestHandler , type HookClientIpConfig } from "./hooks-request-handler.js" ;
@@ -105,7 +109,7 @@ export function createGatewayHooksRequestHandler(params: {
105109 const safeName = sanitizeInboundSystemTags ( value . name ) ;
106110 const jobId = randomUUID ( ) ;
107111 const runId = randomUUID ( ) ;
108- const now = Date . now ( ) ;
112+ const nowMs = resolveDateTimestampMs ( Date . now ( ) ) ;
109113 const delivery = value . deliver
110114 ? {
111115 mode : "announce" as const ,
@@ -118,9 +122,9 @@ export function createGatewayHooksRequestHandler(params: {
118122 agentId : value . agentId ,
119123 name : safeName ,
120124 enabled : true ,
121- createdAtMs : now ,
122- updatedAtMs : now ,
123- schedule : { kind : "at" , at : new Date ( now ) . toISOString ( ) } ,
125+ createdAtMs : nowMs ,
126+ updatedAtMs : nowMs ,
127+ schedule : { kind : "at" , at : resolveTimestampMsToIsoString ( nowMs ) } ,
124128 sessionTarget : "isolated" ,
125129 wakeMode : value . wakeMode ,
126130 payload : {
@@ -133,7 +137,7 @@ export function createGatewayHooksRequestHandler(params: {
133137 externalContentSource : value . externalContentSource ,
134138 } ,
135139 delivery,
136- state : { nextRunAtMs : now } ,
140+ state : { nextRunAtMs : nowMs } ,
137141 } ;
138142
139143 let hookEventSessionKey : string | undefined ;
0 commit comments