@slates/provider 1.0.0-rc.27 → 1.0.0-rc.29

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.d.cts CHANGED
@@ -41,24 +41,35 @@ declare let createTextAttachment: (content: string, mimeType?: string, attachmen
41
41
  * the hub resolves these placeholders back to live secret values when it proxies an attachment.
42
42
  */
43
43
  declare let AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX: string;
44
+ /** Decides whether an auth-config value (with its dotted path) may be replaced. */
45
+ type AuthConfigSecretFilter = (secret: string, path: string) => boolean;
44
46
  /**
45
47
  * Maps auth-config string leaves to `$$MT$secret$authConfig$<path>` placeholders.
46
48
  * `redact` preserves whole-value substitution for HTTP traces; `redactEmbedded` also
47
49
  * replaces embedded values in attachment credentials, terminating those placeholders with `$$`.
50
+ * Both accept a `wholeValue` filter so diagnostics (traces, error text) can skip
51
+ * non-secret fields such as account IDs, emails, or subdomains; attachment callers keep
52
+ * the default, because the hub resolves every placeholder back to its value.
48
53
  */
49
54
  declare class AuthConfigSecretRedactor {
50
- private readonly secretToPlaceholder;
55
+ private readonly secretToPaths;
51
56
  constructor(authConfig: Record<string, unknown> | undefined);
52
- redact<T>(value: T): T;
53
- redactEmbedded<T>(value: T): T;
57
+ redact<T>(value: T, wholeValue?: AuthConfigSecretFilter): T;
58
+ /**
59
+ * `embeddable` limits which secrets are also replaced inside longer strings;
60
+ * `wholeValue` limits which secrets replace a string that equals them exactly.
61
+ */
62
+ redactEmbedded<T>(value: T, embeddable?: AuthConfigSecretFilter, wholeValue?: AuthConfigSecretFilter): T;
63
+ private placeholderFor;
54
64
  private buildSecretMap;
55
65
  private transform;
56
66
  private isPlainObject;
57
67
  }
68
+ declare let isUrlEmbeddedCredential: (secret: string, path: string) => boolean;
58
69
  /**
59
70
  * Applied to every finalized attachment list right before it's sent over
60
71
  * `slates/action.tool.invoke` (see @slates/provider-handler). Only `type: 'url'` attachments
61
- * carry headers/query -- content/upload_reference attachments pass through untouched.
72
+ * carry credentials -- content/upload_reference attachments pass through untouched.
62
73
  */
63
74
  declare let redactUrlAttachmentSecrets: (attachments: SlateAttachment[] | undefined, authConfig: Record<string, unknown> | undefined) => SlateAttachment[] | undefined;
64
75
 
@@ -523,6 +534,41 @@ type SlateTriggerGroupPollHandler<ConfigType extends {}, AuthType extends {}> =
523
534
  }[];
524
535
  updatedState?: any;
525
536
  }>;
537
+ interface SlateGatewayEvent {
538
+ payload: any;
539
+ idempotencyKey?: string;
540
+ }
541
+ type SlateTriggerGroupGatewayConnectHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
542
+ state: any | null;
543
+ }>) => Promise<{
544
+ url: string;
545
+ state?: any;
546
+ }>;
547
+ /** `closed` is set, with no frames, when the socket closed unexpectedly. */
548
+ type SlateTriggerGroupGatewayReceiveHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
549
+ state: any | null;
550
+ frames: string[];
551
+ closed?: {
552
+ code: number;
553
+ reason: string;
554
+ } | null;
555
+ }>) => Promise<{
556
+ state?: any;
557
+ send?: string[];
558
+ events?: SlateGatewayEvent[];
559
+ /** With `expectsAck`, the hub reconnects when no `heartbeatAcked` arrives before the next beat. */
560
+ heartbeat?: {
561
+ intervalMs: number;
562
+ frame: string;
563
+ expectsAck?: boolean;
564
+ } | null;
565
+ /** Set when `frames` included the provider's heartbeat acknowledgement. */
566
+ heartbeatAcked?: boolean;
567
+ close?: {
568
+ reconnect: boolean;
569
+ reason?: string;
570
+ } | null;
571
+ }>;
526
572
  type SlateWebhookTargetListHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
527
573
  pageToken: any | null;
528
574
  }>) => Promise<{
@@ -574,6 +620,10 @@ interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType ext
574
620
  intervalSeconds: number;
575
621
  pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
576
622
  }
623
+ interface SlateTriggerGroupGatewayParameters<ConfigType extends {}, AuthType extends {}> {
624
+ connect: SlateTriggerGroupGatewayConnectHandler<ConfigType, AuthType>;
625
+ receive: SlateTriggerGroupGatewayReceiveHandler<ConfigType, AuthType>;
626
+ }
577
627
  interface SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType extends {}, AuthType extends {}> {
578
628
  webhookTargetList: SlateWebhookTargetListHandler<ConfigType, AuthType>;
579
629
  webhookRegister: SlateWebhookRegisterHandler<ConfigType, AuthType>;
@@ -598,9 +648,10 @@ interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string
598
648
  eventSchema?: z$1.ZodType<InputType>;
599
649
  }
600
650
  interface SlateTriggerGroupParameters<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> extends SlateTriggerGroupCreateParameters<InputType> {
601
- source: 'polling' | 'webhook';
651
+ source: 'polling' | 'webhook' | 'gateway';
602
652
  polling?: SlateTriggerGroupPollingParameters<ConfigType, AuthType>;
603
653
  webhook?: SlateTriggerGroupWebhookParameters<ConfigType, AuthType>;
654
+ gateway?: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>;
604
655
  routingMatchers: SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>;
605
656
  }
606
657
  declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> {
@@ -614,9 +665,10 @@ declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, Inpu
614
665
  get description(): string | undefined;
615
666
  get metadata(): Record<string, any> | undefined;
616
667
  get eventSchema(): z$1.ZodType<InputType, unknown, z$1.core.$ZodTypeInternals<InputType, unknown>>;
617
- get source(): "polling" | "webhook";
668
+ get source(): "polling" | "webhook" | "gateway";
618
669
  get polling(): SlateTriggerGroupPollingParameters<ConfigType, AuthType> | undefined;
619
670
  get webhook(): SlateTriggerGroupWebhookParameters<ConfigType, AuthType> | undefined;
671
+ get gateway(): SlateTriggerGroupGatewayParameters<ConfigType, AuthType> | undefined;
620
672
  get routingMatchers(): SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>;
621
673
  }
622
674
  declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> {
@@ -634,6 +686,8 @@ declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {
634
686
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema, FullConfigSchema>;
635
687
  process: SlateWebhookProcessHandler;
636
688
  }): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
689
+ /** Receive events over a platform-managed persistent connection (e.g. a WebSocket gateway). */
690
+ gateway(props: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
637
691
  routingMatchers(handler: SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
638
692
  build(): SlateTriggerGroup<ConfigType, AuthType, InputType>;
639
693
  }
@@ -887,6 +941,7 @@ type ApiErrorBuildHelpers = {
887
941
  collectDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
888
942
  extractMessage: (error: unknown, options?: ApiErrorDetailOptions) => string;
889
943
  getResponse: (error: unknown) => ApiErrorResponse | undefined;
944
+ getResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
890
945
  getStatus: (error: unknown) => ApiErrorStatus | undefined;
891
946
  isRecord: (value: unknown) => value is Record<string, unknown>;
892
947
  statusLabelFor: (status?: ApiErrorStatus, statusText?: string) => string;
@@ -913,6 +968,25 @@ declare let isApiErrorRecord: (value: unknown) => value is Record<string, unknow
913
968
  declare let collectApiErrorDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
914
969
  declare let getApiErrorResponse: (error: unknown) => ApiErrorResponse | undefined;
915
970
  declare let getApiErrorStatus: (error: unknown) => ApiErrorStatus | undefined;
971
+ declare let getApiErrorResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
972
+ declare let API_ERROR_MAX_DETAILS: number;
973
+ declare let API_ERROR_MAX_MESSAGE_LENGTH: number;
974
+ declare let API_ERROR_TRUNCATED_PLACEHOLDER: string;
975
+ declare let looksLikeHtmlErrorBody: (value: string) => boolean;
976
+ declare let truncateApiErrorMessage: (value: string, maxLength?: number) => string;
977
+ type ApiErrorTextOptions = {
978
+ includeNumbers?: boolean;
979
+ };
980
+ declare let readApiErrorText: (value: unknown, options?: ApiErrorTextOptions) => string | undefined;
981
+ type BoundedApiErrorDetailOptions = ApiErrorTextOptions & {
982
+ maxDetails?: number;
983
+ field?: string;
984
+ };
985
+ declare let pushBoundedApiErrorDetail: (details: string[], value: unknown, options?: BoundedApiErrorDetailOptions) => void;
986
+ type DecodeApiErrorBodyOptions = {
987
+ maxBytes?: number;
988
+ };
989
+ declare let decodeApiErrorBody: (data: unknown, options?: DecodeApiErrorBodyOptions) => unknown;
916
990
  declare let statusLabelForApiError: (status?: ApiErrorStatus, statusText?: string) => string;
917
991
  declare let extractApiErrorMessage: (error: unknown, options?: ApiErrorDetailOptions & {
918
992
  response?: ApiErrorResponse;
@@ -923,7 +997,7 @@ declare let createApiServiceError: (message: string, options?: {
923
997
  upstreamCode?: string;
924
998
  parent?: unknown;
925
999
  }) => ServiceError<ErrorRecord<"bad_request", 400>>;
926
- declare let buildApiServiceError: (error: unknown, options: BuildApiServiceErrorOptions) => ServiceError<ErrorRecord<"bad_request", 400>>;
1000
+ declare let buildApiServiceError: (error: unknown, options: BuildApiServiceErrorOptions) => ServiceError<any>;
927
1001
 
928
1002
  declare class SlateError extends Error {
929
1003
  cause?: unknown;
@@ -1094,4 +1168,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
1094
1168
  response: Response | SlateWebhookHttpResponseInit;
1095
1169
  };
1096
1170
 
1097
- export { AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, AuthConfigSecretRedactor, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, 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 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, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, 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, extractApiErrorMessage, getApiErrorResponse, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, trigger, triggerGroup, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
1171
+ 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, 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, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
package/dist/index.d.ts CHANGED
@@ -41,24 +41,35 @@ declare let createTextAttachment: (content: string, mimeType?: string, attachmen
41
41
  * the hub resolves these placeholders back to live secret values when it proxies an attachment.
42
42
  */
43
43
  declare let AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX: string;
44
+ /** Decides whether an auth-config value (with its dotted path) may be replaced. */
45
+ type AuthConfigSecretFilter = (secret: string, path: string) => boolean;
44
46
  /**
45
47
  * Maps auth-config string leaves to `$$MT$secret$authConfig$<path>` placeholders.
46
48
  * `redact` preserves whole-value substitution for HTTP traces; `redactEmbedded` also
47
49
  * replaces embedded values in attachment credentials, terminating those placeholders with `$$`.
50
+ * Both accept a `wholeValue` filter so diagnostics (traces, error text) can skip
51
+ * non-secret fields such as account IDs, emails, or subdomains; attachment callers keep
52
+ * the default, because the hub resolves every placeholder back to its value.
48
53
  */
49
54
  declare class AuthConfigSecretRedactor {
50
- private readonly secretToPlaceholder;
55
+ private readonly secretToPaths;
51
56
  constructor(authConfig: Record<string, unknown> | undefined);
52
- redact<T>(value: T): T;
53
- redactEmbedded<T>(value: T): T;
57
+ redact<T>(value: T, wholeValue?: AuthConfigSecretFilter): T;
58
+ /**
59
+ * `embeddable` limits which secrets are also replaced inside longer strings;
60
+ * `wholeValue` limits which secrets replace a string that equals them exactly.
61
+ */
62
+ redactEmbedded<T>(value: T, embeddable?: AuthConfigSecretFilter, wholeValue?: AuthConfigSecretFilter): T;
63
+ private placeholderFor;
54
64
  private buildSecretMap;
55
65
  private transform;
56
66
  private isPlainObject;
57
67
  }
68
+ declare let isUrlEmbeddedCredential: (secret: string, path: string) => boolean;
58
69
  /**
59
70
  * Applied to every finalized attachment list right before it's sent over
60
71
  * `slates/action.tool.invoke` (see @slates/provider-handler). Only `type: 'url'` attachments
61
- * carry headers/query -- content/upload_reference attachments pass through untouched.
72
+ * carry credentials -- content/upload_reference attachments pass through untouched.
62
73
  */
63
74
  declare let redactUrlAttachmentSecrets: (attachments: SlateAttachment[] | undefined, authConfig: Record<string, unknown> | undefined) => SlateAttachment[] | undefined;
64
75
 
@@ -523,6 +534,41 @@ type SlateTriggerGroupPollHandler<ConfigType extends {}, AuthType extends {}> =
523
534
  }[];
524
535
  updatedState?: any;
525
536
  }>;
537
+ interface SlateGatewayEvent {
538
+ payload: any;
539
+ idempotencyKey?: string;
540
+ }
541
+ type SlateTriggerGroupGatewayConnectHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
542
+ state: any | null;
543
+ }>) => Promise<{
544
+ url: string;
545
+ state?: any;
546
+ }>;
547
+ /** `closed` is set, with no frames, when the socket closed unexpectedly. */
548
+ type SlateTriggerGroupGatewayReceiveHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
549
+ state: any | null;
550
+ frames: string[];
551
+ closed?: {
552
+ code: number;
553
+ reason: string;
554
+ } | null;
555
+ }>) => Promise<{
556
+ state?: any;
557
+ send?: string[];
558
+ events?: SlateGatewayEvent[];
559
+ /** With `expectsAck`, the hub reconnects when no `heartbeatAcked` arrives before the next beat. */
560
+ heartbeat?: {
561
+ intervalMs: number;
562
+ frame: string;
563
+ expectsAck?: boolean;
564
+ } | null;
565
+ /** Set when `frames` included the provider's heartbeat acknowledgement. */
566
+ heartbeatAcked?: boolean;
567
+ close?: {
568
+ reconnect: boolean;
569
+ reason?: string;
570
+ } | null;
571
+ }>;
526
572
  type SlateWebhookTargetListHandler<ConfigType extends {}, AuthType extends {}> = (context: SlateContext<ConfigType, AuthType, {
527
573
  pageToken: any | null;
528
574
  }>) => Promise<{
@@ -574,6 +620,10 @@ interface SlateTriggerGroupPollingParameters<ConfigType extends {}, AuthType ext
574
620
  intervalSeconds: number;
575
621
  pollEvents: SlateTriggerGroupPollHandler<ConfigType, AuthType>;
576
622
  }
623
+ interface SlateTriggerGroupGatewayParameters<ConfigType extends {}, AuthType extends {}> {
624
+ connect: SlateTriggerGroupGatewayConnectHandler<ConfigType, AuthType>;
625
+ receive: SlateTriggerGroupGatewayReceiveHandler<ConfigType, AuthType>;
626
+ }
577
627
  interface SlateTriggerGroupWebhookAutoRegistrationParameters<ConfigType extends {}, AuthType extends {}> {
578
628
  webhookTargetList: SlateWebhookTargetListHandler<ConfigType, AuthType>;
579
629
  webhookRegister: SlateWebhookRegisterHandler<ConfigType, AuthType>;
@@ -598,9 +648,10 @@ interface SlateTriggerGroupCreateParameters<InputType extends {} = Record<string
598
648
  eventSchema?: z$1.ZodType<InputType>;
599
649
  }
600
650
  interface SlateTriggerGroupParameters<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> extends SlateTriggerGroupCreateParameters<InputType> {
601
- source: 'polling' | 'webhook';
651
+ source: 'polling' | 'webhook' | 'gateway';
602
652
  polling?: SlateTriggerGroupPollingParameters<ConfigType, AuthType>;
603
653
  webhook?: SlateTriggerGroupWebhookParameters<ConfigType, AuthType>;
654
+ gateway?: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>;
604
655
  routingMatchers: SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>;
605
656
  }
606
657
  declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> {
@@ -614,9 +665,10 @@ declare class SlateTriggerGroup<ConfigType extends {}, AuthType extends {}, Inpu
614
665
  get description(): string | undefined;
615
666
  get metadata(): Record<string, any> | undefined;
616
667
  get eventSchema(): z$1.ZodType<InputType, unknown, z$1.core.$ZodTypeInternals<InputType, unknown>>;
617
- get source(): "polling" | "webhook";
668
+ get source(): "polling" | "webhook" | "gateway";
618
669
  get polling(): SlateTriggerGroupPollingParameters<ConfigType, AuthType> | undefined;
619
670
  get webhook(): SlateTriggerGroupWebhookParameters<ConfigType, AuthType> | undefined;
671
+ get gateway(): SlateTriggerGroupGatewayParameters<ConfigType, AuthType> | undefined;
620
672
  get routingMatchers(): SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>;
621
673
  }
622
674
  declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {}, InputType extends {} = Record<string, unknown>> {
@@ -634,6 +686,8 @@ declare class SlateTriggerGroupBuilder<ConfigType extends {}, AuthType extends {
634
686
  manualRegistration?: SlateTriggerGroupWebhookManualRegistrationParameters<UserConfigSchema, FullConfigSchema>;
635
687
  process: SlateWebhookProcessHandler;
636
688
  }): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
689
+ /** Receive events over a platform-managed persistent connection (e.g. a WebSocket gateway). */
690
+ gateway(props: SlateTriggerGroupGatewayParameters<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
637
691
  routingMatchers(handler: SlateTriggerGroupRoutingMatchersHandler<ConfigType, AuthType>): SlateTriggerGroupBuilder<ConfigType, AuthType, InputType>;
638
692
  build(): SlateTriggerGroup<ConfigType, AuthType, InputType>;
639
693
  }
@@ -887,6 +941,7 @@ type ApiErrorBuildHelpers = {
887
941
  collectDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
888
942
  extractMessage: (error: unknown, options?: ApiErrorDetailOptions) => string;
889
943
  getResponse: (error: unknown) => ApiErrorResponse | undefined;
944
+ getResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
890
945
  getStatus: (error: unknown) => ApiErrorStatus | undefined;
891
946
  isRecord: (value: unknown) => value is Record<string, unknown>;
892
947
  statusLabelFor: (status?: ApiErrorStatus, statusText?: string) => string;
@@ -913,6 +968,25 @@ declare let isApiErrorRecord: (value: unknown) => value is Record<string, unknow
913
968
  declare let collectApiErrorDetails: (value: unknown, details: string[], options?: ApiErrorDetailOptions) => void;
914
969
  declare let getApiErrorResponse: (error: unknown) => ApiErrorResponse | undefined;
915
970
  declare let getApiErrorStatus: (error: unknown) => ApiErrorStatus | undefined;
971
+ declare let getApiErrorResponseWithBody: (error: unknown) => ApiErrorResponse | undefined;
972
+ declare let API_ERROR_MAX_DETAILS: number;
973
+ declare let API_ERROR_MAX_MESSAGE_LENGTH: number;
974
+ declare let API_ERROR_TRUNCATED_PLACEHOLDER: string;
975
+ declare let looksLikeHtmlErrorBody: (value: string) => boolean;
976
+ declare let truncateApiErrorMessage: (value: string, maxLength?: number) => string;
977
+ type ApiErrorTextOptions = {
978
+ includeNumbers?: boolean;
979
+ };
980
+ declare let readApiErrorText: (value: unknown, options?: ApiErrorTextOptions) => string | undefined;
981
+ type BoundedApiErrorDetailOptions = ApiErrorTextOptions & {
982
+ maxDetails?: number;
983
+ field?: string;
984
+ };
985
+ declare let pushBoundedApiErrorDetail: (details: string[], value: unknown, options?: BoundedApiErrorDetailOptions) => void;
986
+ type DecodeApiErrorBodyOptions = {
987
+ maxBytes?: number;
988
+ };
989
+ declare let decodeApiErrorBody: (data: unknown, options?: DecodeApiErrorBodyOptions) => unknown;
916
990
  declare let statusLabelForApiError: (status?: ApiErrorStatus, statusText?: string) => string;
917
991
  declare let extractApiErrorMessage: (error: unknown, options?: ApiErrorDetailOptions & {
918
992
  response?: ApiErrorResponse;
@@ -923,7 +997,7 @@ declare let createApiServiceError: (message: string, options?: {
923
997
  upstreamCode?: string;
924
998
  parent?: unknown;
925
999
  }) => ServiceError<ErrorRecord<"bad_request", 400>>;
926
- declare let buildApiServiceError: (error: unknown, options: BuildApiServiceErrorOptions) => ServiceError<ErrorRecord<"bad_request", 400>>;
1000
+ declare let buildApiServiceError: (error: unknown, options: BuildApiServiceErrorOptions) => ServiceError<any>;
927
1001
 
928
1002
  declare class SlateError extends Error {
929
1003
  cause?: unknown;
@@ -1094,4 +1168,4 @@ declare let skipWebhook: (reason: string, response?: Response | SlateWebhookHttp
1094
1168
  response: Response | SlateWebhookHttpResponseInit;
1095
1169
  };
1096
1170
 
1097
- export { AUTH_CONFIG_SECRET_PLACEHOLDER_PREFIX, type ApiErrorBuildHelpers, type ApiErrorDetailOptions, type ApiErrorResponse, type ApiErrorStatus, type ApiServiceError, AuthConfigSecretRedactor, type BuildApiServiceErrorOptions, type CreateHmacSignatureOptions, 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 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, type SlateToolInvocationHandler, type SlateToolParameters, SlateTrigger, SlateTriggerGroup, SlateTriggerGroupBuilder, type SlateTriggerGroupCreateParameters, 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, extractApiErrorMessage, getApiErrorResponse, getApiErrorStatus, getBase64ByteLength, getCurrentContext, getFileUrlTool, getFileUrlToolInputSchema, getFileUrlToolOutputSchema, getGraphWebhookValidationResponse, getMetaWebhookVerificationResponse, getOAuthExpiresAtFromExpiresIn, getResponseHeaderValue, getServiceErrorData, graphWebhookHttp, inferSlateErrorFromAxios, isApiErrorRecord, isAxiosErrorLike, isServiceErrorData, mapServiceErrorCode, mapServiceErrorToSlateErrorInput, mergeScopes, metaWebhookHttp, normalizeOAuthTokenResponse, pickDefined, publicTool, redactUrlAttachmentSecrets, requestAxios, requestAxiosData, runWithContext, scopeClause, setIfDefined, skipWebhook, spec, statusLabelForApiError, tool, trigger, triggerGroup, uploadAttachmentDirect, validateScopes, verifyHmacSignature };
1171
+ 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, 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, trigger, triggerGroup, truncateApiErrorMessage, uploadAttachmentDirect, validateScopes, verifyHmacSignature };