@walkeros/core 4.0.0 → 4.1.0-next-1778155282668

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
@@ -312,7 +312,6 @@ interface Instance$6 {
312
312
  timing: number;
313
313
  user: User;
314
314
  pending: {
315
- sources: InitSources;
316
315
  destinations: InitDestinations;
317
316
  };
318
317
  }
@@ -347,34 +346,36 @@ declare namespace context {
347
346
  }
348
347
 
349
348
  /**
350
- * Context provided to the destroy() lifecycle method.
351
- *
352
- * A subset of the init context — config, env, logger, and id.
353
- * Does NOT include collector or event data. Destroy should only
354
- * clean up resources, not interact with the event pipeline.
349
+ * Shared context for one-shot lifecycle hooks (setup, destroy).
350
+ * No event pipeline machinery — just config, env, logger, and id.
355
351
  */
356
- interface DestroyContext<C = unknown, E = unknown> {
357
- /** Step instance ID. */
352
+ interface LifecycleContext<C = unknown, E = unknown> {
358
353
  id: string;
359
- /** Step configuration (contains settings with SDK clients, etc.). */
360
354
  config: C;
361
- /** Runtime environment/dependencies (DB clients, auth clients, etc.). */
362
355
  env: E;
363
- /** Scoped logger for this step instance. */
364
356
  logger: Instance$4;
365
357
  }
358
+ /**
359
+ * Setup function signature. Called once via `walkeros setup <kind>.<name>`.
360
+ * Packages own idempotency and error semantics. Return value (if any) is
361
+ * JSON-stringified to stdout by the CLI for scripting use.
362
+ */
363
+ type SetupFn<C = unknown, E = unknown> = (context: LifecycleContext<C, E>) => PromiseOrValue<unknown>;
366
364
  /**
367
365
  * Destroy function signature for step lifecycle cleanup.
368
- *
369
- * Implementations should be idempotent — calling destroy() twice must not throw.
370
- * Used for closing connections, clearing timers, releasing SDK clients.
371
366
  */
372
- type DestroyFn<C = unknown, E = unknown> = (context: DestroyContext<C, E>) => PromiseOrValue<void>;
367
+ type DestroyFn<C = unknown, E = unknown> = (context: LifecycleContext<C, E>) => PromiseOrValue<void>;
368
+ /**
369
+ * @deprecated Use `LifecycleContext` instead. Kept as alias for one minor cycle.
370
+ */
371
+ type DestroyContext<C = unknown, E = unknown> = LifecycleContext<C, E>;
373
372
 
374
373
  type lifecycle_DestroyContext<C = unknown, E = unknown> = DestroyContext<C, E>;
375
374
  type lifecycle_DestroyFn<C = unknown, E = unknown> = DestroyFn<C, E>;
375
+ type lifecycle_LifecycleContext<C = unknown, E = unknown> = LifecycleContext<C, E>;
376
+ type lifecycle_SetupFn<C = unknown, E = unknown> = SetupFn<C, E>;
376
377
  declare namespace lifecycle {
377
- export type { lifecycle_DestroyContext as DestroyContext, lifecycle_DestroyFn as DestroyFn };
378
+ export type { lifecycle_DestroyContext as DestroyContext, lifecycle_DestroyFn as DestroyFn, lifecycle_LifecycleContext as LifecycleContext, lifecycle_SetupFn as SetupFn };
378
379
  }
379
380
 
380
381
  /**
@@ -393,13 +394,14 @@ interface BaseEnv$3 {
393
394
  }
394
395
  /**
395
396
  * Type bundle for destination generics.
396
- * Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
397
+ * Groups Settings, InitSettings, Mapping, Env, and Setup into a single type parameter.
397
398
  */
398
- interface Types$4<S = unknown, M = unknown, E = BaseEnv$3, I = S> {
399
+ interface Types$4<S = unknown, M = unknown, E = BaseEnv$3, I = S, U = unknown> {
399
400
  settings: S;
400
401
  initSettings: I;
401
402
  mapping: M;
402
403
  env: E;
404
+ setup: U;
403
405
  }
404
406
  /**
405
407
  * Generic constraint for Types - ensures T has required properties for indexed access
@@ -409,6 +411,7 @@ type TypesGeneric$3 = {
409
411
  initSettings: any;
410
412
  mapping: any;
411
413
  env: any;
414
+ setup: any;
412
415
  };
413
416
  /**
414
417
  * Type extractors for consistent usage with Types bundle
@@ -417,6 +420,7 @@ type Settings$3<T extends TypesGeneric$3 = Types$4> = T['settings'];
417
420
  type InitSettings$3<T extends TypesGeneric$3 = Types$4> = T['initSettings'];
418
421
  type Mapping$1<T extends TypesGeneric$3 = Types$4> = T['mapping'];
419
422
  type Env$3<T extends TypesGeneric$3 = Types$4> = T['env'];
423
+ type SetupOptions$2<T extends TypesGeneric$3 = Types$4> = T['setup'];
420
424
  /**
421
425
  * Inference helper: Extract Types from Instance
422
426
  */
@@ -432,6 +436,7 @@ interface Instance$5<T extends TypesGeneric$3 = Types$4> {
432
436
  batches?: BatchRegistry<Mapping$1<T>>;
433
437
  type?: string;
434
438
  env?: Env$3<T>;
439
+ setup?: SetupFn<Config$5<T>, Env$3<T>>;
435
440
  init?: InitFn$2<T>;
436
441
  push: PushFn<T>;
437
442
  pushBatch?: PushBatchFn<T>;
@@ -465,6 +470,11 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
465
470
  queue?: boolean;
466
471
  /** Defer destination initialization until these collector events fire (e.g., `['consent']`). */
467
472
  require?: string[];
473
+ /**
474
+ * Provisioning options for `walker setup`. `boolean | object`.
475
+ * Triggered only by explicit CLI invocation; never automatic.
476
+ */
477
+ setup?: boolean | SetupOptions$2<T>;
468
478
  /** Transformer chain to run after collector processing but before this destination. */
469
479
  before?: Next;
470
480
  /** Transformer chain to run after destination push completes. Push response available at ingest._response. */
@@ -476,7 +486,7 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
476
486
  /** Return this value instead of calling push(). Uses !== undefined check to support falsy values. */
477
487
  mock?: unknown;
478
488
  }
479
- type PartialConfig$1<T extends TypesGeneric$3 = Types$4> = Config$5<Types$4<Partial<Settings$3<T>> | Settings$3<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$3<T>>>;
489
+ type PartialConfig$2<T extends TypesGeneric$3 = Types$4> = Config$5<Types$4<Partial<Settings$3<T>> | Settings$3<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$3<T>, InitSettings$3<T>, SetupOptions$2<T>>>;
480
490
  interface Policy {
481
491
  [key: string]: Value;
482
492
  }
@@ -558,7 +568,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
558
568
  type destination_PushFn<T extends TypesGeneric$3 = Types$4> = PushFn<T>;
559
569
  type destination_Ref = Ref;
560
570
  declare namespace destination {
561
- export type { BaseEnv$3 as BaseEnv, destination_Batch as Batch, destination_BatchRegistry as BatchRegistry, Code$1 as Code, Config$5 as Config, Context$5 as Context, destination_DLQ as DLQ, destination_Data as Data, destination_Destinations as Destinations, Env$3 as Env, Init$3 as Init, destination_InitDestinations as InitDestinations, InitFn$2 as InitFn, InitSettings$3 as InitSettings, Instance$5 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, destination_Policy as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Settings$3 as Settings, Types$4 as Types, TypesGeneric$3 as TypesGeneric, TypesOf$3 as TypesOf };
571
+ export type { BaseEnv$3 as BaseEnv, destination_Batch as Batch, destination_BatchRegistry as BatchRegistry, Code$1 as Code, Config$5 as Config, Context$5 as Context, destination_DLQ as DLQ, destination_Data as Data, destination_Destinations as Destinations, Env$3 as Env, Init$3 as Init, destination_InitDestinations as InitDestinations, InitFn$2 as InitFn, InitSettings$3 as InitSettings, Instance$5 as Instance, Mapping$1 as Mapping, PartialConfig$2 as PartialConfig, destination_Policy as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Settings$3 as Settings, SetupOptions$2 as SetupOptions, Types$4 as Types, TypesGeneric$3 as TypesGeneric, TypesOf$3 as TypesOf };
562
572
  }
563
573
 
564
574
  interface EventFn<R = Promise<PushResult>> {
@@ -608,7 +618,8 @@ declare namespace elb {
608
618
  * Represents one deployment target (e.g., web_prod, server_stage).
609
619
  * Platform is determined by `config.platform` ('web' | 'server').
610
620
  *
611
- * Variables/definitions cascade: source/destination > flow > root config.
621
+ * Variables cascade (resolveFlowSettings): step > flow > root config.
622
+ * "step" applies uniformly to source, destination, transformer, and store.
612
623
  */
613
624
  interface Flow {
614
625
  /** Per-flow configuration: platform, url, settings, bundle. */
@@ -672,11 +683,6 @@ interface Flow {
672
683
  * Override root variables; overridden by source/destination variables.
673
684
  */
674
685
  variables?: Flow.Variables;
675
- /**
676
- * Flow-level definitions.
677
- * Extend root definitions; overridden by source/destination definitions.
678
- */
679
- definitions?: Flow.Definitions;
680
686
  }
681
687
  declare namespace Flow {
682
688
  /**
@@ -721,11 +727,6 @@ declare namespace Flow {
721
727
  * Syntax: $var.name
722
728
  */
723
729
  variables?: Variables;
724
- /**
725
- * Reusable configuration definitions.
726
- * Syntax: $def.name
727
- */
728
- definitions?: Definitions;
729
730
  /**
730
731
  * Data contract definition.
731
732
  * Entity → action keyed JSON Schema with additive inheritance.
@@ -765,23 +766,17 @@ declare namespace Flow {
765
766
  */
766
767
  settings?: Settings;
767
768
  /**
768
- * Bundle configuration: NPM packages to include, transitive dependency overrides.
769
+ * Bundle configuration: NPM packages to include, transitive dependency
770
+ * overrides, and extra trace includes for server bundles.
769
771
  * Consumed by the CLI bundler at build time.
770
772
  */
771
773
  bundle?: Bundle;
772
774
  }
773
- /** Primitive value types for variables. */
774
- type Primitive = string | number | boolean;
775
775
  /**
776
- * Variables record type for interpolation.
777
- * Used at root, flow, source, destination, transformer, and store levels.
776
+ * Reusable values referenced via `$var.name` (with optional deep paths).
777
+ * Whole-string references preserve native type; inline interpolation requires scalars.
778
778
  */
779
- type Variables = Record<string, Primitive>;
780
- /**
781
- * Definitions record type for reusable configurations.
782
- * Used at root, flow, source, destination, transformer, and store levels.
783
- */
784
- type Definitions = Record<string, unknown>;
779
+ type Variables = Record<string, unknown>;
785
780
  /**
786
781
  * Free-form settings bag inside `Flow.Config.settings`.
787
782
  * Mirrors the package settings convention (arbitrary keys).
@@ -790,8 +785,12 @@ declare namespace Flow {
790
785
  /**
791
786
  * Bundle configuration for a flow.
792
787
  *
793
- * Groups all build-time bundling concerns: NPM packages to include and
794
- * transitive dependency overrides. Consumed by the CLI bundler.
788
+ * Groups all build-time bundling concerns: NPM packages to include,
789
+ * transitive dependency overrides, and extra trace includes (server only).
790
+ * Consumed by the CLI bundler.
791
+ *
792
+ * The `flow.config.bundle.external` sub-field is no longer supported
793
+ * (replaced by nft tracing in @walkeros/cli@4.x).
795
794
  */
796
795
  interface Bundle {
797
796
  /** NPM packages to bundle, keyed by package name. */
@@ -799,7 +798,7 @@ declare namespace Flow {
799
798
  /**
800
799
  * Transitive dependency version pins.
801
800
  *
802
- * Maps package name version spec. Applied during bundle package install
801
+ * Maps package name to version spec. Applied during bundle package install
803
802
  * to force transitive dependencies to a specific version. Useful for
804
803
  * resolving conflicts between packages that depend on incompatible
805
804
  * versions of a shared dependency.
@@ -812,6 +811,17 @@ declare namespace Flow {
812
811
  * ```
813
812
  */
814
813
  overrides?: Record<string, string>;
814
+ /**
815
+ * Extra paths the bundler must include in the trace output.
816
+ *
817
+ * Each entry is either a literal path or a glob (matched via picomatch),
818
+ * resolved against the bundler's install root. Use as an escape hatch
819
+ * when the file tracer cannot statically discover an asset (e.g.,
820
+ * dynamic require, runtime configuration files).
821
+ *
822
+ * Server flows only.
823
+ */
824
+ traceInclude?: string[];
815
825
  }
816
826
  /**
817
827
  * Single bundle package entry.
@@ -907,11 +917,6 @@ declare namespace Flow {
907
917
  * Overrides flow and root variables.
908
918
  */
909
919
  variables?: Variables;
910
- /**
911
- * Source-level definitions (highest priority in cascade).
912
- * Overrides flow and root definitions.
913
- */
914
- definitions?: Definitions;
915
920
  /**
916
921
  * Named examples for testing and documentation.
917
922
  * Stripped during flow resolution (not included in bundles).
@@ -959,8 +964,6 @@ declare namespace Flow {
959
964
  cache?: Cache;
960
965
  /** Destination-level variables (highest priority in cascade). */
961
966
  variables?: Variables;
962
- /** Destination-level definitions (highest priority in cascade). */
963
- definitions?: Definitions;
964
967
  /**
965
968
  * Named examples for testing and documentation.
966
969
  * Stripped during flow resolution.
@@ -1005,8 +1008,6 @@ declare namespace Flow {
1005
1008
  cache?: Cache;
1006
1009
  /** Transformer-level variables (highest priority in cascade). */
1007
1010
  variables?: Variables;
1008
- /** Transformer-level definitions (highest priority in cascade). */
1009
- definitions?: Definitions;
1010
1011
  /**
1011
1012
  * Named examples for testing and documentation.
1012
1013
  * Stripped during flow resolution.
@@ -1031,8 +1032,6 @@ declare namespace Flow {
1031
1032
  env?: unknown;
1032
1033
  /** Store-level variables (highest priority in cascade). */
1033
1034
  variables?: Variables;
1034
- /** Store-level definitions (highest priority in cascade). */
1035
- definitions?: Definitions;
1036
1035
  /**
1037
1036
  * Named examples for testing and documentation.
1038
1037
  * Stripped during flow resolution.
@@ -1595,20 +1594,22 @@ interface BaseEnv$1 {
1595
1594
  }
1596
1595
  /**
1597
1596
  * Type bundle for source generics.
1598
- * Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
1597
+ * Groups Settings, Mapping, Push, Env, InitSettings, and Setup into a single type parameter.
1599
1598
  *
1600
1599
  * @template S - Settings configuration type
1601
1600
  * @template M - Mapping configuration type
1602
1601
  * @template P - Push function signature (flexible to support HTTP handlers, etc.)
1603
1602
  * @template E - Environment dependencies type
1604
1603
  * @template I - InitSettings configuration type (user input)
1604
+ * @template U - Setup options type (provisioning options for `walker setup`)
1605
1605
  */
1606
- interface Types$1<S = unknown, M = unknown, P = Fn$3, E = BaseEnv$1, I = S> {
1606
+ interface Types$1<S = unknown, M = unknown, P = Fn$3, E = BaseEnv$1, I = S, U = unknown> {
1607
1607
  settings: S;
1608
1608
  initSettings: I;
1609
1609
  mapping: M;
1610
1610
  push: P;
1611
1611
  env: E;
1612
+ setup: U;
1612
1613
  }
1613
1614
  /**
1614
1615
  * Generic constraint for Types - ensures T has required properties for indexed access
@@ -1619,6 +1620,7 @@ type TypesGeneric$1 = {
1619
1620
  mapping: any;
1620
1621
  push: any;
1621
1622
  env: any;
1623
+ setup: any;
1622
1624
  };
1623
1625
  /**
1624
1626
  * Type extractors for consistent usage with Types bundle
@@ -1628,6 +1630,7 @@ type InitSettings$1<T extends TypesGeneric$1 = Types$1> = T['initSettings'];
1628
1630
  type Mapping<T extends TypesGeneric$1 = Types$1> = T['mapping'];
1629
1631
  type Push<T extends TypesGeneric$1 = Types$1> = T['push'];
1630
1632
  type Env$1<T extends TypesGeneric$1 = Types$1> = T['env'];
1633
+ type SetupOptions$1<T extends TypesGeneric$1 = Types$1> = T['setup'];
1631
1634
  /**
1632
1635
  * Inference helper: Extract Types from Instance
1633
1636
  */
@@ -1645,6 +1648,11 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> extends Config$7<Mapping<
1645
1648
  primary?: boolean;
1646
1649
  /** Defer source initialization until these collector events fire (e.g., `['consent']`). */
1647
1650
  require?: string[];
1651
+ /**
1652
+ * Provisioning options for `walker setup`. `boolean | object`.
1653
+ * Triggered only by explicit CLI invocation; never automatic.
1654
+ */
1655
+ setup?: boolean | SetupOptions$1<T>;
1648
1656
  /**
1649
1657
  * Ingest metadata extraction mapping.
1650
1658
  * Extracts values from raw request objects (Express req, Lambda event, etc.)
@@ -1660,14 +1668,39 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> extends Config$7<Mapping<
1660
1668
  ingest?: Data$1;
1661
1669
  /** Completely skip this source — no init, no event capture. */
1662
1670
  disabled?: boolean;
1671
+ /**
1672
+ * Init lifecycle flag. Set by the collector to `true` after `Instance.init()`
1673
+ * has been called. Used together with `require` to gate `on()` delivery:
1674
+ * lifecycle events are queued in `Instance.queueOn` until both
1675
+ * `config.init === true` and `config.require` is empty/absent, then replayed.
1676
+ */
1677
+ init?: boolean;
1663
1678
  }
1664
- type PartialConfig<T extends TypesGeneric$1 = Types$1> = Config$1<Types$1<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env$1<T>>>;
1679
+ type PartialConfig$1<T extends TypesGeneric$1 = Types$1> = Config$1<Types$1<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env$1<T>, InitSettings$1<T>, SetupOptions$1<T>>>;
1665
1680
  interface Instance$2<T extends TypesGeneric$1 = Types$1> {
1666
1681
  type: string;
1667
1682
  config: Config$1<T>;
1683
+ setup?: SetupFn<Config$1<T>, Env$1<T>>;
1668
1684
  push: Push<T>;
1669
1685
  destroy?: DestroyFn<Config$1<T>, Env$1<T>>;
1670
1686
  on?(event: Types$3, context?: unknown): void | boolean | Promise<void | boolean>;
1687
+ /**
1688
+ * Optional setup hook. Called by the collector eagerly after all source
1689
+ * factories have run, regardless of `config.require`. Use for prep work
1690
+ * such as draining a pre-init window queue or attaching DOM listeners.
1691
+ * The collector still gates `on()` delivery, and `Collector.push`
1692
+ * enforces `allowed`/consent at the destination layer.
1693
+ */
1694
+ init?: () => void | Promise<void>;
1695
+ /**
1696
+ * Lifecycle event queue. Populated by `onApply` when the source is not
1697
+ * yet started (`config.init !== true` or `config.require` non-empty).
1698
+ * Flushed by the collector when the source becomes started.
1699
+ */
1700
+ queueOn?: Array<{
1701
+ type: Types$3;
1702
+ data: unknown;
1703
+ }>;
1671
1704
  }
1672
1705
  /**
1673
1706
  * Context provided to source init function.
@@ -1713,36 +1746,44 @@ type Renderer = 'browser' | 'codebox';
1713
1746
  type source_InitSource<T extends TypesGeneric$1 = Types$1> = InitSource<T>;
1714
1747
  type source_InitSources = InitSources;
1715
1748
  type source_Mapping<T extends TypesGeneric$1 = Types$1> = Mapping<T>;
1716
- type source_PartialConfig<T extends TypesGeneric$1 = Types$1> = PartialConfig<T>;
1717
1749
  type source_Push<T extends TypesGeneric$1 = Types$1> = Push<T>;
1718
1750
  type source_Renderer = Renderer;
1719
1751
  declare namespace source {
1720
- export type { BaseEnv$1 as BaseEnv, Config$1 as Config, Context$1 as Context, Env$1 as Env, Init$1 as Init, InitSettings$1 as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, Instance$2 as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Renderer as Renderer, Settings$1 as Settings, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1752
+ export type { BaseEnv$1 as BaseEnv, Config$1 as Config, Context$1 as Context, Env$1 as Env, Init$1 as Init, InitSettings$1 as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, Instance$2 as Instance, source_Mapping as Mapping, PartialConfig$1 as PartialConfig, source_Push as Push, source_Renderer as Renderer, Settings$1 as Settings, SetupOptions$1 as SetupOptions, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1721
1753
  }
1722
1754
 
1723
1755
  interface BaseEnv {
1724
1756
  [key: string]: unknown;
1725
1757
  }
1726
- interface Types<S = unknown, E = BaseEnv, I = S> {
1758
+ interface Types<S = unknown, E = BaseEnv, I = S, U = unknown> {
1727
1759
  settings: S;
1728
1760
  initSettings: I;
1729
1761
  env: E;
1762
+ setup: U;
1730
1763
  }
1731
1764
  type TypesGeneric = {
1732
1765
  settings: any;
1733
1766
  initSettings: any;
1734
1767
  env: any;
1768
+ setup: any;
1735
1769
  };
1736
1770
  type Settings<T extends TypesGeneric = Types> = T['settings'];
1737
1771
  type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
1738
1772
  type Env<T extends TypesGeneric = Types> = T['env'];
1773
+ type SetupOptions<T extends TypesGeneric = Types> = T['setup'];
1739
1774
  type TypesOf<I> = I extends Instance$1<infer T> ? T : never;
1740
1775
  interface Config<T extends TypesGeneric = Types> {
1741
1776
  settings?: InitSettings<T>;
1742
1777
  env?: Env<T>;
1743
1778
  id?: string;
1744
1779
  logger?: Config$4;
1780
+ /**
1781
+ * Provisioning options for `walker setup`. `boolean | object`.
1782
+ * Triggered only by explicit CLI invocation; never automatic.
1783
+ */
1784
+ setup?: boolean | SetupOptions<T>;
1745
1785
  }
1786
+ type PartialConfig<T extends TypesGeneric = Types> = Config<Types<Partial<Settings<T>> | Settings<T>, Env<T>, InitSettings<T>, SetupOptions<T>>>;
1746
1787
  interface Context<T extends TypesGeneric = Types> extends Base<Config<T>, Env<T>> {
1747
1788
  id: string;
1748
1789
  }
@@ -1755,6 +1796,7 @@ interface Instance$1<T extends TypesGeneric = Types> {
1755
1796
  get: GetFn;
1756
1797
  set: SetFn;
1757
1798
  delete: DeleteFn;
1799
+ setup?: SetupFn<Config<T>, Env<T>>;
1758
1800
  destroy?: DestroyFn<Config<T>, Env<T>>;
1759
1801
  }
1760
1802
  type Init<T extends TypesGeneric = Types> = (context: Context<Types<Partial<Settings<T>>, Env<T>, InitSettings<T>>>) => Instance$1<T> | Promise<Instance$1<T>>;
@@ -1782,14 +1824,16 @@ type store_InitFn<T extends TypesGeneric = Types> = InitFn<T>;
1782
1824
  type store_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
1783
1825
  type store_InitStore<T extends TypesGeneric = Types> = InitStore<T>;
1784
1826
  type store_InitStores = InitStores;
1827
+ type store_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
1785
1828
  type store_SetFn<T = unknown> = SetFn<T>;
1786
1829
  type store_Settings<T extends TypesGeneric = Types> = Settings<T>;
1830
+ type store_SetupOptions<T extends TypesGeneric = Types> = SetupOptions<T>;
1787
1831
  type store_Stores = Stores;
1788
- type store_Types<S = unknown, E = BaseEnv, I = S> = Types<S, E, I>;
1832
+ type store_Types<S = unknown, E = BaseEnv, I = S, U = unknown> = Types<S, E, I, U>;
1789
1833
  type store_TypesGeneric = TypesGeneric;
1790
1834
  type store_TypesOf<I> = TypesOf<I>;
1791
1835
  declare namespace store {
1792
- export type { store_BaseEnv as BaseEnv, store_Config as Config, store_Context as Context, store_DeleteFn as DeleteFn, store_Env as Env, store_GetFn as GetFn, store_Init as Init, store_InitFn as InitFn, store_InitSettings as InitSettings, store_InitStore as InitStore, store_InitStores as InitStores, Instance$1 as Instance, store_SetFn as SetFn, store_Settings as Settings, store_Stores as Stores, store_Types as Types, store_TypesGeneric as TypesGeneric, store_TypesOf as TypesOf };
1836
+ export type { store_BaseEnv as BaseEnv, store_Config as Config, store_Context as Context, store_DeleteFn as DeleteFn, store_Env as Env, store_GetFn as GetFn, store_Init as Init, store_InitFn as InitFn, store_InitSettings as InitSettings, store_InitStore as InitStore, store_InitStores as InitStores, Instance$1 as Instance, store_PartialConfig as PartialConfig, store_SetFn as SetFn, store_Settings as Settings, store_SetupOptions as SetupOptions, store_Stores as Stores, store_Types as Types, store_TypesGeneric as TypesGeneric, store_TypesOf as TypesOf };
1793
1837
  }
1794
1838
 
1795
1839
  /**
@@ -2133,9 +2177,9 @@ declare function walkPath(value: unknown, path: string, refPrefix: string): unkn
2133
2177
  * Resolver callback for `$flow.X.Y` references.
2134
2178
  *
2135
2179
  * Given a sibling flow name, returns its fully resolved `Flow.Config` block
2136
- * (with `$env`/`$var`/`$def`/`$contract` already resolved) as `unknown` so
2137
- * that {@link walkPath} can traverse it. Returns `undefined` if the flow
2138
- * does not exist. Implementations are responsible for cycle detection across
2180
+ * (with `$env`/`$var`/`$contract` already resolved) as `unknown` so that
2181
+ * {@link walkPath} can traverse it. Returns `undefined` if the flow does
2182
+ * not exist. Implementations are responsible for cycle detection across
2139
2183
  * recursive calls.
2140
2184
  */
2141
2185
  type FlowConfigResolver = (flowName: string) => unknown;
@@ -2152,20 +2196,22 @@ declare function packageNameToVariable(packageName: string): string;
2152
2196
  *
2153
2197
  * Resolution pass order:
2154
2198
  * 1. `$env` / `$var` resolve per-flow in isolation (no cross-flow context).
2199
+ * `$var` resolves recursively (variables may reference other variables,
2200
+ * `$env`, `$contract`, or `$flow`); cycles are detected via a visiting set.
2155
2201
  * 2. `$flow.X.Y` resolves against pass-1 outputs of sibling flows (so `$env`/`$var`
2156
2202
  * inside the referenced flow are already resolved when `$flow` reads it).
2157
- * 3. `$def` / `$contract` resolve last (with `$flow` results available).
2203
+ * 3. `$contract` resolves last (with `$flow` results available).
2158
2204
  *
2159
2205
  * In practice these passes are interleaved by the resolver: when `$flow.X.Y`
2160
2206
  * is encountered, the sibling flow X's `Flow.Config` block is recursively
2161
- * resolved on demand (with all its own `$env`/`$var`/`$def`/`$contract`
2162
- * references resolved first), then the deep path is walked. Cycles are
2163
- * detected via a visiting set.
2207
+ * resolved on demand (with all its own `$env`/`$var`/`$contract` references
2208
+ * resolved first), then the deep path is walked. Cycles are detected via a
2209
+ * visiting set.
2164
2210
  *
2165
2211
  * @param config - The complete Flow.Json (root multi-flow config)
2166
2212
  * @param flowName - Flow name (auto-selected if only one exists)
2167
2213
  * @param options - Resolution options
2168
- * @returns Resolved {@link Flow} with $var, $env, $def, $contract, and $flow patterns resolved
2214
+ * @returns Resolved {@link Flow} with $var, $env, $contract, and $flow patterns resolved
2169
2215
  * @throws Error if flow selection is required but not specified, or flow not found
2170
2216
  * @throws Error if a `$flow.X.Y` reference forms a cycle
2171
2217
  *
@@ -2736,6 +2782,15 @@ declare function transformData(data?: SendDataValue): string | undefined;
2736
2782
  */
2737
2783
  declare function getHeaders(headers?: SendHeaders): SendHeaders;
2738
2784
 
2785
+ /**
2786
+ * Normalize `config.setup` into a concrete options object, or null when disabled.
2787
+ *
2788
+ * - `false` / `undefined` → null (no setup)
2789
+ * - `true` → `defaults` as-is
2790
+ * - object → shallow merge of defaults and overrides (overrides win)
2791
+ */
2792
+ declare function resolveSetup<T extends object>(value: boolean | T | undefined, defaults: T): T | null;
2793
+
2739
2794
  /**
2740
2795
  * Throws an error.
2741
2796
  *
@@ -3046,8 +3101,8 @@ declare function formatOut(out: StepOut): string;
3046
3101
  * app secrets service, explorer IntelliSense) imports these — no
3047
3102
  * inline regexes elsewhere.
3048
3103
  */
3049
- declare const REF_VAR: RegExp;
3050
- declare const REF_DEF: RegExp;
3104
+ declare const REF_VAR_FULL: RegExp;
3105
+ declare const REF_VAR_INLINE: RegExp;
3051
3106
  declare const REF_ENV: RegExp;
3052
3107
  declare const REF_CONTRACT: RegExp;
3053
3108
  /** Whole-string `$flow.<name>(.<path>)?`: cross-flow value reference. */
@@ -3056,4 +3111,4 @@ declare const REF_STORE: RegExp;
3056
3111
  declare const REF_SECRET: RegExp;
3057
3112
  declare const REF_CODE_PREFIX = "$code:";
3058
3113
 
3059
- export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_DEF, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };
3114
+ export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, type DestroyContext, type DestroyFn, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, resolveSetup, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };