@zapier/kitcore 0.17.2 → 0.19.0

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.mts CHANGED
@@ -4521,7 +4521,7 @@ type SendHttpRequest = (request: HttpRequest) => ReturnType<typeof fetch>;
4521
4521
  * removes the only boundary below `initializeHttpRequest`, and a retry wrap
4522
4522
  * would then re-initialize and mint a fresh `operationId` per attempt.
4523
4523
  */
4524
- declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>;
4524
+ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>;
4525
4525
 
4526
4526
  /**
4527
4527
  * Completes the operation context: normalizes the caller's request and records
@@ -4530,6 +4530,28 @@ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", Attem
4530
4530
  */
4531
4531
  declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>;
4532
4532
 
4533
+ /**
4534
+ * Details about a retry the loop has scheduled.
4535
+ *
4536
+ * `request` preserves the caller's request-object identity so observers can
4537
+ * correlate the retry with its originating call. `delayMilliseconds` is the
4538
+ * exact delay selected by the loop.
4539
+ */
4540
+ interface RetryHttpRequestAttempt {
4541
+ request: HttpRequest;
4542
+ operationId: string;
4543
+ /** 1-based number of the attempt that just failed. */
4544
+ attemptNumber: number;
4545
+ delayMilliseconds: number;
4546
+ /**
4547
+ * The response being retried. Its body is released as soon as the observer
4548
+ * returns, so read status and headers only. Absent when the attempt threw
4549
+ * instead of answering.
4550
+ */
4551
+ response?: HttpResponse;
4552
+ /** The error the attempt threw, when `retryOnError` is on. */
4553
+ error?: unknown;
4554
+ }
4533
4555
  /**
4534
4556
  * Options for {@link retryHttpRequestPlugin}, supplied by id like every other
4535
4557
  * kitcore configuration value. Absent means the defaults below.
@@ -4537,7 +4559,13 @@ declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest",
4537
4559
  interface RetryHttpRequestOptions {
4538
4560
  /** Total attempts including the first. Default 3. */
4539
4561
  maxAttempts?: number;
4540
- /** Refuse a delay longer than this and give up instead. Default 60 seconds. */
4562
+ /**
4563
+ * Requested ceiling for a retry wait. Default 60 seconds.
4564
+ *
4565
+ * Server-specified delays above this limit stop retrying. Generated backoff
4566
+ * is capped at this value, then raised to `MIN_BACKOFF_MILLISECONDS` when
4567
+ * needed to preserve a minimum wait.
4568
+ */
4541
4569
  maxDelayMilliseconds?: number;
4542
4570
  /** Statuses to retry on an idempotent method. Default 429, 500, 502, 503, 504. */
4543
4571
  retryStatuses?: readonly number[];
@@ -4556,6 +4584,22 @@ interface RetryHttpRequestOptions {
4556
4584
  * choice rather than a default.
4557
4585
  */
4558
4586
  retryOnError?: boolean;
4587
+ /**
4588
+ * Called when the loop schedules a retry, after selecting the delay and
4589
+ * before waiting. An abort during that wait can prevent the next attempt, so
4590
+ * a reported retry is one the loop intends to send, not one it has sent.
4591
+ *
4592
+ * Reporting before the wait rather than after is the point: a consumer learns
4593
+ * about a sixty-second retry when it starts, not a minute later.
4594
+ *
4595
+ * Observability only: what it throws is swallowed, because an observer must
4596
+ * not be able to cancel a retry the loop already decided on.
4597
+ *
4598
+ * The `void` return is the contract — the loop does not wait on an observer,
4599
+ * so an `async` one runs detached and cannot delay a retry. TypeScript accepts
4600
+ * an `async` function here regardless, so a rejected promise is swallowed too.
4601
+ */
4602
+ onRetry?: (attempt: RetryHttpRequestAttempt) => void;
4559
4603
  }
4560
4604
  declare const RETRY_HTTP_REQUEST_OPTIONS_ID = "kitcore/retryHttpRequestOptions";
4561
4605
  declare const retryHttpRequestOptionsPluginRef: PropertyPlugin<"retryHttpRequestOptions", RetryHttpRequestOptions | undefined> & PluginSummary<never, never> & StandInId<"kitcore/retryHttpRequestOptions">;
@@ -4594,7 +4638,15 @@ declare const prepareHttpRequestPlugin: MethodPlugin<"prepareHttpRequest", Prepa
4594
4638
 
4595
4639
  declare const authorizeHttpRequestPlugin: MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>;
4596
4640
 
4597
- declare const dispatchHttpRequestPlugin: MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>;
4641
+ declare const HTTP_FETCH_ID = "kitcore/httpFetch";
4642
+ /**
4643
+ * Optional fetch implementation for the default dispatch stage. Keeping it a
4644
+ * property lets an SDK provide a debug wrapper or test double without using the
4645
+ * `dispatchHttpRequest` wrap slot that hosts use to replace dispatch. When
4646
+ * absent, dispatch uses `globalThis.fetch`.
4647
+ */
4648
+ declare const httpFetchPluginRef: PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">;
4649
+ declare const dispatchHttpRequestPlugin: MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>;
4598
4650
 
4599
4651
  declare const receiveHttpResponsePlugin: MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>;
4600
4652
 
@@ -4625,7 +4677,7 @@ declare const receiveHttpResponsePlugin: MethodPlugin<"receiveHttpResponse", Rec
4625
4677
  * No retry by default: with nothing composed this runs exactly one attempt.
4626
4678
  * `retryHttpRequestPlugin` is opt-in.
4627
4679
  */
4628
- declare const sendHttpRequestPlugin: MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>;
4680
+ declare const sendHttpRequestPlugin: MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>;
4629
4681
 
4630
4682
  /**
4631
4683
  * `fetch` — native `fetch(url, init)` ergonomics over the transport. It
@@ -4654,7 +4706,7 @@ declare const fetchPlugin: MethodPlugin<"fetch", {
4654
4706
  }, Promise<Response>, readonly ["url", "init"], {
4655
4707
  url: string | URL;
4656
4708
  init?: Omit<HttpRequestInput, "url">;
4657
- }> & LeafSummary<"kitcore", "fetch", readonly [MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>]>;
4709
+ }> & LeafSummary<"kitcore", "fetch", readonly [MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>]>;
4658
4710
 
4659
4711
  /**
4660
4712
  * Headers with every credential value masked, as a plain object a logger can
@@ -4722,4 +4774,4 @@ declare const normalizeConnectionPlugin: MethodPlugin<"normalizeConnection", Nor
4722
4774
  */
4723
4775
  declare const resolveConnectionPlugin: MethodPlugin<"resolveConnection", ResolveConnectionInput, string | undefined, readonly [], ResolveConnectionInput> & LeafSummary<"kitcore", "resolveConnection", readonly []>;
4724
4776
 
4725
- export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
4777
+ export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestAttempt, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
package/dist/index.d.ts CHANGED
@@ -4521,7 +4521,7 @@ type SendHttpRequest = (request: HttpRequest) => ReturnType<typeof fetch>;
4521
4521
  * removes the only boundary below `initializeHttpRequest`, and a retry wrap
4522
4522
  * would then re-initialize and mint a fresh `operationId` per attempt.
4523
4523
  */
4524
- declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>;
4524
+ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>;
4525
4525
 
4526
4526
  /**
4527
4527
  * Completes the operation context: normalizes the caller's request and records
@@ -4530,6 +4530,28 @@ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", Attem
4530
4530
  */
4531
4531
  declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>;
4532
4532
 
4533
+ /**
4534
+ * Details about a retry the loop has scheduled.
4535
+ *
4536
+ * `request` preserves the caller's request-object identity so observers can
4537
+ * correlate the retry with its originating call. `delayMilliseconds` is the
4538
+ * exact delay selected by the loop.
4539
+ */
4540
+ interface RetryHttpRequestAttempt {
4541
+ request: HttpRequest;
4542
+ operationId: string;
4543
+ /** 1-based number of the attempt that just failed. */
4544
+ attemptNumber: number;
4545
+ delayMilliseconds: number;
4546
+ /**
4547
+ * The response being retried. Its body is released as soon as the observer
4548
+ * returns, so read status and headers only. Absent when the attempt threw
4549
+ * instead of answering.
4550
+ */
4551
+ response?: HttpResponse;
4552
+ /** The error the attempt threw, when `retryOnError` is on. */
4553
+ error?: unknown;
4554
+ }
4533
4555
  /**
4534
4556
  * Options for {@link retryHttpRequestPlugin}, supplied by id like every other
4535
4557
  * kitcore configuration value. Absent means the defaults below.
@@ -4537,7 +4559,13 @@ declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest",
4537
4559
  interface RetryHttpRequestOptions {
4538
4560
  /** Total attempts including the first. Default 3. */
4539
4561
  maxAttempts?: number;
4540
- /** Refuse a delay longer than this and give up instead. Default 60 seconds. */
4562
+ /**
4563
+ * Requested ceiling for a retry wait. Default 60 seconds.
4564
+ *
4565
+ * Server-specified delays above this limit stop retrying. Generated backoff
4566
+ * is capped at this value, then raised to `MIN_BACKOFF_MILLISECONDS` when
4567
+ * needed to preserve a minimum wait.
4568
+ */
4541
4569
  maxDelayMilliseconds?: number;
4542
4570
  /** Statuses to retry on an idempotent method. Default 429, 500, 502, 503, 504. */
4543
4571
  retryStatuses?: readonly number[];
@@ -4556,6 +4584,22 @@ interface RetryHttpRequestOptions {
4556
4584
  * choice rather than a default.
4557
4585
  */
4558
4586
  retryOnError?: boolean;
4587
+ /**
4588
+ * Called when the loop schedules a retry, after selecting the delay and
4589
+ * before waiting. An abort during that wait can prevent the next attempt, so
4590
+ * a reported retry is one the loop intends to send, not one it has sent.
4591
+ *
4592
+ * Reporting before the wait rather than after is the point: a consumer learns
4593
+ * about a sixty-second retry when it starts, not a minute later.
4594
+ *
4595
+ * Observability only: what it throws is swallowed, because an observer must
4596
+ * not be able to cancel a retry the loop already decided on.
4597
+ *
4598
+ * The `void` return is the contract — the loop does not wait on an observer,
4599
+ * so an `async` one runs detached and cannot delay a retry. TypeScript accepts
4600
+ * an `async` function here regardless, so a rejected promise is swallowed too.
4601
+ */
4602
+ onRetry?: (attempt: RetryHttpRequestAttempt) => void;
4559
4603
  }
4560
4604
  declare const RETRY_HTTP_REQUEST_OPTIONS_ID = "kitcore/retryHttpRequestOptions";
4561
4605
  declare const retryHttpRequestOptionsPluginRef: PropertyPlugin<"retryHttpRequestOptions", RetryHttpRequestOptions | undefined> & PluginSummary<never, never> & StandInId<"kitcore/retryHttpRequestOptions">;
@@ -4594,7 +4638,15 @@ declare const prepareHttpRequestPlugin: MethodPlugin<"prepareHttpRequest", Prepa
4594
4638
 
4595
4639
  declare const authorizeHttpRequestPlugin: MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>;
4596
4640
 
4597
- declare const dispatchHttpRequestPlugin: MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>;
4641
+ declare const HTTP_FETCH_ID = "kitcore/httpFetch";
4642
+ /**
4643
+ * Optional fetch implementation for the default dispatch stage. Keeping it a
4644
+ * property lets an SDK provide a debug wrapper or test double without using the
4645
+ * `dispatchHttpRequest` wrap slot that hosts use to replace dispatch. When
4646
+ * absent, dispatch uses `globalThis.fetch`.
4647
+ */
4648
+ declare const httpFetchPluginRef: PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">;
4649
+ declare const dispatchHttpRequestPlugin: MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>;
4598
4650
 
4599
4651
  declare const receiveHttpResponsePlugin: MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>;
4600
4652
 
@@ -4625,7 +4677,7 @@ declare const receiveHttpResponsePlugin: MethodPlugin<"receiveHttpResponse", Rec
4625
4677
  * No retry by default: with nothing composed this runs exactly one attempt.
4626
4678
  * `retryHttpRequestPlugin` is opt-in.
4627
4679
  */
4628
- declare const sendHttpRequestPlugin: MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>;
4680
+ declare const sendHttpRequestPlugin: MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>;
4629
4681
 
4630
4682
  /**
4631
4683
  * `fetch` — native `fetch(url, init)` ergonomics over the transport. It
@@ -4654,7 +4706,7 @@ declare const fetchPlugin: MethodPlugin<"fetch", {
4654
4706
  }, Promise<Response>, readonly ["url", "init"], {
4655
4707
  url: string | URL;
4656
4708
  init?: Omit<HttpRequestInput, "url">;
4657
- }> & LeafSummary<"kitcore", "fetch", readonly [MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>]>;
4709
+ }> & LeafSummary<"kitcore", "fetch", readonly [MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly [], HttpRequestInput> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly [], AttemptHttpRequestInput> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly [], PrepareHttpRequestInput> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly [], AuthorizeHttpRequestInput> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly [], DispatchHttpRequestInput> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly [PropertyPlugin<"httpFetch", typeof fetch | undefined> & PluginSummary<never, never> & StandInId<"kitcore/httpFetch">]>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly [], ReceiveHttpResponseInput> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>]>;
4658
4710
 
4659
4711
  /**
4660
4712
  * Headers with every credential value masked, as a plain object a logger can
@@ -4722,4 +4774,4 @@ declare const normalizeConnectionPlugin: MethodPlugin<"normalizeConnection", Nor
4722
4774
  */
4723
4775
  declare const resolveConnectionPlugin: MethodPlugin<"resolveConnection", ResolveConnectionInput, string | undefined, readonly [], ResolveConnectionInput> & LeafSummary<"kitcore", "resolveConnection", readonly []>;
4724
4776
 
4725
- export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
4777
+ export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestAttempt, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
package/dist/index.mjs CHANGED
@@ -643,6 +643,11 @@ function toIterable(source) {
643
643
  return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
644
644
  }
645
645
 
646
+ // src/utils/promise-utils.ts
647
+ function isPromiseLike(value) {
648
+ return value !== null && typeof value === "object" && typeof value.then === "function";
649
+ }
650
+
646
651
  // src/utils/validation.ts
647
652
  var parseOrThrow = (schema, input, { adaptError } = {}) => {
648
653
  const result = schema.safeParse(input);
@@ -1111,7 +1116,7 @@ function createRawFunction(coreFn, options) {
1111
1116
  try {
1112
1117
  const parsed = schema ? validateOptions(schema, input, { adaptError }) : input;
1113
1118
  const result = coreFn(parsed, context);
1114
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
1119
+ if (isPromiseLike(result)) {
1115
1120
  return result.then(
1116
1121
  (value) => {
1117
1122
  fireEnd();
@@ -2443,9 +2448,6 @@ function applyListOutputPolicy(page, policy) {
2443
2448
  var FRAMEWORK_CONFIGURATION_IDS = /* @__PURE__ */ new Set([
2444
2449
  CORE_OPTIONS_ID
2445
2450
  ]);
2446
- function isPromiseLike(value) {
2447
- return value !== null && typeof value === "object" && typeof value.then === "function";
2448
- }
2449
2451
  function normalizeOutput(output) {
2450
2452
  if (output === void 0) return { type: "raw" };
2451
2453
  if (typeof output === "string") return { type: output };
@@ -4816,6 +4818,8 @@ var authorizeHttpRequestPlugin = defineMethod({
4816
4818
 
4817
4819
  // src/transport/dispatch-http-request.ts
4818
4820
  import { z as z7 } from "zod";
4821
+ var HTTP_FETCH_ID = "kitcore/httpFetch";
4822
+ var httpFetchPluginRef = declareOptionalProperty({ id: HTTP_FETCH_ID });
4819
4823
  function toFetchInput(request) {
4820
4824
  const init = { ...request };
4821
4825
  const { url } = request;
@@ -4826,11 +4830,12 @@ function toFetchInput(request) {
4826
4830
  var dispatchHttpRequestPlugin = defineMethod({
4827
4831
  name: "dispatchHttpRequest",
4828
4832
  namespace: "kitcore",
4833
+ imports: [httpFetchPluginRef],
4829
4834
  inputSchema: z7.custom(),
4830
4835
  skipInputValidation: true,
4831
- run: async ({ input }) => {
4836
+ run: async ({ input, imports }) => {
4832
4837
  const { url, init } = toFetchInput(input.request);
4833
- return fetch(url, init);
4838
+ return (imports.httpFetch ?? fetch)(url, init);
4834
4839
  }
4835
4840
  });
4836
4841
 
@@ -4929,6 +4934,7 @@ var DEFAULT_IDEMPOTENT_METHODS = [
4929
4934
  "TRACE"
4930
4935
  ];
4931
4936
  var BASE_BACKOFF_MILLISECONDS = 1e3;
4937
+ var MIN_BACKOFF_MILLISECONDS = 100;
4932
4938
  var JITTER_FACTOR = 0.5;
4933
4939
  var EPOCH_THRESHOLD_SECONDS = 1e9;
4934
4940
  function directedDelayMilliseconds(response) {
@@ -4953,6 +4959,12 @@ function backoffMilliseconds(attemptNumber) {
4953
4959
  const base = BASE_BACKOFF_MILLISECONDS * 2 ** (attemptNumber - 1);
4954
4960
  return base + Math.random() * JITTER_FACTOR * base;
4955
4961
  }
4962
+ function clampBackoffMilliseconds(attemptNumber, maxDelayMilliseconds) {
4963
+ return Math.max(
4964
+ Math.min(backoffMilliseconds(attemptNumber), maxDelayMilliseconds),
4965
+ MIN_BACKOFF_MILLISECONDS
4966
+ );
4967
+ }
4956
4968
  function abortReason(signal) {
4957
4969
  const reason = signal?.reason;
4958
4970
  return reason ?? new Error("The request was aborted.");
@@ -4987,6 +4999,20 @@ var retryHttpRequestPlugin = defineHook({
4987
4999
  const maxDelayMilliseconds = options.maxDelayMilliseconds ?? DEFAULT_MAX_DELAY_MILLISECONDS;
4988
5000
  const idempotentMethods = options.idempotentMethods ?? DEFAULT_IDEMPOTENT_METHODS;
4989
5001
  const statuses = isIdempotent(input.request, idempotentMethods) ? options.retryStatuses ?? DEFAULT_RETRY_STATUSES : options.nonIdempotentRetryStatuses ?? DEFAULT_NON_IDEMPOTENT_RETRY_STATUSES;
5002
+ const notifyRetry = (notice) => {
5003
+ try {
5004
+ const observed = options.onRetry?.({
5005
+ ...notice,
5006
+ request: input.attempt.operation.request,
5007
+ operationId: input.attempt.operation.operationId
5008
+ });
5009
+ if (isPromiseLike(observed)) {
5010
+ void observed.then(void 0, () => {
5011
+ });
5012
+ }
5013
+ } catch {
5014
+ }
5015
+ };
4990
5016
  for (let attemptNumber = 1; ; attemptNumber++) {
4991
5017
  const attempt = {
4992
5018
  ...input.attempt,
@@ -5008,10 +5034,16 @@ var retryHttpRequestPlugin = defineHook({
5008
5034
  )) {
5009
5035
  throw error;
5010
5036
  }
5011
- await sleep(
5012
- Math.min(backoffMilliseconds(attemptNumber), maxDelayMilliseconds),
5013
- attempt.signal
5037
+ const errorDelay = clampBackoffMilliseconds(
5038
+ attemptNumber,
5039
+ maxDelayMilliseconds
5014
5040
  );
5041
+ notifyRetry({
5042
+ attemptNumber,
5043
+ delayMilliseconds: errorDelay,
5044
+ error
5045
+ });
5046
+ await sleep(errorDelay, attempt.signal);
5015
5047
  continue;
5016
5048
  }
5017
5049
  if (!statuses.includes(response.status) || !canRetry(
@@ -5024,10 +5056,8 @@ var retryHttpRequestPlugin = defineHook({
5024
5056
  const directed = directedDelayMilliseconds(response);
5025
5057
  if (directed != null && directed > maxDelayMilliseconds)
5026
5058
  return response;
5027
- const delay = Math.min(
5028
- directed ?? backoffMilliseconds(attemptNumber),
5029
- maxDelayMilliseconds
5030
- );
5059
+ const delay = directed ?? clampBackoffMilliseconds(attemptNumber, maxDelayMilliseconds);
5060
+ notifyRetry({ attemptNumber, delayMilliseconds: delay, response });
5031
5061
  await response.body?.cancel().catch(() => {
5032
5062
  });
5033
5063
  await sleep(delay, attempt.signal);
@@ -5182,6 +5212,7 @@ export {
5182
5212
  CoreError,
5183
5213
  CoreErrorCode,
5184
5214
  CoreSignal,
5215
+ HTTP_FETCH_ID,
5185
5216
  RETRY_HTTP_REQUEST_OPTIONS_ID,
5186
5217
  STABILITY_LEVELS,
5187
5218
  STABILITY_TITLES,
@@ -5242,6 +5273,7 @@ export {
5242
5273
  getRegistry,
5243
5274
  getRegistryPlugin,
5244
5275
  getSchemaDescription,
5276
+ httpFetchPluginRef,
5245
5277
  initializeHttpRequestPlugin,
5246
5278
  isCoreCancelledSignal,
5247
5279
  isCoreError,