@zapier/kitcore 0.7.0 → 0.9.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
@@ -20,31 +20,124 @@ interface SdkPage<T = unknown> {
20
20
  nextCursor?: string;
21
21
  }
22
22
  /**
23
- * Return type of every paginated SDK method. The same value is both:
23
+ * Return type of every paginated SDK method. The documented surface is:
24
24
  *
25
- * - a Promise that resolves to the first page (`SdkPage<TItem>`), and
26
- * - an AsyncIterable that yields each page in turn,
25
+ * - `await` the result for the first page (`SdkPage<TItem>`),
26
+ * - `.pages()` for an AsyncIterable over pages, and
27
+ * - `.items()` for an AsyncIterable over individual items across pages.
27
28
  *
28
- * with an `.items()` method that returns an AsyncIterable over individual
29
- * items across all pages. Named so paginated plugin signatures serialize
30
- * as `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the
31
- * full triple-intersection at every callsite.
29
+ * `.pages()` and `.items()` return plain iterables (not thenables), so they
30
+ * survive being returned from an `async` function; the result itself is a
31
+ * thenable, so an `async` boundary silently collapses it to the first page.
32
+ * Named so paginated plugin signatures serialize as
33
+ * `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the full
34
+ * intersection at every callsite.
32
35
  *
33
36
  * The faces share one underlying cursor, so a result is consumed once:
34
37
  *
35
38
  * - `await` / `.then()` read the buffered first page without starting the
36
39
  * stream, so awaiting is a repeatable peek and you can still iterate the
37
40
  * result afterward.
38
- * - The page-iterable and `.items()` are two views over one page stream, so
39
- * consuming either drains the other: the second view yields nothing (it
40
- * does not replay page 1). To read a result more than once, call the
41
- * method again for a fresh result.
41
+ * - `.pages()`, `.items()`, and the deprecated bare iteration are views
42
+ * over one page stream, so consuming any view drains the others: the
43
+ * second view yields nothing (it does not replay page 1). To read a
44
+ * result more than once, call the method again for a fresh result.
42
45
  */
43
- interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem>>, AsyncIterable<SdkPage<TItem>> {
46
+ interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem>> {
47
+ /**
48
+ * @deprecated Iterate `.pages()` instead. Bare iteration works but is easy
49
+ * to break: because the result is also a thenable, an `async` boundary
50
+ * collapses it to its first page and the iterable is silently lost.
51
+ *
52
+ * Deliberately no runtime deprecation warning: this face is not scheduled
53
+ * for deletion (removing it is a breaking change deferred to a separate
54
+ * decision), and structural consumers such as the CLI's page streaming
55
+ * detect pagination via `Symbol.asyncIterator`, so a warning would fire on
56
+ * the SDK's own machinery.
57
+ */
58
+ [Symbol.asyncIterator](): AsyncIterator<SdkPage<TItem>>;
59
+ pages(): AsyncIterable<SdkPage<TItem>>;
44
60
  items(): AsyncIterable<TItem>;
45
61
  }
46
62
  type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => PaginatedSdkResult<TItem>;
47
63
 
64
+ /**
65
+ * Per-call context threaded explicitly through the method boundary in place of
66
+ * ambient AsyncLocalStorage. It carries call identity, nesting depth, and a
67
+ * per-invocation annotation bag. Because it travels as data, correlation and
68
+ * nested-call dedup work without `async_hooks` — including in browsers, where
69
+ * the old ALS store was inert and nested calls all looked top-level.
70
+ *
71
+ * Framework-neutral: heads surface `callId` under their own name (e.g. a
72
+ * correlation id) and own their annotation field names.
73
+ */
74
+ /**
75
+ * A private brand (a fresh `Symbol()`, never `Symbol.for`) makes a CallContext
76
+ * unforgeable: no outside code can name the symbol to synthesize an id-bearing
77
+ * context, and the brand never collides across bundled copies. This is the same
78
+ * unforgeability the `INTERNAL_CALL` sentinel relies on.
79
+ */
80
+ declare const CALL_CONTEXT_BRAND: unique symbol;
81
+ interface CallContext {
82
+ /** Minted once at the root call; copied verbatim to every nested (child) call. */
83
+ callId: string | null;
84
+ /** 0 at the outermost call; `parent.depth + 1` for a delegated call. */
85
+ depth: number;
86
+ /**
87
+ * Per-invocation scratch space. Never forwarded to callees — a child call
88
+ * gets a fresh bag — so annotations describe one method's own invocation.
89
+ */
90
+ annotations: Record<string, unknown>;
91
+ readonly [CALL_CONTEXT_BRAND]: true;
92
+ }
93
+
94
+ /**
95
+ * Method-call lifecycle hooks. Plugins contribute `onMethodStart` and/or
96
+ * `onMethodEnd` on their context; `buildHooks` composes contributions across
97
+ * plugins so multiple observers can coexist. Composition is right-additive
98
+ * (newer plugins fire after earlier ones); only opt-in methods built through
99
+ * `createPluginMethod` / `createPaginatedPluginMethod` trigger the hooks.
100
+ */
101
+ interface OnMethodStartContext {
102
+ methodName: string;
103
+ args: unknown[];
104
+ isPaginated: boolean;
105
+ /**
106
+ * Depth of this method invocation in the SDK call tree. 0 = outermost
107
+ * (user-initiated) call; 1+ = called from inside another SDK method.
108
+ * Observers can use this to ignore nested calls if they only want
109
+ * top-level events.
110
+ */
111
+ depth: number;
112
+ }
113
+ type OnMethodStart = (ctx: OnMethodStartContext) => void;
114
+ interface OnMethodEndContext {
115
+ methodName: string;
116
+ args: unknown[];
117
+ isPaginated: boolean;
118
+ depth: number;
119
+ durationMs: number;
120
+ error?: Error;
121
+ }
122
+ type OnMethodEnd = (ctx: OnMethodEndContext) => void;
123
+ interface MethodHooks {
124
+ onMethodStart?: OnMethodStart;
125
+ onMethodEnd?: OnMethodEnd;
126
+ }
127
+
128
+ /**
129
+ * Plugins with a required-parameter rename declare two schemas: a canonical one
130
+ * (new names only, carrying `.meta({ aliases })`) and a `z.union([canonical,
131
+ * deprecated])` for runtime input parsing (so callers passing old names still
132
+ * validate). The union has no object shape, so everything that reads parameter
133
+ * shape/requiredness — the registry projection, generated docs, and the
134
+ * resolution planner — must read the canonical variant, not the union.
135
+ *
136
+ * Convention: the FIRST union variant is the canonical schema. Every plugin
137
+ * that uses unions follows this; it's explicit and needs no extra metadata.
138
+ * Runtime validation still uses the full union; only shape reading canonicalizes.
139
+ */
140
+ declare function canonicalInputSchema(schema: z.ZodSchema | undefined): z.ZodSchema | undefined;
48
141
  interface FormattedItem {
49
142
  title: string;
50
143
  /**
@@ -141,8 +234,6 @@ type ListPromptConfig = PromptConfig & {
141
234
  * - `filter` — no resolver uses it; transform values in `listItems` instead.
142
235
  * - `validate`— validation is the resolver's top-level `validate`, which
143
236
  * never routes through rendering (and gets `imports`).
144
- * (The legacy `SchemaParameterResolver` still honors `default`/`filter`/
145
- * `validate`, so the full `PromptConfig` stays for that path.)
146
237
  */
147
238
  type ResolverPromptConfig = Omit<PromptConfig, "name" | "default" | "filter" | "validate">;
148
239
  interface Resolver$1 {
@@ -322,40 +413,6 @@ declare function withPositional<T extends z.ZodType>(schema: T): T & {
322
413
  declare function isPositional(schema: z.ZodType): boolean;
323
414
  declare function openEnum<const T extends readonly [string, ...string[]]>(values: T, description: string): z.ZodUnion<readonly [z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: { [k_1 in T[number]]: k_1; }[k]; } : never>, z.ZodString]>;
324
415
 
325
- /**
326
- * Method-call lifecycle hooks. Plugins contribute `onMethodStart` and/or
327
- * `onMethodEnd` on their context; `buildHooks` composes contributions across
328
- * plugins so multiple observers can coexist. Composition is right-additive
329
- * (newer plugins fire after earlier ones); only opt-in methods built through
330
- * `createPluginMethod` / `createPaginatedPluginMethod` trigger the hooks.
331
- */
332
- interface OnMethodStartContext {
333
- methodName: string;
334
- args: unknown[];
335
- isPaginated: boolean;
336
- /**
337
- * Depth of this method invocation in the SDK call tree. 0 = outermost
338
- * (user-initiated) call; 1+ = called from inside another SDK method.
339
- * Observers can use this to ignore nested calls if they only want
340
- * top-level events.
341
- */
342
- depth: number;
343
- }
344
- type OnMethodStart = (ctx: OnMethodStartContext) => void;
345
- interface OnMethodEndContext {
346
- methodName: string;
347
- args: unknown[];
348
- isPaginated: boolean;
349
- depth: number;
350
- durationMs: number;
351
- error?: Error;
352
- }
353
- type OnMethodEnd = (ctx: OnMethodEndContext) => void;
354
- interface MethodHooks {
355
- onMethodStart?: OnMethodStart;
356
- onMethodEnd?: OnMethodEnd;
357
- }
358
-
359
416
  /**
360
417
  * Descriptive metadata a leaf carries for the registry / CLI / MCP / docs:
361
418
  * description, categories, type, formatter, resolvers, etc.
@@ -378,10 +435,6 @@ interface LeafMetaFields {
378
435
  itemType?: string;
379
436
  returnType?: string;
380
437
  outputSchema?: z.ZodSchema;
381
- inputParameters?: Array<{
382
- name: string;
383
- schema: z.ZodSchema;
384
- }>;
385
438
  packages?: string[];
386
439
  experimental?: boolean;
387
440
  confirm?: "create-secret" | "delete";
@@ -555,12 +608,11 @@ interface DynamicResolver extends ResolverBase {
555
608
  input: Record<string, unknown>;
556
609
  }) => PromiseLike<unknown>;
557
610
  /** Produce the candidate list. Behaves like an SDK list method: returns a
558
- * paginated result (await for the first page + `nextCursor`, or iterate pages),
559
- * never a bare array. `cursor` is the stateless re-entry hook for "load more":
560
- * an in-process host iterates the result; a distributed host awaits one page,
561
- * carries `nextCursor`, and calls again with `cursor`. Required: a dynamic
562
- * resolver IS a candidate-lister; a free-text field (with or without
563
- * auto-resolution someday) is the `static` kind's job. */
611
+ * paginated result (the engine awaits the first page + `nextCursor`), never a
612
+ * bare array. `cursor` is the stateless re-entry hook for "load more": the
613
+ * engine awaits one page, carries `nextCursor`, and calls again with `cursor`.
614
+ * Required: a dynamic resolver IS a candidate-lister; a free-text field (with
615
+ * or without auto-resolution someday) is the `static` kind's job. */
564
616
  listItems: (bag: {
565
617
  imports: Record<string, unknown>;
566
618
  input: Record<string, unknown>;
@@ -644,6 +696,27 @@ interface ObjectResolver extends ResolverBase {
644
696
  input: Record<string, unknown>;
645
697
  }) => PromiseLike<Record<string, Field>>;
646
698
  definitions?: Record<string, Resolver>;
699
+ /** Open-ended entries whose keys aren't known up front (a `z.record`): the
700
+ * walk collects entries in an add/done loop, asking each entry's key (via
701
+ * `keys`, default a free-text string) then its value (via `values`), and
702
+ * assembling them onto the object alongside any fixed `properties`. The
703
+ * JSON-Schema `additionalProperties` analog. */
704
+ additionalKeys?: AdditionalKeys;
705
+ }
706
+ /** The open-keyed-entry spec for an {@link ObjectResolver.additionalKeys}. */
707
+ interface AdditionalKeys {
708
+ /** Resolver for each entry's key; defaults to a free-text string prompt. A
709
+ * `{ ref }` resolves against the object's `definitions`. */
710
+ keys?: Resolver | ResolverRef;
711
+ /** Resolver for each entry's value. A `{ ref }` resolves against the
712
+ * object's `definitions`. */
713
+ values: Resolver | ResolverRef;
714
+ minEntries?: number;
715
+ maxEntries?: number;
716
+ /** Coarse value types so a free-text key/value answer coerces (usually
717
+ * `"string"` for the key), the way `Field.valueType` does. */
718
+ keyValueType?: string;
719
+ valueValueType?: string;
647
720
  }
648
721
  /** A homogeneous list: each element resolves through `items`. */
649
722
  interface ArrayResolver extends ResolverBase {
@@ -689,9 +762,9 @@ interface Formatter extends MethodAttachment {
689
762
  }) => FormattedItem;
690
763
  }
691
764
  /** What a dynamic resolver's `listItems` yields: an SDK list-method result
692
- * (`await` for the first page + `nextCursor`, or iterate pages in-process), or a
693
- * plain page / promise of one. No bare array and no scalar: it behaves like any
694
- * other list method, and exact-match short-circuits live on `tryResolveFromSearch`. */
765
+ * (the engine awaits the first page + `nextCursor`), or a plain page / promise
766
+ * of one. No bare array and no scalar: it behaves like any other list method,
767
+ * and exact-match short-circuits live on `tryResolveFromSearch`. */
695
768
  type ListItemsResult<TItem> = PaginatedSdkResult<TItem> | SdkPage<TItem> | Promise<SdkPage<TItem>>;
696
769
  /** A bound object resolver's literal property: its resolver is already bound
697
770
  * (or a `{ ref }` the CLI resolves against `definitions` at runtime). */
@@ -762,7 +835,8 @@ interface BoundDynamicResolver extends BoundResolverBase {
762
835
  } | null>;
763
836
  }
764
837
  /** Keyed members: static `properties` (bound) or a `getProperties`-built
765
- * (unbound) field map; `definitions` holds ref targets. */
838
+ * (unbound) field map; `definitions` holds ref targets. `additionalKeys`
839
+ * carries open-ended entries (a `z.record`). */
766
840
  interface BoundObjectResolver extends BoundResolverBase {
767
841
  type: "object";
768
842
  properties?: Record<string, BoundField>;
@@ -770,6 +844,17 @@ interface BoundObjectResolver extends BoundResolverBase {
770
844
  getProperties?: (bag: {
771
845
  input: Record<string, unknown>;
772
846
  }) => PromiseLike<Record<string, Field>>;
847
+ additionalKeys?: BoundAdditionalKeys;
848
+ }
849
+ /** The bound form of {@link AdditionalKeys}: `keys`/`values` are bound (or a
850
+ * `{ ref }` into the object's `definitions`). */
851
+ interface BoundAdditionalKeys {
852
+ keys?: BoundResolver | ResolverRef;
853
+ values: BoundResolver | ResolverRef;
854
+ minEntries?: number;
855
+ maxEntries?: number;
856
+ keyValueType?: string;
857
+ valueValueType?: string;
773
858
  }
774
859
  /** A homogeneous list resolved through `items` (bound, or a ref into
775
860
  * `definitions`). */
@@ -1177,9 +1262,18 @@ interface MethodEntry {
1177
1262
  * `resolvePlugin` bind this; the surface and registry bind `value`. Absent
1178
1263
  * on legacy graph entries (they bind `value`). */
1179
1264
  internalValue?: (input: any) => any;
1265
+ /** Produce the import-facing twin for a given call context: with a context,
1266
+ * the twin mints a fresh child per invocation (callee inherits `callId`, sits
1267
+ * one level deeper); without one it is the parent-less `internalValue`.
1268
+ * `buildImports` binds this. Absent on legacy graph entries. */
1269
+ bindInternal?: (ctx?: CallContext) => (...args: any[]) => any;
1180
1270
  chain: MiddlewareWrap[];
1181
1271
  /** Carried from the descriptor for the registry / CLI / MCP / docs. */
1182
1272
  inputSchema?: z.ZodType;
1273
+ /** When true, the method owns its input validation and the boundary passes it
1274
+ * through unparsed; carried so the controller skips its final `safeParse` too
1275
+ * (it still uses `inputSchema` to plan/prompt parameters). */
1276
+ skipInputValidation?: boolean;
1183
1277
  meta?: LeafMeta;
1184
1278
  /** Resolved output mode; the registry derives presentation from it. */
1185
1279
  output?: NormalizedOutput;
@@ -1424,7 +1518,7 @@ interface CategoryDefinition {
1424
1518
  /** Plural form of `title`. Auto-derived from the resolved title if omitted. */
1425
1519
  titlePlural?: string;
1426
1520
  }
1427
- interface FunctionRegistryEntry<TSdk = any> {
1521
+ interface FunctionRegistryEntry {
1428
1522
  name: string;
1429
1523
  /**
1430
1524
  * Human-readable description of the function. Surfaced wherever the
@@ -1437,29 +1531,30 @@ interface FunctionRegistryEntry<TSdk = any> {
1437
1531
  itemType?: string;
1438
1532
  returnType?: string;
1439
1533
  inputSchema?: z.ZodSchema;
1440
- inputParameters?: Array<{
1441
- name: string;
1442
- schema: z.ZodSchema;
1443
- }>;
1534
+ /**
1535
+ * When true, the method owns its input validation and its boundary passes the
1536
+ * input through unparsed. The resolution controller reads this to skip its
1537
+ * final `safeParse` (it still uses `inputSchema` to plan/prompt parameters),
1538
+ * so a method routed through the controller isn't re-validated against a
1539
+ * schema it deliberately opts out of. Lifted off the materialized entry.
1540
+ */
1541
+ skipInputValidation?: boolean;
1444
1542
  outputSchema?: z.ZodSchema;
1445
1543
  /**
1446
1544
  * Ordered input keys the public surface projects onto positional arguments
1447
1545
  * (the method's `positional` declaration). Absent when the method takes only
1448
1546
  * the canonical single bag. Lifted off the materialized method entry by the
1449
- * surface builder, like `boundResolvers` — a runtime projection, not
1547
+ * surface builder, like `resolvers` — a runtime projection, not
1450
1548
  * descriptive meta.
1451
1549
  */
1452
1550
  positional?: readonly string[];
1453
1551
  categories: string[];
1454
- resolvers?: Record<string, ResolverMetadata<TSdk, any, any>>;
1455
1552
  /**
1456
- * Per-parameter bound resolvers from the new model (imports already captured,
1457
- * called with `input` only, no sdk). Parallel to the legacy `resolvers` field
1458
- * and `formatter`: the surface builder lifts these off the materialized method
1459
- * entry. Additive bridge — populated for migrated `defineMethod` plugins; the
1460
- * legacy `resolvers` field above stays the source for unmigrated ones.
1553
+ * Per-parameter bound resolvers (imports already captured, called with
1554
+ * `input` only, no sdk). Lifted off the materialized method entry by the
1555
+ * surface builder.
1461
1556
  */
1462
- boundResolvers?: Record<string, BoundResolver>;
1557
+ resolvers?: Record<string, BoundResolver>;
1463
1558
  packages?: string[];
1464
1559
  /**
1465
1560
  * True if the plugin is registered only in the experimental SDK
@@ -1493,8 +1588,8 @@ interface FunctionDeprecation {
1493
1588
  /** User-facing deprecation message for why/how to migrate */
1494
1589
  message: string;
1495
1590
  }
1496
- interface RegistryResult<TSdk = any> {
1497
- functions: FunctionRegistryEntry<TSdk>[];
1591
+ interface RegistryResult {
1592
+ functions: FunctionRegistryEntry[];
1498
1593
  categories: {
1499
1594
  key: string;
1500
1595
  title: string;
@@ -1599,7 +1694,7 @@ type Sdk<T = {
1599
1694
  }> = T & {
1600
1695
  getRegistry(options?: {
1601
1696
  package?: string;
1602
- }): RegistryResult<T>;
1697
+ }): RegistryResult;
1603
1698
  };
1604
1699
 
1605
1700
  /**
@@ -2187,6 +2282,8 @@ declare function defineResolver<const TImports extends ImportsInput = readonly [
2187
2282
  input: TInput;
2188
2283
  }) => PromiseLike<Record<string, Field>>;
2189
2284
  definitions?: Record<string, Resolver>;
2285
+ /** Open-ended entries whose keys aren't known up front (a `z.record`). */
2286
+ additionalKeys?: AdditionalKeys;
2190
2287
  }): ObjectResolver;
2191
2288
  declare function defineResolver(config: {
2192
2289
  type: "array";
@@ -2667,7 +2764,7 @@ declare const dangerousContextPlugin: PropertyPlugin<"context", SdkContext>;
2667
2764
  */
2668
2765
  declare const getRegistryPlugin: MethodPlugin<"getRegistry", {
2669
2766
  package?: string | undefined;
2670
- } | undefined, RegistryResult<any>, readonly []> & LeafSummary<"kitcore", "getRegistry", readonly [PropertyPlugin<"context", SdkContext>]>;
2767
+ } | undefined, RegistryResult, readonly []> & LeafSummary<"kitcore", "getRegistry", readonly [PropertyPlugin<"context", SdkContext>]>;
2671
2768
 
2672
2769
  /**
2673
2770
  * The external escape-hatch key for an SDK's context. A Symbol,
@@ -2828,13 +2925,13 @@ type ControllerQuestion = {
2828
2925
  path: ControllerPath;
2829
2926
  message: string;
2830
2927
  description?: string;
2831
- /** Which container kind this decision gates. `array` is the add-another
2832
- * loop; `object` is the entry gate on an optional object, fired BEFORE
2833
- * its fields are fetched (`add` descends into the fields, `done` skips
2834
- * the container). A host that renders `message` + `actions` generically
2835
- * needs nothing else; this is additive metadata for hosts that render
2836
- * containers specially. */
2837
- container: "array" | "object";
2928
+ /** Which container type this decision is about. `array`/`record` are the
2929
+ * add-another loops; `object` covers both the optional-object gate (fired
2930
+ * BEFORE its fields are fetched: `add` descends, `done` skips it) and the
2931
+ * optional-fields gate. A host that renders `message` + `actions`
2932
+ * generically needs nothing else; this is additive metadata for hosts
2933
+ * that render containers specially. */
2934
+ container: "array" | "object" | "record";
2838
2935
  /** Object optionals gate only: the fields the `add` action would walk
2839
2936
  * (key + display label + coarse value type), so a smart host can render
2840
2937
  * them (or a form section) instead of a blind yes/no. Dumb hosts keep
@@ -2943,11 +3040,16 @@ interface ControllerState {
2943
3040
  /** The path of the parameter (or nested field) currently being asked. */
2944
3041
  current?: ControllerPath;
2945
3042
  /** Which container decision the outstanding `collection` question is, when
2946
- * `current` points at one: the array add/done loop, an optional object's
2947
- * entry gate, or an object's optionals gate. Recorded explicitly so `step`'s
2948
- * add/done handling never infers the decision from value presence or
2949
- * resolver shape. Absent when `current` is a plain leaf question. */
2950
- gate?: "array" | "entry" | "optionals";
3043
+ * `current` points at one, named `<container>_<subject>`: `array_items` and
3044
+ * `record_entries` are the add/done loops; `object_optional` is whether to
3045
+ * provide an optional object at all (fired before its fields are fetched);
3046
+ * `object_optional_properties` is whether to fill that object's optional
3047
+ * fields. `record_key` marks the one bespoke record step (collecting an
3048
+ * entry's key); the value that follows is an ordinary leaf question with no
3049
+ * gate. Recorded explicitly so `step`'s handling never infers the decision
3050
+ * from value presence or resolver shape. Absent when `current` is a plain
3051
+ * leaf question. */
3052
+ gate?: "array_items" | "record_entries" | "record_key" | "object_optional" | "object_optional_properties";
2951
3053
  /** Where pagination stands for the current dynamic leaf: coordinates only
2952
3054
  * (cursor trail, generation), never items or live iterators — the page's
2953
3055
  * items ride the ask's question. */
@@ -3174,7 +3276,7 @@ type FunctionSdk = {
3174
3276
  * and `context.core`
3175
3277
  * @param options.schema - optional Zod schema for input validation
3176
3278
  */
3177
- declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptions = TOptions>(coreFn: (options: TOptions) => Promise<TResult>, options: {
3279
+ declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptions = TOptions>(coreFn: (options: TOptions, context?: CallContext) => Promise<TResult>, options: {
3178
3280
  sdk: FunctionSdk;
3179
3281
  schema?: z.ZodSchema<TSchemaOptions>;
3180
3282
  name?: string;
@@ -3200,7 +3302,7 @@ type ItemType<TResult> = TResult extends {
3200
3302
  declare function createPaginatedFunction<TUserOptions, TResponse, TItem = ItemType<TResponse>>(coreFn: (options: TUserOptions & {
3201
3303
  cursor?: string;
3202
3304
  pageSize?: number;
3203
- }) => Promise<TResponse>, options: {
3305
+ }, context?: CallContext) => Promise<TResponse>, options: {
3204
3306
  sdk: FunctionSdk;
3205
3307
  schema?: z.ZodSchema<TUserOptions>;
3206
3308
  name?: string;
@@ -3376,41 +3478,54 @@ interface PaginatedResult<TItem> {
3376
3478
  nextCursor?: string;
3377
3479
  }
3378
3480
  /**
3379
- * One page-at-a-time source for `concatPaginated`: called with that source's
3380
- * own cursor, resolves one page. An SDK paginated method fits directly
3381
- * (`({ cursor }) => sdk.listThings({ cursor })` awaiting a paginated
3481
+ * Supplies one list to `concatLists`: called with that list's own cursor,
3482
+ * resolves one page. An SDK paginated method fits directly
3483
+ * (`({ cursor }) => sdk.listThings({ cursor })`; awaiting a paginated
3382
3484
  * result yields the requested page).
3383
3485
  */
3384
- type PaginatedSource<TItem> = (options: {
3486
+ type ListSource<TItem> = (options: {
3385
3487
  cursor?: string;
3386
3488
  }) => PromiseLike<PaginatedResult<TItem>>;
3387
3489
  /**
3388
- * Concatenate multiple paginated sources into a single paginated stream.
3389
- * Sources are drained in order, one page per underlying call.
3490
+ * List one page of several paginated lists joined end to end. Lists are
3491
+ * drained in order; pass a page's `nextCursor` back in to get the next page.
3390
3492
  *
3391
- * Pagination is stateless: every outgoing cursor encodes which source to
3392
- * resume plus that source's own cursor, so a fresh `concatPaginated` call
3393
- * with `cursor` continues exactly where the previous page left off. Sources
3394
- * must therefore produce disjoint items themselves; there is no cross-source
3395
- * dedupe (an in-memory seen-set could not survive the cursor round-trip).
3493
+ * Pagination is stateless: every outgoing cursor encodes which list to
3494
+ * resume plus that list's own cursor, so a fresh `concatLists` call
3495
+ * continues exactly where the previous page left off. A cursor stores its
3496
+ * position by list index, so it is only valid while `sources` keeps the
3497
+ * same lists in the same order. Lists must produce disjoint items
3498
+ * themselves; there is no cross-list dedupe (an in-memory seen-set could
3499
+ * not survive the cursor round-trip).
3396
3500
  *
3397
- * Uses paginateBuffered internally to normalize page sizes across source
3398
- * boundaries — e.g. if the first source only has 2 items, they'll be
3399
- * buffered with items from the next source into a full page.
3400
- *
3401
- * The result is a thenable for the first page that also async-iterates
3402
- * pages in-process.
3501
+ * Uses paginateBuffered internally to normalize page sizes across list
3502
+ * boundaries: if the first list only has 2 items, they'll be buffered with
3503
+ * items from the next list into a full page.
3504
+ */
3505
+ declare function concatLists<TItem>({ sources, pageSize, cursor, }: {
3506
+ /** The lists to concatenate, each supplied as a page-fetching source. */
3507
+ sources: ListSource<TItem>[];
3508
+ pageSize?: number;
3509
+ /** Cursor from a previous `concatLists` page; resumes there. */
3510
+ cursor?: string;
3511
+ }): Promise<PaginatedResult<TItem>>;
3512
+ /**
3513
+ * @deprecated Use {@link concatLists}; awaiting either yields the same one
3514
+ * page. The page-iterable half of the old return shape is gone; to walk
3515
+ * pages, pass each page's `nextCursor` to a fresh call.
3403
3516
  */
3404
3517
  declare function concatPaginated<TItem>({ sources, pageSize, cursor, }: {
3405
- sources: PaginatedSource<TItem>[];
3518
+ sources: ListSource<TItem>[];
3406
3519
  pageSize?: number;
3407
- /** Cursor from a previous `concatPaginated` page; resumes the stream. */
3408
3520
  cursor?: string;
3409
- }): PromiseLike<PaginatedResult<TItem>> & AsyncIterable<PaginatedResult<TItem>>;
3521
+ }): Promise<PaginatedResult<TItem>>;
3410
3522
  /**
3411
3523
  * Strip the PromiseLike from an async iterable, returning a plain
3412
3524
  * AsyncIterable. This prevents async functions from unwrapping the
3413
3525
  * iterable (since async only unwraps PromiseLike, not AsyncIterable).
3526
+ *
3527
+ * @deprecated Call `.pages()` on the paginated result instead; it returns a
3528
+ * plain AsyncIterable over pages with no wrapper needed.
3414
3529
  */
3415
3530
  declare function toIterable<T>(source: AsyncIterable<T>): AsyncIterable<T>;
3416
3531
 
@@ -3495,4 +3610,4 @@ declare class CoreCancelledSignal extends CoreSignal {
3495
3610
  constructor(message?: string);
3496
3611
  }
3497
3612
 
3498
- export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, 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, composePlugins, 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, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
3613
+ export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, 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, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };