@slates/provider 1.0.0-rc.32 → 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,
@@ -86,7 +87,9 @@ __export(index_exports, {
86
87
  getMetaWebhookVerificationResponse: () => getMetaWebhookVerificationResponse,
87
88
  getOAuthExpiresAtFromExpiresIn: () => getOAuthExpiresAtFromExpiresIn,
88
89
  getResponseHeaderValue: () => getResponseHeaderValue,
90
+ getRuntimeInfo: () => getRuntimeInfo,
89
91
  getServiceErrorData: () => getServiceErrorData,
92
+ getUpstreamErrorStatus: () => getUpstreamErrorStatus,
90
93
  graphWebhookHttp: () => graphWebhookHttp,
91
94
  inferSlateErrorFromAxios: () => inferSlateErrorFromAxios,
92
95
  isApiErrorRecord: () => isApiErrorRecord,
@@ -99,19 +102,25 @@ __export(index_exports, {
99
102
  mergeScopes: () => mergeScopes,
100
103
  metaWebhookHttp: () => metaWebhookHttp,
101
104
  normalizeOAuthTokenResponse: () => normalizeOAuthTokenResponse,
105
+ parseWithServiceError: () => parseWithServiceError,
102
106
  pickDefined: () => pickDefined,
107
+ pruneSeenEntries: () => pruneSeenEntries,
103
108
  publicTool: () => publicTool,
104
109
  pushBoundedApiErrorDetail: () => pushBoundedApiErrorDetail,
105
110
  readApiErrorText: () => readApiErrorText,
106
111
  redactUrlAttachmentSecrets: () => redactUrlAttachmentSecrets,
112
+ rememberPageToken: () => rememberPageToken,
107
113
  requestAxios: () => requestAxios,
108
114
  requestAxiosData: () => requestAxiosData,
109
115
  runWithContext: () => runWithContext,
110
116
  scopeClause: () => scopeClause,
117
+ seenEntryKey: () => seenEntryKey,
118
+ seenEntrySchema: () => seenEntrySchema,
111
119
  setIfDefined: () => setIfDefined,
112
120
  skipWebhook: () => skipWebhook,
113
121
  spec: () => spec,
114
122
  statusLabelForApiError: () => statusLabelForApiError,
123
+ timingSafeStringEqual: () => timingSafeStringEqual,
115
124
  tool: () => tool,
116
125
  toolCategory: () => toolCategory,
117
126
  trigger: () => trigger,
@@ -1024,6 +1033,7 @@ var getCurrentContext = () => {
1024
1033
  }
1025
1034
  return context;
1026
1035
  };
1036
+ var getRuntimeInfo = () => asyncLocalStorage.getStore()?.runtimeInfo ?? null;
1027
1037
 
1028
1038
  // src/error/defaults.ts
1029
1039
  var DEFAULT_CODE = "internal.unexpected";
@@ -1390,6 +1400,11 @@ var getApiErrorResponse = (error) => {
1390
1400
  };
1391
1401
  };
1392
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
+ };
1393
1408
  var getApiErrorResponseWithBody = (error) => {
1394
1409
  let response = getApiErrorResponse(error);
1395
1410
  if (response?.data !== void 0) return response;
@@ -1897,6 +1912,13 @@ var SlateDeclarationError = class _SlateDeclarationError extends SlateError {
1897
1912
  }
1898
1913
  };
1899
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
+
1900
1922
  // src/action/scopes.ts
1901
1923
  var scopeClause = (...scopes) => {
1902
1924
  assertScopeValues(scopes);
@@ -2274,6 +2296,9 @@ var SlateTriggerGroup = class _SlateTriggerGroup {
2274
2296
  get source() {
2275
2297
  return this._params.source;
2276
2298
  }
2299
+ get selectionSchema() {
2300
+ return this._params.selectionSchema;
2301
+ }
2277
2302
  get polling() {
2278
2303
  return this._params.polling;
2279
2304
  }
@@ -2321,11 +2346,41 @@ var SlateTriggerGroupBuilder = class {
2321
2346
  "Webhook trigger groups require exactly one of autoRegistration or manualRegistration"
2322
2347
  );
2323
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
+ }
2324
2376
  this.#source = "webhook";
2325
2377
  this.#webhook = {
2326
2378
  autoRegistration: props.autoRegistration,
2327
2379
  manualRegistration: props.manualRegistration,
2328
- process: props.process
2380
+ deliveryConfig: props.deliveryConfig,
2381
+ process: props.process,
2382
+ expandWebhook: props.expandWebhook,
2383
+ reconcileIntervalSeconds: props.reconcileIntervalSeconds
2329
2384
  };
2330
2385
  return this;
2331
2386
  }
@@ -2894,6 +2949,10 @@ var resolveDefaultExport = (value) => {
2894
2949
  var PQueue = resolveDefaultExport(import_p_queue.default);
2895
2950
 
2896
2951
  // src/context/context.ts
2952
+ var freezeRuntimeInfo = (runtimeInfo) => Object.freeze({
2953
+ ...runtimeInfo,
2954
+ ...runtimeInfo.metorial ? { metorial: Object.freeze({ ...runtimeInfo.metorial }) } : {}
2955
+ });
2897
2956
  var isBufferLike = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
2898
2957
  var toUint8Array = (value) => value instanceof ArrayBuffer ? new Uint8Array(value) : value;
2899
2958
  var isReadableStream = (value) => typeof ReadableStream !== "undefined" && value instanceof ReadableStream;
@@ -2910,17 +2969,19 @@ var readStreamToBuffer = async (stream) => {
2910
2969
  return Buffer.concat(chunks);
2911
2970
  };
2912
2971
  var SlatePublicContext = class {
2913
- constructor(input, spec2, logger, liveInvocation = null) {
2972
+ constructor(input, spec2, logger, liveInvocation = null, runtimeInfo = null) {
2914
2973
  this.spec = spec2;
2915
2974
  this.logger = logger;
2916
2975
  this.#input = input;
2917
2976
  this.#liveInvocation = liveInvocation;
2977
+ this.#runtimeInfo = runtimeInfo && freezeRuntimeInfo(runtimeInfo);
2918
2978
  }
2919
2979
  spec;
2920
2980
  logger;
2921
2981
  #input;
2922
2982
  #httpTraces = [];
2923
2983
  #liveInvocation;
2984
+ #runtimeInfo;
2924
2985
  #attachmentsDisabled = false;
2925
2986
  #attachments = [];
2926
2987
  #pendingUploads = [];
@@ -2931,6 +2992,9 @@ var SlatePublicContext = class {
2931
2992
  }
2932
2993
  return this.#uploadQueue;
2933
2994
  }
2995
+ get runtimeInfo() {
2996
+ return this.#runtimeInfo;
2997
+ }
2934
2998
  get specification() {
2935
2999
  return this.spec;
2936
3000
  }
@@ -3071,8 +3135,8 @@ var SlatePublicContext = class {
3071
3135
  var SlateContext = class extends SlatePublicContext {
3072
3136
  #config;
3073
3137
  #auth;
3074
- constructor(config2, input, auth2, spec2, logger, liveInvocation = null) {
3075
- super(input, spec2, logger, liveInvocation);
3138
+ constructor(config2, input, auth2, spec2, logger, liveInvocation = null, runtimeInfo = null) {
3139
+ super(input, spec2, logger, liveInvocation, runtimeInfo);
3076
3140
  this.#config = config2;
3077
3141
  this.#auth = auth2;
3078
3142
  }
@@ -3096,13 +3160,29 @@ var createHmacSignature = ({
3096
3160
  digest,
3097
3161
  prefix = ""
3098
3162
  }) => `${prefix}${(0, import_crypto.createHmac)(algorithm, secret).update(payload).digest(digest)}`;
3099
- var verifyHmacSignature = (options) => {
3100
- let expected = createHmacSignature(options);
3163
+ var timingSafeStringEqual = (expected, received) => {
3101
3164
  let expectedBytes = Buffer.from(expected);
3102
- let signatureBytes = Buffer.from(options.signature);
3103
- let lengthsMatch = signatureBytes.length === expectedBytes.length;
3104
- let comparableSignature = lengthsMatch ? signatureBytes : Buffer.alloc(expectedBytes.length);
3105
- 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);
3106
3186
  };
3107
3187
 
3108
3188
  // src/file/index.ts
@@ -3232,6 +3312,16 @@ var setIfDefined = (target, key, value) => {
3232
3312
  return target;
3233
3313
  };
3234
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
+
3235
3325
  // src/specification/slate.ts
3236
3326
  var Slate = class _Slate {
3237
3327
  constructor(_spec, _actions, _adapters, _triggerGroups, _toolCategories, _toolCategoryKeysByActionKey) {
@@ -3283,12 +3373,12 @@ var Slate = class _Slate {
3283
3373
  }
3284
3374
  seenTriggerGroupKeys.add(group.key);
3285
3375
  }
3286
- let manualWebhookTriggerGroups = triggerGroups.filter(
3287
- (group) => group.source === "webhook" && group.webhook?.manualRegistration
3376
+ let configuredWebhookTriggerGroups = triggerGroups.filter(
3377
+ (group) => group.source === "webhook" && (group.webhook?.manualRegistration || group.webhook?.deliveryConfig)
3288
3378
  );
3289
- if (manualWebhookTriggerGroups.length > 1) {
3379
+ if (configuredWebhookTriggerGroups.length > 1) {
3290
3380
  throw new SlateDeclarationError(
3291
- `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(", ")}`
3292
3382
  );
3293
3383
  }
3294
3384
  let toolCategories = params.toolCategories ?? [];
@@ -3390,7 +3480,7 @@ var resolveToolCategoryMembership = (toolCategories, actions) => {
3390
3480
  };
3391
3481
 
3392
3482
  // src/specification/specification.ts
3393
- var import_zod3 = __toESM(require("zod"), 1);
3483
+ var import_zod4 = __toESM(require("zod"), 1);
3394
3484
  var SlateSpecification = class _SlateSpecification {
3395
3485
  constructor(_config, _auth, _params) {
3396
3486
  this._config = _config;
@@ -3407,7 +3497,7 @@ var SlateSpecification = class _SlateSpecification {
3407
3497
  return this._config.configSchema;
3408
3498
  }
3409
3499
  get authSchema() {
3410
- 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({});
3411
3501
  }
3412
3502
  get config() {
3413
3503
  return this._config;
@@ -3523,6 +3613,7 @@ var skipWebhook = (reason, response) => ({
3523
3613
  adapterSpec,
3524
3614
  allOf,
3525
3615
  anyOf,
3616
+ assertNewPageToken,
3526
3617
  auth,
3527
3618
  axios,
3528
3619
  buildApiServiceError,
@@ -3550,7 +3641,9 @@ var skipWebhook = (reason, response) => ({
3550
3641
  getMetaWebhookVerificationResponse,
3551
3642
  getOAuthExpiresAtFromExpiresIn,
3552
3643
  getResponseHeaderValue,
3644
+ getRuntimeInfo,
3553
3645
  getServiceErrorData,
3646
+ getUpstreamErrorStatus,
3554
3647
  graphWebhookHttp,
3555
3648
  inferSlateErrorFromAxios,
3556
3649
  isApiErrorRecord,
@@ -3563,19 +3656,25 @@ var skipWebhook = (reason, response) => ({
3563
3656
  mergeScopes,
3564
3657
  metaWebhookHttp,
3565
3658
  normalizeOAuthTokenResponse,
3659
+ parseWithServiceError,
3566
3660
  pickDefined,
3661
+ pruneSeenEntries,
3567
3662
  publicTool,
3568
3663
  pushBoundedApiErrorDetail,
3569
3664
  readApiErrorText,
3570
3665
  redactUrlAttachmentSecrets,
3666
+ rememberPageToken,
3571
3667
  requestAxios,
3572
3668
  requestAxiosData,
3573
3669
  runWithContext,
3574
3670
  scopeClause,
3671
+ seenEntryKey,
3672
+ seenEntrySchema,
3575
3673
  setIfDefined,
3576
3674
  skipWebhook,
3577
3675
  spec,
3578
3676
  statusLabelForApiError,
3677
+ timingSafeStringEqual,
3579
3678
  tool,
3580
3679
  toolCategory,
3581
3680
  trigger,
package/dist/index.d.cts CHANGED
@@ -459,6 +459,13 @@ declare class SlateSpecification<ConfigType extends {}, AuthType extends {}> {
459
459
  }
460
460
  declare let spec: <ConfigType extends {}, AuthType extends {}>(params: SlateSpecificationCreateParameters<ConfigType, AuthType>) => SlateSpecification<ConfigType, AuthType>;
461
461
 
462
+ interface SlateRuntimeInfo {
463
+ metorial?: {
464
+ apiUrl: string;
465
+ region?: string | null;
466
+ environment?: string | null;
467
+ };
468
+ }
462
469
  type SlateAddAttachmentContent = Buffer | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | NodeJS.ReadableStream | Response;
463
470
  type SlateAddAttachmentInput = {
464
471
  type: 'url';
@@ -479,7 +486,8 @@ declare class SlatePublicContext<InputType extends {}> {
479
486
  #private;
480
487
  private readonly spec;
481
488
  private readonly logger;
482
- constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
489
+ constructor(input: InputType, spec: SlateSpecification<any, any>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
490
+ get runtimeInfo(): Readonly<SlateRuntimeInfo> | null;
483
491
  get specification(): SlateSpecification<any, any>;
484
492
  get input(): Readonly<InputType>;
485
493
  get event(): Readonly<InputType>;
@@ -517,7 +525,7 @@ declare class SlatePublicContext<InputType extends {}> {
517
525
  }
518
526
  declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType extends {}> extends SlatePublicContext<InputType> {
519
527
  #private;
520
- constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null);
528
+ constructor(config: ConfigType, input: InputType, auth: AuthType, spec: SlateSpecification<ConfigType, AuthType>, logger: SlateLogger, liveInvocation?: SlateLiveInvocationInfo | null, runtimeInfo?: SlateRuntimeInfo | null);
521
529
  get config(): Readonly<ConfigType>;
522
530
  get auth(): Readonly<AuthType>;
523
531
  _getAuthConfigForRedaction(): Record<string, unknown> | undefined;
@@ -525,9 +533,11 @@ declare class SlateContext<ConfigType extends {}, AuthType extends {}, InputType
525
533
 
526
534
  declare let runWithContext: <InputType extends {}, RV>(context: SlatePublicContext<InputType>, fn: () => Promise<RV>) => Promise<RV>;
527
535
  declare let getCurrentContext: <ConfigType extends {}, AuthType extends {}, InputType extends {}>() => SlateContext<ConfigType, AuthType, InputType>;
536
+ declare let getRuntimeInfo: () => Readonly<SlateRuntimeInfo> | null;
528
537
 
529
538
  declare let SlateDefaultPollingIntervalSeconds: number;
530
539
  type SlateTriggerRoutingMatcher = Record<string, any>;
540
+ type SlateTriggerGroupSelection = Record<string, any>;
531
541
  type SlateWebhookTargetOwnership = 'single_user' | 'multi_user';
532
542
  interface SlateWebhookTarget {
533
543
  webhookTargetIdentifier: string;
@@ -540,6 +550,7 @@ interface SlateWebhookTarget {
540
550
  type SlateTriggerGroupRoutingMatchersHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {}>) => Promise<SlateTriggerRoutingMatcher[]>;
541
551
  type SlateTriggerGroupPollHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
542
552
  state: any | null;
553
+ selection?: SlateTriggerGroupSelection;
543
554
  }>) => Promise<{
544
555
  events: {
545
556
  payload: any;
@@ -584,6 +595,7 @@ type SlateTriggerGroupGatewayReceiveHandler<ConfigType extends {}, AuthType exte
584
595
  }>;
585
596
  type SlateWebhookTargetListHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
586
597
  pageToken: any | null;
598
+ selection?: SlateTriggerGroupSelection;
587
599
  }>) => Promise<{
588
600
  targets: SlateWebhookTarget[];
589
601
  nextPageToken: any | null;
@@ -593,9 +605,40 @@ type SlateWebhookRegisterHandler<ConfigType extends {}, AuthType extends {}> = (
593
605
  webhookTargetIdentifier: string;
594
606
  webhookTargetPayload: any;
595
607
  webhookUrl: string;
596
- }>) => 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, {
597
621
  webhookRegistrationIdentifier: string;
598
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;
599
642
  }>;
600
643
  type SlateWebhookUnregisterHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
601
644
  webhookRegistrationIdentifier: string;
@@ -629,6 +672,23 @@ type SlateWebhookProcessHandler = (context: SlateContext<{}, {}, {
629
672
  interface SlateWebhookSkipped {
630
673
  reason: string;
631
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>;
632
692
  interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType extends {}> {
633
693
  intervalSeconds: number;
634
694
  pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
@@ -640,6 +700,7 @@ interface SlateTriggerGroupGatewayParameters<ConfigType extends {}, AuthType ext
640
700
  interface SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType extends {}, AuthType extends {}> {
641
701
  webhookTargetList: SlateWebhookTargetListHandler<ConfigType, AuthType>;
642
702
  webhookRegister: SlateWebhookRegisterHandler<ConfigType, AuthType>;
703
+ webhookRenew?: SlateWebhookRenewHandler<ConfigType, AuthType>;
643
704
  webhookUnregister: SlateWebhookUnregisterHandler<ConfigType, AuthType>;
644
705
  }
645
706
  interface SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>, FullConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>> {
@@ -648,10 +709,18 @@ interface SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema
648
709
  setup: SlateWebhookManualSetupHandler<FullConfigSchema>;
649
710
  finish?: SlateWebhookManualFinishHandler<UserConfigSchema, FullConfigSchema>;
650
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
+ };
651
717
  interface SlateTriggerGroupWebhookParameters<ConfigType extends {}, AuthType extends {}> {
652
718
  autoRegistration?: SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType, AuthType>;
653
719
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<any, any>;
720
+ deliveryConfig?: SlateTriggerGroupWebhookDeliveryConfigParameters<any, any>;
654
721
  process: SlateWebhookProcessHandler;
722
+ expandWebhook?: SlateWebhookExpandHandler<ConfigType, AuthType>;
723
+ reconcileIntervalSeconds?: number;
655
724
  }
656
725
  interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string, unknown>> {
657
726
  key: string;
@@ -659,6 +728,7 @@ interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string
659
728
  description?: string;
660
729
  metadata?: Record<string, any>;
661
730
  eventSchema?: z$1.ZodType<InputType>;
731
+ selectionSchema?: z$1.ZodType<SlateTriggerGroupSelection>;
662
732
  }
663
733
  interface SlateTriggerGroupParameters<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> extends SlateTriggerGroupCreateParameters<InputType> {
664
734
  source: 'polling' | 'webhook' | 'gateway';
@@ -679,6 +749,7 @@ declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, Inpu
679
749
  get metadata(): Record<string, any> | undefined;
680
750
  get eventSchema(): z$1.ZodType<InputType, unknown, z$1.core.$ZodTypeInternals<InputType, unknown>>;
681
751
  get source(): "polling" | "webhook" | "gateway";
752
+ get selectionSchema(): z$1.ZodType<SlateTriggerGroupSelection, unknown, z$1.core.$ZodTypeInternals<SlateTriggerGroupSelection, unknown>> | undefined;
682
753
  get polling(): SlateTriggerGroupPollingParameters<ConfigType, AuthType> | undefined;
683
754
  get webhook(): SlateTriggerGroupWebhookParameters<ConfigType, AuthType> | undefined;
684
755
  get gateway(): SlateTriggerGroupGatewayParameters<ConfigType, AuthType> | undefined;
@@ -697,7 +768,10 @@ declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {
697
768
  webhook<UserConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>, FullConfigSchema extends z$1.ZodType<any> = z$1.ZodType<any>>(props: {
698
769
  autoRegistration?: SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType, AuthType>;
699
770
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema, FullConfigSchema>;
771
+ deliveryConfig?: SlateTriggerGroupWebhookDeliveryConfigParameters<UserConfigSchema, FullConfigSchema>;
700
772
  process: SlateWebhookProcessHandler;
773
+ expandWebhook?: SlateWebhookExpandHandler<ConfigType, AuthType>;
774
+ reconcileIntervalSeconds?: number;
701
775
  }): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
702
776
  /** Receive events over a platform-managed persistent connection (e.g. a WebSocket gateway). */
703
777
  gateway(props: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
@@ -1000,6 +1074,8 @@ declare let isApiErrorRecord: (value: unknown) => value is Record<string, unknow
1000
1074
  declare let collectApiErrorDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
1001
1075
  declare let getApiErrorResponse: (error: unknown) => ApiErrorResponse | undefined;
1002
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;
1003
1079
  declare let getApiErrorResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
1004
1080
  declare let API_ERROR_MAX_DETAILS: number;
1005
1081
  declare let API_ERROR_MAX_MESSAGE_LENGTH: number;
@@ -1109,6 +1185,11 @@ declare class SlateDeclarationError extends SlateError {
1109
1185
  static is(error: unknown): error is SlateDeclarationError;
1110
1186
  }
1111
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
+
1112
1193
  declare let mapServiceErrorCode: (code: string, status?: number) => string;
1113
1194
  declare let isServiceErrorData: (value: unknown) => value is SlateServiceErrorData;
1114
1195
  declare let getServiceErrorData: (error: unknown) => SlateServiceErrorData | null;
@@ -1143,14 +1224,38 @@ interface VerifyHmacSignatureOptions extends CreateHmacSignatureOptions {
1143
1224
  signature: string;
1144
1225
  }
1145
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;
1146
1229
  declare let verifyHmacSignature: (options: VerifyHmacSignatureOptions) => boolean;
1147
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
+
1148
1248
  declare let getResponseHeaderValue: (headers: unknown, name: string) => string | undefined;
1149
1249
  declare let getBase64ByteLength: (contentBase64: string) => number;
1150
1250
 
1151
1251
  declare let pickDefined: <T extends object>(value: T) => Partial<T> & Record<string, unknown>;
1152
1252
  declare let setIfDefined: (target: Record<string, unknown>, key: string, value: unknown) => Record<string, unknown>;
1153
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
+
1154
1259
  declare class Slate<ConfigType extends {}, AuthType extends {}> {
1155
1260
  private readonly _spec;
1156
1261
  private readonly _actions;
@@ -1206,4 +1311,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
1206
1311
  response: Response | SlateWebhookHttpResponseInit;
1207
1312
  };
1208
1313
 
1209
- 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 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, 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 };