@slates/provider 1.0.0-rc.33 → 1.0.0-rc.34

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.
package/dist/index.cjs CHANGED
@@ -59,6 +59,7 @@ __export(index_exports, {
59
59
  adapterSpec: () => adapterSpec,
60
60
  allOf: () => allOf,
61
61
  anyOf: () => anyOf,
62
+ assertNewPageToken: () => assertNewPageToken,
62
63
  auth: () => auth,
63
64
  axios: () => axios,
64
65
  buildApiServiceError: () => buildApiServiceError,
@@ -88,6 +89,7 @@ __export(index_exports, {
88
89
  getResponseHeaderValue: () => getResponseHeaderValue,
89
90
  getRuntimeInfo: () => getRuntimeInfo,
90
91
  getServiceErrorData: () => getServiceErrorData,
92
+ getUpstreamErrorStatus: () => getUpstreamErrorStatus,
91
93
  graphWebhookHttp: () => graphWebhookHttp,
92
94
  inferSlateErrorFromAxios: () => inferSlateErrorFromAxios,
93
95
  isApiErrorRecord: () => isApiErrorRecord,
@@ -100,19 +102,25 @@ __export(index_exports, {
100
102
  mergeScopes: () => mergeScopes,
101
103
  metaWebhookHttp: () => metaWebhookHttp,
102
104
  normalizeOAuthTokenResponse: () => normalizeOAuthTokenResponse,
105
+ parseWithServiceError: () => parseWithServiceError,
103
106
  pickDefined: () => pickDefined,
107
+ pruneSeenEntries: () => pruneSeenEntries,
104
108
  publicTool: () => publicTool,
105
109
  pushBoundedApiErrorDetail: () => pushBoundedApiErrorDetail,
106
110
  readApiErrorText: () => readApiErrorText,
107
111
  redactUrlAttachmentSecrets: () => redactUrlAttachmentSecrets,
112
+ rememberPageToken: () => rememberPageToken,
108
113
  requestAxios: () => requestAxios,
109
114
  requestAxiosData: () => requestAxiosData,
110
115
  runWithContext: () => runWithContext,
111
116
  scopeClause: () => scopeClause,
117
+ seenEntryKey: () => seenEntryKey,
118
+ seenEntrySchema: () => seenEntrySchema,
112
119
  setIfDefined: () => setIfDefined,
113
120
  skipWebhook: () => skipWebhook,
114
121
  spec: () => spec,
115
122
  statusLabelForApiError: () => statusLabelForApiError,
123
+ timingSafeStringEqual: () => timingSafeStringEqual,
116
124
  tool: () => tool,
117
125
  toolCategory: () => toolCategory,
118
126
  trigger: () => trigger,
@@ -1392,6 +1400,11 @@ var getApiErrorResponse = (error) => {
1392
1400
  };
1393
1401
  };
1394
1402
  var getApiErrorStatus = (error) => getApiErrorResponse(error)?.status;
1403
+ var getUpstreamErrorStatus = (error) => {
1404
+ let value = error instanceof import_error.ServiceError ? error.data.upstreamStatus : getApiErrorStatus(error);
1405
+ let status = Number(value);
1406
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : void 0;
1407
+ };
1395
1408
  var getApiErrorResponseWithBody = (error) => {
1396
1409
  let response = getApiErrorResponse(error);
1397
1410
  if (response?.data !== void 0) return response;
@@ -1899,6 +1912,13 @@ var SlateDeclarationError = class _SlateDeclarationError extends SlateError {
1899
1912
  }
1900
1913
  };
1901
1914
 
1915
+ // src/error/parse.ts
1916
+ var parseWithServiceError = (schema, value, message, options = {}) => {
1917
+ let result = schema.safeParse(value);
1918
+ if (!result.success) throw createApiServiceError(message, options);
1919
+ return result.data;
1920
+ };
1921
+
1902
1922
  // src/action/scopes.ts
1903
1923
  var scopeClause = (...scopes) => {
1904
1924
  assertScopeValues(scopes);
@@ -2276,6 +2296,9 @@ var SlateTriggerGroup = class _SlateTriggerGroup {
2276
2296
  get source() {
2277
2297
  return this._params.source;
2278
2298
  }
2299
+ get selectionSchema() {
2300
+ return this._params.selectionSchema;
2301
+ }
2279
2302
  get polling() {
2280
2303
  return this._params.polling;
2281
2304
  }
@@ -2323,11 +2346,41 @@ var SlateTriggerGroupBuilder = class {
2323
2346
  "Webhook trigger groups require exactly one of autoRegistration or manualRegistration"
2324
2347
  );
2325
2348
  }
2349
+ if (props.deliveryConfig !== void 0) {
2350
+ if (!props.autoRegistration) {
2351
+ throw new SlateDeclarationError(
2352
+ "A webhook delivery config requires automatic webhook registration"
2353
+ );
2354
+ }
2355
+ if (!props.deliveryConfig.finish) {
2356
+ throw new SlateDeclarationError("A webhook delivery config requires a finish handler");
2357
+ }
2358
+ if (!props.deliveryConfig.authenticate) {
2359
+ throw new SlateDeclarationError(
2360
+ "A webhook delivery config requires an authenticate handler"
2361
+ );
2362
+ }
2363
+ }
2364
+ if (props.reconcileIntervalSeconds !== void 0) {
2365
+ if (!Number.isSafeInteger(props.reconcileIntervalSeconds) || props.reconcileIntervalSeconds < 900) {
2366
+ throw new SlateDeclarationError(
2367
+ "Webhook reconciliation interval must be an integer of at least 900 seconds"
2368
+ );
2369
+ }
2370
+ if (!props.expandWebhook) {
2371
+ throw new SlateDeclarationError(
2372
+ "Webhook reconciliation requires an expandWebhook handler"
2373
+ );
2374
+ }
2375
+ }
2326
2376
  this.#source = "webhook";
2327
2377
  this.#webhook = {
2328
2378
  autoRegistration: props.autoRegistration,
2329
2379
  manualRegistration: props.manualRegistration,
2330
- process: props.process
2380
+ deliveryConfig: props.deliveryConfig,
2381
+ process: props.process,
2382
+ expandWebhook: props.expandWebhook,
2383
+ reconcileIntervalSeconds: props.reconcileIntervalSeconds
2331
2384
  };
2332
2385
  return this;
2333
2386
  }
@@ -3107,13 +3160,29 @@ var createHmacSignature = ({
3107
3160
  digest,
3108
3161
  prefix = ""
3109
3162
  }) => `${prefix}${(0, import_crypto.createHmac)(algorithm, secret).update(payload).digest(digest)}`;
3110
- var verifyHmacSignature = (options) => {
3111
- let expected = createHmacSignature(options);
3163
+ var timingSafeStringEqual = (expected, received) => {
3112
3164
  let expectedBytes = Buffer.from(expected);
3113
- let signatureBytes = Buffer.from(options.signature);
3114
- let lengthsMatch = signatureBytes.length === expectedBytes.length;
3115
- let comparableSignature = lengthsMatch ? signatureBytes : Buffer.alloc(expectedBytes.length);
3116
- return (0, import_crypto.timingSafeEqual)(comparableSignature, expectedBytes) && lengthsMatch;
3165
+ let receivedBytes = Buffer.from(received ?? "");
3166
+ let lengthsMatch = receivedBytes.length === expectedBytes.length;
3167
+ let comparable = lengthsMatch ? receivedBytes : Buffer.alloc(expectedBytes.length);
3168
+ return (0, import_crypto.timingSafeEqual)(comparable, expectedBytes) && lengthsMatch && expectedBytes.length > 0;
3169
+ };
3170
+ var verifyHmacSignature = (options) => timingSafeStringEqual(createHmacSignature(options), options.signature);
3171
+
3172
+ // src/dedup/index.ts
3173
+ var import_crypto2 = require("crypto");
3174
+ var import_zod3 = require("zod");
3175
+ var seenEntrySchema = import_zod3.z.object({ key: import_zod3.z.string().min(1), at: import_zod3.z.number().finite() });
3176
+ var seenEntryKey = (idempotencyKey) => (0, import_crypto2.createHash)("sha256").update(idempotencyKey).digest("base64url").slice(0, 16);
3177
+ var pruneSeenEntries = (entries, options) => {
3178
+ let kept = [];
3179
+ for (let { key, at, retain } of entries) {
3180
+ if (retain || at >= options.cutoff) kept.push({ key, at });
3181
+ }
3182
+ kept.sort((a, b) => b.at - a.at || (a.key < b.key ? -1 : 1));
3183
+ if (kept.length <= options.maxEntries) return kept;
3184
+ options.onOverflow?.(kept.length - options.maxEntries);
3185
+ return kept.slice(0, options.maxEntries);
3117
3186
  };
3118
3187
 
3119
3188
  // src/file/index.ts
@@ -3243,6 +3312,16 @@ var setIfDefined = (target, key, value) => {
3243
3312
  return target;
3244
3313
  };
3245
3314
 
3315
+ // src/pagination/index.ts
3316
+ var rememberPageToken = (seen, token) => {
3317
+ if (seen.has(token)) return false;
3318
+ seen.add(token);
3319
+ return true;
3320
+ };
3321
+ var assertNewPageToken = (seen, token, repeated) => {
3322
+ if (token && !rememberPageToken(seen, token)) throw repeated();
3323
+ };
3324
+
3246
3325
  // src/specification/slate.ts
3247
3326
  var Slate = class _Slate {
3248
3327
  constructor(_spec, _actions, _adapters, _triggerGroups, _toolCategories, _toolCategoryKeysByActionKey) {
@@ -3294,12 +3373,12 @@ var Slate = class _Slate {
3294
3373
  }
3295
3374
  seenTriggerGroupKeys.add(group.key);
3296
3375
  }
3297
- let manualWebhookTriggerGroups = triggerGroups.filter(
3298
- (group) => group.source === "webhook" && group.webhook?.manualRegistration
3376
+ let configuredWebhookTriggerGroups = triggerGroups.filter(
3377
+ (group) => group.source === "webhook" && (group.webhook?.manualRegistration || group.webhook?.deliveryConfig)
3299
3378
  );
3300
- if (manualWebhookTriggerGroups.length > 1) {
3379
+ if (configuredWebhookTriggerGroups.length > 1) {
3301
3380
  throw new SlateDeclarationError(
3302
- `Only one trigger group may use manual webhook registration, but found: ${manualWebhookTriggerGroups.map((group) => group.key).join(", ")}`
3381
+ `Only one trigger group may use manual webhook registration or a delivery config, but found: ${configuredWebhookTriggerGroups.map((group) => group.key).join(", ")}`
3303
3382
  );
3304
3383
  }
3305
3384
  let toolCategories = params.toolCategories ?? [];
@@ -3401,7 +3480,7 @@ var resolveToolCategoryMembership = (toolCategories, actions) => {
3401
3480
  };
3402
3481
 
3403
3482
  // src/specification/specification.ts
3404
- var import_zod3 = __toESM(require("zod"), 1);
3483
+ var import_zod4 = __toESM(require("zod"), 1);
3405
3484
  var SlateSpecification = class _SlateSpecification {
3406
3485
  constructor(_config, _auth, _params) {
3407
3486
  this._config = _config;
@@ -3418,7 +3497,7 @@ var SlateSpecification = class _SlateSpecification {
3418
3497
  return this._config.configSchema;
3419
3498
  }
3420
3499
  get authSchema() {
3421
- return "outputSchema" in this._auth ? this._auth.outputSchema : import_zod3.default.object({});
3500
+ return "outputSchema" in this._auth ? this._auth.outputSchema : import_zod4.default.object({});
3422
3501
  }
3423
3502
  get config() {
3424
3503
  return this._config;
@@ -3534,6 +3613,7 @@ var skipWebhook = (reason, response) => ({
3534
3613
  adapterSpec,
3535
3614
  allOf,
3536
3615
  anyOf,
3616
+ assertNewPageToken,
3537
3617
  auth,
3538
3618
  axios,
3539
3619
  buildApiServiceError,
@@ -3563,6 +3643,7 @@ var skipWebhook = (reason, response) => ({
3563
3643
  getResponseHeaderValue,
3564
3644
  getRuntimeInfo,
3565
3645
  getServiceErrorData,
3646
+ getUpstreamErrorStatus,
3566
3647
  graphWebhookHttp,
3567
3648
  inferSlateErrorFromAxios,
3568
3649
  isApiErrorRecord,
@@ -3575,19 +3656,25 @@ var skipWebhook = (reason, response) => ({
3575
3656
  mergeScopes,
3576
3657
  metaWebhookHttp,
3577
3658
  normalizeOAuthTokenResponse,
3659
+ parseWithServiceError,
3578
3660
  pickDefined,
3661
+ pruneSeenEntries,
3579
3662
  publicTool,
3580
3663
  pushBoundedApiErrorDetail,
3581
3664
  readApiErrorText,
3582
3665
  redactUrlAttachmentSecrets,
3666
+ rememberPageToken,
3583
3667
  requestAxios,
3584
3668
  requestAxiosData,
3585
3669
  runWithContext,
3586
3670
  scopeClause,
3671
+ seenEntryKey,
3672
+ seenEntrySchema,
3587
3673
  setIfDefined,
3588
3674
  skipWebhook,
3589
3675
  spec,
3590
3676
  statusLabelForApiError,
3677
+ timingSafeStringEqual,
3591
3678
  tool,
3592
3679
  toolCategory,
3593
3680
  trigger,
package/dist/index.d.cts CHANGED
@@ -537,6 +537,7 @@ declare let getRuntimeInfo: () => Readonly<SlateRuntimeInfo> | null;
537
537
 
538
538
  declare let SlateDefaultPollingIntervalSeconds: number;
539
539
  type SlateTriggerRoutingMatcher = Record<string, any>;
540
+ type SlateTriggerGroupSelection = Record<string, any>;
540
541
  type SlateWebhookTargetOwnership = 'single_user' | 'multi_user';
541
542
  interface SlateWebhookTarget {
542
543
  webhookTargetIdentifier: string;
@@ -549,6 +550,7 @@ interface SlateWebhookTarget {
549
550
  type SlateTriggerGroupRoutingMatchersHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {}>) => Promise<SlateTriggerRoutingMatcher[]>;
550
551
  type SlateTriggerGroupPollHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
551
552
  state: any | null;
553
+ selection?: SlateTriggerGroupSelection;
552
554
  }>) => Promise<{
553
555
  events: {
554
556
  payload: any;
@@ -593,6 +595,7 @@ type SlateTriggerGroupGatewayReceiveHandler<ConfigType extends {}, AuthType exte
593
595
  }>;
594
596
  type SlateWebhookTargetListHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
595
597
  pageToken: any | null;
598
+ selection?: SlateTriggerGroupSelection;
596
599
  }>) => Promise<{
597
600
  targets: SlateWebhookTarget[];
598
601
  nextPageToken: any | null;
@@ -602,9 +605,40 @@ type SlateWebhookRegisterHandler<ConfigType extends {}, AuthType extends {}> = (
602
605
  webhookTargetIdentifier: string;
603
606
  webhookTargetPayload: any;
604
607
  webhookUrl: string;
605
- }>) => Promise<{
608
+ operationId?: string;
609
+ selection?: SlateTriggerGroupSelection;
610
+ deliveryConfig?: unknown;
611
+ }>) => Promise<SlateWebhookRegistrationResult>;
612
+ interface SlateWebhookRegistrationResult {
613
+ webhookRegistrationIdentifier: string;
614
+ webhookRegistrationPayload: any;
615
+ expiresAt?: string | null;
616
+ renewAfter?: string | null;
617
+ /** Identities of this registration on a delivery channel shared with other registrations. */
618
+ routingKeys?: string[];
619
+ }
620
+ type SlateWebhookRenewHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
606
621
  webhookRegistrationIdentifier: string;
607
622
  webhookRegistrationPayload: any;
623
+ webhookUrl: string;
624
+ webhookTargetIdentifier: string;
625
+ webhookTargetPayload: any;
626
+ operationId: string;
627
+ selection?: SlateTriggerGroupSelection;
628
+ deliveryConfig?: unknown;
629
+ }>) => Promise<SlateWebhookRegistrationResult>;
630
+ type SlateWebhookExpandHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
631
+ payload: unknown | null;
632
+ state: any | null;
633
+ selection?: SlateTriggerGroupSelection;
634
+ deliveryId: string;
635
+ webhookRegistrationPayload: any;
636
+ }>) => Promise<{
637
+ events: {
638
+ payload: any;
639
+ idempotencyKey?: string;
640
+ }[];
641
+ updatedState?: any;
608
642
  }>;
609
643
  type SlateWebhookUnregisterHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
610
644
  webhookRegistrationIdentifier: string;
@@ -638,6 +672,23 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
638
672
  interface SlateWebhookSkipped {
639
673
  reason: string;
640
674
  }
675
+ /**
676
+ * Routing keys name the registrations a request addresses; an empty list acknowledges it
677
+ * without handing it to any. A rejection answers the sender with its status.
678
+ */
679
+ type SlateWebhookDeliveryAuthentication = {
680
+ routingKeys: string[];
681
+ rejected?: undefined;
682
+ } | {
683
+ rejected: {
684
+ status: number;
685
+ };
686
+ routingKeys?: undefined;
687
+ };
688
+ type SlateWebhookDeliveryAuthenticateHandler = (context: SlateContext<{}, {}, {
689
+ request: Request;
690
+ deliveryConfig: unknown;
691
+ }>) => Promise<SlateWebhookDeliveryAuthentication>;
641
692
  interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
642
693
  intervalSeconds: number;
643
694
  pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
@@ -649,6 +700,7 @@ interface SlateTriggerGroupGatewayParameters<ConfigType extends {}, AuthType ext
649
700
  interface SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType extends {}, AuthType extends {}> {
650
701
  webhookTargetList: SlateWebhookTargetListHandler<ConfigType, AuthType>;
651
702
  webhookRegister: SlateWebhookRegisterHandler<ConfigType, AuthType>;
703
+ webhookRenew?: SlateWebhookRenewHandler<ConfigType, AuthType>;
652
704
  webhookUnregister: SlateWebhookUnregisterHandler<ConfigType, AuthType>;
653
705
  }
654
706
  interface SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>, FullConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>> {
@@ -657,10 +709,18 @@ interface SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema
657
709
  setup: SlateWebhookManualSetupHandler<FullConfigSchema>;
658
710
  finish?: SlateWebhookManualFinishHandler<UserConfigSchema, FullConfigSchema>;
659
711
  }
712
+ /** A delivery setup a person completes once for an automatically registered group. */
713
+ type SlateTriggerGroupWebhookDeliveryConfigParameters<UserConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>, FullConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>> = SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema, FullConfigSchema> & {
714
+ finish: SlateWebhookManualFinishHandler<UserConfigSchema, FullConfigSchema>;
715
+ authenticate: SlateWebhookDeliveryAuthenticateHandler;
716
+ };
660
717
  interface SlateTriggerGroupWebhookParameters<ConfigType extends {}, AuthType extends {}> {
661
718
  autoRegistration?: SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType, AuthType>;
662
719
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<any, any>;
720
+ deliveryConfig?: SlateTriggerGroupWebhookDeliveryConfigParameters<any, any>;
663
721
  process: SlateWebhookProcessHandler;
722
+ expandWebhook?: SlateWebhookExpandHandler<ConfigType, AuthType>;
723
+ reconcileIntervalSeconds?: number;
664
724
  }
665
725
  interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string, unknown>> {
666
726
  key: string;
@@ -668,6 +728,7 @@ interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string
668
728
  description?: string;
669
729
  metadata?: Record<string, any>;
670
730
  eventSchema?: z$1.ZodType<InputType>;
731
+ selectionSchema?: z$1.ZodType<SlateTriggerGroupSelection>;
671
732
  }
672
733
  interface SlateTriggerGroupParameters<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> extends SlateTriggerGroupCreateParameters<InputType> {
673
734
  source: 'polling' | 'webhook' | 'gateway';
@@ -688,6 +749,7 @@ declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, Inpu
688
749
  get metadata(): Record<string, any> | undefined;
689
750
  get eventSchema(): z$1.ZodType<InputType, unknown, z$1.core.$ZodTypeInternals<InputType, unknown>>;
690
751
  get source(): "polling" | "webhook" | "gateway";
752
+ get selectionSchema(): z$1.ZodType<SlateTriggerGroupSelection, unknown, z$1.core.$ZodTypeInternals<SlateTriggerGroupSelection, unknown>> | undefined;
691
753
  get polling(): SlateTriggerGroupPollingParameters<ConfigType, AuthType> | undefined;
692
754
  get webhook(): SlateTriggerGroupWebhookParameters<ConfigType, AuthType> | undefined;
693
755
  get gateway(): SlateTriggerGroupGatewayParameters<ConfigType, AuthType> | undefined;
@@ -706,7 +768,10 @@ declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {
706
768
  webhook<UserConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>, FullConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>>(props: {
707
769
  autoRegistration?: SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType, AuthType>;
708
770
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema, FullConfigSchema>;
771
+ deliveryConfig?: SlateTriggerGroupWebhookDeliveryConfigParameters<UserConfigSchema, FullConfigSchema>;
709
772
  process: SlateWebhookProcessHandler;
773
+ expandWebhook?: SlateWebhookExpandHandler<ConfigType, AuthType>;
774
+ reconcileIntervalSeconds?: number;
710
775
  }): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
711
776
  /** Receive events over a platform-managed persistent connection (e.g. a WebSocket gateway). */
712
777
  gateway(props: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
@@ -1009,6 +1074,8 @@ declare let isApiErrorRecord: (value: unknown) => value is Record<string, unknow
1009
1074
  declare let collectApiErrorDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
1010
1075
  declare let getApiErrorResponse: (error: unknown) => ApiErrorResponse | undefined;
1011
1076
  declare let getApiErrorStatus: (error: unknown) => ApiErrorStatus | undefined;
1077
+ /** Upstream HTTP status of an HTTP client error or a ServiceError with `upstreamStatus`. */
1078
+ declare let getUpstreamErrorStatus: (error: unknown) => number | undefined;
1012
1079
  declare let getApiErrorResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
1013
1080
  declare let API_ERROR_MAX_DETAILS: number;
1014
1081
  declare let API_ERROR_MAX_MESSAGE_LENGTH: number;
@@ -1118,6 +1185,11 @@ declare class SlateDeclarationError extends SlateError {
1118
1185
  static is(error: unknown): error is SlateDeclarationError;
1119
1186
  }
1120
1187
 
1188
+ /** Parses a saved or received value, throwing a user-facing `ServiceError` on mismatch. */
1189
+ declare let parseWithServiceError: <T extends z$1.ZodType>(schema: T, value: unknown, message: string, options?: {
1190
+ reason?: string;
1191
+ }) => z$1.output<T>;
1192
+
1121
1193
  declare let mapServiceErrorCode: (code: string, status?: number) => string;
1122
1194
  declare let isServiceErrorData: (value: unknown) => value is SlateServiceErrorData;
1123
1195
  declare let getServiceErrorData: (error: unknown) => SlateServiceErrorData | null;
@@ -1152,14 +1224,38 @@ interface VerifyHmacSignatureOptions extends CreateHmacSignatureOptions {
1152
1224
  signature: string;
1153
1225
  }
1154
1226
  declare let createHmacSignature: ({ secret, payload, algorithm, digest, prefix }: CreateHmacSignatureOptions) => string;
1227
+ /** Constant-time secret comparison; an empty expected secret matches nothing. */
1228
+ declare let timingSafeStringEqual: (expected: string, received: string | null | undefined) => boolean;
1155
1229
  declare let verifyHmacSignature: (options: VerifyHmacSignatureOptions) => boolean;
1156
1230
 
1231
+ /** An event a poller already reported, saved so an overlapping read can skip it. */
1232
+ declare let seenEntrySchema: z$1.ZodObject<{
1233
+ key: z$1.ZodString;
1234
+ at: z$1.ZodNumber;
1235
+ }, z$1.core.$strip>;
1236
+ type SeenEntry = z$1.infer<typeof seenEntrySchema>;
1237
+ /** A short stable key for an idempotency key, so remembered events cost little state. */
1238
+ declare let seenEntryKey: (idempotencyKey: string) => string;
1239
+ /** Keeps entries at or after `cutoff` (or `retain`), newest first, at most `maxEntries`. */
1240
+ declare let pruneSeenEntries: (entries: Iterable<SeenEntry & {
1241
+ retain?: boolean;
1242
+ }>, options: {
1243
+ cutoff: number;
1244
+ maxEntries: number;
1245
+ onOverflow?: (dropped: number) => void;
1246
+ }) => SeenEntry[];
1247
+
1157
1248
  declare let getResponseHeaderValue: (headers: unknown, name: string) => string | undefined;
1158
1249
  declare let getBase64ByteLength: (contentBase64: string) => number;
1159
1250
 
1160
1251
  declare let pickDefined: <T extends object>(value: T) => Partial<T> & Record<string, unknown>;
1161
1252
  declare let setIfDefined: (target: Record<string, unknown>, key: string, value: unknown) => Record<string, unknown>;
1162
1253
 
1254
+ /** Records a page token in `seen`; `false` means it repeated and following it would loop. */
1255
+ declare let rememberPageToken: (seen: Set<string>, token: string) => boolean;
1256
+ /** Throws `repeated()` when a listing returns a page token it already returned. */
1257
+ declare let assertNewPageToken: (seen: Set<string>, token: string | null | undefined, repeated: () => unknown) => void;
1258
+
1163
1259
  declare class Slate<ConfigType extends {}, AuthType extends {}> {
1164
1260
  private readonly _spec;
1165
1261
  private readonly _actions;
@@ -1215,4 +1311,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
1215
1311
  response: Response | SlateWebhookHttpResponseInit;
1216
1312
  };
1217
1313
 
1218
- export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, GET_FILE_URL_TOOL_ID, type GetFileUrlHandler, type GetFileUrlToolInput, type GetFileUrlToolOutput, type NormalizeOAuthTokenResponseOptions, type OAuthExpiresAtOptions, type OAuthRefreshTokenFallbackMode, type OAuthTokenResponse, Slate, SlateAction, SlateActionBuilder, type SlateActionCreateParameters, type SlateActionDocsReference, type SlateActionParameters, type SlateActionParametersAny, type SlateActionParametersTool, type SlateActionParametersTrigger, type SlateActionScopeClause, type SlateActionScopeClauseInput, type SlateActionScopeValue, type SlateActionScopes, type SlateActionScopesInput, type SlateActionType, SlateAdapter, type SlateAdapterCapability, SlateAdapterSpec, type SlateAdapterSpecParameters, type SlateAddAttachmentContent, type SlateAddAttachmentInput, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUploadReferenceContent, type SlateAttachmentUrlContent, SlateAuth, type SlateAuthDocsReference, type SlateAuthType, type SlateAuthWithCustomData, type SlateAuthWithNone, type SlateAuthWithOauth, type SlateAuthWithServiceAccount, type SlateAuthWithToken, type SlateAuthenticatedAxiosDefaults, type SlateAxiosDefaults, type SlateAxiosErrorAdapter, type SlateAxiosErrorOptions, SlateConfig, type SlateConfigDocsReference, SlateContext, SlateDeclarationError, SlateDefaultPollingIntervalSeconds, type SlateDirectUploadInput, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateGatewayEvent, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateRuntimeInfo, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, type SlateTriggerGroupParameters, type SlateTriggerGroupPollHandler, type SlateTriggerGroupPollingParameters, type SlateTriggerGroupRoutingMatchersHandler, type SlateTriggerGroupWebhookAutoRegistrationParameters, type SlateTriggerGroupWebhookManualRegistrationParameters, type SlateTriggerGroupWebhookParameters, type SlateTriggerMappingHandler, type SlateTriggerMatchesHandler, type SlateTriggerParameters, type SlateTriggerRoutingMatcher, type SlateTypedDocsReference, type SlateWebhookHttpResponseInit, type SlateWebhookManualFinishHandler, type SlateWebhookManualSetupHandler, type SlateWebhookProcessHandler, type SlateWebhookRegisterHandler, type SlateWebhookSkipped, type SlateWebhookTarget, type SlateWebhookTargetListHandler, type SlateWebhookTargetOwnership, type SlateWebhookUnregisterHandler, type VerifyHmacSignatureOptions, adapterSpec, allOf, anyOf, auth, axios, buildApiServiceError, collectApiErrorDetails, config, createApiServiceError, createAuthenticatedAxios, createAxios, createBase64Attachment, createHmacSignature, createSlateError, createTextAttachment, createUrlAttachment, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getRuntimeInfo, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
1314
+ export { API_ERROR_MAX_DETAILS, API_ERROR_MAX_MESSAGE_LENGTH, API_ERROR_TRUNCATED_PLACEHOLDER, AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiErrorTextOptions, type ApiServiceError, type AuthConfigSecretFilter, AuthConfigSecretRedactor, type BoundedApiErrorDetailOptions, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, type DecodeApiErrorBodyOptions, GET_FILE_URL_TOOL_ID, type GetFileUrlHandler, type GetFileUrlToolInput, type GetFileUrlToolOutput, type NormalizeOAuthTokenResponseOptions, type OAuthExpiresAtOptions, type OAuthRefreshTokenFallbackMode, type OAuthTokenResponse, type SeenEntry, Slate, SlateAction, SlateActionBuilder, type SlateActionCreateParameters, type SlateActionDocsReference, type SlateActionParameters, type SlateActionParametersAny, type SlateActionParametersTool, type SlateActionParametersTrigger, type SlateActionScopeClause, type SlateActionScopeClauseInput, type SlateActionScopeValue, type SlateActionScopes, type SlateActionScopesInput, type SlateActionType, SlateAdapter, type SlateAdapterCapability, SlateAdapterSpec, type SlateAdapterSpecParameters, type SlateAddAttachmentContent, type SlateAddAttachmentInput, type SlateAttachment, type SlateAttachmentInlineContent, type SlateAttachmentUploadReferenceContent, type SlateAttachmentUrlContent, SlateAuth, type SlateAuthDocsReference, type SlateAuthType, type SlateAuthWithCustomData, type SlateAuthWithNone, type SlateAuthWithOauth, type SlateAuthWithServiceAccount, type SlateAuthWithToken, type SlateAuthenticatedAxiosDefaults, type SlateAxiosDefaults, type SlateAxiosErrorAdapter, type SlateAxiosErrorOptions, SlateConfig, type SlateConfigDocsReference, SlateContext, SlateDeclarationError, SlateDefaultPollingIntervalSeconds, type SlateDirectUploadInput, type SlateDocsReference, SlateError, type SlateErrorInput, type SlateErrorIssue, type SlateErrorKind, type SlateErrorProviderInfo, type SlateErrorResponse, type SlateErrorUpstreamInfo, type SlateGatewayEvent, type SlateLiveInvocationInfo, type SlateLogEntry, type SlateLogFields, type SlateLogListener, type SlateLogMessageInput, type SlateLogType, SlateLogger, type SlateProviderDocsReference, SlatePublicContext, SlatePublicTool, type SlatePublicToolInvocationHandler, type SlatePublicToolParameters, type SlateRuntimeInfo, type SlateServiceErrorData, SlateSpecification, type SlateSpecificationCreateParameters, type SlateSpecificationParameters, SlateTool, SlateToolCategory, type SlateToolCategoryParameters, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, type SlateTriggerGroupGatewayConnectHandler, type SlateTriggerGroupGatewayParameters, type SlateTriggerGroupGatewayReceiveHandler, type SlateTriggerGroupParameters, type SlateTriggerGroupPollHandler, type SlateTriggerGroupPollingParameters, type SlateTriggerGroupRoutingMatchersHandler, type SlateTriggerGroupSelection, type SlateTriggerGroupWebhookAutoRegistrationParameters, type SlateTriggerGroupWebhookDeliveryConfigParameters, type SlateTriggerGroupWebhookManualRegistrationParameters, type SlateTriggerGroupWebhookParameters, type SlateTriggerMappingHandler, type SlateTriggerMatchesHandler, type SlateTriggerParameters, type SlateTriggerRoutingMatcher, type SlateTypedDocsReference, type SlateWebhookDeliveryAuthenticateHandler, type SlateWebhookDeliveryAuthentication, type SlateWebhookExpandHandler, type SlateWebhookHttpResponseInit, type SlateWebhookManualFinishHandler, type SlateWebhookManualSetupHandler, type SlateWebhookProcessHandler, type SlateWebhookRegisterHandler, type SlateWebhookRegistrationResult, type SlateWebhookRenewHandler, type SlateWebhookSkipped, type SlateWebhookTarget, type SlateWebhookTargetListHandler, type SlateWebhookTargetOwnership, type SlateWebhookUnregisterHandler, type VerifyHmacSignatureOptions, adapterSpec, allOf, anyOf, assertNewPageToken, auth, axios, buildApiServiceError, collectApiErrorDetails, config, createApiServiceError, createAuthenticatedAxios, createAxios, createBase64Attachment, createHmacSignature, createSlateError, createTextAttachment, createUrlAttachment, decodeApiErrorBody, extractApiErrorMessage, getApiErrorResponse, getApiErrorResponseWithBody, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getRuntimeInfo, getServiceErrorData, getUpstreamErrorStatus, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, isUrlEmbeddedCredential, looksLikeHtmlErrorBody, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, parseWithServiceError, pickDefined, pruneSeenEntries, publicTool, pushBoundedApiErrorDetail, readApiErrorText, redactUrlAttachmentSecrets, rememberPageToken, requestAxios, requestAxiosData, runWithContext, scopeClause, seenEntryKey, seenEntrySchema, setIfDefined, skipWebhook, spec, statusLabelForApiError, timingSafeStringEqual, tool, toolCategory, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };