@almadar/core 10.21.0 → 10.23.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.
@@ -1,6 +1,7 @@
1
- import { E as Expression, S as SExpr } from './expression-BUIi9ezJ.js';
2
- import { T as TraitConfig, l as TraitConfigObject, S as ServiceRef, d as Entity, f as EntityField, g as EntityPersistence, i as TraitRef, m as EventPayloadField, n as ConfigFieldDeclaration, o as ServiceDefinition, a as Trait } from './trait-BcRvHKLW.js';
1
+ import { bS as TraitConfig, bT as TraitConfigObject, bk as ServiceRef, a2 as Entity, E as EntityField, a as EntityPersistence, c3 as TraitRef, ai as EventPayloadField, O as ConfigFieldDeclaration, bg as ServiceDefinition, d as Trait, cf as UISlot, Z as Effect, aZ as RenderBinding, a$ as RenderUIEffect, T as TraitEventListener, C as CallSiteConfig, b$ as TraitEventContract, e as EntityRow, b as TraitReference } from './trait-Cs8Mrdw9.js';
3
2
  import { z } from 'zod';
3
+ import { d as Expression, S as SExpr } from './expression-BVRFm0sV.js';
4
+ import { AnyPatternConfig } from '@almadar/patterns';
4
5
 
5
6
  /**
6
7
  * Page view types.
@@ -59279,4 +59280,582 @@ declare function safeParseOrbitalSchema(data: unknown): z.SafeParseReturnType<{
59279
59280
  type OrbitalSchemaInput = z.input<typeof OrbitalSchemaSchema>;
59280
59281
  type OrbitalConfigInput = z.input<typeof OrbitalConfigSchema>;
59281
59282
 
59282
- export { type EntitySemanticRole as $, AGENT_DOMAIN_CATEGORIES as A, type DesignPreferencesInput as B, type ColorSlice as C, type DensitySlice as D, type EntityRef as E, DesignPreferencesSchema as F, type DesignTokens as G, type DesignTokensInput as H, DesignTokensSchema as I, type DomainCategory as J, DomainCategorySchema as K, type DomainContext as L, type DomainContextInput as M, DomainContextSchema as N, type OrbitalSchema as O, type PageRef as P, type DomainVocabulary as Q, DomainVocabularySchema as R, type ElevationSlice as S, ElevationSliceSchema as T, type UseDeclaration as U, type ElevationTokens as V, ElevationTokensSchema as W, type EntityCall as X, EntityCallSchema as Y, EntityRefSchema as Z, EntityRefStringSchema as _, type OrbitalDefinition as a, PageSchema as a$, EntitySemanticRoleSchema as a0, type EventListener as a1, EventListenerSchema as a2, type EventSemanticRole as a3, EventSemanticRoleSchema as a4, type EventSource as a5, EventSourceSchema as a6, type Orbital as a7, type GameSubCategory as a8, GameSubCategorySchema as a9, MotionIntentMapSchema as aA, MotionIntentSchema as aB, type MotionSlice as aC, MotionSliceSchema as aD, type MotionTokens as aE, MotionTokensSchema as aF, type NodeClassification as aG, NodeClassificationSchema as aH, type OrbitalConfig as aI, type OrbitalConfigInput as aJ, OrbitalConfigSchema as aK, OrbitalDefinitionSchema as aL, type OrbitalInput as aM, type OrbitalPage as aN, type OrbitalPageInput as aO, OrbitalPageSchema as aP, type OrbitalPageStrictInput as aQ, OrbitalPageStrictSchema as aR, type OrbitalSchemaInput as aS, OrbitalSchemaSchema as aT, type OrbitalSchemaWithTraits as aU, type OrbitalUnit as aV, OrbitalUnitSchema as aW, OrbitalSchema$1 as aX, PageRefObjectSchema as aY, PageRefSchema as aZ, PageRefStringSchema as a_, type GeometrySlice as aa, GeometrySliceSchema as ab, type GeometryTokens as ac, GeometryTokensSchema as ad, type IconFamily as ae, IconFamilySchema as af, type IconographySlice as ag, IconographySliceSchema as ah, type IconographyTokens as ai, IconographyTokensSchema as aj, type IllustrationSlice as ak, IllustrationSliceSchema as al, type IllustrationStyle as am, IllustrationStyleSchema as an, type IllustrationTokens as ao, IllustrationTokensSchema as ap, type MotionDurationKey as aq, MotionDurationKeySchema as ar, type MotionDurationPalette as as, MotionDurationPaletteSchema as at, type MotionEasingKey as au, MotionEasingKeySchema as av, type MotionEasingPalette as aw, MotionEasingPaletteSchema as ax, type MotionIntent as ay, type MotionIntentMap as az, type Page as b, type PageTraitRef as b0, PageTraitRefSchema as b1, type RelatedLink as b2, RelatedLinkSchema as b3, type SchemaMetadata as b4, SchemaMetadataSchema as b5, type SkinSpec as b6, SkinSpecSchema as b7, type SpacingScale as b8, SpacingScaleSchema as b9, TypeSliceSchema as bA, type TypeSlot as bB, TypeSlotSchema as bC, type TypeWeight as bD, TypeWeightSchema as bE, type UXHints as bF, UXHintsSchema as bG, UseDeclarationSchema as bH, type UserPersona as bI, type UserPersonaInput as bJ, UserPersonaSchema as bK, type ViewType as bL, ViewTypeSchema as bM, isEntityCall as bN, isEntityReference as bO, isEntityReferenceAny as bP, isImportedTraitRef as bQ, isOrbitalDefinition as bR, isPageReference as bS, isPageReferenceObject as bT, isPageReferenceString as bU, isThemeReference as bV, parseEntityRef as bW, parseImportedTraitRef as bX, parseOrbitalSchema as bY, parsePageRef as bZ, safeParseOrbitalSchema as b_, type StateSemanticRole as ba, StateSemanticRoleSchema as bb, type SuggestedGuard as bc, SuggestedGuardSchema as bd, type ThemeDefinition as be, ThemeDefinitionSchema as bf, type ThemeRef as bg, ThemeRefSchema as bh, ThemeRefStringSchema as bi, type ThemeTokens as bj, ThemeTokensSchema as bk, type ThemeVariant as bl, ThemeVariantSchema as bm, type TypeIntent as bn, type TypeIntentMap as bo, TypeIntentMapSchema as bp, TypeIntentSchema as bq, type TypeScale as br, type TypeScaleEntry as bs, TypeScaleEntrySchema as bt, TypeScaleSchema as bu, type TypeScaleTokens as bv, TypeScaleTokensSchema as bw, type TypeSizeKey as bx, TypeSizeKeySchema as by, type TypeSlice as bz, type PageRefObject as c, ALLOWED_CUSTOM_COMPONENTS as d, type AgentDomainCategory as e, AgentDomainCategorySchema as f, type AllowedCustomComponent as g, ColorSliceSchema as h, type ColorTokens as i, ColorTokensSchema as j, type ComputedEventContract as k, ComputedEventContractSchema as l, type ComputedEventListener as m, ComputedEventListenerSchema as n, type ConfigProvenanceRecord as o, ConfigProvenanceRecordSchema as p, type CustomPatternDefinition as q, type CustomPatternDefinitionInput as r, CustomPatternDefinitionSchema as s, type CustomPatternMap as t, type CustomPatternMapInput as u, CustomPatternMapSchema as v, DensitySliceSchema as w, type DensityTokens as x, DensityTokensSchema as y, type DesignPreferences as z };
59283
+ /**
59284
+ * Event Wiring
59285
+ *
59286
+ * Applies cross-orbital event wiring to orbital definitions.
59287
+ * Adds emits/listens declarations to traits so they can communicate
59288
+ * across orbital boundaries.
59289
+ *
59290
+ * @packageDocumentation
59291
+ */
59292
+
59293
+ /**
59294
+ * A single event wiring entry connecting two traits across orbitals.
59295
+ */
59296
+ interface EventWiringEntry {
59297
+ /** Source trait name or orbital name */
59298
+ from: string;
59299
+ /** Event name (UPPER_SNAKE_CASE) */
59300
+ event: string;
59301
+ /** Target trait name or orbital name */
59302
+ to: string;
59303
+ /** Event to trigger on the listener side */
59304
+ triggers: string;
59305
+ }
59306
+ /**
59307
+ * Apply event wiring to orbital definitions.
59308
+ *
59309
+ * For each wiring entry:
59310
+ * 1. Find the source trait and add an external emit (if not already present)
59311
+ * 2. Find the target trait and add an external listen (if not already present)
59312
+ *
59313
+ * Returns a new array of orbitals with wiring applied (deep-cloned).
59314
+ */
59315
+ declare function applyEventWiring(orbitals: OrbitalDefinition[], wiring: EventWiringEntry[]): OrbitalDefinition[];
59316
+
59317
+ /**
59318
+ * Layout Strategy Detection
59319
+ *
59320
+ * Auto-detects the best layout strategy for a composed application
59321
+ * based on the number of orbitals and their event wiring topology.
59322
+ *
59323
+ * @packageDocumentation
59324
+ */
59325
+
59326
+ /**
59327
+ * Layout strategy for the composed application.
59328
+ *
59329
+ * - 'single': One orbital, one page
59330
+ * - 'tabs': 2-4 orbitals with no sequential chain
59331
+ * - 'sidebar': 5+ orbitals (navigation-heavy)
59332
+ * - 'dashboard': Single page with all orbitals visible
59333
+ * - 'wizard-flow': Sequential event chain detected (A -> B -> C)
59334
+ */
59335
+ type LayoutStrategy = 'sidebar' | 'tabs' | 'dashboard' | 'wizard-flow' | 'single';
59336
+ /**
59337
+ * Detect the best layout strategy based on orbital count and event wiring.
59338
+ *
59339
+ * Heuristic:
59340
+ * 1. Sequential event chain detected -> 'wizard-flow'
59341
+ * 2. 1 orbital -> 'single'
59342
+ * 3. 2-4 orbitals -> 'tabs'
59343
+ * 4. 5+ orbitals -> 'sidebar'
59344
+ */
59345
+ declare function detectLayoutStrategy(orbitals: OrbitalDefinition[], eventWiring?: EventWiringEntry[]): LayoutStrategy;
59346
+
59347
+ /**
59348
+ * Compose Behaviors
59349
+ *
59350
+ * Main entry point for composing multiple orbital definitions into
59351
+ * a single OrbitalSchema application. Handles event wiring, layout
59352
+ * strategy detection, and page generation.
59353
+ *
59354
+ * @packageDocumentation
59355
+ */
59356
+
59357
+ /**
59358
+ * Input for composing behaviors into an application.
59359
+ */
59360
+ interface ComposeBehaviorsInput {
59361
+ /** Application name */
59362
+ appName: string;
59363
+ /** Orbital definitions (or schemas) to compose */
59364
+ orbitals: (OrbitalDefinition | OrbitalSchema)[];
59365
+ /** Layout strategy override, or 'auto' to detect */
59366
+ layoutStrategy?: LayoutStrategy | 'auto';
59367
+ /** Cross-orbital event wiring */
59368
+ eventWiring?: EventWiringEntry[];
59369
+ /** Optional entity name mappings (original -> renamed) */
59370
+ entityMappings?: Record<string, string>;
59371
+ }
59372
+ /**
59373
+ * Result of composing behaviors.
59374
+ */
59375
+ interface ComposeBehaviorsResult {
59376
+ /** The composed OrbitalSchema */
59377
+ schema: OrbitalSchema;
59378
+ /** Layout metadata */
59379
+ layout: {
59380
+ strategy: LayoutStrategy;
59381
+ pageCount: number;
59382
+ };
59383
+ /** Wiring metadata */
59384
+ wiring: {
59385
+ connections: number;
59386
+ };
59387
+ }
59388
+ /**
59389
+ * Compose multiple orbital definitions into a single application schema.
59390
+ *
59391
+ * Steps:
59392
+ * 1. Apply event wiring (adds emits/listens to traits)
59393
+ * 2. Detect or use provided layout strategy
59394
+ * 3. Generate pages based on the strategy
59395
+ * 4. Build the final OrbitalSchema
59396
+ */
59397
+ declare function composeBehaviors(input: ComposeBehaviorsInput): ComposeBehaviorsResult;
59398
+
59399
+ /**
59400
+ * Apply trait config overrides to a schema — pure, returns a new schema.
59401
+ *
59402
+ * Used by config-driven preview surfaces (the playground property inspector and
59403
+ * the verify config-sweep) to render a behavior with different `config` values
59404
+ * WITHOUT recompiling: the override is written onto the matching trait, then the
59405
+ * schema is re-registered and re-rendered.
59406
+ *
59407
+ * The resolved schema's traits are inlined `Trait`s whose `config` is the
59408
+ * DECLARED schema (`{ field: { type, default, ... } }`), so an override patches
59409
+ * each field's `default`. A trait that instead carries call-site value config
59410
+ * (a `{ ref, config }` reference) gets the values merged directly.
59411
+ *
59412
+ * @packageDocumentation
59413
+ */
59414
+
59415
+ /**
59416
+ * Return a new schema with `config` overrides applied to traits whose identity
59417
+ * (`name`, falling back to `ref`) matches a key in `overrides`. Fields not
59418
+ * declared on the trait are ignored — overrides never invent config.
59419
+ */
59420
+ declare function applyTraitConfigOverrides(schema: OrbitalSchema, overrides: Readonly<Record<string, TraitConfig>>): OrbitalSchema;
59421
+
59422
+ /**
59423
+ * Layout-Trait Builders
59424
+ *
59425
+ * Helpers for constructing the canonical inline LayoutTrait pattern that
59426
+ * std layout-shell molecules (`std-filtered-list`, `std-master-detail-layout`,
59427
+ * etc.) use to wrap a set of atom trait references in a `(render-ui main)`
59428
+ * effect with `@trait.X` slot embeds.
59429
+ *
59430
+ * The canonical LayoutTrait is stateless: ONE state (`composing`, initial),
59431
+ * ONE transition (`INIT` self-loop) carrying two effects — `(fetch Entity
59432
+ * {emit: {success, failure}})` and `(render-ui "main" <pattern-tree>)`. Atoms
59433
+ * embedded via `@trait.X` slot references react to the bus events the fetch
59434
+ * emits; the LayoutTrait owns no further state.
59435
+ *
59436
+ * Usage from a std layout-shell molecule:
59437
+ *
59438
+ * ```ts
59439
+ * import { makeSlot, makeLayoutTrait } from '@almadar/core/builders';
59440
+ *
59441
+ * const layout = makeLayoutTrait({
59442
+ * name: 'DashboardLayout',
59443
+ * linkedEntity: 'Metric',
59444
+ * fetchEntity: 'Metric',
59445
+ * loadedEvent: 'MetricLoaded',
59446
+ * loadFailedEvent: 'MetricLoadFailed',
59447
+ * renderUI: {
59448
+ * type: 'stack',
59449
+ * direction: 'vertical',
59450
+ * children: [
59451
+ * makeSlot('StatsRow'),
59452
+ * makeSlot('ChartsRow'),
59453
+ * makeSlot('FeedRow'),
59454
+ * ],
59455
+ * },
59456
+ * });
59457
+ * ```
59458
+ *
59459
+ * @packageDocumentation
59460
+ */
59461
+
59462
+ /**
59463
+ * Build a `@trait.<name>` slot reference string. Used as a child entry in a
59464
+ * pattern tree to embed another trait's render-ui at that position. The
59465
+ * runtime resolves `@trait.X` to the matching trait's render-ui inline.
59466
+ *
59467
+ * @example makeSlot('FilteredItemSearch') // "@trait.FilteredItemSearch"
59468
+ */
59469
+ declare function makeSlot(traitName: string): string;
59470
+ /**
59471
+ * Build a `(render-ui <slot> <root>)` effect tuple. Pattern-typed sugar over
59472
+ * the raw `RenderUIEffect` literal so callers don't have to spell out the
59473
+ * three-element tuple form.
59474
+ *
59475
+ * @param slot - Canonical UI slot name (`'main'`, `'header'`, etc. — see UI_SLOTS).
59476
+ * @param root - The pattern config for this slot's content, OR a `@`-binding
59477
+ * string ({@link RenderBinding}) pointing at a render tree in `config` /
59478
+ * `payload` (e.g. `'@config.bodyContent'`). Pass `null` to clear.
59479
+ */
59480
+ declare function makeRenderUI(slot: UISlot, root: AnyPatternConfig | RenderBinding | null): RenderUIEffect;
59481
+ /**
59482
+ * Options for {@link makeLayoutTrait}.
59483
+ */
59484
+ interface MakeLayoutTraitOpts {
59485
+ /** Trait name, e.g. `"DashboardGridLayout"`. */
59486
+ name: string;
59487
+ /** Entity this layout's emits/listens bind to. */
59488
+ linkedEntity: string;
59489
+ /** Optional human-readable description (carried through to `Trait.description`). */
59490
+ description?: string;
59491
+ /**
59492
+ * Entity name to fetch on INIT. When set, a `(fetch <Entity> {emit:
59493
+ * {success, failure}})` effect is prepended to the INIT transition. Omit
59494
+ * for purely-presentational layouts that don't load data themselves.
59495
+ */
59496
+ fetchEntity?: string;
59497
+ /**
59498
+ * Event name emitted on successful fetch. Required when `fetchEntity` is
59499
+ * set; the LayoutTrait declares this event in its `emits` and uses it as
59500
+ * the `success` emit-name in the fetch effect.
59501
+ * Convention: `"<Entity>Loaded"`.
59502
+ */
59503
+ loadedEvent?: string;
59504
+ /**
59505
+ * Event name emitted on fetch failure. Required when `fetchEntity` is
59506
+ * set. Convention: `"<Entity>LoadFailed"`.
59507
+ */
59508
+ loadFailedEvent?: string;
59509
+ /**
59510
+ * Payload schema for the loaded event. Defaults to `[{ name: "data", type:
59511
+ * "[<Entity>]" }]` when `fetchEntity` is set. Provide explicitly when the
59512
+ * payload should carry additional fields.
59513
+ */
59514
+ loadedPayloadSchema?: Array<{
59515
+ name: string;
59516
+ type: string;
59517
+ required?: boolean;
59518
+ }>;
59519
+ /**
59520
+ * The pattern tree for the layout's main slot. Children may include
59521
+ * `@trait.X` slot strings (built via {@link makeSlot}) interleaved with
59522
+ * inline pattern configs (`{ type: 'stack', ... }`). The shape conforms to
59523
+ * `AnyPatternConfig` from `@almadar/patterns`.
59524
+ */
59525
+ renderUI: AnyPatternConfig;
59526
+ /**
59527
+ * Override the slot the render-ui effect targets. Defaults to `'main'`.
59528
+ * Specify when the layout shell should render into a sub-slot (rare).
59529
+ */
59530
+ slot?: UISlot;
59531
+ /**
59532
+ * Additional effects appended to the INIT transition AFTER the fetch +
59533
+ * render-ui pair. Most layouts don't need this; provided for advanced
59534
+ * cases (analytics emit, persistence seed, etc.).
59535
+ */
59536
+ extraEffects?: Effect[];
59537
+ }
59538
+ /**
59539
+ * Build the canonical stateless LayoutTrait used by std layout-shell molecules.
59540
+ *
59541
+ * Result shape:
59542
+ * - `category: 'interaction'`, `scope: 'instance'`
59543
+ * - `linkedEntity` set per the option
59544
+ * - `emits` declares the loaded + loadFailed events when `fetchEntity` is set
59545
+ * - One state: `'composing'` (`isInitial: true`)
59546
+ * - One transition: `composing → composing` on `INIT`, with effects:
59547
+ * - (when `fetchEntity` set) `['fetch', '<Entity>', { emit: { success, failure } }]`
59548
+ * - `['render-ui', slot, renderUI]`
59549
+ * - …`extraEffects` if provided
59550
+ *
59551
+ * Atoms whose trait names appear as `@trait.<name>` strings inside `renderUI`
59552
+ * get embedded by the runtime when the orbital instantiates. The LayoutTrait
59553
+ * itself stays stateless — all reactive behaviour lives in the embedded atoms.
59554
+ */
59555
+ declare function makeLayoutTrait(opts: MakeLayoutTraitOpts): Trait;
59556
+
59557
+ /**
59558
+ * Orbital Builders
59559
+ *
59560
+ * Pure functions for constructing and composing Orbitals.
59561
+ * No new types. Everything uses existing core types:
59562
+ * Entity, Trait, Page, OrbitalDefinition, OrbitalSchema.
59563
+ *
59564
+ * Three categories:
59565
+ * 1. Builders: construct Entity, Page from common params
59566
+ * 2. Utilities: ensureIdField, resolveDefaults
59567
+ * 3. Composition: connect, compose, pipe
59568
+ *
59569
+ * @packageDocumentation
59570
+ */
59571
+
59572
+ /**
59573
+ * Ensure the fields array has an `id` field. Prepends one if missing.
59574
+ */
59575
+ declare function ensureIdField(fields?: EntityField[]): EntityField[];
59576
+ /**
59577
+ * Simple pluralization: append 's'.
59578
+ */
59579
+ declare function plural(name: string): string;
59580
+ interface MakeEntityOpts {
59581
+ name: string;
59582
+ fields: EntityField[];
59583
+ persistence?: EntityPersistence;
59584
+ collection?: string;
59585
+ /** Pre-authored seed data instances */
59586
+ instances?: EntityRow[];
59587
+ }
59588
+ /**
59589
+ * Build an Entity from options. Auto-adds id field, auto-derives collection.
59590
+ */
59591
+ declare function makeEntity(opts: MakeEntityOpts): Entity;
59592
+ interface MakePageOpts {
59593
+ name: string;
59594
+ path: string;
59595
+ traitName: string;
59596
+ isInitial?: boolean;
59597
+ }
59598
+ /**
59599
+ * Build a Page that binds to a single trait.
59600
+ */
59601
+ declare function makePage(opts: MakePageOpts): Page;
59602
+ /**
59603
+ * Build an OrbitalDefinition from its three components.
59604
+ */
59605
+ declare function makeOrbital(name: string, entity: Entity, traits: Trait[], pages: Page[]): OrbitalDefinition;
59606
+ /**
59607
+ * Options for {@link makeTraitRef}.
59608
+ */
59609
+ interface MakeTraitRefOpts {
59610
+ /**
59611
+ * Optional registry path disambiguator that pairs with {@link ref}
59612
+ * (see {@link TraitReference.from}).
59613
+ */
59614
+ from?: string;
59615
+ /** Trait reference string, e.g. "Browse.traits.BrowseItemBrowse". */
59616
+ ref: string;
59617
+ /** Rename the inlined trait at the call site. */
59618
+ name?: string;
59619
+ /** Rebind the trait to a different linkedEntity. */
59620
+ linkedEntity?: string;
59621
+ /** Per-key rename map, e.g. `{ OPEN: "ADD_ITEM" }`. */
59622
+ events?: Record<string, string>;
59623
+ /**
59624
+ * Entity-field remap, e.g. `{ name: "title", folder: "parentId" }`. Rewrites
59625
+ * the inlined trait's canonical `@entity.X` / `@payload.row.X` references to
59626
+ * the consumer entity's field names. Mirrors {@link TraitReference.fields}.
59627
+ */
59628
+ fields?: Record<string, string>;
59629
+ /**
59630
+ * Per-event SExpression effect replacement. Keys are POST-rename event
59631
+ * names. See {@link TraitReference.effects} for the full contract.
59632
+ */
59633
+ effects?: Record<string, SExpr[]>;
59634
+ /** Replace the imported trait's `listens` array entirely. */
59635
+ listens?: TraitEventListener[];
59636
+ /** Set every emit's scope. */
59637
+ emitsScope?: 'internal' | 'external';
59638
+ /**
59639
+ * Call-site config overrides. Each entry is either a plain wiring value
59640
+ * (`TraitConfigValue`) or a fully-annotated re-declaration
59641
+ * (`ConfigFieldDeclaration`). Matches {@link TraitReference.config}.
59642
+ */
59643
+ config?: CallSiteConfig;
59644
+ }
59645
+ /**
59646
+ * Typed-narrowing variant of {@link MakeTraitRefOpts} for callers that know
59647
+ * the imported atom's overridable surfaces — its event-key set, listen-key
59648
+ * set, and config shape. Generated std factories use this variant so an LLM
59649
+ * tool consumer (orbital-agent) sees the closed event-name set and the
59650
+ * config field schema instead of the un-narrowed `Record<string, string>` /
59651
+ * `TraitConfig` defaults.
59652
+ *
59653
+ * Type parameters:
59654
+ * - `EventKey` — string union of the atom's emit event names. Narrows the
59655
+ * `events` rename map's keys to legal originals only.
59656
+ * - `ConfigShape` — typed shape of the trait's `config { ... }` block (literal
59657
+ * unions intact). Narrows the `config` override to the atom's actual fields.
59658
+ * Extends `CallSiteConfig` to allow both plain wiring values and annotated
59659
+ * declarations. Existing callers using plain `TraitConfig` shapes are
59660
+ * unaffected (TraitConfig ⊆ CallSiteConfig).
59661
+ * - `ListenKey` — string union of the atom's listen-key contract. Narrows
59662
+ * each listens entry's `event` against the atom's real subscription set.
59663
+ *
59664
+ * Runtime behavior is unchanged — {@link makeTraitRef} accepts both the
59665
+ * narrow and wide forms via the standard structural-typing rules. This is
59666
+ * a type-level narrowing only; widening at the call boundary is intentional.
59667
+ */
59668
+ interface MakeTraitRefOptsTyped<EventKey extends string = string, ConfigShape extends CallSiteConfig = Record<string, never>, ListenKey extends string = string> extends Omit<MakeTraitRefOpts, 'events' | 'effects' | 'listens' | 'config'> {
59669
+ /** Per-key rename map, narrowed to the atom's actual event keys. */
59670
+ events?: Partial<Record<EventKey, string>>;
59671
+ /**
59672
+ * Per-event SExpression effect replacement. Keys are POST-rename event
59673
+ * names so they're caller-defined (no narrowing here); values stay typed
59674
+ * as `SExpr[]`.
59675
+ */
59676
+ effects?: Partial<Record<string, SExpr[]>>;
59677
+ /**
59678
+ * Replace the imported trait's `listens` array entirely. Each entry's
59679
+ * `event` field is narrowed to {@link ListenKey} where the atom's
59680
+ * subscription set is fixed; otherwise this widens to plain string.
59681
+ */
59682
+ listens?: Array<TraitEventListener & {
59683
+ event?: ListenKey;
59684
+ }>;
59685
+ /** Typed call-site config overrides — narrowed to {@link ConfigShape}. */
59686
+ config?: ConfigShape;
59687
+ }
59688
+ /**
59689
+ * Build a {@link TraitReference} from options.
59690
+ *
59691
+ * Pass-through factory: copies only the fields that are actually provided,
59692
+ * so optionals stay absent (no `key: undefined` slots) and the emitted
59693
+ * object matches the inliner's expectation that "present = override".
59694
+ */
59695
+ declare function makeTraitRef(opts: MakeTraitRefOpts): TraitReference;
59696
+ /**
59697
+ * Options for {@link makePageRef}.
59698
+ */
59699
+ interface MakePageRefOpts {
59700
+ /**
59701
+ * Optional registry path disambiguator that pairs with {@link ref}
59702
+ * (see {@link PageRefObject.from}).
59703
+ */
59704
+ from?: string;
59705
+ /** Page reference string, e.g. "Browse.pages.BrowseItemPage". */
59706
+ ref: string;
59707
+ /** URL path override. */
59708
+ path?: string;
59709
+ /** Rebind the page's primary entity. */
59710
+ linkedEntity?: string;
59711
+ /** Replace the page's trait list. */
59712
+ traits?: TraitRef[];
59713
+ }
59714
+ /**
59715
+ * Typed-narrowing variant of {@link MakePageRefOpts}. Narrows the `traits`
59716
+ * override array's entries to the orbital's known trait-name union — so the
59717
+ * agent can't pass a trait name that doesn't exist on the page's owning
59718
+ * orbital. Generated std page-helpers use this variant to surface the
59719
+ * trait set in the tool schema; un-narrowed call sites stay compatible.
59720
+ *
59721
+ * Type parameter:
59722
+ * - `TraitName` — string union of trait names the page may reference.
59723
+ */
59724
+ interface MakePageRefOptsTyped<TraitName extends string = string> extends Omit<MakePageRefOpts, 'traits'> {
59725
+ traits?: Array<{
59726
+ ref: TraitName;
59727
+ } | TraitRef>;
59728
+ }
59729
+ /**
59730
+ * Build a {@link PageRefObject} from options. Pass-through factory — omits
59731
+ * optional keys that are `undefined`.
59732
+ */
59733
+ declare function makePageRef(opts: MakePageRefOpts): PageRefObject;
59734
+ /**
59735
+ * Options for {@link makeOrbitalWithUses}.
59736
+ */
59737
+ interface MakeOrbitalWithUsesOpts {
59738
+ /** Orbital name. */
59739
+ name: string;
59740
+ /**
59741
+ * Per-orbital `uses:` header entries (see CLAUDE.md "uses: lives inside
59742
+ * the orbital").
59743
+ */
59744
+ uses: UseDeclaration[];
59745
+ /** Entity (inline or reference form). */
59746
+ entity: EntityRef;
59747
+ /** Trait references. */
59748
+ traits: TraitRef[];
59749
+ /** Optional page references (omitted entirely when not provided). */
59750
+ pages?: PageRef[];
59751
+ }
59752
+ /**
59753
+ * Build an {@link OrbitalDefinition} with the `uses:` header set. Follows
59754
+ * the convention that `uses:` lives on the orbital (not the schema).
59755
+ *
59756
+ * When `pages` is omitted, the result has no `pages` property (matches the
59757
+ * existing {@link OrbitalDefinition.pages} optionality in descriptors that
59758
+ * carry trait-only atoms).
59759
+ */
59760
+ declare function makeOrbitalWithUses(opts: MakeOrbitalWithUsesOpts): OrbitalDefinition;
59761
+ /**
59762
+ * Options for {@link makeAtomOrbital}.
59763
+ *
59764
+ * Overrides for the single trait reference. Mirrors the {@link MakeTraitRefOpts}
59765
+ * subset that is meaningful at the atom-wrapping call site.
59766
+ */
59767
+ interface MakeAtomOrbitalTraitOverrides {
59768
+ name?: string;
59769
+ events?: Record<string, string>;
59770
+ effects?: Record<string, SExpr[]>;
59771
+ listens?: TraitEventListener[];
59772
+ emitsScope?: 'internal' | 'external';
59773
+ config?: CallSiteConfig;
59774
+ }
59775
+ /**
59776
+ * Options for {@link makeAtomOrbital}.
59777
+ */
59778
+ interface MakeAtomOrbitalOpts {
59779
+ /** Orbital name, e.g. `${entityName}Orbital`. */
59780
+ name: string;
59781
+ /** Atom registry path, e.g. `std/behaviors/atoms/std-browse`. */
59782
+ atomPath: string;
59783
+ /** Import alias (PascalCase), e.g. `Browse`. */
59784
+ alias: string;
59785
+ /** Entity definition to attach to the orbital. */
59786
+ entity: Entity;
59787
+ /** Trait reference string, e.g. `Browse.traits.BrowseItemBrowse`. */
59788
+ traitRef: string;
59789
+ /** Optional trait-level overrides applied at the call site. */
59790
+ traitOverrides?: MakeAtomOrbitalTraitOverrides;
59791
+ /** Optional page reference string, e.g. `Browse.pages.BrowseItemPage`. */
59792
+ pageRef?: string;
59793
+ /** Optional page-level overrides applied at the call site. */
59794
+ pageOverrides?: {
59795
+ path?: string;
59796
+ };
59797
+ }
59798
+ /**
59799
+ * Build a single-atom {@link OrbitalDefinition}.
59800
+ *
59801
+ * The common atom shape: one entity + one trait reference + (optionally) one
59802
+ * page reference, all under a single `uses:` import. Wraps
59803
+ * {@link makeTraitRef}, {@link makePageRef}, and {@link makeOrbitalWithUses}.
59804
+ *
59805
+ * The trait reference is linkedEntity-bound to `entity.name` by default so
59806
+ * that the inliner's entity-substitution pass rewrites every `["ref", X]`
59807
+ * and `@X.path` reference inside the atom.
59808
+ */
59809
+ declare function makeAtomOrbital(opts: MakeAtomOrbitalOpts): OrbitalDefinition;
59810
+ /**
59811
+ * Wrap one or more OrbitalDefinitions into an OrbitalSchema.
59812
+ * Every .orb file should be a full OrbitalSchema — this is the builder for that.
59813
+ */
59814
+ declare function makeSchema(name: string, ...definitions: OrbitalDefinition[]): OrbitalSchema;
59815
+ /**
59816
+ * Merge multiple OrbitalDefinitions into one.
59817
+ * Collects all traits from all sources into a single orbital with a shared entity.
59818
+ * Pure: clones all traits, no mutation.
59819
+ */
59820
+ declare function mergeOrbitals(name: string, entity: Entity, sources: OrbitalDefinition[], pages: Page[]): OrbitalDefinition;
59821
+ /**
59822
+ * Wire an intra-orbital event between two traits.
59823
+ * Adds emits to the source trait, listens to the target trait.
59824
+ * Pure: returns cloned traits, no mutation.
59825
+ */
59826
+ declare function wire(source: Trait, target: Trait, event: TraitEventContract, triggers: string): [Trait, Trait];
59827
+ /**
59828
+ * Extract the first trait from an OrbitalDefinition or OrbitalSchema.
59829
+ * If given an OrbitalSchema, unwraps to the first orbital inside it.
59830
+ */
59831
+ declare function extractTrait(input: OrbitalDefinition | OrbitalSchema): Trait;
59832
+ /**
59833
+ * Wire a cross-orbital event between two orbitals.
59834
+ * Adds emits to a's first trait, listens to b's first trait.
59835
+ * Pure: returns new orbitals, no mutation.
59836
+ */
59837
+ declare function connect(a: OrbitalDefinition | OrbitalSchema, b: OrbitalDefinition | OrbitalSchema, event: TraitEventContract, triggers?: string): [OrbitalDefinition, OrbitalDefinition];
59838
+ interface ComposeConnection {
59839
+ from: string;
59840
+ to: string;
59841
+ event: TraitEventContract;
59842
+ triggers?: string;
59843
+ }
59844
+ interface ComposePage {
59845
+ name: string;
59846
+ path: string;
59847
+ traits: string[];
59848
+ isInitial?: boolean;
59849
+ }
59850
+ /**
59851
+ * Compose multiple orbitals into a single OrbitalSchema (application).
59852
+ * Applies connections (cross-orbital event wiring) and page assignments.
59853
+ */
59854
+ declare function compose(orbitals: (OrbitalDefinition | OrbitalSchema)[], pages: ComposePage[], connections: ComposeConnection[], appName?: string): OrbitalSchema;
59855
+ /**
59856
+ * Chain orbitals in sequence with automatic event wiring.
59857
+ * Sugar over connect + compose: wires events[0] from orbital[0] to orbital[1], etc.
59858
+ */
59859
+ declare function pipe(orbitals: (OrbitalDefinition | OrbitalSchema)[], events: TraitEventContract[], appName?: string): OrbitalSchema;
59860
+
59861
+ export { EntitySemanticRoleSchema as $, AGENT_DOMAIN_CATEGORIES as A, type DesignPreferencesInput as B, type ColorSlice as C, type DensitySlice as D, DesignPreferencesSchema as E, type DesignTokens as F, type DesignTokensInput as G, DesignTokensSchema as H, type DomainCategory as I, DomainCategorySchema as J, type DomainContext as K, type DomainContextInput as L, type MakeTraitRefOpts as M, DomainContextSchema as N, type OrbitalSchema as O, type DomainVocabulary as P, DomainVocabularySchema as Q, type ElevationSlice as R, ElevationSliceSchema as S, type ElevationTokens as T, ElevationTokensSchema as U, type EntityCall as V, EntityCallSchema as W, type EntityRef as X, EntityRefSchema as Y, EntityRefStringSchema as Z, type EntitySemanticRole as _, type OrbitalDefinition as a, type PageRefObject as a$, type EventListener as a0, EventListenerSchema as a1, type EventSemanticRole as a2, EventSemanticRoleSchema as a3, type EventSource as a4, EventSourceSchema as a5, type EventWiringEntry as a6, type Orbital as a7, type GameSubCategory as a8, GameSubCategorySchema as a9, type MotionIntentMap as aA, MotionIntentMapSchema as aB, MotionIntentSchema as aC, type MotionSlice as aD, MotionSliceSchema as aE, type MotionTokens as aF, MotionTokensSchema as aG, type NodeClassification as aH, NodeClassificationSchema as aI, type OrbitalConfig as aJ, type OrbitalConfigInput as aK, OrbitalConfigSchema as aL, OrbitalDefinitionSchema as aM, type OrbitalInput as aN, type OrbitalPage as aO, type OrbitalPageInput as aP, OrbitalPageSchema as aQ, type OrbitalPageStrictInput as aR, OrbitalPageStrictSchema as aS, type OrbitalSchemaInput as aT, OrbitalSchemaSchema as aU, type OrbitalSchemaWithTraits as aV, type OrbitalUnit as aW, OrbitalUnitSchema as aX, OrbitalSchema$1 as aY, type Page as aZ, type PageRef as a_, type GeometrySlice as aa, GeometrySliceSchema as ab, type GeometryTokens as ac, GeometryTokensSchema as ad, type IconFamily as ae, IconFamilySchema as af, type IconographySlice as ag, IconographySliceSchema as ah, type IconographyTokens as ai, IconographyTokensSchema as aj, type IllustrationSlice as ak, IllustrationSliceSchema as al, type IllustrationStyle as am, IllustrationStyleSchema as an, type IllustrationTokens as ao, IllustrationTokensSchema as ap, type LayoutStrategy as aq, type MotionDurationKey as ar, MotionDurationKeySchema as as, type MotionDurationPalette as at, MotionDurationPaletteSchema as au, type MotionEasingKey as av, MotionEasingKeySchema as aw, type MotionEasingPalette as ax, MotionEasingPaletteSchema as ay, type MotionIntent as az, ALLOWED_CUSTOM_COMPONENTS as b, isPageReferenceObject as b$, PageRefObjectSchema as b0, PageRefSchema as b1, PageRefStringSchema as b2, PageSchema as b3, type PageTraitRef as b4, PageTraitRefSchema as b5, type RelatedLink as b6, RelatedLinkSchema as b7, type SchemaMetadata as b8, SchemaMetadataSchema as b9, TypeScaleTokensSchema as bA, type TypeSizeKey as bB, TypeSizeKeySchema as bC, type TypeSlice as bD, TypeSliceSchema as bE, type TypeSlot as bF, TypeSlotSchema as bG, type TypeWeight as bH, TypeWeightSchema as bI, type UXHints as bJ, UXHintsSchema as bK, type UseDeclaration as bL, UseDeclarationSchema as bM, type UserPersona as bN, type UserPersonaInput as bO, UserPersonaSchema as bP, type ViewType as bQ, ViewTypeSchema as bR, applyEventWiring as bS, composeBehaviors as bT, detectLayoutStrategy as bU, isEntityCall as bV, isEntityReference as bW, isEntityReferenceAny as bX, isImportedTraitRef as bY, isOrbitalDefinition as bZ, isPageReference as b_, type SkinSpec as ba, SkinSpecSchema as bb, type SpacingScale as bc, SpacingScaleSchema as bd, type StateSemanticRole as be, StateSemanticRoleSchema as bf, type SuggestedGuard as bg, SuggestedGuardSchema as bh, type ThemeDefinition as bi, ThemeDefinitionSchema as bj, type ThemeRef as bk, ThemeRefSchema as bl, ThemeRefStringSchema as bm, type ThemeTokens as bn, ThemeTokensSchema as bo, type ThemeVariant as bp, ThemeVariantSchema as bq, type TypeIntent as br, type TypeIntentMap as bs, TypeIntentMapSchema as bt, TypeIntentSchema as bu, type TypeScale as bv, type TypeScaleEntry as bw, TypeScaleEntrySchema as bx, TypeScaleSchema as by, type TypeScaleTokens as bz, type AgentDomainCategory as c, isPageReferenceString as c0, isThemeReference as c1, parseEntityRef as c2, parseImportedTraitRef as c3, parseOrbitalSchema as c4, parsePageRef as c5, safeParseOrbitalSchema as c6, type ComposeConnection as c7, type ComposePage as c8, type MakeAtomOrbitalOpts as c9, plural as cA, wire as cB, type MakeAtomOrbitalTraitOverrides as ca, type MakeEntityOpts as cb, type MakeLayoutTraitOpts as cc, type MakeOrbitalWithUsesOpts as cd, type MakePageOpts as ce, type MakePageRefOpts as cf, type MakePageRefOptsTyped as cg, type MakeTraitRefOptsTyped as ch, applyTraitConfigOverrides as ci, compose as cj, connect as ck, ensureIdField as cl, extractTrait as cm, makeAtomOrbital as cn, makeEntity as co, makeLayoutTrait as cp, makeOrbital as cq, makeOrbitalWithUses as cr, makePage as cs, makePageRef as ct, makeRenderUI as cu, makeSchema as cv, makeSlot as cw, makeTraitRef as cx, mergeOrbitals as cy, pipe as cz, AgentDomainCategorySchema as d, type AllowedCustomComponent as e, ColorSliceSchema as f, type ColorTokens as g, ColorTokensSchema as h, type ComposeBehaviorsInput as i, type ComposeBehaviorsResult as j, type ComputedEventContract as k, ComputedEventContractSchema as l, type ComputedEventListener as m, ComputedEventListenerSchema as n, type ConfigProvenanceRecord as o, ConfigProvenanceRecordSchema as p, type CustomPatternDefinition as q, type CustomPatternDefinitionInput as r, CustomPatternDefinitionSchema as s, type CustomPatternMap as t, type CustomPatternMapInput as u, CustomPatternMapSchema as v, DensitySliceSchema as w, type DensityTokens as x, DensityTokensSchema as y, type DesignPreferences as z };