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43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/**
 * Generated by orval v8.5.3 🍺
 * Do not edit manually.
 * Api
 * Guardian Agent API — dark pattern detection and checkout protection
 * OpenAPI spec version: 0.1.0
 */
import * as zod from "zod";

/**
 * Returns server health status
 * @summary Health check
 */
export const HealthCheckResponse = zod.object({
  status: zod.string(),
});

/**
 * Analyzes page content for dark patterns using AI classification
 * @summary Detect dark patterns on a page
 */
export const DetectDarkPatternsBody = zod.object({
  domain: zod.string().describe("The website domain being analyzed"),
  pageText: zod.string().describe("Extracted text content from the page"),
  timerElements: zod
    .array(zod.string())
    .optional()
    .describe("Text from countdown timer elements found on the page"),
  stockAlerts: zod
    .array(zod.string())
    .optional()
    .describe("Text from stock\/scarcity alert elements"),
  buttonLabels: zod
    .array(zod.string())
    .optional()
    .describe("Text from all buttons on the page"),
  formFields: zod
    .array(
      zod.object({
        id: zod.string(),
        label: zod.string(),
        type: zod.string(),
        checked: zod.boolean().nullish(),
        optional: zod.boolean().nullish(),
      }),
    )
    .optional()
    .describe("Form field info including pre-checked state"),
  priceStrings: zod
    .array(zod.string())
    .optional()
    .describe("All price strings found on the page"),
});

export const DetectDarkPatternsResponse = zod.object({
  domain: zod.string(),
  falseUrgency: zod.object({
    detected: zod.boolean(),
    evidence: zod.string(),
    isTimerFake: zod.boolean().nullish(),
  }),
  falseScarcity: zod.object({
    detected: zod.boolean(),
    evidence: zod.string(),
  }),
  confirmShaming: zod.object({
    detected: zod.boolean(),
    shamingText: zod.string(),
    rewrittenText: zod.string(),
  }),
  hiddenFees: zod.object({
    detected: zod.boolean(),
    feeItems: zod.array(
      zod.object({
        label: zod.string(),
        amount: zod.number(),
      }),
    ),
    totalExtra: zod.number().nullish(),
  }),
  preCheckedAddOns: zod.object({
    detected: zod.boolean(),
    fieldIds: zod.array(zod.string()),
    addOnLabels: zod.array(zod.string()),
  }),
  misdirection: zod.object({
    detected: zod.boolean(),
    hiddenDeclineText: zod.string(),
  }),
  trustScore: zod.number().describe("Trust score 0-100"),
  summary: zod.string().describe("Human-readable summary of findings"),
});

/**
 * Identifies what type of upsell/add-on screen is being shown
 * @summary Classify an upsell page type
 */
export const ClassifyUpsellBody = zod.object({
  domain: zod.string(),
  pageText: zod.string().describe("Text content of the upsell page"),
});

export const ClassifyUpsellResponse = zod.object({
  type: zod.enum([
    "insurance",
    "breakfast",
    "room_upgrade",
    "seat_selection",
    "newsletter",
    "sms_alerts",
    "warranty",
    "refundable_rate",
    "other",
  ]),
  confidence: zod.number(),
  recommendedAction: zod
    .string()
    .describe("Suggested action: decline, accept, or ask_user"),
  declineButtonHint: zod
    .string()
    .describe("Text or selector hint for the decline button"),
});

/**
 * Returns trust ratings for all tracked domains
 * @summary List all site trust ratings
 */
export const ListTrustRatingsResponseItem = zod.object({
  id: zod.number(),
  domain: zod.string(),
  score: zod.number().describe("Trust score 0-100"),
  tier: zod.enum([
    "gold",
    "clean",
    "neutral",
    "suspicious",
    "high_manipulation",
  ]),
  totalScans: zod.number(),
  patternsDetectedCount: zod.number(),
  hiddenFeesCount: zod.number(),
  lastScannedAt: zod.string().nullish(),
  createdAt: zod.string(),
  updatedAt: zod.string(),
});
export const ListTrustRatingsResponse = zod.array(ListTrustRatingsResponseItem);

/**
 * Returns the trust rating and history for a specific domain
 * @summary Get trust rating for a domain
 */
export const GetTrustRatingParams = zod.object({
  domain: zod.coerce.string(),
});

export const GetTrustRatingResponse = zod.object({
  id: zod.number(),
  domain: zod.string(),
  score: zod.number().describe("Trust score 0-100"),
  tier: zod.enum([
    "gold",
    "clean",
    "neutral",
    "suspicious",
    "high_manipulation",
  ]),
  totalScans: zod.number(),
  patternsDetectedCount: zod.number(),
  hiddenFeesCount: zod.number(),
  lastScannedAt: zod.string().nullish(),
  createdAt: zod.string(),
  updatedAt: zod.string(),
});

/**
 * Updates the trust rating after a checkout interaction
 * @summary Create or update trust rating for a domain
 */
export const UpsertTrustRatingParams = zod.object({
  domain: zod.coerce.string(),
});

export const UpsertTrustRatingBody = zod.object({
  scoreDelta: zod
    .number()
    .describe("Amount to adjust the score (positive or negative)"),
  patternsFound: zod.number(),
  hiddenFeesFound: zod.number(),
});

export const UpsertTrustRatingResponse = zod.object({
  id: zod.number(),
  domain: zod.string(),
  score: zod.number().describe("Trust score 0-100"),
  tier: zod.enum([
    "gold",
    "clean",
    "neutral",
    "suspicious",
    "high_manipulation",
  ]),
  totalScans: zod.number(),
  patternsDetectedCount: zod.number(),
  hiddenFeesCount: zod.number(),
  lastScannedAt: zod.string().nullish(),
  createdAt: zod.string(),
  updatedAt: zod.string(),
});

/**
 * Returns recent dark pattern detection reports
 * @summary List detection reports
 */
export const ListReportsQueryParams = zod.object({
  domain: zod.coerce.string().nullish(),
  limit: zod.coerce.number().nullish(),
});

export const ListReportsResponseItem = zod.object({
  id: zod.number(),
  domain: zod.string(),
  url: zod.string(),
  trustScore: zod.number(),
  falseUrgencyDetected: zod.boolean(),
  falseScarcityDetected: zod.boolean(),
  confirmShamingDetected: zod.boolean(),
  hiddenFeesDetected: zod.boolean(),
  preCheckedAddOnsDetected: zod.boolean(),
  misdirectionDetected: zod.boolean(),
  totalPatternsDetected: zod.number(),
  hiddenFeesTotal: zod.number().nullish(),
  summary: zod.string(),
  createdAt: zod.string(),
});
export const ListReportsResponse = zod.array(ListReportsResponseItem);

/**
 * Stores a dark pattern detection report for a session
 * @summary Save a detection report
 */
export const CreateReportBody = zod.object({
  domain: zod.string(),
  url: zod.string(),
  trustScore: zod.number(),
  falseUrgencyDetected: zod.boolean(),
  falseScarcityDetected: zod.boolean(),
  confirmShamingDetected: zod.boolean(),
  hiddenFeesDetected: zod.boolean(),
  preCheckedAddOnsDetected: zod.boolean(),
  misdirectionDetected: zod.boolean(),
  totalPatternsDetected: zod.number(),
  hiddenFeesTotal: zod.number().nullish(),
  summary: zod.string(),
});

/**
 * @summary Get a detection report by ID
 */
export const GetReportParams = zod.object({
  id: zod.coerce.number(),
});

export const GetReportResponse = zod.object({
  id: zod.number(),
  domain: zod.string(),
  url: zod.string(),
  trustScore: zod.number(),
  falseUrgencyDetected: zod.boolean(),
  falseScarcityDetected: zod.boolean(),
  confirmShamingDetected: zod.boolean(),
  hiddenFeesDetected: zod.boolean(),
  preCheckedAddOnsDetected: zod.boolean(),
  misdirectionDetected: zod.boolean(),
  totalPatternsDetected: zod.number(),
  hiddenFeesTotal: zod.number().nullish(),
  summary: zod.string(),
  createdAt: zod.string(),
});

/**
 * Returns aggregated stats — total scans, patterns detected, money saved estimates
 * @summary Get overall statistics summary
 */
export const GetStatsSummaryResponse = zod.object({
  totalScans: zod.number(),
  totalPatternsDetected: zod.number(),
  totalHiddenFeesBlocked: zod
    .number()
    .describe("Estimated total money saved in dollars"),
  totalDomainsTracked: zod.number(),
  totalReportsLast30Days: zod.number(),
  avgTrustScore: zod.number(),
  goldTierDomains: zod.number(),
  highManipulationDomains: zod.number(),
});

/**
 * Returns counts by dark pattern type across all reports
 * @summary Get pattern detection breakdown
 */
export const GetPatternBreakdownResponse = zod.object({
  falseUrgency: zod.number(),
  falseScarcity: zod.number(),
  confirmShaming: zod.number(),
  hiddenFees: zod.number(),
  preCheckedAddOns: zod.number(),
  misdirection: zod.number(),
});

/**
 * Detects dark patterns, saves report, and updates trust rating in one call. Perfect for live demos.
 * @summary All-in-one demo scan
 */
export const DemoScanBody = zod.object({
  domain: zod.string(),
  url: zod.string(),
  pageText: zod.string(),
  timerElements: zod.array(zod.string()).optional(),
  stockAlerts: zod.array(zod.string()).optional(),
  buttonLabels: zod.array(zod.string()).optional(),
  priceStrings: zod.array(zod.string()).optional(),
  scenarioName: zod
    .string()
    .nullish()
    .describe("Name of the preset scenario being run"),
});

export const DemoScanResponse = zod.object({
  report: zod.object({
    id: zod.number(),
    domain: zod.string(),
    url: zod.string(),
    trustScore: zod.number(),
    falseUrgencyDetected: zod.boolean(),
    falseScarcityDetected: zod.boolean(),
    confirmShamingDetected: zod.boolean(),
    hiddenFeesDetected: zod.boolean(),
    preCheckedAddOnsDetected: zod.boolean(),
    misdirectionDetected: zod.boolean(),
    totalPatternsDetected: zod.number(),
    hiddenFeesTotal: zod.number().nullish(),
    summary: zod.string(),
    createdAt: zod.string(),
  }),
  darkPatternReport: zod.object({
    domain: zod.string(),
    falseUrgency: zod.object({
      detected: zod.boolean(),
      evidence: zod.string(),
      isTimerFake: zod.boolean().nullish(),
    }),
    falseScarcity: zod.object({
      detected: zod.boolean(),
      evidence: zod.string(),
    }),
    confirmShaming: zod.object({
      detected: zod.boolean(),
      shamingText: zod.string(),
      rewrittenText: zod.string(),
    }),
    hiddenFees: zod.object({
      detected: zod.boolean(),
      feeItems: zod.array(
        zod.object({
          label: zod.string(),
          amount: zod.number(),
        }),
      ),
      totalExtra: zod.number().nullish(),
    }),
    preCheckedAddOns: zod.object({
      detected: zod.boolean(),
      fieldIds: zod.array(zod.string()),
      addOnLabels: zod.array(zod.string()),
    }),
    misdirection: zod.object({
      detected: zod.boolean(),
      hiddenDeclineText: zod.string(),
    }),
    trustScore: zod.number().describe("Trust score 0-100"),
    summary: zod.string().describe("Human-readable summary of findings"),
  }),
  trustRating: zod.object({
    id: zod.number(),
    domain: zod.string(),
    score: zod.number().describe("Trust score 0-100"),
    tier: zod.enum([
      "gold",
      "clean",
      "neutral",
      "suspicious",
      "high_manipulation",
    ]),
    totalScans: zod.number(),
    patternsDetectedCount: zod.number(),
    hiddenFeesCount: zod.number(),
    lastScannedAt: zod.string().nullish(),
    createdAt: zod.string(),
    updatedAt: zod.string(),
  }),
});

/**
 * Uses AI to estimate hidden fees and total true price for a given site and listing price
 * @summary Estimate true final price
 */
export const demoFeeEstimateBodyCurrencyDefault = `USD`;

export const DemoFeeEstimateBody = zod.object({
  domain: zod.string(),
  merchantType: zod
    .string()
    .describe(
      "Type of merchant: hotel, airline, ecommerce, vacation_rental, car_rental",
    ),
  listedPrice: zod.number(),
  currency: zod.string().default(demoFeeEstimateBodyCurrencyDefault),
  itemDescription: zod.string().nullish(),
});

export const DemoFeeEstimateResponse = zod.object({
  listedPrice: zod.number(),
  estimatedTotal: zod.number(),
  savingsOpportunity: zod.number(),
  feeBreakdown: zod.array(
    zod.object({
      label: zod.string(),
      amount: zod.number(),
    }),
  ),
  confidence: zod.enum(["high", "medium", "low"]),
  warningLevel: zod.enum(["green", "orange", "red"]),
  explanation: zod.string(),
});

/**
 * Returns the domains with the most detected dark patterns
 * @summary Get top offending domains
 */
export const GetTopOffendersQueryParams = zod.object({
  limit: zod.coerce.number().nullish(),
});

export const GetTopOffendersResponseItem = zod.object({
  domain: zod.string(),
  totalPatternsDetected: zod.number(),
  trustScore: zod.number(),
  tier: zod.string(),
  totalScans: zod.number(),
});
export const GetTopOffendersResponse = zod.array(GetTopOffendersResponseItem);