@zapier/kitcore 0.11.0 → 0.12.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
@@ -8,9 +8,33 @@ declare module "zod" {
8
8
  }
9
9
  }
10
10
 
11
+ /**
12
+ * The response `meta` sidecar, shared by both output modes: an item method's
13
+ * `{ data, meta }` envelope and a list method's page carry the same shape, so a
14
+ * caller reads a framework report the same way regardless of the mode it came
15
+ * from.
16
+ *
17
+ * Every member is optional and framework-owned. A method's `run` returns `data`;
18
+ * the boundary attaches what belongs here.
19
+ */
20
+ interface ResponseMeta {
21
+ /**
22
+ * What output validation's strip removed from the response, present only when
23
+ * the head enables the `includeOutputValidationDroppedPaths` core option AND
24
+ * something was actually dropped. Paths are relative to `data` in both modes
25
+ * (`a.b` for an item), with array elements collapsed to one `[]` segment and
26
+ * unioned (`[].b` on a page, `items[].b` for an array inside an item), matching
27
+ * connectors' format.
28
+ */
29
+ outputValidation?: {
30
+ droppedPaths: string[];
31
+ };
32
+ }
33
+
11
34
  /**
12
35
  * Pagination shapes used by the plugin framework.
13
36
  */
37
+
14
38
  /**
15
39
  * Single page of a paginated SDK list result. Returned from the page-level
16
40
  * promise and yielded from the page-level async iterable.
@@ -18,6 +42,10 @@ declare module "zod" {
18
42
  interface SdkPage<T = unknown> {
19
43
  data: T[];
20
44
  nextCursor?: string;
45
+ /** Additive per-page framework sidecar, the same shape an item method's
46
+ * envelope carries. Framework-set, not something a handler or `adaptPage`
47
+ * returns. See {@link ResponseMeta}. */
48
+ meta?: ResponseMeta;
21
49
  }
22
50
  /**
23
51
  * Return type of every paginated SDK method. The documented surface is:
@@ -504,6 +532,13 @@ interface LeafMetaFields {
504
532
  itemType?: string;
505
533
  returnType?: string;
506
534
  outputSchema?: z.ZodSchema;
535
+ /** Behavioral opt-out that rides on this config for every `defineMethod`
536
+ * overload (all merge `LeafMetaFields`), the partner of `outputSchema`: when
537
+ * true, the materializer skips validating/stripping the output. It is
538
+ * consumed at build time and stored as a first-class plugin field, NOT folded
539
+ * into the projected meta (hence absent from `LEAF_META_KEYS`), so it stays
540
+ * off the registry / CLI / MCP surface, exactly like `skipInputValidation`. */
541
+ skipOutputValidation?: boolean;
507
542
  packages?: string[];
508
543
  experimental?: boolean;
509
544
  confirm?: "create-secret" | "delete";
@@ -1008,9 +1043,15 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
1008
1043
  /** True for a `declareMethod` stand-in: a typed reference with no real
1009
1044
  * implementation. A real plugin under the same id satisfies it. */
1010
1045
  standIn?: boolean;
1011
- /** True for a `declareOptionalProperty` stand-in over a method id: dependents bind
1012
- * `undefined` if no real plugin satisfies it. */
1046
+ /** True for a `declareOptionalMethod` stand-in: dependents bind `undefined` if
1047
+ * no real plugin satisfies it, and `PluginSurface` types the binding
1048
+ * `| undefined`. */
1013
1049
  optional?: boolean;
1050
+ /** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
1051
+ * for its id (preempted by any explicit provider). Its value is the wrapped
1052
+ * plugin, so two defaults for one id dedup (same source) or conflict
1053
+ * (different source). */
1054
+ defaultSource?: AnyLeafPlugin;
1014
1055
  imports: readonly AnyPlugin[];
1015
1056
  /** Binding-name to plugin-id edges, normalized from `imports`;
1016
1057
  * what the `imports` bag is built from. */
@@ -1032,6 +1073,10 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
1032
1073
  * For raw methods that own their own validation and must not have their input
1033
1074
  * transformed, e.g. `fetch` passing a `RequestInit` bag through unchanged. */
1034
1075
  skipInputValidation?: boolean;
1076
+ /** When true, the materializer skips validating/stripping `run`'s output
1077
+ * against `meta.outputSchema` (the schema stays for projection). The output
1078
+ * partner of {@link MethodPlugin.skipInputValidation}. */
1079
+ skipOutputValidation?: boolean;
1035
1080
  /** Descriptive metadata for the registry / CLI / MCP / docs (carry-only at
1036
1081
  * runtime). */
1037
1082
  meta?: LeafMeta;
@@ -1146,6 +1191,11 @@ interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1146
1191
  * property satisfies it, dependents bind `undefined` rather than the build
1147
1192
  * failing on a missing dependency. */
1148
1193
  optional?: boolean;
1194
+ /** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
1195
+ * for its id (preempted by any explicit provider). Its value is the wrapped
1196
+ * plugin, so two defaults for one id dedup (same source) or conflict
1197
+ * (different source). */
1198
+ defaultSource?: AnyLeafPlugin;
1149
1199
  imports: readonly AnyPlugin[];
1150
1200
  /** Binding-name to plugin-id edges, normalized from `imports`;
1151
1201
  * what the `imports` bag is built from. */
@@ -1483,7 +1533,11 @@ type ExportSurface<TChild extends AnyLeafPlugin> = TChild extends MethodPlugin<a
1483
1533
  * bag and `ProvidesOf` is the completeness ledger's phantom ids — both
1484
1534
  * different concepts.
1485
1535
  */
1486
- type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? {
1536
+ type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? P extends {
1537
+ optional: true;
1538
+ } ? {
1539
+ [K in TName]: SurfaceCall<TInput, TOutput, TPositional> | undefined;
1540
+ } : {
1487
1541
  [K in TName]: SurfaceCall<TInput, TOutput, TPositional>;
1488
1542
  } : P extends PropertyPlugin<infer TName, infer TValue> ? {
1489
1543
  [K in TName]: TValue;
@@ -2229,6 +2283,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse exte
2229
2283
  run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TResponse | Promise<TResponse>;
2230
2284
  } & LeafMetaFields): MethodPlugin<TName, TInput, Promise<{
2231
2285
  data: TData;
2286
+ meta?: ResponseMeta;
2232
2287
  }>> & LeafSummary<TNamespace, TName, TImports>;
2233
2288
  declare function defineMethod<const TName extends string, TInput, TResponse extends StrictPage$1<TResponse>, TItem = ItemOf$1<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
2234
2289
  name: TName;
@@ -2450,6 +2505,19 @@ declare function defineFormatter<const TImports extends ImportsInput = readonly
2450
2505
  declare function declareMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
2451
2506
  id: LiteralString<TId>;
2452
2507
  }): MethodPlugin<LastSegment<TId>, TInput, TOutput> & PluginSummary<TId, never>;
2508
+ /**
2509
+ * Declare an OPTIONAL stand-in for a method registered elsewhere: the method twin
2510
+ * of `declareOptionalProperty`. Unlike `declareMethod`, an unsatisfied optional
2511
+ * reference is NOT a missing dependency; the binding is typed
2512
+ * `((input) => output) | undefined`, so the consumer must handle the absent case
2513
+ * (`imports.track?.(...)`). Use it to reference a foreign method userland may or
2514
+ * may not import, without claiming its slot.
2515
+ */
2516
+ declare function declareOptionalMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
2517
+ id: LiteralString<TId>;
2518
+ }): MethodPlugin<LastSegment<TId>, TInput, TOutput> & {
2519
+ optional: true;
2520
+ } & PluginSummary<never, never>;
2453
2521
  /**
2454
2522
  * Define a property leaf. Either a static `value` or a computed `get` (eager,
2455
2523
  * dependencies first, like `setup`). `createSdk`, a dependent's `imports`, or
@@ -2507,6 +2575,21 @@ declare function declareProperty<const TId extends string, TValue = unknown>(con
2507
2575
  declare function declareOptionalProperty<const TId extends string, TValue = unknown>(config: {
2508
2576
  id: LiteralString<TId>;
2509
2577
  }): PropertyPlugin<LastSegment<TId>, TValue | undefined> & PluginSummary<never, never>;
2578
+ /**
2579
+ * Declare a DEFAULT provider for a dependency you own: import the capability the
2580
+ * given plugin provides, and fall back to that plugin when nothing else provides
2581
+ * its id. Kind-agnostic (the plugin supplies id, type, and kind), so no
2582
+ * method/property split.
2583
+ *
2584
+ * A default materializes a real, single node, so it works out of the box and can
2585
+ * be wrapped or replaced: an explicit provider of the same id silently preempts
2586
+ * it, and two different defaults for one id error only when nothing else provides
2587
+ * it. See the Defaults section in the kitcore README for default vs optional
2588
+ * reference.
2589
+ */
2590
+ declare function declareDefault<P extends AnyLeafPlugin>({ plugin, }: {
2591
+ plugin: P;
2592
+ }): P;
2510
2593
  /**
2511
2594
  * Define a method-lifecycle hook: a leaf whose `observe` contributes
2512
2595
  * fire-and-forget observers (`onMethodStart` / `onMethodEnd`) the method
@@ -2859,6 +2942,15 @@ interface CoreOptions {
2859
2942
  * reserved for an `on*`-named observer when the unified event bus lands.
2860
2943
  */
2861
2944
  logDeprecation?: (warning: DeprecationWarning) => void;
2945
+ /**
2946
+ * Report what output validation stripped, on the response's
2947
+ * `meta.outputValidation.droppedPaths` (the name mirrors that path). Off by
2948
+ * default: the report is a debugging aid for reconciling a schema against the
2949
+ * wire, and a sidecar every caller has to ignore is worse than one a head
2950
+ * turns on while it audits its schemas. Off also skips the recursive
2951
+ * raw-vs-parsed diff, so the strip costs a parse and nothing more.
2952
+ */
2953
+ includeOutputValidationDroppedPaths?: boolean;
2862
2954
  }
2863
2955
 
2864
2956
  /**
@@ -3449,6 +3541,8 @@ declare function createPaginatedFunction<TUserOptions, TResponse, TItem = ItemTy
3449
3541
  adaptPage?: (response: TResponse) => SdkPage<NoInfer<TItem>>;
3450
3542
  /** Pre-run per-method annotator (see applyAnnotations). */
3451
3543
  annotator?: (input: unknown) => Annotations;
3544
+ /** Applied to each canonical page after the shape guard (output validation). */
3545
+ finalizePage?: (page: SdkPage<TItem>) => SdkPage<TItem>;
3452
3546
  /** Live read of the method's deprecation meta (see signalDeprecation). */
3453
3547
  getDeprecation?: () => FunctionDeprecation | undefined;
3454
3548
  }): (options?: TUserOptions & {
@@ -3749,4 +3843,4 @@ declare class CoreCancelledSignal extends CoreSignal {
3749
3843
  */
3750
3844
  declare function isCoreCancelledSignal(value: unknown): value is CoreCancelledSignal;
3751
3845
 
3752
- 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 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 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, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, 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 };
3846
+ 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 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, 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 };
package/dist/index.d.ts CHANGED
@@ -8,9 +8,33 @@ declare module "zod" {
8
8
  }
9
9
  }
10
10
 
11
+ /**
12
+ * The response `meta` sidecar, shared by both output modes: an item method's
13
+ * `{ data, meta }` envelope and a list method's page carry the same shape, so a
14
+ * caller reads a framework report the same way regardless of the mode it came
15
+ * from.
16
+ *
17
+ * Every member is optional and framework-owned. A method's `run` returns `data`;
18
+ * the boundary attaches what belongs here.
19
+ */
20
+ interface ResponseMeta {
21
+ /**
22
+ * What output validation's strip removed from the response, present only when
23
+ * the head enables the `includeOutputValidationDroppedPaths` core option AND
24
+ * something was actually dropped. Paths are relative to `data` in both modes
25
+ * (`a.b` for an item), with array elements collapsed to one `[]` segment and
26
+ * unioned (`[].b` on a page, `items[].b` for an array inside an item), matching
27
+ * connectors' format.
28
+ */
29
+ outputValidation?: {
30
+ droppedPaths: string[];
31
+ };
32
+ }
33
+
11
34
  /**
12
35
  * Pagination shapes used by the plugin framework.
13
36
  */
37
+
14
38
  /**
15
39
  * Single page of a paginated SDK list result. Returned from the page-level
16
40
  * promise and yielded from the page-level async iterable.
@@ -18,6 +42,10 @@ declare module "zod" {
18
42
  interface SdkPage<T = unknown> {
19
43
  data: T[];
20
44
  nextCursor?: string;
45
+ /** Additive per-page framework sidecar, the same shape an item method's
46
+ * envelope carries. Framework-set, not something a handler or `adaptPage`
47
+ * returns. See {@link ResponseMeta}. */
48
+ meta?: ResponseMeta;
21
49
  }
22
50
  /**
23
51
  * Return type of every paginated SDK method. The documented surface is:
@@ -504,6 +532,13 @@ interface LeafMetaFields {
504
532
  itemType?: string;
505
533
  returnType?: string;
506
534
  outputSchema?: z.ZodSchema;
535
+ /** Behavioral opt-out that rides on this config for every `defineMethod`
536
+ * overload (all merge `LeafMetaFields`), the partner of `outputSchema`: when
537
+ * true, the materializer skips validating/stripping the output. It is
538
+ * consumed at build time and stored as a first-class plugin field, NOT folded
539
+ * into the projected meta (hence absent from `LEAF_META_KEYS`), so it stays
540
+ * off the registry / CLI / MCP surface, exactly like `skipInputValidation`. */
541
+ skipOutputValidation?: boolean;
507
542
  packages?: string[];
508
543
  experimental?: boolean;
509
544
  confirm?: "create-secret" | "delete";
@@ -1008,9 +1043,15 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
1008
1043
  /** True for a `declareMethod` stand-in: a typed reference with no real
1009
1044
  * implementation. A real plugin under the same id satisfies it. */
1010
1045
  standIn?: boolean;
1011
- /** True for a `declareOptionalProperty` stand-in over a method id: dependents bind
1012
- * `undefined` if no real plugin satisfies it. */
1046
+ /** True for a `declareOptionalMethod` stand-in: dependents bind `undefined` if
1047
+ * no real plugin satisfies it, and `PluginSurface` types the binding
1048
+ * `| undefined`. */
1013
1049
  optional?: boolean;
1050
+ /** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
1051
+ * for its id (preempted by any explicit provider). Its value is the wrapped
1052
+ * plugin, so two defaults for one id dedup (same source) or conflict
1053
+ * (different source). */
1054
+ defaultSource?: AnyLeafPlugin;
1014
1055
  imports: readonly AnyPlugin[];
1015
1056
  /** Binding-name to plugin-id edges, normalized from `imports`;
1016
1057
  * what the `imports` bag is built from. */
@@ -1032,6 +1073,10 @@ interface MethodPlugin<TName extends string = string, TInput = unknown, TOutput
1032
1073
  * For raw methods that own their own validation and must not have their input
1033
1074
  * transformed, e.g. `fetch` passing a `RequestInit` bag through unchanged. */
1034
1075
  skipInputValidation?: boolean;
1076
+ /** When true, the materializer skips validating/stripping `run`'s output
1077
+ * against `meta.outputSchema` (the schema stays for projection). The output
1078
+ * partner of {@link MethodPlugin.skipInputValidation}. */
1079
+ skipOutputValidation?: boolean;
1035
1080
  /** Descriptive metadata for the registry / CLI / MCP / docs (carry-only at
1036
1081
  * runtime). */
1037
1082
  meta?: LeafMeta;
@@ -1146,6 +1191,11 @@ interface PropertyPlugin<TName extends string = string, TValue = unknown> {
1146
1191
  * property satisfies it, dependents bind `undefined` rather than the build
1147
1192
  * failing on a missing dependency. */
1148
1193
  optional?: boolean;
1194
+ /** Present on a `declareDefault` wrapper: this entry is the DEFAULT provider
1195
+ * for its id (preempted by any explicit provider). Its value is the wrapped
1196
+ * plugin, so two defaults for one id dedup (same source) or conflict
1197
+ * (different source). */
1198
+ defaultSource?: AnyLeafPlugin;
1149
1199
  imports: readonly AnyPlugin[];
1150
1200
  /** Binding-name to plugin-id edges, normalized from `imports`;
1151
1201
  * what the `imports` bag is built from. */
@@ -1483,7 +1533,11 @@ type ExportSurface<TChild extends AnyLeafPlugin> = TChild extends MethodPlugin<a
1483
1533
  * bag and `ProvidesOf` is the completeness ledger's phantom ids — both
1484
1534
  * different concepts.
1485
1535
  */
1486
- type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? {
1536
+ type PluginSurface<P extends AnyPlugin> = P extends MethodPlugin<infer TName, infer TInput, infer TOutput, infer TPositional> ? P extends {
1537
+ optional: true;
1538
+ } ? {
1539
+ [K in TName]: SurfaceCall<TInput, TOutput, TPositional> | undefined;
1540
+ } : {
1487
1541
  [K in TName]: SurfaceCall<TInput, TOutput, TPositional>;
1488
1542
  } : P extends PropertyPlugin<infer TName, infer TValue> ? {
1489
1543
  [K in TName]: TValue;
@@ -2229,6 +2283,7 @@ declare function defineMethod<const TName extends string, TInput, TResponse exte
2229
2283
  run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TResponse | Promise<TResponse>;
2230
2284
  } & LeafMetaFields): MethodPlugin<TName, TInput, Promise<{
2231
2285
  data: TData;
2286
+ meta?: ResponseMeta;
2232
2287
  }>> & LeafSummary<TNamespace, TName, TImports>;
2233
2288
  declare function defineMethod<const TName extends string, TInput, TResponse extends StrictPage$1<TResponse>, TItem = ItemOf$1<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
2234
2289
  name: TName;
@@ -2450,6 +2505,19 @@ declare function defineFormatter<const TImports extends ImportsInput = readonly
2450
2505
  declare function declareMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
2451
2506
  id: LiteralString<TId>;
2452
2507
  }): MethodPlugin<LastSegment<TId>, TInput, TOutput> & PluginSummary<TId, never>;
2508
+ /**
2509
+ * Declare an OPTIONAL stand-in for a method registered elsewhere: the method twin
2510
+ * of `declareOptionalProperty`. Unlike `declareMethod`, an unsatisfied optional
2511
+ * reference is NOT a missing dependency; the binding is typed
2512
+ * `((input) => output) | undefined`, so the consumer must handle the absent case
2513
+ * (`imports.track?.(...)`). Use it to reference a foreign method userland may or
2514
+ * may not import, without claiming its slot.
2515
+ */
2516
+ declare function declareOptionalMethod<const TId extends string, TInput = unknown, TOutput = unknown>(config: {
2517
+ id: LiteralString<TId>;
2518
+ }): MethodPlugin<LastSegment<TId>, TInput, TOutput> & {
2519
+ optional: true;
2520
+ } & PluginSummary<never, never>;
2453
2521
  /**
2454
2522
  * Define a property leaf. Either a static `value` or a computed `get` (eager,
2455
2523
  * dependencies first, like `setup`). `createSdk`, a dependent's `imports`, or
@@ -2507,6 +2575,21 @@ declare function declareProperty<const TId extends string, TValue = unknown>(con
2507
2575
  declare function declareOptionalProperty<const TId extends string, TValue = unknown>(config: {
2508
2576
  id: LiteralString<TId>;
2509
2577
  }): PropertyPlugin<LastSegment<TId>, TValue | undefined> & PluginSummary<never, never>;
2578
+ /**
2579
+ * Declare a DEFAULT provider for a dependency you own: import the capability the
2580
+ * given plugin provides, and fall back to that plugin when nothing else provides
2581
+ * its id. Kind-agnostic (the plugin supplies id, type, and kind), so no
2582
+ * method/property split.
2583
+ *
2584
+ * A default materializes a real, single node, so it works out of the box and can
2585
+ * be wrapped or replaced: an explicit provider of the same id silently preempts
2586
+ * it, and two different defaults for one id error only when nothing else provides
2587
+ * it. See the Defaults section in the kitcore README for default vs optional
2588
+ * reference.
2589
+ */
2590
+ declare function declareDefault<P extends AnyLeafPlugin>({ plugin, }: {
2591
+ plugin: P;
2592
+ }): P;
2510
2593
  /**
2511
2594
  * Define a method-lifecycle hook: a leaf whose `observe` contributes
2512
2595
  * fire-and-forget observers (`onMethodStart` / `onMethodEnd`) the method
@@ -2859,6 +2942,15 @@ interface CoreOptions {
2859
2942
  * reserved for an `on*`-named observer when the unified event bus lands.
2860
2943
  */
2861
2944
  logDeprecation?: (warning: DeprecationWarning) => void;
2945
+ /**
2946
+ * Report what output validation stripped, on the response's
2947
+ * `meta.outputValidation.droppedPaths` (the name mirrors that path). Off by
2948
+ * default: the report is a debugging aid for reconciling a schema against the
2949
+ * wire, and a sidecar every caller has to ignore is worse than one a head
2950
+ * turns on while it audits its schemas. Off also skips the recursive
2951
+ * raw-vs-parsed diff, so the strip costs a parse and nothing more.
2952
+ */
2953
+ includeOutputValidationDroppedPaths?: boolean;
2862
2954
  }
2863
2955
 
2864
2956
  /**
@@ -3449,6 +3541,8 @@ declare function createPaginatedFunction<TUserOptions, TResponse, TItem = ItemTy
3449
3541
  adaptPage?: (response: TResponse) => SdkPage<NoInfer<TItem>>;
3450
3542
  /** Pre-run per-method annotator (see applyAnnotations). */
3451
3543
  annotator?: (input: unknown) => Annotations;
3544
+ /** Applied to each canonical page after the shape guard (output validation). */
3545
+ finalizePage?: (page: SdkPage<TItem>) => SdkPage<TItem>;
3452
3546
  /** Live read of the method's deprecation meta (see signalDeprecation). */
3453
3547
  getDeprecation?: () => FunctionDeprecation | undefined;
3454
3548
  }): (options?: TUserOptions & {
@@ -3749,4 +3843,4 @@ declare class CoreCancelledSignal extends CoreSignal {
3749
3843
  */
3750
3844
  declare function isCoreCancelledSignal(value: unknown): value is CoreCancelledSignal;
3751
3845
 
3752
- 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 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 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, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, 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 };
3846
+ 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 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, 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 };