11import { z } from "zod/v4" ;
2+ import { discriminatedUnion } from "../utils/zod.js" ;
23
3- // Ingress webhook verification config. Kept in a LEAF module (imports only `z`) so it
4- // can be consumed by resources.ts / schemas.ts without dragging in the alert-webhook
4+ // Ingress webhook verification config. Kept in a LEAF module (imports only `z` and
5+ // the Zod compatibility helper) so it can be consumed by resources.ts / schemas.ts without dragging in the alert-webhook
56// `Webhook` union in webhooks.ts, which imports api.js (RunStatus). resources.ts is
67// imported by api.ts, so a resources -> webhooks -> api edge would be a module-init cycle.
78
@@ -24,7 +25,7 @@ export type WebhookIdempotencyField = z.infer<typeof WebhookIdempotencyField>;
2425// Where a scalar value comes from. Used for the timestamp and for signing-string template vars.
2526// "signatureField" reads a field parsed out of the signature header (e.g. Stripe `t`).
2627// "url" is the inbound request URL (e.g. Square signs `{url}{body}`). "constant" is a literal.
27- export const WebhookValueSource = z . discriminatedUnion ( "from" , [
28+ export const WebhookValueSource = discriminatedUnion ( "from" , [
2829 z . object ( { from : z . literal ( "header" ) , name : z . string ( ) } ) ,
2930 z . object ( { from : z . literal ( "signatureField" ) , field : z . string ( ) } ) ,
3031 z . object ( { from : z . literal ( "body" ) , path : z . string ( ) } ) ,
@@ -133,7 +134,7 @@ export const WebhookUrlSecretConfig = z.object({
133134} ) ;
134135export type WebhookUrlSecretConfig = z . infer < typeof WebhookUrlSecretConfig > ;
135136
136- export const WebhookVerifierConfig = z . discriminatedUnion ( "scheme" , [
137+ export const WebhookVerifierConfig = discriminatedUnion ( "scheme" , [
137138 WebhookHmacConfig ,
138139 WebhookSharedSecretConfig ,
139140 WebhookUrlSecretConfig ,
@@ -152,7 +153,7 @@ export const WebhookHandshakeConfig = z.object({
152153export type WebhookHandshakeConfig = z . infer < typeof WebhookHandshakeConfig > ;
153154
154155// ── Verifier artifact: data-only tagged union stored on WebhookEndpoint.verifierArtifact ──
155- export const WebhookVerifierArtifact = z . discriminatedUnion ( "kind" , [
156+ export const WebhookVerifierArtifact = discriminatedUnion ( "kind" , [
156157 z . object ( {
157158 kind : z . literal ( "config" ) ,
158159 config : WebhookVerifierConfig ,
@@ -173,7 +174,7 @@ export type WebhookVerifierArtifact = z.infer<typeof WebhookVerifierArtifact>;
173174// session: keyTemplate resolves the externalId, deliverAs selects the mode. "action" (chat.event)
174175// carries actionType → the onAction envelope's action.type; "message" (channels) carries connectorId
175176// → the run resolves the connector's inbound() mapper and runs a turn.
176- export const WebhookRoutingTarget = z . discriminatedUnion ( "type" , [
177+ export const WebhookRoutingTarget = discriminatedUnion ( "type" , [
177178 z . object ( { type : z . literal ( "task" ) , taskId : z . string ( ) } ) ,
178179 z . object ( {
179180 type : z . literal ( "session" ) ,
0 commit comments