@zapier/kitcore 0.13.0 → 0.15.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.ts CHANGED
@@ -222,6 +222,72 @@ interface MethodHooks {
222
222
  annotator?: ComposedAnnotator;
223
223
  }
224
224
 
225
+ /**
226
+ * API stability tiers.
227
+ *
228
+ * A plugin declares exactly one level via `PluginMeta.stability`; tier
229
+ * membership (which subpath aggregate exports the plugin) is structural,
230
+ * so nothing here compares levels ordinally. The array is the single
231
+ * source of truth: it derives the {@link StabilityLevel} type, gives the
232
+ * ladder tests their adjacent-tier iteration order, and gives docs a
233
+ * render order.
234
+ */
235
+ declare const STABILITY_LEVELS: readonly ["stable", "beta", "experimental"];
236
+ type StabilityLevel = (typeof STABILITY_LEVELS)[number];
237
+ /**
238
+ * Title-case display names for each level, for section-level badges in
239
+ * generated docs (e.g. `Code Workflows (Beta)`). Inline description
240
+ * labels go through {@link applyStabilityLabel} instead.
241
+ */
242
+ declare const STABILITY_TITLES: {
243
+ readonly stable: "Stable";
244
+ readonly beta: "Beta";
245
+ readonly experimental: "Experimental";
246
+ };
247
+ /**
248
+ * Normalize authored meta to a concrete level: absent means `"stable"`,
249
+ * and the deprecated `experimental: true` boolean means `"experimental"`.
250
+ * The registry projection runs every entry through this, so
251
+ * `FunctionRegistryEntry.stability` is always concrete and consumers
252
+ * never branch on `undefined`.
253
+ *
254
+ * The declared value can cross a JSON boundary from a hand-written
255
+ * plugin, so at runtime it may be any string. An unrecognized level
256
+ * clamps to `"experimental"` — the author declared the method not
257
+ * stable, and clamping keeps the raw string out of notices and labels.
258
+ * It doesn't throw because this also runs in the `getStability` live
259
+ * read on the call path, where a throw would break the observed call.
260
+ */
261
+ declare function normalizeStability(meta: {
262
+ stability?: StabilityLevel;
263
+ experimental?: boolean;
264
+ }): StabilityLevel;
265
+ /**
266
+ * The shared label renderer: every consumer that renders a registry
267
+ * entry's description (CLI help, MCP tool descriptions) labels it
268
+ * through this function, so a new consumer cannot silently drop the
269
+ * label. `stability` stays structured data on the registry entry — the
270
+ * label is applied at render time, never baked into the stored
271
+ * description (docs badge at the section level, so baking it in would
272
+ * double-badge).
273
+ *
274
+ * The label follows the plugin's declared level, not the subpath that
275
+ * surfaced it: a beta method surfaced through an experimental-tier
276
+ * consumer still reads "(beta)".
277
+ */
278
+ declare function applyStabilityLabel({ description, stability, placement, }: {
279
+ description: string;
280
+ /** Absent means stable (the value may arrive from outside the
281
+ * normalized registry projection, e.g. hand-built JSON). */
282
+ stability: StabilityLevel | undefined;
283
+ /**
284
+ * `"suffix"` renders `<description> (beta)` (CLI help);
285
+ * `"prefix"` renders `[Beta] <description>` (MCP tool descriptions,
286
+ * where the front of the string is what an LLM reads first).
287
+ */
288
+ placement?: "suffix" | "prefix";
289
+ }): string;
290
+
225
291
  /**
226
292
  * Plugins with a required-parameter rename declare two schemas: a canonical one
227
293
  * (new names only, carrying `.meta({ aliases })`) and a `z.union([canonical,
@@ -562,6 +628,8 @@ interface LeafMetaFields {
562
628
  * off the registry / CLI / MCP surface, exactly like `skipInputValidation`. */
563
629
  skipOutputValidation?: boolean;
564
630
  packages?: string[];
631
+ stability?: StabilityLevel;
632
+ /** @deprecated Use `stability: "experimental"` instead. */
565
633
  experimental?: boolean;
566
634
  confirm?: "create-secret" | "delete";
567
635
  deprecation?: FunctionDeprecation;
@@ -1748,8 +1816,17 @@ interface FunctionRegistryEntry {
1748
1816
  resolvers?: Record<string, BoundResolver>;
1749
1817
  packages?: string[];
1750
1818
  /**
1751
- * True if the plugin is registered only in the experimental SDK
1752
- * factory. See `PluginMeta.experimental`.
1819
+ * API stability tier of the plugin, normalized from `PluginMeta.stability`
1820
+ * (absent means `"stable"`; the legacy `experimental: true` boolean means
1821
+ * `"experimental"`). Always concrete here, so consumers never branch on
1822
+ * `undefined`.
1823
+ */
1824
+ stability: StabilityLevel;
1825
+ /**
1826
+ * @deprecated Read `stability` instead. Derived as
1827
+ * `stability === "experimental"` — literal by name, so beta reads
1828
+ * `false`; the not-stable warning duty lives in `stability` and the
1829
+ * runtime stability notice.
1753
1830
  */
1754
1831
  experimental?: boolean;
1755
1832
  /** Confirmation prompt type - prompts user before executing */
@@ -1845,10 +1922,19 @@ interface PluginMeta<TSdk = unknown> {
1845
1922
  /** Confirmation prompt type - prompts user before executing */
1846
1923
  confirm?: "create-secret" | "delete";
1847
1924
  /**
1848
- * Marks this plugin as experimental wrappers can keep it out of
1849
- * their stable build (typically by gating it behind an
1850
- * `experimental` subpath import) and the registry can badge it in
1851
- * generated docs / CLI help. No runtime capability check.
1925
+ * API stability tier this plugin belongs to. Absent means `"stable"`;
1926
+ * the registry projection normalizes it, so registry consumers always
1927
+ * read a concrete {@link StabilityLevel}. Wrappers keep non-stable
1928
+ * plugins out of their stable build (by gating them behind a `beta` /
1929
+ * `experimental` subpath import) and consumers badge the level in
1930
+ * generated docs, CLI help, and MCP tool descriptions. No runtime
1931
+ * capability check.
1932
+ */
1933
+ stability?: StabilityLevel;
1934
+ /**
1935
+ * @deprecated Use `stability: "experimental"` instead. Kept as an
1936
+ * input for external authors; `true` normalizes to
1937
+ * `stability: "experimental"` in the registry projection.
1852
1938
  */
1853
1939
  experimental?: boolean;
1854
1940
  [key: string]: any;
@@ -2928,6 +3014,16 @@ interface DeprecationWarning {
2928
3014
  * once-per-process per message.
2929
3015
  */
2930
3016
  declare function defaultLogDeprecation({ methodName, deprecation, }: DeprecationWarning): void;
3017
+ /**
3018
+ * What the boundary reports when a non-stable (beta / experimental) method
3019
+ * is called: the method plus its declared level. `DeprecationWarning`'s
3020
+ * sibling — same self-describing shape, same handler-not-observer contract.
3021
+ */
3022
+ interface StabilityNotice {
3023
+ type: "stability";
3024
+ methodName: string;
3025
+ stability: StabilityLevel;
3026
+ }
2931
3027
  /**
2932
3028
  * The well-known id for framework options: heads inject a `CoreOptions` bag
2933
3029
  * under it via `createSdk`'s `configuration` (or register a property plugin),
@@ -2964,6 +3060,16 @@ interface CoreOptions {
2964
3060
  * reserved for an `on*`-named observer when the unified event bus lands.
2965
3061
  */
2966
3062
  logDeprecation?: (warning: DeprecationWarning) => void;
3063
+ /**
3064
+ * `logDeprecation`'s sibling for API stability: the framework signals
3065
+ * every surface call of a method declaring a non-stable `stability`
3066
+ * level (beta / experimental), and this gate decides what happens.
3067
+ * Exactly one: absent falls back to {@link defaultLogStabilityNotice}
3068
+ * (once-per-process per message), supplied replaces it. Runs isolated,
3069
+ * so a throwing handler never breaks the observed call. Internal
3070
+ * delegation never signals, matching the deprecation contract.
3071
+ */
3072
+ logStabilityNotice?: (notice: StabilityNotice) => void;
2967
3073
  /**
2968
3074
  * Report what output validation stripped, on the response's
2969
3075
  * `meta.outputValidation.droppedPaths` (the name mirrors that path). Off by
@@ -3527,6 +3633,8 @@ declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptio
3527
3633
  annotator?: (input: unknown) => Annotations;
3528
3634
  /** Live read of the method's deprecation meta (see signalDeprecation). */
3529
3635
  getDeprecation?: () => FunctionDeprecation | undefined;
3636
+ /** Live read of the method's stability level (see signalStability). */
3637
+ getStability?: () => StabilityLevel | undefined;
3530
3638
  }): (callOptions?: TOptions) => Promise<TResult>;
3531
3639
  /**
3532
3640
  * Higher-order function that creates a paginated function that wraps
@@ -3567,6 +3675,8 @@ declare function createPaginatedFunction<TUserOptions, TResponse, TItem = ItemTy
3567
3675
  finalizePage?: (page: SdkPage<TItem>) => SdkPage<TItem>;
3568
3676
  /** Live read of the method's deprecation meta (see signalDeprecation). */
3569
3677
  getDeprecation?: () => FunctionDeprecation | undefined;
3678
+ /** Live read of the method's stability level (see signalStability). */
3679
+ getStability?: () => StabilityLevel | undefined;
3570
3680
  }): (options?: TUserOptions & {
3571
3681
  cursor?: string;
3572
3682
  pageSize?: number;
@@ -3808,6 +3918,16 @@ interface DeprecationLogger {
3808
3918
  * channels while sharing the implementation.
3809
3919
  */
3810
3920
  declare function createDeprecationLogger(tag: string): DeprecationLogger;
3921
+ interface StabilityNoticeLogger {
3922
+ logStabilityNotice(message: string): void;
3923
+ resetStabilityNotices(): void;
3924
+ }
3925
+ /**
3926
+ * Create a package-tagged stability-notice logger: the deprecation logger's
3927
+ * sibling for non-stable (beta / experimental) API warnings, with the same
3928
+ * once-per-process dedupe policy and its own independent message Set.
3929
+ */
3930
+ declare function createStabilityNoticeLogger(tag: string): StabilityNoticeLogger;
3811
3931
 
3812
3932
  /**
3813
3933
  * Core signal machinery.
@@ -3865,4 +3985,374 @@ declare class CoreCancelledSignal extends CoreSignal {
3865
3985
  */
3866
3986
  declare function isCoreCancelledSignal(value: unknown): value is CoreCancelledSignal;
3867
3987
 
3868
- export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, 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 DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, 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 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 OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type ResponseMeta, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
3988
+ /**
3989
+ * Transport wire types.
3990
+ *
3991
+ * The request is fetch's `RequestInit` plus the smallest delta the SDK needs
3992
+ * (see `docs/design/2026-08-03-kitcore-transport.md`): `url` (fetch's first
3993
+ * argument, relocated onto the request so wraps can rewrite it) and an opaque
3994
+ * `connection` reference. The response is the native `Response`.
3995
+ *
3996
+ * The fetch types are derived from the ambient `fetch` global rather than the
3997
+ * named `RequestInit` / `Response`, which require the DOM lib. kitcore targets
3998
+ * both Node and the browser and deliberately omits the DOM lib (so a white-label
3999
+ * core can't reach for `window` / `document`), so we take whatever `fetch` the
4000
+ * host provides — Node's global fetch, the browser's, or a polyfill.
4001
+ */
4002
+ /** The `init` bag of the ambient `fetch` (i.e. `RequestInit`), lib-agnostic. */
4003
+ type HttpFetchInit = NonNullable<Parameters<typeof fetch>[1]>;
4004
+ /**
4005
+ * A request over the transport: `RequestInit` plus two additions.
4006
+ *
4007
+ * - `url` — fetch's first argument, on the request so a routing wrap can rewrite
4008
+ * host/path.
4009
+ * - `connection` — opaque credential reference; the credential-holding
4010
+ * transport resolves it (Relay server-side, or a local resolver).
4011
+ * Unresolvable throws.
4012
+ * Widen to `string | ConnectionRef` later; that is a non-breaking change.
4013
+ *
4014
+ * Everything else (`method`, `headers`, `body`, `signal`, `redirect`, `cache`,
4015
+ * …) is inherited from `RequestInit` unchanged.
4016
+ *
4017
+ * A deadline is `signal` (`AbortSignal.timeout`), which is what a local dispatch
4018
+ * can act on. A transport that dispatches to a remote service needs a number
4019
+ * instead, because a signal does not serialize; that field arrives with the
4020
+ * first transport that reads one, as a non-breaking addition.
4021
+ */
4022
+ type HttpRequest = HttpFetchInit & {
4023
+ url: string;
4024
+ connection?: string;
4025
+ };
4026
+ /**
4027
+ * What a CALLER may hand the transport, as opposed to what the pipeline passes
4028
+ * around. The only difference is `url`, which may also be a `URL` here, because
4029
+ * global `fetch` accepts one and building a url with `URLSearchParams` is
4030
+ * ordinary.
4031
+ *
4032
+ * `initializeHttpRequest` is the seam that narrows this to {@link HttpRequest},
4033
+ * so every stage below it, and every wrap on those stages, only ever sees a
4034
+ * string url. Widening `HttpRequest.url` itself would push the `string | URL`
4035
+ * check onto every wrap that rewrites a destination, which is the ceremony this
4036
+ * exists to remove.
4037
+ *
4038
+ * `Request` is deliberately not accepted, though global `fetch` takes one: it
4039
+ * carries its own body and headers, which would have to be merged with the
4040
+ * additions above rather than normalized away.
4041
+ */
4042
+ type HttpRequestInput = Omit<HttpRequest, "url"> & {
4043
+ url: string | URL;
4044
+ };
4045
+ type HttpResponse = Awaited<ReturnType<typeof fetch>>;
4046
+ type HttpPipelineState = Record<PropertyKey, unknown>;
4047
+ /**
4048
+ * What `sendHttpRequest` knows before any stage runs. `initializeHttpRequest`
4049
+ * turns this into the full {@link HttpOperationContext}, so this narrower shape
4050
+ * is what that one stage receives: it cannot be handed fields it exists to
4051
+ * produce.
4052
+ */
4053
+ interface HttpOperationStart {
4054
+ operationId: string;
4055
+ signal?: HttpFetchInit["signal"];
4056
+ }
4057
+ /**
4058
+ * Facts true of the whole operation, built once by `initializeHttpRequest` and
4059
+ * carried on every attempt. Retries share one of these, which is the point:
4060
+ * `replayable` describes the caller's body, not an attempt.
4061
+ *
4062
+ * `request` is the caller's request as it entered the pipeline, normalized and
4063
+ * otherwise untouched. Later stages rewrite their OWN request (routing rewrites
4064
+ * the url, auth removes `connection` and adds headers), so this is the only
4065
+ * place that still holds what was originally asked for. That is what lets
4066
+ * `dispatchHttpRequest` and `receiveHttpResponse` name the connection behind a
4067
+ * failure, long after auth consumed it.
4068
+ *
4069
+ * Treat it as read-only. A stage that mutated a request in place instead of
4070
+ * returning a new one would corrupt this snapshot, and `initializeHttpRequest`
4071
+ * copies only when it must, so `request` is often the caller's own object.
4072
+ *
4073
+ * None of it is wire data. `dispatchHttpRequest` builds its fetch input from
4074
+ * the stage request alone; a dispatch replacement must not serialize this.
4075
+ */
4076
+ interface HttpOperationContext extends HttpOperationStart {
4077
+ /** The caller's request, normalized, before any stage rewrote it. */
4078
+ request: HttpRequest;
4079
+ /** Whether the body can be sent again. A `ReadableStream` cannot, so anything
4080
+ * re-issuing a request must refuse it. Inferred from the body rather than
4081
+ * declared, so retry is correct without the caller remembering to say so. */
4082
+ replayable: boolean;
4083
+ }
4084
+ interface HttpAttemptContext {
4085
+ attemptNumber: number;
4086
+ operation: HttpOperationContext;
4087
+ signal?: HttpFetchInit["signal"];
4088
+ /** Per-attempt scratch for cross-stage handoffs, keyed by `PropertyKey`; use a
4089
+ * symbol for a private one. Reset for each attempt, because a handoff from a
4090
+ * previous attempt describes a request that is no longer in flight. Operation
4091
+ * facts belong on {@link HttpOperationContext} instead. */
4092
+ state: HttpPipelineState;
4093
+ }
4094
+ interface InitializeHttpRequestInput {
4095
+ request: HttpRequestInput;
4096
+ operation: HttpOperationStart;
4097
+ }
4098
+ /**
4099
+ * One physical attempt at a request: prepare, authorize, dispatch, receive.
4100
+ *
4101
+ * A distinct stage from `sendHttpRequest` because the transport has two
4102
+ * lifecycle scopes, not one. `sendHttpRequest` is the OPERATION (once per
4103
+ * caller request, where `initializeHttpRequest` and `operationId` live);
4104
+ * `attemptHttpRequest` is the ATTEMPT (once per physical request). Anything
4105
+ * that re-issues a request wraps here, so it inherits one `operationId` for the
4106
+ * whole operation, sets each attempt's `attemptNumber`, and can read
4107
+ * `attempt.operation.replayable` before deciding to resend. Wrapping
4108
+ * `sendHttpRequest` instead would re-run initialize and mint a new operation
4109
+ * per attempt.
4110
+ */
4111
+ interface AttemptHttpRequestInput {
4112
+ request: HttpRequest;
4113
+ attempt: HttpAttemptContext;
4114
+ }
4115
+ interface PrepareHttpRequestInput {
4116
+ request: HttpRequest;
4117
+ attempt: HttpAttemptContext;
4118
+ }
4119
+ /**
4120
+ * Removing `connection` from the returned request is how a wrap CLAIMS it. The
4121
+ * default stage at the end of the chain throws on a reference that is still
4122
+ * set, so a reference nothing claimed stops the request instead of sending it
4123
+ * unauthenticated.
4124
+ *
4125
+ * Claiming is not lossy: the reference stays readable at every stage on
4126
+ * `attempt.operation.request.connection`, so a wrap that needs it later reads
4127
+ * it there rather than stashing a copy in `attempt.state`.
4128
+ */
4129
+ interface AuthorizeHttpRequestInput {
4130
+ request: HttpRequest;
4131
+ attempt: HttpAttemptContext;
4132
+ }
4133
+ interface DispatchHttpRequestInput {
4134
+ request: HttpRequest;
4135
+ attempt: HttpAttemptContext;
4136
+ }
4137
+ interface ReceiveHttpResponseInput {
4138
+ request: HttpRequest;
4139
+ response: HttpResponse;
4140
+ attempt: HttpAttemptContext;
4141
+ }
4142
+ /**
4143
+ * The transport method: a request in, a native `Response` out (exactly what
4144
+ * `fetch` returns). Wraps around this method are contract-preserving over it.
4145
+ */
4146
+ type SendHttpRequest = (request: HttpRequest) => ReturnType<typeof fetch>;
4147
+
4148
+ /**
4149
+ * One physical attempt: prepare, authorize, dispatch, receive.
4150
+ *
4151
+ * This exists as its own stage to give the ATTEMPT scope a seam. See
4152
+ * {@link AttemptHttpRequestInput} for why the operation and the attempt are
4153
+ * different lifecycles, and why re-issuing a request has to wrap here rather
4154
+ * than around `sendHttpRequest`.
4155
+ *
4156
+ * Do not fold this back into `sendHttpRequest` to save an indirection: doing so
4157
+ * removes the only boundary below `initializeHttpRequest`, and a retry wrap
4158
+ * would then re-initialize and mint a fresh `operationId` per attempt.
4159
+ */
4160
+ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>;
4161
+
4162
+ /**
4163
+ * Completes the operation context: normalizes the caller's request and records
4164
+ * whether its body can be sent again. Everything below this stage reads those
4165
+ * two facts off `attempt.operation`, and neither changes across retries.
4166
+ */
4167
+ declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly []> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>;
4168
+
4169
+ /**
4170
+ * Options for {@link retryHttpRequestPlugin}, supplied by id like every other
4171
+ * kitcore configuration value. Absent means the defaults below.
4172
+ */
4173
+ interface RetryHttpRequestOptions {
4174
+ /** Total attempts including the first. Default 3. */
4175
+ maxAttempts?: number;
4176
+ /** Refuse a delay longer than this and give up instead. Default 60 seconds. */
4177
+ maxDelayMilliseconds?: number;
4178
+ /** Statuses to retry on an idempotent method. Default 429, 500, 502, 503, 504. */
4179
+ retryStatuses?: readonly number[];
4180
+ /**
4181
+ * Statuses to retry on a NON-idempotent method. Default 429 only: a rate
4182
+ * limit rejects the request before the server does any work, so it is known
4183
+ * not to have executed. A 502 or 504 carries no such promise.
4184
+ */
4185
+ nonIdempotentRetryStatuses?: readonly number[];
4186
+ /** Methods safe to resend. Default the RFC 9110 idempotent set. */
4187
+ idempotentMethods?: readonly string[];
4188
+ /**
4189
+ * Retry when an attempt THROWS (a network failure) rather than answering.
4190
+ * Default false. A thrown request may still have reached the server, and
4191
+ * turning this on silently widens what gets resent, so it is a deliberate
4192
+ * choice rather than a default.
4193
+ */
4194
+ retryOnError?: boolean;
4195
+ }
4196
+ declare const RETRY_HTTP_REQUEST_OPTIONS_ID = "kitcore/retryHttpRequestOptions";
4197
+ declare const retryHttpRequestOptionsPluginRef: PropertyPlugin<"retryHttpRequestOptions", RetryHttpRequestOptions | undefined> & PluginSummary<never, never>;
4198
+ /**
4199
+ * Re-issue a failed attempt, opt-in by composition.
4200
+ *
4201
+ * Wraps `attemptHttpRequest` rather than `sendHttpRequest`, which is what makes
4202
+ * the retry correct rather than merely present: `initializeHttpRequest` has
4203
+ * already run, so every attempt shares one `operationId`, and this can read
4204
+ * `attempt.operation.replayable` before resending.
4205
+ *
4206
+ * Three independent gates, each answering a different question:
4207
+ *
4208
+ * replayable CAN we resend? a consumed stream body cannot go out again
4209
+ * idempotent is it SAFE? a 504 may mean the server DID process it
4210
+ * status SHOULD we? policy, configurable
4211
+ *
4212
+ * The idempotency gate is the subtle one. A 429 is DIRECTED: the server told us
4213
+ * when to return, and a rate limit rejects before doing work, so it is known not
4214
+ * to have executed and any method may be resent. A 5xx is SPECULATIVE: no
4215
+ * instruction, and the request may have succeeded with the response lost, so
4216
+ * resending a POST would double-execute it.
4217
+ *
4218
+ * Exhausting the retries RETURNS the last response rather than throwing.
4219
+ * Deciding what counts as a failure belongs to `receiveHttpResponse` and a
4220
+ * head's error mapping; this decides only whether to try again.
4221
+ *
4222
+ * Cancellation is the one exception, and it throws. A caller who aborts wants
4223
+ * the operation to stop, not to receive whichever response the last attempt
4224
+ * happened to produce, so an abort during the wait ends the loop with the
4225
+ * caller's own reason.
4226
+ */
4227
+ declare const retryHttpRequestPlugin: HookPlugin<string>;
4228
+
4229
+ declare const prepareHttpRequestPlugin: MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>;
4230
+
4231
+ declare const authorizeHttpRequestPlugin: MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>;
4232
+
4233
+ declare const dispatchHttpRequestPlugin: MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>;
4234
+
4235
+ declare const receiveHttpResponsePlugin: MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>;
4236
+
4237
+ /**
4238
+ * The transport orchestrator: turn an {@link HttpRequestInput} into a native
4239
+ * `Response`. It owns the OPERATION, the things that happen once per caller
4240
+ * request, and delegates the per-attempt work to `attemptHttpRequest`:
4241
+ *
4242
+ * initialize once -> attempt (prepare, authorize, dispatch, receive)
4243
+ *
4244
+ * The split is the seam that makes re-issuing a request possible. A wrap here
4245
+ * sees the whole operation (a concurrency permit, an overall deadline); a wrap
4246
+ * on `attemptHttpRequest` sees one attempt and may run it more than once
4247
+ * (retry, an approval re-issue). Cross-cutting behavior should still wrap the
4248
+ * narrowest stage it owns.
4249
+ *
4250
+ * A caller's `url` may be a `URL`; initialize normalizes it, so every stage
4251
+ * from prepare onward receives a plain string.
4252
+ *
4253
+ * A raw method: it owns its input (the fetch-shaped `HttpRequest`), so
4254
+ * `skipInputValidation` keeps the caller's object identity intact: no parse, no
4255
+ * coercion, no clone. The `inputSchema` is projection-only (never run as a
4256
+ * validator) and exists so the registry has a shape to describe.
4257
+ *
4258
+ * An unresolved `connection` fails in the default authorize stage: no auth wrap
4259
+ * consumed it, so the request would otherwise go out unauthenticated.
4260
+ *
4261
+ * No retry by default: with nothing composed this runs exactly one attempt.
4262
+ * `retryHttpRequestPlugin` is opt-in.
4263
+ */
4264
+ declare const sendHttpRequestPlugin: MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly []> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>;
4265
+
4266
+ /**
4267
+ * `fetch` — native `fetch(url, init)` ergonomics over the transport. It
4268
+ * delegates to `sendHttpRequest`, inheriting its stage pipeline and any wraps
4269
+ * composed around those stages.
4270
+ *
4271
+ * It imports the transport as a DEFAULT (`declareDefault`), so `fetchPlugin`
4272
+ * works alone: with nothing else composed, the default pipeline dispatches
4273
+ * through `globalThis.fetch`. A composed transport provider of the same id
4274
+ * preempts the default, so hello-world is just `fetchPlugin`.
4275
+ *
4276
+ * `fetch` is branch-free and never inspects `connection` — it just delegates, and
4277
+ * the default authorizer fails loud on an unresolved reference. A raw method
4278
+ * (`skipInputValidation`): the caller's `init` passes through untouched, so this
4279
+ * is global `fetch` plus the `url` / `connection` shape. Content-type inference
4280
+ * for non-standard bodies (a plain object → JSON) is a head ergonomic, not
4281
+ * kitcore-generic.
4282
+ *
4283
+ * `url` takes a `URL` as well as a string, matching global `fetch`. A `Request`
4284
+ * is the one first argument global `fetch` takes that this does not; see
4285
+ * {@link HttpRequestInput}.
4286
+ */
4287
+ declare const fetchPlugin: MethodPlugin<"fetch", {
4288
+ url: string | URL;
4289
+ init?: Omit<HttpRequestInput, "url">;
4290
+ }, Promise<Response>, readonly ["url", "init"]> & LeafSummary<"kitcore", "fetch", readonly [MethodPlugin<"sendHttpRequest", HttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "sendHttpRequest", readonly [MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly []> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>, MethodPlugin<"attemptHttpRequest", AttemptHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "attemptHttpRequest", readonly [MethodPlugin<"prepareHttpRequest", PrepareHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "prepareHttpRequest", readonly []>, MethodPlugin<"authorizeHttpRequest", AuthorizeHttpRequestInput, Promise<HttpRequest>, readonly []> & LeafSummary<"kitcore", "authorizeHttpRequest", readonly []>, MethodPlugin<"dispatchHttpRequest", DispatchHttpRequestInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "dispatchHttpRequest", readonly []>, MethodPlugin<"receiveHttpResponse", ReceiveHttpResponseInput, Promise<Response>, readonly []> & LeafSummary<"kitcore", "receiveHttpResponse", readonly []>]>]>]>;
4291
+
4292
+ /**
4293
+ * Headers with every credential value masked, as a plain object a logger can
4294
+ * print. Header names come back lowercased, because `Headers` normalizes them.
4295
+ */
4296
+ declare function redactHeaders(headers?: HeadersInit): Record<string, string> | undefined;
4297
+ /**
4298
+ * A log-safe view of a request: credential headers masked, and `connection`
4299
+ * masked with it.
4300
+ *
4301
+ * `connection` is the half a head cannot redact for itself. The transport
4302
+ * treats it as an opaque string, so its value is whatever a caller passed,
4303
+ * including a raw credential (see {@link HttpRequest}). A hook printing a
4304
+ * stage's `args` would put it on the terminal.
4305
+ *
4306
+ * The url and the body are NOT redacted. A token can ride either, in a query
4307
+ * parameter or a form field, but kitcore does not know which one, and masking
4308
+ * by guessed name would hide the wrong thing while claiming the rest is safe.
4309
+ * A head that puts credentials there has to redact them itself.
4310
+ *
4311
+ * Returns a new object. The pipeline treats `HttpOperationContext.request` as
4312
+ * read-only, and a logger must not be the thing that breaks that.
4313
+ */
4314
+ declare function redactHttpRequest(request: HttpRequest): HttpRequest;
4315
+
4316
+ interface DefaultConnectionSchemeInput {
4317
+ connection: string;
4318
+ }
4319
+ interface NormalizeConnectionInput {
4320
+ connection?: string;
4321
+ }
4322
+ interface ResolveConnectionInput {
4323
+ /** The explicit connection reference the caller passed, if any. */
4324
+ connection?: string;
4325
+ /** The connection type the tool declared (`connection: "<type>"`). kitcore
4326
+ * never reads it; it is the key a head's discovery wrap routes on, and the key
4327
+ * the connection-route registry is looked up by. */
4328
+ connectionType: string;
4329
+ }
4330
+ interface NormalizedConnection {
4331
+ connection: string;
4332
+ scheme?: string;
4333
+ value: string;
4334
+ }
4335
+
4336
+ declare const defaultConnectionSchemePlugin: MethodPlugin<"defaultConnectionScheme", DefaultConnectionSchemeInput, string | undefined, readonly []> & LeafSummary<"kitcore", "defaultConnectionScheme", readonly []>;
4337
+
4338
+ declare const normalizeConnectionPlugin: MethodPlugin<"normalizeConnection", NormalizeConnectionInput, NormalizedConnection | undefined, readonly []> & LeafSummary<"kitcore", "normalizeConnection", readonly [MethodPlugin<"defaultConnectionScheme", DefaultConnectionSchemeInput, string | undefined, readonly []> & LeafSummary<"kitcore", "defaultConnectionScheme", readonly []>]>;
4339
+
4340
+ /**
4341
+ * SELECT which connection REFERENCE a call should use: the explicit one if the
4342
+ * caller passed it, else `undefined`. It deals only in references, never a
4343
+ * secret. Turning a reference into a credential is `authorizeHttpRequest`.
4344
+ *
4345
+ * The default is a pass-through, so this exists to be wrapped. A head adds
4346
+ * discovery or defaulting with a `defineHook` over `resolveConnection`, keyed by
4347
+ * `input.connectionType` (reading a connection id from an env var, say). Because
4348
+ * it is an ordinary method rather than an interactive prompt, a caller in plain
4349
+ * code gets the head's defaulting too, not only a caller driven by the
4350
+ * controller.
4351
+ *
4352
+ * Returning `undefined` is not an error here. Whether a missing connection is
4353
+ * fatal depends on what the caller declared it needs, which this stage cannot
4354
+ * see, so this stays policy-free.
4355
+ */
4356
+ declare const resolveConnectionPlugin: MethodPlugin<"resolveConnection", ResolveConnectionInput, string | undefined, readonly []> & LeafSummary<"kitcore", "resolveConnection", readonly []>;
4357
+
4358
+ 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 OutputFormatter, 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 ResolverType, type ResponseMeta, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, 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, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistryPlugin, getSchemaDescription, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };