@cyberart-io/engine 0.0.8 → 0.0.10

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.
@@ -440,9 +440,17 @@ type SnapshotIntegrity = {
440
440
  alg: string;
441
441
  hash: string;
442
442
  };
443
+ type SnapshotSignatureRef = {
444
+ id: string;
445
+ alg: string;
446
+ };
443
447
  type SnapshotProvenance = {
444
448
  source?: string;
445
449
  integrity?: SnapshotIntegrity;
450
+ publisher?: string;
451
+ version?: string;
452
+ signature?: SnapshotSignatureRef;
453
+ grants?: string[];
446
454
  };
447
455
  type SnapshotEnvelope = {
448
456
  schemaVersion: typeof SNAPSHOT_SCHEMA_VERSION;
@@ -472,7 +480,7 @@ type ExportSnapshotOptions = {
472
480
 
473
481
  declare const ASSET_KINDS: readonly ["image", "audio", "font", "spritesheet"];
474
482
  type AssetKind = (typeof ASSET_KINDS)[number];
475
- declare const ASSET_FAILURE_CODES: readonly ["timeout", "cors", "not-found", "invalid", "aborted", "resolver"];
483
+ declare const ASSET_FAILURE_CODES: readonly ["timeout", "cors", "not-found", "invalid", "aborted", "resolver", "undeclared", "hash-mismatch", "unsigned"];
476
484
  type AssetFailureCode = (typeof ASSET_FAILURE_CODES)[number];
477
485
  type AssetCorsMode = 'anonymous' | 'use-credentials' | 'omit';
478
486
  type AssetProvenance = {
@@ -926,10 +934,14 @@ type RuntimeGroupParticipantInspect = {
926
934
  emit: string[];
927
935
  subscribe: string[];
928
936
  authoritative: boolean;
937
+ /** True when the group skips this slot on `step` (portal parent suspend). */
938
+ suspended: boolean;
929
939
  };
930
940
  type RuntimeGroupDiagnostics = {
931
941
  paused: boolean;
932
942
  participantIds: string[];
943
+ /** Participants skipped by `step` until `resumeParticipant`. Sorted. */
944
+ suspendedIds: string[];
933
945
  clocks: Record<string, ClockSnapshot>;
934
946
  rejections: unknown[];
935
947
  };
@@ -961,6 +973,13 @@ type RuntimeGroup = {
961
973
  resize(width: number, height: number): void;
962
974
  /** Tear down one participant without destroying the group or blanking siblings. */
963
975
  detach(id: string): void;
976
+ /**
977
+ * Pause this cart's live loop and skip it on group `step`. Snapshot-safe
978
+ * state is retained. Used by portal lifecycle; does not pause siblings.
979
+ */
980
+ suspendParticipant(id: string): void;
981
+ resumeParticipant(id: string): void;
982
+ isParticipantSuspended(id: string): boolean;
964
983
  dispatch(participantId: string, event: HostEvent): void;
965
984
  publish(event: EventInput, extras?: PublishExtras): EventEnvelope | undefined;
966
985
  inspectParticipants(): Array<RouterParticipantInspect & {
@@ -1425,6 +1444,183 @@ declare function replayExportedTrace(exported: ReplayInspectorExport, group: Run
1425
1444
  report: ReplayInspectorReport;
1426
1445
  }>;
1427
1446
 
1447
+ /**
1448
+ * Copyright (c) 2026 Aaron Boyarsky
1449
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
1450
+ * See packages/engine/LICENSE
1451
+ *
1452
+ * Content-selection and presentation-decision traces. Hosts record why a
1453
+ * binding, revision, asset, sequence, or fallback won. Reuses CYB-65
1454
+ * redaction, bounded retention, and correlation ids. There is no Player UI.
1455
+ */
1456
+
1457
+ declare const SELECTION_TRACE_SCHEMA_VERSION: 1;
1458
+ declare const DEFAULT_MAX_SELECTION_RECORDS = 512;
1459
+ declare const SELECTION_REASON_CODES: readonly ["binding-conflict", "asset-failure", "revision-rollback", "sequence-interruption", "text-only-fallback"];
1460
+ type SelectionReasonCode = (typeof SELECTION_REASON_CODES)[number];
1461
+ declare const SELECTION_DECISION_KINDS: readonly ["state-projection", "binding", "content-revision", "staging", "asset", "sequence", "presentation", "snapshot"];
1462
+ type SelectionDecisionKind = (typeof SELECTION_DECISION_KINDS)[number];
1463
+ declare const SELECTION_TRACE_SENSITIVE_KEYS: readonly ["prompt", "credentials", "credential", "authorization", "apiKey", "secret", "privatePrompt", "signedUrl", "signedURL", "signed_url", "presignedUrl", "password"];
1464
+ declare function isSelectionReasonCode(value: unknown): value is SelectionReasonCode;
1465
+ declare function isSelectionDecisionKind(value: unknown): value is SelectionDecisionKind;
1466
+ type SelectionBindingEvaluation = {
1467
+ bindingId: string;
1468
+ priority: number;
1469
+ predicateResult: boolean;
1470
+ winner?: boolean;
1471
+ rejectedReason?: string;
1472
+ };
1473
+ type SelectionContentIdentity = {
1474
+ contentId: string;
1475
+ revision: string;
1476
+ manifestVersion?: number;
1477
+ source?: string;
1478
+ publisher?: string;
1479
+ hashes?: Record<string, string>;
1480
+ };
1481
+ type SelectionStagingOutcome = 'validated' | 'rejected' | 'cache-hit' | 'cache-miss' | 'superseded' | 'rollback' | 'retained';
1482
+ type SelectionStagingResult = {
1483
+ outcome: SelectionStagingOutcome;
1484
+ cache?: 'hit' | 'miss';
1485
+ detail?: string;
1486
+ };
1487
+ type SelectionAssetResolution = {
1488
+ logicalRef: string;
1489
+ resolver?: string;
1490
+ adapter?: string;
1491
+ mediaHash?: string;
1492
+ ready: boolean;
1493
+ failure?: string;
1494
+ fallback?: string | null;
1495
+ };
1496
+ type SelectionSequenceDecision = {
1497
+ sequenceId: string;
1498
+ invocationId: string;
1499
+ stepId?: string | null;
1500
+ track?: string | null;
1501
+ decision: 'play' | 'skip' | 'interrupt' | 'replay' | 'complete';
1502
+ capabilityFallback?: string | null;
1503
+ };
1504
+ type SelectionPresentationDecision = {
1505
+ layerId?: string;
1506
+ variant?: string;
1507
+ regionId?: string;
1508
+ maskRevision?: string | number;
1509
+ blend?: string;
1510
+ hitTest?: boolean;
1511
+ caption?: string | null;
1512
+ audioIntent?: string | null;
1513
+ };
1514
+ type SelectionSnapshotProvenance = {
1515
+ revision?: string | number | null;
1516
+ schemaVersion?: number;
1517
+ seed?: string;
1518
+ };
1519
+ type SelectionDecisionInput = {
1520
+ kind: SelectionDecisionKind;
1521
+ reason: SelectionReasonCode | string;
1522
+ summary: string;
1523
+ turn?: number;
1524
+ time?: number;
1525
+ correlationId?: string;
1526
+ causationId?: string;
1527
+ envelopeId?: string;
1528
+ initiatingEventType?: string;
1529
+ projectionRevision?: string | number;
1530
+ projection?: unknown;
1531
+ hostState?: unknown;
1532
+ bindings?: readonly SelectionBindingEvaluation[];
1533
+ winningBindingId?: string | null;
1534
+ rejectedBindingIds?: readonly string[];
1535
+ defaultFallback?: boolean;
1536
+ requestedContent?: SelectionContentIdentity;
1537
+ activatedContent?: SelectionContentIdentity | null;
1538
+ staging?: SelectionStagingResult;
1539
+ lastKnownGood?: SelectionContentIdentity | null;
1540
+ asset?: SelectionAssetResolution;
1541
+ sequence?: SelectionSequenceDecision;
1542
+ presentation?: SelectionPresentationDecision;
1543
+ snapshot?: SelectionSnapshotProvenance;
1544
+ };
1545
+ type SelectionDecisionRecord = {
1546
+ index: number;
1547
+ kind: SelectionDecisionKind;
1548
+ reason: string;
1549
+ summary: string;
1550
+ turn?: number;
1551
+ time?: number;
1552
+ correlationId?: string;
1553
+ causationId?: string;
1554
+ envelopeId?: string;
1555
+ initiatingEventType?: string;
1556
+ projectionRevision?: string | number;
1557
+ projection?: unknown;
1558
+ bindings?: SelectionBindingEvaluation[];
1559
+ winningBindingId?: string | null;
1560
+ rejectedBindingIds?: string[];
1561
+ defaultFallback?: boolean;
1562
+ requestedContent?: SelectionContentIdentity;
1563
+ activatedContent?: SelectionContentIdentity | null;
1564
+ staging?: SelectionStagingResult;
1565
+ lastKnownGood?: SelectionContentIdentity | null;
1566
+ asset?: SelectionAssetResolution;
1567
+ sequence?: SelectionSequenceDecision;
1568
+ presentation?: SelectionPresentationDecision;
1569
+ snapshot?: SelectionSnapshotProvenance;
1570
+ };
1571
+ type SelectionTraceFilter = {
1572
+ kinds?: readonly SelectionDecisionKind[];
1573
+ reasons?: readonly string[];
1574
+ correlationId?: string;
1575
+ causationId?: string;
1576
+ envelopeId?: string;
1577
+ contentId?: string;
1578
+ sequenceId?: string;
1579
+ };
1580
+ type CreateSelectionTraceOptions = {
1581
+ redactedKeys?: readonly string[];
1582
+ maxRecords?: number;
1583
+ sampleRate?: number;
1584
+ /** Safe host-projection field names. All other projection/hostState keys redact. */
1585
+ projectionWhitelist?: readonly string[];
1586
+ inspector?: Pick<ReplayInspector, 'records'>;
1587
+ };
1588
+ type SelectionTraceExport = {
1589
+ schemaVersion: typeof SELECTION_TRACE_SCHEMA_VERSION;
1590
+ redactedKeys: string[];
1591
+ projectionWhitelist: string[];
1592
+ dropped: number;
1593
+ sampledOut: number;
1594
+ records: SelectionDecisionRecord[];
1595
+ inspectorRecords: InspectorRecord[];
1596
+ snapshotRevision?: string | number | null;
1597
+ snapshotSchemaVersion?: number;
1598
+ snapshotSeed?: string;
1599
+ };
1600
+ type SelectionTraceReport = {
1601
+ schemaVersion: typeof SELECTION_TRACE_SCHEMA_VERSION;
1602
+ records: SelectionDecisionRecord[];
1603
+ dropped: number;
1604
+ sampledOut: number;
1605
+ };
1606
+ type SelectionTrace = {
1607
+ recordSelectionDecision(input: SelectionDecisionInput): SelectionDecisionRecord | null;
1608
+ records(filter?: SelectionTraceFilter): SelectionDecisionRecord[];
1609
+ query(filter?: SelectionTraceFilter): SelectionDecisionRecord[];
1610
+ chain(correlationId: string): SelectionDecisionRecord[];
1611
+ exportTrace(filter?: SelectionTraceFilter): SelectionTraceExport;
1612
+ importTrace(exported: SelectionTraceExport | string): void;
1613
+ report(filter?: SelectionTraceFilter): SelectionTraceReport;
1614
+ setSnapshotProvenance(meta: SelectionSnapshotProvenance): void;
1615
+ reset(): void;
1616
+ destroy(): void;
1617
+ };
1618
+ declare function recordSelectionDecision(trace: SelectionTrace, input: SelectionDecisionInput): SelectionDecisionRecord | null;
1619
+ declare function attachSelectionTrace<T extends object>(bundle: T, trace: SelectionTraceExport | null): T & {
1620
+ selectionTrace: SelectionTraceExport | null;
1621
+ };
1622
+ declare function createSelectionTrace(options?: CreateSelectionTraceOptions): SelectionTrace;
1623
+
1428
1624
  type CueEasing = 'linear' | 'ease-out';
1429
1625
  type CueDuplicatePolicy = 'ignore' | 'replace' | 'reject';
1430
1626
  type CueRepeatPolicy = {
@@ -1482,6 +1678,7 @@ type PlayCueResult = {
1482
1678
  */
1483
1679
 
1484
1680
  declare const AUDIO_CUE_EVENTS: readonly ["audio.cue.scheduled", "audio.cue.started", "audio.cue.skipped", "audio.cue.failed"];
1681
+ declare const AUDIO_CUE_SNAPSHOT_SCHEMA_VERSION: 1;
1485
1682
  type AudioCueEventType = (typeof AUDIO_CUE_EVENTS)[number];
1486
1683
  type AudioCueSkipReason = 'reduced-sensory' | 'muted' | 'unauthorized';
1487
1684
  type AudioCueFailReason = 'asset-failed' | 'torn-down' | 'invalid';
@@ -1499,6 +1696,8 @@ type AudioCueView = CueView & {
1499
1696
  participantId?: string;
1500
1697
  priority: number;
1501
1698
  audioPhase: 'scheduled' | 'started' | 'skipped' | 'failed' | 'completed';
1699
+ /** Original play spec; omitted when the cue was not repeating. */
1700
+ repeat?: CueRepeatPolicy;
1502
1701
  };
1503
1702
  type AudioCueEvent = {
1504
1703
  type: AudioCueEventType;
@@ -1512,11 +1711,28 @@ type AudioCueEvent = {
1512
1711
  progress: number;
1513
1712
  };
1514
1713
  type AudioCueTimelineSnapshot = {
1714
+ schemaVersion: typeof AUDIO_CUE_SNAPSHOT_SCHEMA_VERSION;
1515
1715
  frame: number;
1516
1716
  reducedSensory: boolean;
1517
1717
  cues: AudioCueView[];
1518
1718
  events: AudioCueEvent[];
1519
1719
  };
1720
+ type HeadlessAudioAdapterSnapshot = AudioCueTimelineSnapshot & {
1721
+ unlock: AudioUnlockStatus;
1722
+ muted: boolean;
1723
+ };
1724
+ type AudioCueDiagnostic = {
1725
+ code: string;
1726
+ detail: string;
1727
+ path?: string;
1728
+ };
1729
+ type RestoreAudioCueResult = {
1730
+ ok: true;
1731
+ snapshot: AudioCueTimelineSnapshot;
1732
+ } | {
1733
+ ok: false;
1734
+ errors: AudioCueDiagnostic[];
1735
+ };
1520
1736
  type PlayAudioCueResult = {
1521
1737
  ok: true;
1522
1738
  cue: AudioCueView;
@@ -1531,8 +1747,15 @@ type AudioCueTimeline = {
1531
1747
  cancel(idempotencyKey: string): boolean;
1532
1748
  reset(): void;
1533
1749
  snapshot(): AudioCueTimelineSnapshot;
1750
+ restore(input: unknown): RestoreAudioCueResult;
1534
1751
  get(idempotencyKey: string): AudioCueView | undefined;
1535
1752
  dispose(): void;
1753
+ /**
1754
+ * Updates skip-playback for future cue starts. Already-started cues
1755
+ * continue; scheduled cues that have not started yet use the new flag
1756
+ * when they start.
1757
+ */
1758
+ setReducedSensory(value: boolean): void;
1536
1759
  readonly frame: number;
1537
1760
  readonly reducedSensory: boolean;
1538
1761
  };
@@ -1543,12 +1766,13 @@ type HeadlessAudioAdapter = {
1543
1766
  play(spec: AudioCueSpec): PlayAudioCueResult;
1544
1767
  step(frames?: number): AudioCueEvent[];
1545
1768
  handleHostEvent(event: HostEvent): void;
1546
- snapshot(): AudioCueTimelineSnapshot & {
1547
- unlock: AudioUnlockStatus;
1548
- muted: boolean;
1549
- };
1769
+ snapshot(): HeadlessAudioAdapterSnapshot;
1770
+ restore(input: unknown): RestoreAudioCueResult;
1550
1771
  destroy(): void;
1772
+ setReducedSensory(value: boolean): void;
1773
+ readonly reducedSensory: boolean;
1551
1774
  };
1775
+ declare function parseAudioCueSnapshot(input: unknown): RestoreAudioCueResult;
1552
1776
  declare function createHeadlessAudioAdapter(options?: {
1553
1777
  reducedSensory?: boolean;
1554
1778
  originFrame?: number;
@@ -1697,9 +1921,15 @@ type VisualLayerController = {
1697
1921
  inspect(): VisualLayerInspect[];
1698
1922
  captureComposedFrame(): ComposedFrame;
1699
1923
  destroy(): void;
1924
+ /**
1925
+ * Updates the host flag used by future `play()` calls. In-flight
1926
+ * transitions keep the durations they were compiled with.
1927
+ */
1928
+ setReducedMotion(value: boolean): void;
1700
1929
  readonly frame: number;
1701
1930
  readonly sceneId: string | null;
1702
1931
  readonly compositor: Compositor;
1932
+ readonly reducedMotion: boolean;
1703
1933
  };
1704
1934
  type VisualLayerCapture = {
1705
1935
  frame: ComposedFrame;
@@ -1713,47 +1943,2402 @@ declare function createVisualLayerController(options: CreateVisualLayerControlle
1713
1943
  * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
1714
1944
  * See packages/engine/LICENSE
1715
1945
  *
1716
- * Cart-agnostic update/render frame benchmark for CI and agent workflows.
1717
- * Prefer this over ad-hoc vitest probes when evaluating hash / trait cost.
1946
+ * Shared normalized coordinate, anchor, and hit-region contract. Hosts and
1947
+ * adapters may adopt this later; pixel `PresentationRegion` is unchanged.
1948
+ *
1949
+ * Coordinate spaces:
1950
+ * - `normalized` — 0–1 of the **content** box (full intrinsic artwork, not letterbox).
1951
+ * - `asset` — intrinsic content pixels (`contentWidth` × `contentHeight`).
1952
+ * - `css` / `viewport` — layout pixels (`viewportWidth` × `viewportHeight`).
1953
+ * - `canvas` — drawing-buffer pixels (`css * devicePixelRatio`). Pointers match
1954
+ * `PointerManager` / harness `click` when the buffer is the drawing canvas.
1955
+ *
1956
+ * Pointer helpers default to **canvas** space. Pass `{ space: 'css' }` for
1957
+ * layout pixels. Round-trip: `ROUND_TRIP_TOLERANCE` (1e-6 normalized) or
1958
+ * `ROUND_TRIP_TOLERANCE_CANVAS_PX` (0.5 canvas px).
1718
1959
  */
1960
+ declare const GEOMETRY_CONTRACT_VERSION: 1;
1961
+ type PresentationFitMode = 'contain' | 'cover' | 'crop';
1962
+ declare const ANCHOR_ORIGINS: readonly ["center", "top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right"];
1963
+ type AnchorOrigin = (typeof ANCHOR_ORIGINS)[number];
1964
+ type NormalizedPoint = {
1965
+ x: number;
1966
+ y: number;
1967
+ };
1968
+ type NormalizedRect = {
1969
+ x: number;
1970
+ y: number;
1971
+ width: number;
1972
+ height: number;
1973
+ };
1974
+ type NormalizedPolygon = readonly NormalizedPoint[];
1975
+ type GeometryPadding = {
1976
+ top: number;
1977
+ right: number;
1978
+ bottom: number;
1979
+ left: number;
1980
+ };
1981
+ /** Insets from the content edges in normalized units (0–1). */
1982
+ type GeometrySafeArea = GeometryPadding;
1983
+ type GeometryAnchor = {
1984
+ id: string;
1985
+ point: NormalizedPoint;
1986
+ origin?: AnchorOrigin;
1987
+ };
1988
+ type GeometryHitbox = {
1989
+ id: string;
1990
+ rect?: NormalizedRect;
1991
+ polygon?: NormalizedPolygon;
1992
+ };
1993
+ type GeometryDocument = {
1994
+ version: typeof GEOMETRY_CONTRACT_VERSION;
1995
+ landmarks: GeometryAnchor[];
1996
+ regions: GeometryHitbox[];
1997
+ padding?: GeometryPadding;
1998
+ safeArea?: GeometrySafeArea;
1999
+ };
2000
+ type PresentationLayout = {
2001
+ mode: PresentationFitMode;
2002
+ contentWidth: number;
2003
+ contentHeight: number;
2004
+ viewportWidth: number;
2005
+ viewportHeight: number;
2006
+ devicePixelRatio: number;
2007
+ /** Content → CSS pixels. */
2008
+ scale: number;
2009
+ /** Letterbox (positive) or crop (negative) offset of content origin in CSS. */
2010
+ offsetX: number;
2011
+ offsetY: number;
2012
+ canvasWidth: number;
2013
+ canvasHeight: number;
2014
+ /** Visible slice of the content box in normalized space. */
2015
+ visibleNormalizedRect: NormalizedRect;
2016
+ };
1719
2017
 
1720
- type FrameBenchmarkOptions = {
1721
- /** Measured frames after warmup. Default 30. */
1722
- frames?: number;
1723
- /** Discarded frames before measurement. Default 5. */
1724
- warmupFrames?: number;
1725
- /** Simulated frame advance in ms. Default 1000/60. */
1726
- frameStepMs?: number;
1727
- width?: number;
1728
- height?: number;
1729
- tokenId?: string;
2018
+ /**
2019
+ * Copyright (c) 2026 Aaron Boyarsky
2020
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2021
+ * See packages/engine/LICENSE
2022
+ *
2023
+ * Cart-published named semantic regions (mask / polygon / depth) in normalized
2024
+ * space. The host drives hover/focus/selected and supplies a11y names/roles.
2025
+ * Geometry, blend, and hit-test policy stay with the cart. Snapshot JSON is
2026
+ * hostState-safe. Headless inspect does not require a DOM overlay.
2027
+ */
2028
+
2029
+ declare const SEMANTIC_LAYER_SNAPSHOT_SCHEMA_VERSION: 1;
2030
+ declare const SEMANTIC_GEOMETRY_KINDS: readonly ["mask", "polygon", "rect", "depth"];
2031
+ type SemanticGeometryKind = (typeof SEMANTIC_GEOMETRY_KINDS)[number];
2032
+ declare const SEMANTIC_HIT_TEST_POLICIES: readonly ["pass-through", "absorb", "exclusive", "depth-ordered"];
2033
+ type SemanticHitTestPolicy = (typeof SEMANTIC_HIT_TEST_POLICIES)[number];
2034
+ declare const SEMANTIC_APPEARANCE_KEYS: readonly ["idle", "hover", "focus", "selected"];
2035
+ type SemanticAppearanceKey = (typeof SEMANTIC_APPEARANCE_KEYS)[number];
2036
+ type SemanticRegionState = {
2037
+ hover: boolean;
2038
+ focus: boolean;
2039
+ selected: boolean;
2040
+ };
2041
+ type SemanticRegionA11y = {
2042
+ name: string;
2043
+ role: string;
2044
+ };
2045
+ type SemanticMaskGrid = {
2046
+ width: number;
2047
+ height: number;
2048
+ /** Row-major coverage in [0, 1]. Length must be width * height. */
2049
+ alpha: readonly number[];
2050
+ /** Where the grid maps in normalized space. Default full content box. */
2051
+ bounds?: NormalizedRect;
2052
+ };
2053
+ type SemanticRegionGeometry = {
2054
+ mask?: SemanticMaskGrid;
2055
+ polygon?: NormalizedPolygon;
2056
+ rect?: NormalizedRect;
2057
+ /** Higher values are closer to the viewer. Default 0. */
2058
+ depth?: number;
2059
+ };
2060
+ type SemanticRegionVisual = {
2061
+ opacity?: number;
2062
+ blend?: CompositorBlendMode;
2063
+ /** Visual-layer version applied when `visualLayerId` is set. */
2064
+ version?: string;
2065
+ };
2066
+ type SemanticRegionVisuals = Partial<Record<SemanticAppearanceKey, SemanticRegionVisual>>;
2067
+ type SemanticRegionDeclaration = {
2068
+ id: string;
2069
+ geometry: SemanticRegionGeometry;
2070
+ hitTest?: SemanticHitTestPolicy;
2071
+ blend?: CompositorBlendMode;
2072
+ order?: number;
2073
+ compositorLayerId?: string;
2074
+ visualLayerId?: string;
2075
+ visuals?: SemanticRegionVisuals;
2076
+ initialState?: Partial<SemanticRegionState>;
2077
+ };
2078
+ type SemanticRegionInspect = {
2079
+ id: string;
2080
+ geometryKinds: SemanticGeometryKind[];
2081
+ hitTest: SemanticHitTestPolicy;
2082
+ blend: CompositorBlendMode;
2083
+ order: number;
2084
+ depth: number;
2085
+ state: SemanticRegionState;
2086
+ appearance: SemanticAppearanceKey;
2087
+ a11y: SemanticRegionA11y | null;
2088
+ visual: SemanticRegionVisual;
2089
+ };
2090
+ type SemanticPublishedRegion = {
2091
+ id: string;
2092
+ geometryKinds: SemanticGeometryKind[];
2093
+ a11y: SemanticRegionA11y | null;
2094
+ };
2095
+ type SemanticRegionSnapshotRow = {
2096
+ id: string;
2097
+ geometry: SemanticRegionGeometry;
2098
+ hitTest: SemanticHitTestPolicy;
2099
+ blend: CompositorBlendMode;
2100
+ order: number;
2101
+ compositorLayerId: string | null;
2102
+ visualLayerId: string | null;
2103
+ visuals: SemanticRegionVisuals;
2104
+ state: SemanticRegionState;
2105
+ a11y: SemanticRegionA11y | null;
2106
+ };
2107
+ type SemanticLayerControllerSnapshot = {
2108
+ schemaVersion: typeof SEMANTIC_LAYER_SNAPSHOT_SCHEMA_VERSION;
2109
+ frame: number;
2110
+ regions: SemanticRegionSnapshotRow[];
2111
+ };
2112
+ type RestoreSemanticLayerResult = {
2113
+ ok: true;
2114
+ snapshot: SemanticLayerControllerSnapshot;
2115
+ } | {
2116
+ ok: false;
2117
+ errors: string[];
2118
+ };
2119
+ type CreateSemanticLayerControllerOptions = {
2120
+ regions: readonly SemanticRegionDeclaration[];
2121
+ compositor?: Compositor;
2122
+ visualLayers?: VisualLayerController;
2123
+ originFrame?: number;
2124
+ };
2125
+ type SemanticLayerController = {
2126
+ list(): SemanticRegionInspect[];
2127
+ inspect(): SemanticRegionInspect[];
2128
+ inspectPublished(): SemanticPublishedRegion[];
2129
+ get(id: string): SemanticRegionInspect | undefined;
2130
+ geometryOf(id: string): SemanticRegionGeometry | undefined;
2131
+ setRegionState(id: string, state: Partial<SemanticRegionState>): void;
2132
+ setRegionA11y(id: string, a11y: SemanticRegionA11y | null): void;
2133
+ hitTest(point: NormalizedPoint): SemanticRegionInspect | undefined;
2134
+ hitTestAll(point: NormalizedPoint): SemanticRegionInspect[];
2135
+ snapshot(): SemanticLayerControllerSnapshot;
2136
+ restore(input: unknown): RestoreSemanticLayerResult;
2137
+ destroy(): void;
2138
+ readonly frame: number;
2139
+ };
2140
+ declare function createSemanticLayerController(options: CreateSemanticLayerControllerOptions): SemanticLayerController;
2141
+
2142
+ /**
2143
+ * Copyright (c) 2026 Aaron Boyarsky
2144
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2145
+ * See packages/engine/LICENSE
2146
+ *
2147
+ * Cross-modal presentation sequences. One frame-stepped clock coordinates
2148
+ * audio, captions, semantic-region state, visual layers, and typed cues.
2149
+ * Authored content is JSON-serializable: no callbacks, no ambient host access.
2150
+ * Dialogue graphs and game rules stay with the host.
2151
+ */
2152
+
2153
+ declare const PRESENTATION_SEQUENCE_SNAPSHOT_SCHEMA_VERSION: 1;
2154
+ declare const PRESENTATION_SEQUENCE_EVENTS: readonly ["presentation.sequence.state.requested", "presentation.sequence.state.preloading", "presentation.sequence.state.ready", "presentation.sequence.state.started", "presentation.sequence.state.step-started", "presentation.sequence.state.step-completed", "presentation.sequence.state.skipped", "presentation.sequence.state.interrupted", "presentation.sequence.state.failed", "presentation.sequence.state.completed", "presentation.sequence.diagnostic.lifecycle"];
2155
+ type PresentationSequenceEventType = (typeof PRESENTATION_SEQUENCE_EVENTS)[number];
2156
+ declare const PRESENTATION_TRACK_KINDS: readonly ["audio", "caption", "semantic-region", "visual-layer", "cue"];
2157
+ type PresentationTrackKind = (typeof PRESENTATION_TRACK_KINDS)[number];
2158
+ declare const PRESENTATION_INTERRUPTION_POLICIES: readonly ["replace", "queue", "reject", "ignore"];
2159
+ type PresentationInterruptionPolicy = (typeof PRESENTATION_INTERRUPTION_POLICIES)[number];
2160
+ declare const PRESENTATION_COMPLETION_RULES: readonly ["duration", "immediate"];
2161
+ type PresentationCompletionRule = (typeof PRESENTATION_COMPLETION_RULES)[number];
2162
+ declare const PRESENTATION_AUDIO_CAPABILITY_STATUSES: readonly ["unavailable", "failed", "unauthorized", "muted"];
2163
+ type PresentationAudioCapabilityStatus = (typeof PRESENTATION_AUDIO_CAPABILITY_STATUSES)[number];
2164
+ declare const PRESENTATION_INVOCATION_PHASES: readonly ["requested", "preloading", "ready", "playing", "paused", "skipped", "interrupted", "failed", "completed"];
2165
+ type PresentationInvocationPhase = (typeof PRESENTATION_INVOCATION_PHASES)[number];
2166
+ type PresentationSequenceDiagnostic = {
2167
+ code: string;
2168
+ detail: string;
2169
+ path?: string;
2170
+ };
2171
+ type PresentationStepTiming = {
2172
+ kind: 'absolute';
2173
+ atFrame: number;
2174
+ } | {
2175
+ kind: 'relative';
2176
+ afterStepId?: string;
2177
+ delayFrames?: number;
2178
+ } | {
2179
+ kind: 'simultaneous';
2180
+ withStepId: string;
2181
+ order?: number;
2182
+ delayFrames?: number;
2183
+ };
2184
+ type PresentationStepEffect = {
2185
+ kind: 'audio';
2186
+ assetBinding: string;
2187
+ channelBinding?: string;
2188
+ } | {
2189
+ kind: 'caption';
2190
+ textBinding: string;
2191
+ visible: boolean;
2192
+ } | {
2193
+ kind: 'semantic-region';
2194
+ regionBinding: string;
2195
+ state: Partial<Pick<SemanticRegionState, 'hover' | 'focus' | 'selected'>>;
2196
+ } | {
2197
+ kind: 'visual-layer';
2198
+ layerBinding: string;
2199
+ transition: Extract<VisualLayerTransitionKind, 'show' | 'hide'>;
2200
+ versionBinding?: string;
2201
+ } | {
2202
+ kind: 'cue';
2203
+ name: string;
2204
+ easing?: CueEasing;
2205
+ };
2206
+ type PresentationStepDefinition = {
2207
+ id: string;
2208
+ timing: PresentationStepTiming;
2209
+ durationFrames: number;
2210
+ delayFrames?: number;
2211
+ completion?: PresentationCompletionRule;
2212
+ effect: PresentationStepEffect;
2213
+ restoreOnComplete?: boolean;
2214
+ reducedMotion?: CueReducedMotionPolicy;
2215
+ reducedSensory?: 'keep' | 'skip-audio' | 'complete';
2216
+ };
2217
+ type PresentationTrackDefinition = {
2218
+ id: string;
2219
+ kind: PresentationTrackKind;
2220
+ steps: readonly PresentationStepDefinition[];
2221
+ };
2222
+ type PresentationFallbackWhen = {
2223
+ capability: 'audio';
2224
+ status: PresentationAudioCapabilityStatus;
2225
+ };
2226
+ type PresentationFallbackDefinition = {
2227
+ id: string;
2228
+ when: PresentationFallbackWhen;
2229
+ omitTrackIds?: readonly string[];
2230
+ };
2231
+ type PresentationSequenceDefinition = {
2232
+ id: string;
2233
+ tracks: readonly PresentationTrackDefinition[];
2234
+ interruptionPolicy?: PresentationInterruptionPolicy;
2235
+ fallbacks?: readonly PresentationFallbackDefinition[];
2236
+ };
2237
+ type PresentationSequenceBindings = {
2238
+ assets?: Record<string, string>;
2239
+ captions?: Record<string, string>;
2240
+ regions?: Record<string, string>;
2241
+ layers?: Record<string, string>;
2242
+ versions?: Record<string, string>;
2243
+ channels?: Record<string, string>;
2244
+ };
2245
+ type PlaySequenceOptions = {
2246
+ invocationId: string;
2247
+ idempotencyKey?: string;
2248
+ bindings?: PresentationSequenceBindings;
2249
+ };
2250
+ type DefinePresentationSequenceResult = {
2251
+ ok: true;
2252
+ sequence: PresentationSequenceDefinition;
2253
+ } | {
2254
+ ok: false;
2255
+ errors: PresentationSequenceDiagnostic[];
2256
+ };
2257
+ type PlaySequenceResult = {
2258
+ ok: true;
2259
+ invocation: PresentationInvocationView;
2260
+ } | {
2261
+ ok: false;
2262
+ reason: 'unknown-sequence' | 'invalid' | 'busy' | 'duplicate';
2263
+ detail: string;
2264
+ };
2265
+ type RestorePresentationSequenceResult = {
2266
+ ok: true;
2267
+ snapshot: PresentationSequenceSnapshot;
2268
+ } | {
2269
+ ok: false;
2270
+ errors: PresentationSequenceDiagnostic[];
2271
+ };
2272
+ type PresentationSequenceEvent = {
2273
+ type: PresentationSequenceEventType;
2274
+ atFrame: number;
2275
+ sequenceId: string;
2276
+ invocationId: string;
2277
+ idempotencyKey: string;
2278
+ stepId?: string;
2279
+ fallbackId?: string;
2280
+ reason?: string;
2281
+ };
2282
+ type PresentationCaptionView = {
2283
+ id: string;
2284
+ text: string;
2285
+ visible: boolean;
2286
+ };
2287
+ type PresentationCueIntent = {
2288
+ sequenceId: string;
2289
+ stepId: string;
2290
+ trackId: string;
2291
+ kind: PresentationTrackKind;
2292
+ startFrame: number;
2293
+ durationFrames: number;
2294
+ order: number;
2295
+ effect: PresentationStepEffect;
2296
+ };
2297
+ type PresentationInvocationView = {
2298
+ sequenceId: string;
2299
+ invocationId: string;
2300
+ idempotencyKey: string;
2301
+ phase: PresentationInvocationPhase;
2302
+ playhead: number;
2303
+ startedAtFrame: number;
2304
+ completedStepIds: string[];
2305
+ activeStepIds: string[];
2306
+ selectedFallbackId: string | null;
2307
+ /** Reduced-motion flag used to compile this invocation's step durations. */
2308
+ compiledReducedMotion: boolean;
2309
+ };
2310
+ type PresentationSequenceSnapshot = {
2311
+ schemaVersion: typeof PRESENTATION_SEQUENCE_SNAPSHOT_SCHEMA_VERSION;
2312
+ frame: number;
2313
+ reducedMotion: boolean;
2314
+ reducedSensory: boolean;
2315
+ paused: boolean;
2316
+ active: PresentationInvocationView | null;
2317
+ queue: PresentationSequenceSnapshotQueued[];
2318
+ captions: PresentationCaptionView[];
2319
+ events: PresentationSequenceEvent[];
2320
+ bindings: PresentationSequenceBindings | null;
2321
+ };
2322
+ type PresentationSequenceSnapshotQueued = {
2323
+ sequenceId: string;
2324
+ invocationId: string;
2325
+ idempotencyKey: string;
2326
+ bindings: PresentationSequenceBindings;
2327
+ };
2328
+ type PresentationSequenceInspect = {
2329
+ frame: number;
2330
+ paused: boolean;
2331
+ reducedMotion: boolean;
2332
+ reducedSensory: boolean;
2333
+ active: PresentationInvocationView | null;
2334
+ queue: PresentationInvocationView[];
2335
+ captions: PresentationCaptionView[];
2336
+ cueIntent: PresentationCueIntent[];
2337
+ };
2338
+ type CreatePresentationSequencePlayerOptions = {
2339
+ originFrame?: number;
2340
+ reducedMotion?: boolean;
2341
+ reducedSensory?: boolean;
2342
+ audio?: AudioCueTimeline | HeadlessAudioAdapter;
2343
+ semantic?: SemanticLayerController;
2344
+ visual?: VisualLayerController;
2345
+ sequences?: readonly PresentationSequenceDefinition[];
2346
+ };
2347
+ type PresentationSequencePlayer = {
2348
+ define(input: PresentationSequenceDefinition): DefinePresentationSequenceResult;
2349
+ playSequence(sequenceId: string, options: PlaySequenceOptions): PlaySequenceResult;
2350
+ skip(invocationId?: string): boolean;
2351
+ replay(invocationId?: string): PlaySequenceResult;
2352
+ pause(): boolean;
2353
+ resume(): boolean;
2354
+ cancel(invocationId?: string): boolean;
2355
+ step(frames?: number): PresentationSequenceEvent[];
2356
+ snapshot(): PresentationSequenceSnapshot;
2357
+ restore(input: unknown): RestorePresentationSequenceResult;
2358
+ inspect(): PresentationSequenceInspect;
2359
+ inspectCueIntent(sequenceId: string, options?: {
2360
+ fallbackId?: string;
2361
+ }): PresentationCueIntent[];
2362
+ get(sequenceId: string): PresentationSequenceDefinition | undefined;
2363
+ destroy(): void;
1730
2364
  /**
1731
- * Mutate state after `getDefaultState` (e.g. skip Tone init in jsdom by
1732
- * setting `audioContextStarted = true`).
2365
+ * Updates the host flag used by future `playSequence` / cue-intent
2366
+ * compilation. The active invocation **continues** with the durations it
2367
+ * was compiled with. Queued plays that have not started yet use the new
2368
+ * policy when they start.
1733
2369
  */
1734
- prepareState?: (state: unknown, featureState: unknown) => void;
1735
- /** Optional stub drawing context; defaults to a no-op `putImageData`. */
1736
- drawingContext?: CanvasRenderingContext2D;
1737
- };
1738
- type FrameBenchmarkResult = {
1739
- frames: number;
1740
- updateAvgMs: number;
1741
- renderAvgMs: number;
1742
- totalAvgMs: number;
1743
- updateMaxMs: number;
1744
- renderMaxMs: number;
1745
- estFps: number;
1746
- updatePct: number;
1747
- renderPct: number;
2370
+ setReducedMotion(value: boolean): void;
2371
+ readonly frame: number;
2372
+ readonly reducedMotion: boolean;
2373
+ readonly reducedSensory: boolean;
1748
2374
  };
2375
+ declare function presentationSequenceEventContracts(): EventContract[];
2376
+ declare function definePresentationSequence(input: unknown): DefinePresentationSequenceResult;
2377
+ declare function createPresentationSequencePlayer(options?: CreatePresentationSequencePlayerOptions): PresentationSequencePlayer;
2378
+
1749
2379
  /**
1750
- * Run a cart's update/render loop headlessly and report average / max phase
1751
- * timings. Does not start audio or mount a live AnimationManager — suitable
1752
- * for jsdom vitest and agent hash probes.
2380
+ * Copyright (c) 2026 Aaron Boyarsky
2381
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2382
+ * See packages/engine/LICENSE
2383
+ *
2384
+ * Declarative projection of host-authoritative state into presentation
2385
+ * resources. The host reducer stays the owner; this module evaluates a
2386
+ * bounded, JSON-serializable binding manifest and applies one coherent
2387
+ * presentation revision (or the declared fail-closed defaults).
1753
2388
  */
1754
- declare function benchmarkCartFrames<T, TFeatureState = undefined>(cart: AnimationCart<T, TFeatureState>, hash: string, rawParams: number[], options?: FrameBenchmarkOptions): FrameBenchmarkResult;
1755
- /** Round timing fields for stable console / snapshot logging. */
1756
- declare function formatFrameBenchmarkResult(result: FrameBenchmarkResult, digits?: number): Record<string, number>;
2389
+
2390
+ declare const PRESENTATION_BINDING_SNAPSHOT_SCHEMA_VERSION: 1;
2391
+ declare const PRESENTATION_BINDING_MANIFEST_VERSION: 1;
2392
+ declare const PRESENTATION_BINDING_APPLIED_EVENT: "presentation.binding.state.applied";
2393
+ declare const PRESENTATION_BINDING_ERROR_CODES: readonly ["invalid-manifest", "invalid-schema", "invalid-version", "invalid-id", "unknown-field", "unknown-resource", "unknown-selector", "duplicate-id", "duplicate-priority", "uncovered-default", "impossible-target", "callbacks-forbidden", "invalid-predicate", "invalid-projection", "invalid-snapshot", "destroyed"];
2394
+ type PresentationBindingErrorCode = (typeof PRESENTATION_BINDING_ERROR_CODES)[number];
2395
+ type PresentationBindingDiagnostic = {
2396
+ code: PresentationBindingErrorCode | string;
2397
+ detail: string;
2398
+ path?: string;
2399
+ };
2400
+ type JsonPrimitive = string | number | boolean | null;
2401
+ type JsonObject = {
2402
+ [key: string]: JsonValue;
2403
+ };
2404
+ type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
2405
+ type PresentationPredicate = {
2406
+ path: string;
2407
+ eq: JsonPrimitive;
2408
+ } | {
2409
+ path: string;
2410
+ neq: JsonPrimitive;
2411
+ } | {
2412
+ path: string;
2413
+ present: boolean;
2414
+ } | {
2415
+ selector: string;
2416
+ } | {
2417
+ all: PresentationPredicate[];
2418
+ } | {
2419
+ any: PresentationPredicate[];
2420
+ } | {
2421
+ not: PresentationPredicate;
2422
+ };
2423
+ type PresentationBindingTarget = {
2424
+ kind: 'visual-layer';
2425
+ layerId: string;
2426
+ version: string;
2427
+ transition?: Extract<VisualLayerTransitionKind, 'show' | 'hide' | 'replace'>;
2428
+ } | {
2429
+ kind: 'presence';
2430
+ entityId: string;
2431
+ present: boolean;
2432
+ regionId?: string;
2433
+ } | {
2434
+ kind: 'prop';
2435
+ propId: string;
2436
+ visible: boolean;
2437
+ layerId?: string;
2438
+ } | {
2439
+ kind: 'semantic-region';
2440
+ regionId: string;
2441
+ state?: Partial<Pick<SemanticRegionState, 'hover' | 'focus' | 'selected'>>;
2442
+ hitTestEnabled?: boolean;
2443
+ } | {
2444
+ kind: 'hotspot';
2445
+ hotspotId: string;
2446
+ enabled: boolean;
2447
+ regionId?: string;
2448
+ } | {
2449
+ kind: 'sequence';
2450
+ sequenceId: string;
2451
+ play?: boolean;
2452
+ } | {
2453
+ kind: 'asset';
2454
+ bindingId: string;
2455
+ assetId: string;
2456
+ };
2457
+ type PresentationBinding = {
2458
+ id: string;
2459
+ priority: number;
2460
+ when: PresentationPredicate;
2461
+ targets: readonly PresentationBindingTarget[];
2462
+ };
2463
+ type PresentationBindingResources = {
2464
+ layers?: readonly string[];
2465
+ versions?: Readonly<Record<string, readonly string[]>>;
2466
+ regions?: readonly string[];
2467
+ sequences?: readonly string[];
2468
+ hotspots?: readonly string[];
2469
+ entities?: readonly string[];
2470
+ props?: readonly string[];
2471
+ assets?: readonly string[];
2472
+ };
2473
+ type PresentationBindingManifest = {
2474
+ id: string;
2475
+ schemaVersion: typeof PRESENTATION_BINDING_MANIFEST_VERSION;
2476
+ bindings: readonly PresentationBinding[];
2477
+ defaults: readonly PresentationBindingTarget[];
2478
+ resources?: PresentationBindingResources;
2479
+ };
2480
+ type DefinePresentationBindingsResult = {
2481
+ ok: true;
2482
+ manifest: PresentationBindingManifest;
2483
+ } | {
2484
+ ok: false;
2485
+ errors: PresentationBindingDiagnostic[];
2486
+ };
2487
+ type PresentationBindingSelector = (projection: JsonObject) => boolean;
2488
+ type PresentationBindingConsidered = {
2489
+ bindingId: string;
2490
+ predicateResult: boolean;
2491
+ detail?: string;
2492
+ };
2493
+ type PresentationBindingRejected = {
2494
+ bindingId: string;
2495
+ targetKey: string;
2496
+ reason: 'lower-priority' | 'predicate-false';
2497
+ };
2498
+ type PresentationBindingFallback = {
2499
+ targetKey: string;
2500
+ reason: 'uncovered-default' | 'missing-state' | 'invalid-projection';
2501
+ };
2502
+ type PresentationBindingExplanation = {
2503
+ considered: PresentationBindingConsidered[];
2504
+ winners: Record<string, {
2505
+ bindingId: string | null;
2506
+ target: PresentationBindingTarget;
2507
+ }>;
2508
+ rejected: PresentationBindingRejected[];
2509
+ fallbacks: PresentationBindingFallback[];
2510
+ fallbackReason: 'missing-state' | 'invalid-projection' | null;
2511
+ };
2512
+ type PresentationBindingEvaluation = {
2513
+ selectedBindingIds: string[];
2514
+ targets: PresentationBindingTarget[];
2515
+ usedFallback: boolean;
2516
+ fallbackReason: 'missing-state' | 'invalid-projection' | null;
2517
+ explanation: PresentationBindingExplanation;
2518
+ };
2519
+ type HostPresentationOverride = {
2520
+ labels?: Record<string, string | Pick<SemanticRegionA11y, 'name' | 'role'>>;
2521
+ reducedSensory?: boolean;
2522
+ reducedMotion?: boolean;
2523
+ };
2524
+ type PresentationBindingInspect = {
2525
+ revision: string | number | null;
2526
+ selectedBindingIds: string[];
2527
+ layers: Record<string, string>;
2528
+ presence: Record<string, boolean>;
2529
+ props: Record<string, boolean>;
2530
+ regions: Record<string, Partial<SemanticRegionState> & {
2531
+ hitTestEnabled?: boolean;
2532
+ }>;
2533
+ hotspots: Record<string, boolean>;
2534
+ sequences: Record<string, 'playing' | 'idle'>;
2535
+ assets: Record<string, string>;
2536
+ override: HostPresentationOverride | null;
2537
+ usedFallback: boolean;
2538
+ fallbackReason: 'missing-state' | 'invalid-projection' | null;
2539
+ explanation: PresentationBindingExplanation | null;
2540
+ };
2541
+ type PresentationBindingSnapshot = {
2542
+ schemaVersion: typeof PRESENTATION_BINDING_SNAPSHOT_SCHEMA_VERSION;
2543
+ manifestId: string;
2544
+ projectionRevision: string | number | null;
2545
+ selectedBindingIds: string[];
2546
+ targets: PresentationBindingTarget[];
2547
+ usedFallback: boolean;
2548
+ fallbackReason: 'missing-state' | 'invalid-projection' | null;
2549
+ override: HostPresentationOverride | null;
2550
+ };
2551
+ type ApplyPresentationBindingsResult = {
2552
+ ok: true;
2553
+ revision: string | number;
2554
+ selectedBindingIds: string[];
2555
+ usedFallback: boolean;
2556
+ fallbackReason: 'missing-state' | 'invalid-projection' | null;
2557
+ explanation: PresentationBindingExplanation;
2558
+ inspect: PresentationBindingInspect;
2559
+ } | {
2560
+ ok: false;
2561
+ errors: PresentationBindingDiagnostic[];
2562
+ inspect: PresentationBindingInspect;
2563
+ };
2564
+ type RestorePresentationBindingsResult = {
2565
+ ok: true;
2566
+ snapshot: PresentationBindingSnapshot;
2567
+ } | {
2568
+ ok: false;
2569
+ errors: PresentationBindingDiagnostic[];
2570
+ };
2571
+ type CreatePresentationBindingRuntimeOptions = {
2572
+ manifest: PresentationBindingManifest | unknown;
2573
+ visual?: VisualLayerController;
2574
+ semantic?: SemanticLayerController;
2575
+ sequences?: PresentationSequencePlayer;
2576
+ selectors?: Readonly<Record<string, PresentationBindingSelector>>;
2577
+ router?: Pick<EventRouter, 'publish'>;
2578
+ onEvent?: (event: EventInput) => void;
2579
+ };
2580
+ type PresentationBindingRuntime = {
2581
+ apply(projection: unknown, options?: {
2582
+ revision?: string | number;
2583
+ }): ApplyPresentationBindingsResult;
2584
+ setOverride(override: HostPresentationOverride | null): void;
2585
+ evaluate(projection: unknown): PresentationBindingEvaluation;
2586
+ inspect(): PresentationBindingInspect;
2587
+ snapshot(): PresentationBindingSnapshot;
2588
+ restore(input: unknown): RestorePresentationBindingsResult;
2589
+ destroy(): void;
2590
+ readonly manifest: PresentationBindingManifest;
2591
+ };
2592
+ declare function presentationBindingEventContracts(): EventContract[];
2593
+ declare function definePresentationBindings(input: unknown): DefinePresentationBindingsResult;
2594
+ declare function evaluatePresentationBindings(manifest: PresentationBindingManifest, projection: unknown, selectors?: Readonly<Record<string, PresentationBindingSelector>>): PresentationBindingEvaluation;
2595
+ declare function createPresentationBindingRuntime(options: CreatePresentationBindingRuntimeOptions): PresentationBindingRuntime;
2596
+
2597
+ /**
2598
+ * Copyright (c) 2026 Aaron Boyarsky
2599
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2600
+ * See packages/engine/LICENSE
2601
+ *
2602
+ * Versioned, JSON-serializable capability manifest for a cart/module.
2603
+ * Definition, parse, and host validation all return structured diagnostics
2604
+ * instead of throwing.
2605
+ */
2606
+ declare const CAPABILITY_MANIFEST_VERSION: 1;
2607
+ declare const CAPABILITY_PHASES: readonly ["loading", "ready", "error", "unsupported"];
2608
+ type CapabilityPhase = (typeof CAPABILITY_PHASES)[number];
2609
+ declare const CAPABILITY_MANAGERS: readonly ["keyboard", "pointer", "audio", "assets", "hostChannel"];
2610
+ type CapabilityManager = (typeof CAPABILITY_MANAGERS)[number];
2611
+ declare const CAPABILITY_ASSET_KINDS: readonly ["image", "audio", "font", "spritesheet"];
2612
+ type CapabilityAssetKind = (typeof CAPABILITY_ASSET_KINDS)[number];
2613
+ declare const CAPABILITY_INTEGRATIONS: readonly ["tone", "midi"];
2614
+ type CapabilityIntegration = (typeof CAPABILITY_INTEGRATIONS)[number];
2615
+ declare const CAPABILITY_BLEND_MODES: readonly ["source-over", "screen"];
2616
+ type CapabilityBlendMode = (typeof CAPABILITY_BLEND_MODES)[number];
2617
+ declare const CAPABILITY_CLEAR_POLICIES: readonly ["transparent", "opaque"];
2618
+ type CapabilityClearPolicy = (typeof CAPABILITY_CLEAR_POLICIES)[number];
2619
+ declare const CAPABILITY_CART_KINDS: readonly ["render", "calculation"];
2620
+ type CapabilityCartKind = (typeof CAPABILITY_CART_KINDS)[number];
2621
+ /** Device/host grants a remote cart may request. Omitted on existing manifests. */
2622
+ declare const CAPABILITY_DEVICE_GRANTS: readonly ["audio", "controller", "network", "persistence", "fullscreen"];
2623
+ type CapabilityDeviceGrant = (typeof CAPABILITY_DEVICE_GRANTS)[number];
2624
+ type CapabilityRuntime = {
2625
+ minContractVersion: number;
2626
+ features: string[];
2627
+ };
2628
+ type CapabilityAssetDeclarationSummary = {
2629
+ id: string;
2630
+ kind: CapabilityAssetKind;
2631
+ };
2632
+ type CapabilityAssetSummary = {
2633
+ kinds: CapabilityAssetKind[];
2634
+ declarations: CapabilityAssetDeclarationSummary[];
2635
+ };
2636
+ type CapabilityPermissions = {
2637
+ emit: string[];
2638
+ subscribe: string[];
2639
+ authoritative?: boolean;
2640
+ };
2641
+ /** Optional surface requirements. Omitted on existing manifests. */
2642
+ type CapabilitySurfaceRequirements = {
2643
+ alpha?: boolean;
2644
+ clearPolicy?: CapabilityClearPolicy;
2645
+ };
2646
+ /** Optional compositor/layer requirements. Omitted on existing manifests. */
2647
+ type CapabilityLayerRequirements = {
2648
+ compositor?: boolean;
2649
+ blend?: CapabilityBlendMode[];
2650
+ };
2651
+ /** Optional executable-module refs. Omitted on existing manifests. */
2652
+ type CapabilityModuleRef = {
2653
+ id: string;
2654
+ version: string;
2655
+ };
2656
+ type CapabilityModuleRequirements = {
2657
+ refs?: CapabilityModuleRef[];
2658
+ };
2659
+ type CapabilityManifest = {
2660
+ version: typeof CAPABILITY_MANIFEST_VERSION;
2661
+ id: string;
2662
+ runtime: CapabilityRuntime;
2663
+ phases: CapabilityPhase[];
2664
+ managers: CapabilityManager[];
2665
+ assets: CapabilityAssetSummary;
2666
+ acceptedEvents: string[];
2667
+ emittedEvents: string[];
2668
+ permissions: CapabilityPermissions;
2669
+ integrations: CapabilityIntegration[];
2670
+ surface?: CapabilitySurfaceRequirements;
2671
+ layers?: CapabilityLayerRequirements;
2672
+ modules?: CapabilityModuleRequirements;
2673
+ /** Omitted means `'render'`. `'calculation'` carts have no surface. */
2674
+ kind?: CapabilityCartKind;
2675
+ /** Optional device grants (CYB-74). Omitted on existing manifests. */
2676
+ grants?: CapabilityDeviceGrant[];
2677
+ };
2678
+ type HostCapabilities = {
2679
+ contractVersion: number;
2680
+ features: string[];
2681
+ integrations: CapabilityIntegration[];
2682
+ managers?: CapabilityManager[];
2683
+ emit?: string[];
2684
+ subscribe?: string[];
2685
+ surface?: CapabilitySurfaceRequirements & {
2686
+ clearPolicy?: CapabilityClearPolicy | CapabilityClearPolicy[];
2687
+ };
2688
+ layers?: CapabilityLayerRequirements;
2689
+ modules?: CapabilityModuleRequirements;
2690
+ /** Cart kinds this host can run. Omitted: kind is not checked. */
2691
+ kinds?: CapabilityCartKind[];
2692
+ /**
2693
+ * Device grants this host is willing to give. Omitted is treated as an
2694
+ * empty set (deny-by-default) when the cart listed `grants`.
2695
+ */
2696
+ grants?: CapabilityDeviceGrant[];
2697
+ };
2698
+
2699
+ type ExecutableModuleRef = {
2700
+ id: string;
2701
+ version: string;
2702
+ };
2703
+ type ExecutableModuleCapabilities = {
2704
+ readonly [key: string]: unknown;
2705
+ };
2706
+ type ExecutableModuleInvokeContext = {
2707
+ signal: AbortSignal;
2708
+ turn: number;
2709
+ };
2710
+ type ExecutableModuleInstance = {
2711
+ invoke(input: unknown, context: ExecutableModuleInvokeContext): unknown | Promise<unknown>;
2712
+ destroy?: () => void;
2713
+ };
2714
+ type ExecutableModuleFactory = (capabilities: ExecutableModuleCapabilities) => ExecutableModuleInstance;
2715
+ type ExecutableModuleRegistration = {
2716
+ id: string;
2717
+ version: string;
2718
+ create: ExecutableModuleFactory;
2719
+ capabilities?: ExecutableModuleCapabilities;
2720
+ };
2721
+
2722
+ /**
2723
+ * Copyright (c) 2026 Aaron Boyarsky
2724
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2725
+ * See packages/engine/LICENSE
2726
+ *
2727
+ * Signed, versioned remote-cart manifests. HMAC signatures, declared-asset
2728
+ * loads, and deny-by-default host grants. Trusted factories only — no eval.
2729
+ */
2730
+
2731
+ declare const REMOTE_CART_MANIFEST_VERSION: 1;
2732
+ declare const REMOTE_CART_SIGNATURE_ALG: "hmac-sha256";
2733
+ declare const HOST_GRANT_SNAPSHOT_SCHEMA_VERSION: 1;
2734
+ type RemoteCartGrant = CapabilityDeviceGrant;
2735
+ declare const REMOTE_CART_ERROR_CODES: readonly ["invalid-json", "invalid-manifest", "invalid-version", "invalid-signature", "unknown-publisher", "unknown-key", "undeclared-asset", "hash-mismatch", "unsigned-bytes", "capability-denied", "destroyed", "load-failed"];
2736
+ type RemoteCartErrorCode = (typeof REMOTE_CART_ERROR_CODES)[number];
2737
+ type RemoteCartDiagnostic = {
2738
+ code: RemoteCartErrorCode | string;
2739
+ detail: string;
2740
+ path?: string;
2741
+ };
2742
+ type RemoteCartAsset = {
2743
+ id: string;
2744
+ kind: AssetKind;
2745
+ url: string;
2746
+ hash: string;
2747
+ alg: 'sha256';
2748
+ };
2749
+ type RemoteCartManifestBody = {
2750
+ version: typeof REMOTE_CART_MANIFEST_VERSION;
2751
+ id: string;
2752
+ cartVersion: string;
2753
+ publisher: string;
2754
+ assets: RemoteCartAsset[];
2755
+ requestedGrants: RemoteCartGrant[];
2756
+ module?: ExecutableModuleRef;
2757
+ capabilities?: CapabilityManifest;
2758
+ };
2759
+ type RemoteCartSignature = {
2760
+ alg: typeof REMOTE_CART_SIGNATURE_ALG;
2761
+ keyId: string;
2762
+ mac: string;
2763
+ };
2764
+ type SignedRemoteCartManifest = {
2765
+ body: RemoteCartManifestBody;
2766
+ signature: RemoteCartSignature;
2767
+ };
2768
+ type HostGrantSnapshot = {
2769
+ schemaVersion: typeof HOST_GRANT_SNAPSHOT_SCHEMA_VERSION;
2770
+ grants: RemoteCartGrant[];
2771
+ };
2772
+ type HostGrantRestoreResult = {
2773
+ ok: true;
2774
+ grants: RemoteCartGrant[];
2775
+ } | {
2776
+ ok: false;
2777
+ errors: RemoteCartDiagnostic[];
2778
+ };
2779
+ type HostGrantSet = {
2780
+ grant(capability: RemoteCartGrant): HostGrantRestoreResult;
2781
+ revoke(capability: RemoteCartGrant): HostGrantRestoreResult;
2782
+ has(capability: RemoteCartGrant): boolean;
2783
+ list(): RemoteCartGrant[];
2784
+ inspect(): HostGrantSnapshot;
2785
+ restore(input: unknown): HostGrantRestoreResult;
2786
+ };
2787
+ type RemoteCartNetworkApi = {
2788
+ fetch(url: string): Promise<Uint8Array>;
2789
+ };
2790
+ type RemoteCartStorageApi = {
2791
+ getItem(key: string): string | null;
2792
+ setItem(key: string, value: string): void;
2793
+ removeItem(key: string): void;
2794
+ clear(): void;
2795
+ };
2796
+ type RemoteCartDeviceApi = {
2797
+ request(): {
2798
+ ok: true;
2799
+ };
2800
+ };
2801
+ type RemoteCartCapabilityBag = ExecutableModuleCapabilities & {
2802
+ grants: readonly RemoteCartGrant[];
2803
+ network: RemoteCartNetworkApi;
2804
+ storage: RemoteCartStorageApi;
2805
+ audio: RemoteCartDeviceApi;
2806
+ controller: RemoteCartDeviceApi;
2807
+ fullscreen: RemoteCartDeviceApi;
2808
+ };
2809
+ type RemoteCartInspect = {
2810
+ id: string;
2811
+ cartVersion: string;
2812
+ publisher: string;
2813
+ signature: {
2814
+ id: string;
2815
+ alg: string;
2816
+ };
2817
+ requestedGrants: RemoteCartGrant[];
2818
+ grants: RemoteCartGrant[];
2819
+ assets: Array<{
2820
+ id: string;
2821
+ url: string;
2822
+ hash: string;
2823
+ }>;
2824
+ loaded: boolean;
2825
+ destroyed: boolean;
2826
+ diagnostics: RemoteCartDiagnostic[];
2827
+ };
2828
+ type RemoteCartSandbox = {
2829
+ listRequestedGrants(): RemoteCartGrant[];
2830
+ grants: HostGrantSet;
2831
+ loadAssets(): Promise<{
2832
+ ok: true;
2833
+ snapshot: AssetPreloadSnapshot;
2834
+ } | {
2835
+ ok: false;
2836
+ errors: RemoteCartDiagnostic[];
2837
+ }>;
2838
+ capabilities(): RemoteCartCapabilityBag | {
2839
+ ok: false;
2840
+ errors: RemoteCartDiagnostic[];
2841
+ };
2842
+ inspect(): RemoteCartInspect;
2843
+ snapshotProvenance(): SnapshotProvenance;
2844
+ destroy(): void;
2845
+ };
2846
+ type CreateRemoteCartSandboxOptions = {
2847
+ manifest: SignedRemoteCartManifest;
2848
+ /** Host HMAC secrets keyed by `signature.keyId`. Sandbox re-verifies before load. */
2849
+ keys: Readonly<Record<string, string>>;
2850
+ grants?: Iterable<RemoteCartGrant>;
2851
+ bytesByUrl: Readonly<Record<string, Uint8Array>>;
2852
+ modules?: readonly ExecutableModuleRegistration[];
2853
+ };
2854
+ declare function createHostGrantSet(initial?: Iterable<RemoteCartGrant>): HostGrantSet;
2855
+ declare function createRemoteCartSandbox(options: CreateRemoteCartSandboxOptions): RemoteCartSandbox;
2856
+
2857
+ /**
2858
+ * Copyright (c) 2026 Aaron Boyarsky
2859
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2860
+ * See packages/engine/LICENSE
2861
+ *
2862
+ * Universal portal/experience lifecycle: enter another cart exclusively,
2863
+ * suspend the parent, transfer host grants, return a versioned outcome.
2864
+ * Cabinet, painting, and other host metaphors are the same primitive.
2865
+ */
2866
+
2867
+ declare const PORTAL_LIFECYCLE_SNAPSHOT_SCHEMA_VERSION: 1;
2868
+ declare const PORTAL_OUTCOME_SCHEMA_VERSION: 1;
2869
+ declare const PORTAL_METAPHORS: readonly ["cabinet", "painting", "dream", "wormhole", "book", "nested-world"];
2870
+ type PortalMetaphor = (typeof PORTAL_METAPHORS)[number];
2871
+ declare const PORTAL_OUTCOME_KINDS: readonly ["completed", "aborted"];
2872
+ type PortalOutcomeKind = (typeof PORTAL_OUTCOME_KINDS)[number];
2873
+ /** Exclusive device grants transferred for the child's lifetime. */
2874
+ declare const PORTAL_EXCLUSIVE_GRANTS: readonly ["audio", "controller", "fullscreen"];
2875
+ type PortalExclusiveGrant = (typeof PORTAL_EXCLUSIVE_GRANTS)[number];
2876
+ declare const PORTAL_ENTERED_EVENT = "portal.lifecycle.entered";
2877
+ declare const PORTAL_EXITED_EVENT = "portal.lifecycle.exited";
2878
+ declare const PORTAL_ABORTED_EVENT = "portal.lifecycle.aborted";
2879
+ declare const PORTAL_LIFECYCLE_EVENTS: readonly ["portal.lifecycle.entered", "portal.lifecycle.exited", "portal.lifecycle.aborted"];
2880
+ type PortalLifecycleEventType = (typeof PORTAL_LIFECYCLE_EVENTS)[number];
2881
+ type PortalDiagnostic = {
2882
+ code: string;
2883
+ detail: string;
2884
+ path?: string;
2885
+ };
2886
+ type PortalOutcome = {
2887
+ schemaVersion: typeof PORTAL_OUTCOME_SCHEMA_VERSION;
2888
+ kind: PortalOutcomeKind;
2889
+ payload?: unknown;
2890
+ };
2891
+ type PortalCartDeclaration = {
2892
+ id: string;
2893
+ /** Cart ids this cart may enter. */
2894
+ targets: readonly string[];
2895
+ acceptedOutcomeSchemaVersion?: number;
2896
+ emittedOutcomeSchemaVersion?: number;
2897
+ };
2898
+ type PortalEnterRequest = {
2899
+ from: string;
2900
+ to: string;
2901
+ metaphor?: PortalMetaphor;
2902
+ seed?: string;
2903
+ clock?: number;
2904
+ /** Extra grants to give the child (exclusive ones are transferred from parent). */
2905
+ grants?: readonly CapabilityDeviceGrant[];
2906
+ state?: unknown;
2907
+ persistence?: unknown;
2908
+ };
2909
+ type PortalFrameInspect = {
2910
+ id: string;
2911
+ parentId: string;
2912
+ childId: string;
2913
+ metaphor: PortalMetaphor;
2914
+ seed: string | null;
2915
+ clock: number | null;
2916
+ parentState: unknown;
2917
+ parentGrants: CapabilityDeviceGrant[];
2918
+ /** Live child grants after transfer + extras. */
2919
+ childGrants: CapabilityDeviceGrant[];
2920
+ /** Child grants before enter, used to restore and revert extras. */
2921
+ childGrantsBefore: CapabilityDeviceGrant[];
2922
+ extraChildGrants: CapabilityDeviceGrant[];
2923
+ persistence: unknown;
2924
+ transferred: PortalExclusiveGrant[];
2925
+ enterCue: typeof PORTAL_ENTERED_EVENT;
2926
+ exitCue: typeof PORTAL_EXITED_EVENT | typeof PORTAL_ABORTED_EVENT | null;
2927
+ };
2928
+ type PortalLifecycleSnapshot = {
2929
+ schemaVersion: typeof PORTAL_LIFECYCLE_SNAPSHOT_SCHEMA_VERSION;
2930
+ activeId: string | null;
2931
+ stack: PortalFrameInspect[];
2932
+ lastOutcome: PortalOutcome | null;
2933
+ cues: PortalLifecycleEventType[];
2934
+ };
2935
+ type PortalInspect = {
2936
+ destroyed: boolean;
2937
+ activeId: string | null;
2938
+ stack: PortalFrameInspect[];
2939
+ lastOutcome: PortalOutcome | null;
2940
+ cues: PortalLifecycleEventType[];
2941
+ grants: Record<string, CapabilityDeviceGrant[]>;
2942
+ };
2943
+ type PortalMutationResult = {
2944
+ ok: true;
2945
+ inspect: PortalInspect;
2946
+ outcome?: PortalOutcome;
2947
+ } | {
2948
+ ok: false;
2949
+ errors: PortalDiagnostic[];
2950
+ };
2951
+ type RestorePortalResult = {
2952
+ ok: true;
2953
+ snapshot: PortalLifecycleSnapshot;
2954
+ } | {
2955
+ ok: false;
2956
+ errors: PortalDiagnostic[];
2957
+ };
2958
+ type CreatePortalLifecycleOptions = {
2959
+ group?: RuntimeGroup;
2960
+ /** Per-participant grant sets. Missing ids get an empty HostGrantSet. */
2961
+ grants?: Readonly<Record<string, HostGrantSet>>;
2962
+ audioBroker?: AudioBroker;
2963
+ declarations?: readonly PortalCartDeclaration[];
2964
+ rootId?: string;
2965
+ maxDepth?: number;
2966
+ createId?: () => string;
2967
+ };
2968
+ type PortalLifecycle = {
2969
+ enter(request: PortalEnterRequest): PortalMutationResult;
2970
+ exit(payload?: unknown): PortalMutationResult;
2971
+ abort(payload?: unknown): PortalMutationResult;
2972
+ stack(): PortalFrameInspect[];
2973
+ activeId(): string | null;
2974
+ inspect(): PortalInspect;
2975
+ snapshot(): PortalLifecycleSnapshot;
2976
+ restore(input: unknown): RestorePortalResult;
2977
+ grantsOf(participantId: string): HostGrantSet;
2978
+ destroy(): void;
2979
+ };
2980
+ /**
2981
+ * Same `enter` / `exit` / `abort` as the session. Metaphor is fixed so cabinet
2982
+ * and painting hosts share lifecycle code.
2983
+ */
2984
+ declare function cabinetPortal(portal: PortalLifecycle): {
2985
+ enter: (request: Omit<PortalEnterRequest, 'metaphor'>) => PortalMutationResult;
2986
+ exit: (payload?: unknown) => PortalMutationResult;
2987
+ abort: (payload?: unknown) => PortalMutationResult;
2988
+ };
2989
+ declare function paintingPortal(portal: PortalLifecycle): {
2990
+ enter: (request: Omit<PortalEnterRequest, 'metaphor'>) => PortalMutationResult;
2991
+ exit: (payload?: unknown) => PortalMutationResult;
2992
+ abort: (payload?: unknown) => PortalMutationResult;
2993
+ };
2994
+ declare function createPortalLifecycle(options?: CreatePortalLifecycleOptions): PortalLifecycle;
2995
+
2996
+ /**
2997
+ * Copyright (c) 2026 Aaron Boyarsky
2998
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
2999
+ * See packages/engine/LICENSE
3000
+ *
3001
+ * Durable asynchronous job orchestration: lifecycle, persistence, worker
3002
+ * boundary, evaluator feedback, and host-owned apply. Wall-clock completion
3003
+ * never mutates authoritative host state.
3004
+ */
3005
+
3006
+ declare const JOB_ORCHESTRATION_SNAPSHOT_SCHEMA_VERSION: 1;
3007
+ declare const JOB_RESULT_REF_SCHEMA_VERSION: 1;
3008
+ declare const JOB_STATES: readonly ["queued", "claimed", "awaiting-evaluation", "retry-scheduled", "ready", "applied", "failed", "canceled", "superseded"];
3009
+ type JobState = (typeof JOB_STATES)[number];
3010
+ declare const JOB_RETRYABILITY: readonly ["retryable", "permanent", "unknown"];
3011
+ type JobRetryability = (typeof JOB_RETRYABILITY)[number];
3012
+ declare const JOB_EVALUATOR_DECISIONS: readonly ["accept", "reject", "revise"];
3013
+ type JobEvaluatorDecision = (typeof JOB_EVALUATOR_DECISIONS)[number];
3014
+ declare const JOB_LIFECYCLE_EVENTS: readonly ["job.intent.submitted", "job.state.queued", "job.state.claimed", "job.state.progress", "job.state.awaiting-evaluation", "job.state.retry-scheduled", "job.state.ready", "job.state.applied", "job.state.failed", "job.state.canceled", "job.state.superseded", "job.diagnostic.lifecycle"];
3015
+ type JobLifecycleEventType = (typeof JOB_LIFECYCLE_EVENTS)[number];
3016
+ type JobDiagnostic = {
3017
+ code: string;
3018
+ detail: string;
3019
+ path?: string;
3020
+ };
3021
+ type JobResultRef = {
3022
+ schemaVersion: typeof JOB_RESULT_REF_SCHEMA_VERSION;
3023
+ kind: string;
3024
+ uri: string;
3025
+ contentType?: string;
3026
+ bytes?: number;
3027
+ };
3028
+ type JobRetryPolicy = {
3029
+ maxAttempts: number;
3030
+ backoffMs: readonly number[];
3031
+ retryableCodes: readonly string[];
3032
+ };
3033
+ type JobFallback = {
3034
+ reasonCode: string;
3035
+ resultRef?: JobResultRef;
3036
+ };
3037
+ type JobDefinition = {
3038
+ id: string;
3039
+ version: number;
3040
+ requestSchema: PayloadSchema;
3041
+ resultKind: string;
3042
+ retry: JobRetryPolicy;
3043
+ timeoutMs: number;
3044
+ leaseMs: number;
3045
+ fallback: JobFallback;
3046
+ };
3047
+ type JobProgress = {
3048
+ value: number;
3049
+ stage: string;
3050
+ message?: string;
3051
+ };
3052
+ type JobFailureRecord = {
3053
+ attempt: number;
3054
+ code: string;
3055
+ retryability: JobRetryability;
3056
+ at: number;
3057
+ detail?: string;
3058
+ };
3059
+ type JobEvaluatorRecord = {
3060
+ decision: JobEvaluatorDecision;
3061
+ at: number;
3062
+ correction?: string;
3063
+ };
3064
+ type JobRecord = {
3065
+ jobId: string;
3066
+ definitionId: string;
3067
+ definitionVersion: number;
3068
+ idempotencyKey: string;
3069
+ state: JobState;
3070
+ request: unknown;
3071
+ resultRef: JobResultRef | null;
3072
+ progress: JobProgress;
3073
+ attempt: number;
3074
+ failureHistory: JobFailureRecord[];
3075
+ evaluatorHistory: JobEvaluatorRecord[];
3076
+ correlationId: string;
3077
+ causationId?: string;
3078
+ workerId: string | null;
3079
+ leaseUntil: number | null;
3080
+ createdAt: number;
3081
+ updatedAt: number;
3082
+ timeoutAt: number;
3083
+ nextRetryAt: number | null;
3084
+ supersededBy: string | null;
3085
+ fallbackApplied: boolean;
3086
+ fallback?: JobFallback;
3087
+ };
3088
+ type JobCoordinatorSnapshot = {
3089
+ schemaVersion: typeof JOB_ORCHESTRATION_SNAPSHOT_SCHEMA_VERSION;
3090
+ jobs: JobRecord[];
3091
+ hostAcceptedJobIds: string[];
3092
+ };
3093
+ type JobInspect = {
3094
+ destroyed: boolean;
3095
+ jobs: JobRecord[];
3096
+ events: JobLifecycleEventType[];
3097
+ };
3098
+ type JobMutationResult = {
3099
+ ok: true;
3100
+ job: JobRecord;
3101
+ } | {
3102
+ ok: false;
3103
+ errors: JobDiagnostic[];
3104
+ };
3105
+ type RestoreJobResult = {
3106
+ ok: true;
3107
+ snapshot: JobCoordinatorSnapshot;
3108
+ } | {
3109
+ ok: false;
3110
+ errors: JobDiagnostic[];
3111
+ };
3112
+ type JobSubmitRequest = {
3113
+ definitionId: string;
3114
+ idempotencyKey: string;
3115
+ request: unknown;
3116
+ correlationId: string;
3117
+ causationId?: string;
3118
+ supersedeJobId?: string;
3119
+ };
3120
+ type JobPersistenceAdapter = {
3121
+ save(job: JobRecord): void;
3122
+ get(jobId: string): JobRecord | undefined;
3123
+ getByIdempotencyKey(key: string): JobRecord | undefined;
3124
+ list(): JobRecord[];
3125
+ replaceAll(jobs: JobRecord[]): void;
3126
+ };
3127
+ type JobWorkRequest = {
3128
+ jobId: string;
3129
+ workerId: string;
3130
+ definitionId: string;
3131
+ request: unknown;
3132
+ attempt: number;
3133
+ };
3134
+ type JobWorkerCallbacks = {
3135
+ reportProgress(jobId: string, progress: JobProgress): JobMutationResult;
3136
+ complete(jobId: string, resultRef: JobResultRef): JobMutationResult;
3137
+ fail(jobId: string, failure: {
3138
+ code: string;
3139
+ retryability: JobRetryability;
3140
+ detail?: string;
3141
+ }): JobMutationResult;
3142
+ heartbeat(jobId: string): JobMutationResult;
3143
+ };
3144
+ type JobWorkerAdapter = {
3145
+ bind(callbacks: JobWorkerCallbacks): void;
3146
+ start(work: JobWorkRequest): void;
3147
+ cancel?(jobId: string): void;
3148
+ };
3149
+ type HeadlessJobWorker = JobWorkerAdapter & {
3150
+ complete(jobId: string, resultRef: JobResultRef): JobMutationResult;
3151
+ fail(jobId: string, failure: {
3152
+ code: string;
3153
+ retryability: JobRetryability;
3154
+ detail?: string;
3155
+ }): JobMutationResult;
3156
+ started(): string[];
3157
+ };
3158
+ type CreateJobCoordinatorOptions = {
3159
+ definitions: readonly JobDefinition[];
3160
+ persistence?: JobPersistenceAdapter;
3161
+ worker?: JobWorkerAdapter;
3162
+ router?: Pick<EventRouter, 'publish'>;
3163
+ now?: () => number;
3164
+ createId?: () => string;
3165
+ maxCorrectionChars?: number;
3166
+ maxFailureHistory?: number;
3167
+ };
3168
+ type JobCoordinator = {
3169
+ submit(request: JobSubmitRequest): JobMutationResult;
3170
+ claim(workerId: string): JobMutationResult;
3171
+ reportProgress(jobId: string, progress: JobProgress): JobMutationResult;
3172
+ heartbeat(jobId: string): JobMutationResult;
3173
+ complete(jobId: string, resultRef: JobResultRef): JobMutationResult;
3174
+ fail(jobId: string, failure: {
3175
+ code: string;
3176
+ retryability: JobRetryability;
3177
+ detail?: string;
3178
+ }): JobMutationResult;
3179
+ evaluate(jobId: string, decision: JobEvaluatorDecision, correction?: string): JobMutationResult;
3180
+ cancel(jobId: string): JobMutationResult;
3181
+ recoverStale(): JobRecord[];
3182
+ tick(): JobRecord[];
3183
+ /** Host policy gate. Ready jobs become applied; never called from worker complete. */
3184
+ accept(jobId: string): JobMutationResult;
3185
+ get(jobId: string): JobRecord | undefined;
3186
+ getByIdempotencyKey(key: string): JobRecord | undefined;
3187
+ inspect(): JobInspect;
3188
+ snapshot(): JobCoordinatorSnapshot;
3189
+ restore(input: unknown): RestoreJobResult;
3190
+ exportTrace(): {
3191
+ jobs: unknown[];
3192
+ events: JobLifecycleEventType[];
3193
+ };
3194
+ destroy(): void;
3195
+ };
3196
+ declare function jobEventContracts(): EventContract[];
3197
+ declare function createMemoryJobPersistence(): JobPersistenceAdapter;
3198
+ declare function createHeadlessJobWorker(): HeadlessJobWorker;
3199
+ declare function createJobCoordinator(options: CreateJobCoordinatorOptions): JobCoordinator;
3200
+
3201
+ /**
3202
+ * Copyright (c) 2026 Aaron Boyarsky
3203
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3204
+ * See packages/engine/LICENSE
3205
+ *
3206
+ * Step-by-step snapshot migrations. The original object is never mutated.
3207
+ * Hosts own persistence; this registry only transforms envelopes in memory.
3208
+ */
3209
+
3210
+ type SnapshotMigration = {
3211
+ from: number;
3212
+ to: number;
3213
+ migrate: (snapshot: unknown) => unknown;
3214
+ };
3215
+
3216
+ /**
3217
+ * Copyright (c) 2026 Aaron Boyarsky
3218
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3219
+ * See packages/engine/LICENSE
3220
+ *
3221
+ * Optional spatial world graph: nodes, edges, discovery projections, entity
3222
+ * transit, and host-owned path policy. Semantic time and story rules stay
3223
+ * with the host. No economy, combat, quest, or narrative.
3224
+ */
3225
+
3226
+ declare const WORLD_GRAPH_SNAPSHOT_SCHEMA_VERSION: 1;
3227
+ declare const WORLD_NODE_KINDS: readonly ["room", "region", "landmark", "frontier"];
3228
+ type WorldNodeKind = (typeof WORLD_NODE_KINDS)[number];
3229
+ declare const WORLD_MAP_LAYERS: readonly ["local", "regional"];
3230
+ type WorldMapLayer = (typeof WORLD_MAP_LAYERS)[number];
3231
+ declare const WORLD_EDGE_VISIBILITIES: readonly ["canonical", "discoverable", "hidden"];
3232
+ type WorldEdgeVisibility = (typeof WORLD_EDGE_VISIBILITIES)[number];
3233
+ declare const WORLD_EDGE_ACCESS: readonly ["open", "locked", "disabled"];
3234
+ type WorldEdgeAccess = (typeof WORLD_EDGE_ACCESS)[number];
3235
+ declare const WORLD_ENTITY_KINDS: readonly ["character", "party"];
3236
+ type WorldEntityKind = (typeof WORLD_ENTITY_KINDS)[number];
3237
+ declare const WORLD_ENTITY_STATUSES: readonly ["available", "busy", "traveling"];
3238
+ type WorldEntityStatus = (typeof WORLD_ENTITY_STATUSES)[number];
3239
+ declare const WORLD_GRAPH_EVENTS: readonly ["world.graph.state.node-added", "world.graph.state.edge-added", "world.graph.state.discovered", "world.graph.state.transit", "world.graph.diagnostic.lifecycle"];
3240
+ type WorldGraphEventType = (typeof WORLD_GRAPH_EVENTS)[number];
3241
+ type WorldGraphDiagnostic = {
3242
+ code: string;
3243
+ detail: string;
3244
+ path?: string;
3245
+ };
3246
+ type WorldNode = {
3247
+ id: string;
3248
+ version: number;
3249
+ kind: WorldNodeKind;
3250
+ mapLayer: WorldMapLayer;
3251
+ frontier?: boolean;
3252
+ metadata?: Record<string, unknown>;
3253
+ };
3254
+ type WorldEdge = {
3255
+ id: string;
3256
+ version: number;
3257
+ from: string;
3258
+ to: string;
3259
+ directed: boolean;
3260
+ kind: string;
3261
+ visibility: WorldEdgeVisibility;
3262
+ access: WorldEdgeAccess;
3263
+ requirements?: Record<string, unknown>;
3264
+ cost?: Record<string, number>;
3265
+ metadata?: Record<string, unknown>;
3266
+ };
3267
+ type WorldTransit = {
3268
+ originNodeId: string;
3269
+ destinationNodeId: string;
3270
+ routeEdgeIds: readonly string[];
3271
+ departedAt: number;
3272
+ expectedArrival: number;
3273
+ };
3274
+ type WorldEntity = {
3275
+ id: string;
3276
+ kind: WorldEntityKind;
3277
+ status: WorldEntityStatus;
3278
+ locationNodeId: string | null;
3279
+ transit: WorldTransit | null;
3280
+ metadata?: Record<string, unknown>;
3281
+ };
3282
+ type WorldObserverDiscovery = {
3283
+ observerId: string;
3284
+ nodeIds: readonly string[];
3285
+ edgeIds: readonly string[];
3286
+ };
3287
+ type WorldGraphSnapshot = {
3288
+ schemaVersion: typeof WORLD_GRAPH_SNAPSHOT_SCHEMA_VERSION;
3289
+ graphId: string;
3290
+ nodes: WorldNode[];
3291
+ edges: WorldEdge[];
3292
+ entities: WorldEntity[];
3293
+ discovery: WorldObserverDiscovery[];
3294
+ };
3295
+ type WorldGraphProjection = {
3296
+ kind: 'canonical' | 'known' | 'local' | 'regional';
3297
+ observerId?: string;
3298
+ focusNodeId?: string;
3299
+ nodes: WorldNode[];
3300
+ edges: WorldEdge[];
3301
+ frontiers: WorldNode[];
3302
+ entities: WorldEntity[];
3303
+ };
3304
+ type WorldPathStep = {
3305
+ edgeId: string;
3306
+ from: string;
3307
+ to: string;
3308
+ cost: number;
3309
+ };
3310
+ type WorldPath = {
3311
+ from: string;
3312
+ to: string;
3313
+ nodeIds: string[];
3314
+ steps: WorldPathStep[];
3315
+ totalCost: number;
3316
+ };
3317
+ type WorldTraversalContext = {
3318
+ semanticTime: number;
3319
+ observerId?: string;
3320
+ hostState?: unknown;
3321
+ };
3322
+ type WorldTraversalPolicy = {
3323
+ canTraverse(edge: WorldEdge, from: string, to: string, ctx: WorldTraversalContext): boolean;
3324
+ cost(edge: WorldEdge, from: string, to: string, ctx: WorldTraversalContext): number;
3325
+ };
3326
+ type WorldQueryBounds = {
3327
+ maxVisits?: number;
3328
+ };
3329
+ type WorldGraphInspect = {
3330
+ destroyed: boolean;
3331
+ graphId: string;
3332
+ nodeCount: number;
3333
+ edgeCount: number;
3334
+ entityCount: number;
3335
+ observerCount: number;
3336
+ events: WorldGraphEventType[];
3337
+ };
3338
+ type WorldMutationResult = {
3339
+ ok: true;
3340
+ } | {
3341
+ ok: false;
3342
+ errors: WorldGraphDiagnostic[];
3343
+ };
3344
+ type RestoreWorldGraphResult = {
3345
+ ok: true;
3346
+ snapshot: WorldGraphSnapshot;
3347
+ } | {
3348
+ ok: false;
3349
+ errors: WorldGraphDiagnostic[];
3350
+ };
3351
+ type WorldPathResult = {
3352
+ ok: true;
3353
+ path: WorldPath;
3354
+ } | {
3355
+ ok: false;
3356
+ errors: WorldGraphDiagnostic[];
3357
+ };
3358
+ type WorldReachabilityResult = {
3359
+ nodeIds: string[];
3360
+ };
3361
+ type WorldGraphPatch = {
3362
+ nodes?: readonly WorldNode[];
3363
+ edges?: readonly WorldEdge[];
3364
+ };
3365
+ type CreateWorldGraphOptions = {
3366
+ graphId?: string;
3367
+ migrations?: readonly SnapshotMigration[];
3368
+ router?: Pick<EventRouter, 'publish'>;
3369
+ source?: string;
3370
+ maxPathVisits?: number;
3371
+ };
3372
+ type WorldGraph = {
3373
+ addNode(node: WorldNode): WorldMutationResult;
3374
+ addEdge(edge: WorldEdge): WorldMutationResult;
3375
+ applyPatch(patch: WorldGraphPatch): WorldMutationResult;
3376
+ removeNode(nodeId: string): WorldMutationResult;
3377
+ removeEdge(edgeId: string): WorldMutationResult;
3378
+ setEdgeAccess(edgeId: string, access: WorldEdgeAccess): WorldMutationResult;
3379
+ discover(observerId: string, known: {
3380
+ nodeIds?: readonly string[];
3381
+ edgeIds?: readonly string[];
3382
+ }): WorldMutationResult;
3383
+ upsertEntity(entity: WorldEntity): WorldMutationResult;
3384
+ startTransit(entityId: string, transit: WorldTransit, status?: Exclude<WorldEntityStatus, 'available'>): WorldMutationResult;
3385
+ completeTransit(entityId: string, semanticTime: number): WorldMutationResult;
3386
+ setEntityStatus(entityId: string, status: WorldEntityStatus): WorldMutationResult;
3387
+ getNode(nodeId: string): WorldNode | undefined;
3388
+ getEdge(edgeId: string): WorldEdge | undefined;
3389
+ getEntity(entityId: string): WorldEntity | undefined;
3390
+ projectCanonical(): WorldGraphProjection;
3391
+ projectKnown(observerId: string): WorldGraphProjection;
3392
+ projectLocal(observerId: string, focusNodeId: string, hops?: number): WorldGraphProjection;
3393
+ projectRegional(observerId: string): WorldGraphProjection;
3394
+ findPath(from: string, to: string, policy: WorldTraversalPolicy, ctx: WorldTraversalContext, bounds?: WorldQueryBounds): WorldPathResult;
3395
+ reachable(from: string, policy: WorldTraversalPolicy, ctx: WorldTraversalContext, bounds?: WorldQueryBounds): WorldReachabilityResult;
3396
+ inspect(): WorldGraphInspect;
3397
+ snapshot(): WorldGraphSnapshot;
3398
+ restore(input: unknown): RestoreWorldGraphResult;
3399
+ events(): readonly EventInput[];
3400
+ destroy(): void;
3401
+ };
3402
+ declare function worldGraphEventContracts(): EventContract[];
3403
+ declare function createWorldGraph(options?: CreateWorldGraphOptions): WorldGraph;
3404
+
3405
+ /**
3406
+ * Copyright (c) 2026 Aaron Boyarsky
3407
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3408
+ * See packages/engine/LICENSE
3409
+ *
3410
+ * Transactional world-patch validation and atomic application. A generated
3411
+ * result becomes one world revision or none — never a half-installed world.
3412
+ * Cyberart is not the host's database of record.
3413
+ */
3414
+
3415
+ declare const WORLD_PATCH_SCHEMA_VERSION: 1;
3416
+ declare const WORLD_PATCH_SNAPSHOT_SCHEMA_VERSION: 1;
3417
+ declare const WORLD_PATCH_OPS: readonly ["add", "replace", "revise", "remove", "tombstone", "link", "unlink"];
3418
+ type WorldPatchOp = (typeof WORLD_PATCH_OPS)[number];
3419
+ declare const WORLD_PATCH_ACCEPTED_EVENT: "world.patch.state.accepted";
3420
+ declare const WORLD_PATCH_EVENTS: readonly ["world.patch.state.accepted", "world.patch.state.rejected", "world.patch.state.superseded", "world.patch.diagnostic.lifecycle"];
3421
+ type WorldPatchEventType = (typeof WORLD_PATCH_EVENTS)[number];
3422
+ declare const WORLD_PATCH_ERROR_CODES: readonly ["invalid-schema", "unknown-field", "unknown-op", "missing-field", "missing-ref", "referential-integrity", "stale-base", "precondition-failed", "asset-unavailable", "content-unavailable", "binding-unavailable", "cycle", "over-limit", "idempotency-conflict", "superseded", "invalid-snapshot", "invalid-version", "destroyed", "domain", "capability-denied", "schema-mismatch", "identity-required", "identity-absent", "entity-revision", "entity-hash", "duplicate-id", "graph-apply-failed", "publish-failed"];
3423
+ type WorldPatchErrorCode = (typeof WORLD_PATCH_ERROR_CODES)[number];
3424
+ type WorldPatchDiagnostic = {
3425
+ code: WorldPatchErrorCode | string;
3426
+ detail: string;
3427
+ path?: string;
3428
+ expectedRevision?: number;
3429
+ actualRevision?: number;
3430
+ };
3431
+ type WorldPatchProvenance = {
3432
+ producer: string;
3433
+ jobId?: string;
3434
+ contentRevisions?: string[];
3435
+ };
3436
+ type WorldPatchRefs = {
3437
+ contentId?: string;
3438
+ contentRevision?: string;
3439
+ binding?: string;
3440
+ asset?: string;
3441
+ identity?: string;
3442
+ };
3443
+ type WorldPatchOperation = {
3444
+ op: WorldPatchOp;
3445
+ kind: string;
3446
+ id: string;
3447
+ order?: number;
3448
+ value?: unknown;
3449
+ from?: string;
3450
+ to?: string;
3451
+ refs?: WorldPatchRefs;
3452
+ };
3453
+ type WorldPatchPrecondition = {
3454
+ type: 'base-revision';
3455
+ revision: number;
3456
+ } | {
3457
+ type: 'entity-revision';
3458
+ kind: string;
3459
+ id: string;
3460
+ revision: number;
3461
+ } | {
3462
+ type: 'entity-hash';
3463
+ kind: string;
3464
+ id: string;
3465
+ hash: string;
3466
+ } | {
3467
+ type: 'identity-required';
3468
+ kind: string;
3469
+ id: string;
3470
+ } | {
3471
+ type: 'identity-absent';
3472
+ kind: string;
3473
+ id: string;
3474
+ } | {
3475
+ type: 'capability';
3476
+ name: string;
3477
+ } | {
3478
+ type: 'schema';
3479
+ schemaVersion: number;
3480
+ };
3481
+ type WorldPatch = {
3482
+ patchId: string;
3483
+ schemaVersion: typeof WORLD_PATCH_SCHEMA_VERSION;
3484
+ baseRevision: number;
3485
+ idempotencyKey: string;
3486
+ preconditions?: WorldPatchPrecondition[];
3487
+ operations: WorldPatchOperation[];
3488
+ provenance: WorldPatchProvenance;
3489
+ supersedes?: string;
3490
+ };
3491
+ type WorldEntityRecord = {
3492
+ kind: string;
3493
+ id: string;
3494
+ revision: number;
3495
+ hash: string;
3496
+ value: unknown;
3497
+ tombstoned: boolean;
3498
+ refs?: WorldPatchRefs;
3499
+ };
3500
+ type WorldLinkRecord = {
3501
+ id: string;
3502
+ kind: string;
3503
+ from: string;
3504
+ to: string;
3505
+ value?: unknown;
3506
+ };
3507
+ type WorldAcceptedPatch = {
3508
+ patchId: string;
3509
+ idempotencyKey: string;
3510
+ revision: number;
3511
+ provenance: WorldPatchProvenance;
3512
+ supersededBy?: string;
3513
+ };
3514
+ type WorldRevisionState = {
3515
+ revision: number;
3516
+ entities: WorldEntityRecord[];
3517
+ links: WorldLinkRecord[];
3518
+ accepted: WorldAcceptedPatch[];
3519
+ };
3520
+ type WorldIdentityChange = {
3521
+ op: WorldPatchOp;
3522
+ kind: string;
3523
+ id: string;
3524
+ };
3525
+ type WorldPatchAuditRecord = {
3526
+ outcome: 'accepted' | 'rejected' | 'superseded';
3527
+ patchId: string;
3528
+ idempotencyKey: string;
3529
+ at: number;
3530
+ oldRevision: number;
3531
+ newRevision: number;
3532
+ reasonCodes: string[];
3533
+ changedIdentities: WorldIdentityChange[];
3534
+ provenance: WorldPatchProvenance | Record<string, unknown>;
3535
+ patch: unknown;
3536
+ };
3537
+ type WorldPatchSnapshot = {
3538
+ schemaVersion: typeof WORLD_PATCH_SNAPSHOT_SCHEMA_VERSION;
3539
+ world: WorldRevisionState;
3540
+ audit: WorldPatchAuditRecord[];
3541
+ graph?: WorldGraphSnapshot;
3542
+ };
3543
+ type WorldPatchInspect = {
3544
+ destroyed: boolean;
3545
+ revision: number;
3546
+ entities: WorldEntityRecord[];
3547
+ links: WorldLinkRecord[];
3548
+ acceptedPatchIds: string[];
3549
+ events: WorldPatchEventType[];
3550
+ lastRejection: WorldPatchDiagnostic[] | null;
3551
+ };
3552
+ type WorldPatchDryRunResult = {
3553
+ ok: true;
3554
+ previewRevision: number;
3555
+ changedIdentities: WorldIdentityChange[];
3556
+ diagnostics: WorldPatchDiagnostic[];
3557
+ } | {
3558
+ ok: false;
3559
+ errors: WorldPatchDiagnostic[];
3560
+ };
3561
+ type WorldPatchCommitResult = {
3562
+ ok: true;
3563
+ patchId: string;
3564
+ oldRevision: number;
3565
+ newRevision: number;
3566
+ changedIdentities: WorldIdentityChange[];
3567
+ idempotent?: boolean;
3568
+ inspect: WorldPatchInspect;
3569
+ } | {
3570
+ ok: false;
3571
+ errors: WorldPatchDiagnostic[];
3572
+ inspect: WorldPatchInspect;
3573
+ };
3574
+ type RestoreWorldPatchResult = {
3575
+ ok: true;
3576
+ snapshot: WorldPatchSnapshot;
3577
+ } | {
3578
+ ok: false;
3579
+ errors: WorldPatchDiagnostic[];
3580
+ };
3581
+ type WorldPersistenceTransaction = {
3582
+ applyWorldRevision(next: WorldRevisionState): void;
3583
+ commit(): void;
3584
+ rollback(): void;
3585
+ };
3586
+ type WorldPatchAcceptedPayload = {
3587
+ patchId: string;
3588
+ oldRevision: number;
3589
+ newRevision: number;
3590
+ changedIdentities: WorldIdentityChange[];
3591
+ producer: string;
3592
+ jobId?: string;
3593
+ contentRevisions?: string[];
3594
+ };
3595
+ type WorldPersistenceAdapter = {
3596
+ begin(): WorldPersistenceTransaction;
3597
+ current(): WorldRevisionState;
3598
+ publish?(payload: WorldPatchAcceptedPayload): void;
3599
+ };
3600
+ type WorldPatchLimits = {
3601
+ maxOperations?: number;
3602
+ maxDiagnostics?: number;
3603
+ maxEntities?: number;
3604
+ maxBytes?: number;
3605
+ };
3606
+ type WorldPatchContentAvailability = {
3607
+ hasRevision?(contentId: string, revision: string): boolean;
3608
+ available?: ReadonlyArray<{
3609
+ contentId?: string;
3610
+ revision: string;
3611
+ }>;
3612
+ };
3613
+ type WorldPatchBindingAvailability = {
3614
+ listedIds?: readonly string[];
3615
+ };
3616
+ type WorldPatchAssetAvailability = {
3617
+ availableIds?: readonly string[];
3618
+ };
3619
+ type WorldPatchGraphPolicy = {
3620
+ allowCycles?: boolean;
3621
+ detectCycle?(preview: WorldRevisionState): boolean;
3622
+ };
3623
+ type WorldPatchDomainValidator = (ctx: {
3624
+ patch: WorldPatch;
3625
+ current: WorldRevisionState;
3626
+ preview: WorldRevisionState;
3627
+ }) => WorldPatchDiagnostic[];
3628
+ type CreateWorldPatchApplierOptions = {
3629
+ persistence?: WorldPersistenceAdapter;
3630
+ graph?: WorldGraph;
3631
+ content?: WorldPatchContentAvailability;
3632
+ bindings?: WorldPatchBindingAvailability;
3633
+ assets?: WorldPatchAssetAvailability;
3634
+ now?: () => number;
3635
+ limits?: WorldPatchLimits;
3636
+ redact?: readonly string[];
3637
+ router?: Pick<EventRouter, 'publish'>;
3638
+ onEvent?: (event: EventInput) => void;
3639
+ domainValidators?: readonly WorldPatchDomainValidator[];
3640
+ capabilities?: readonly string[];
3641
+ graphPolicy?: WorldPatchGraphPolicy;
3642
+ source?: string;
3643
+ };
3644
+ type WorldPatchApplier = {
3645
+ dryRun(patch: unknown): WorldPatchDryRunResult;
3646
+ commit(patch: unknown): WorldPatchCommitResult;
3647
+ inspect(): WorldPatchInspect;
3648
+ snapshot(): WorldPatchSnapshot;
3649
+ restore(input: unknown): RestoreWorldPatchResult;
3650
+ audit(options?: {
3651
+ redact?: boolean;
3652
+ }): WorldPatchAuditRecord[];
3653
+ events(): readonly EventInput[];
3654
+ destroy(): void;
3655
+ };
3656
+ declare function worldPatchEventContracts(): EventContract[];
3657
+ declare function createMemoryWorldPersistence(): WorldPersistenceAdapter;
3658
+ declare function createWorldPatchApplier(options?: CreateWorldPatchApplierOptions): WorldPatchApplier;
3659
+
3660
+ /**
3661
+ * Copyright (c) 2026 Aaron Boyarsky
3662
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3663
+ * See packages/engine/LICENSE
3664
+ *
3665
+ * Atomic external content-revision activation. Adapters discover and load
3666
+ * revision catalogs; the activator stages every declared asset, then commits
3667
+ * one complete bundle (or keeps the last known good). Consumers never see a
3668
+ * mixed old/new scene.
3669
+ */
3670
+
3671
+ declare const CONTENT_REVISION_SNAPSHOT_SCHEMA_VERSION: 1;
3672
+ declare const CONTENT_REVISION_MANIFEST_VERSION: 1;
3673
+ declare const CONTENT_REVISION_ACTIVATED_EVENT: "content.revision.state.activated";
3674
+ declare const CONTENT_REVISION_EVENTS: readonly ["content.revision.state.discovered", "content.revision.state.staging", "content.revision.state.validated", "content.revision.state.rejected", "content.revision.state.activated", "content.revision.state.rolled-back", "content.revision.state.superseded", "content.revision.diagnostic.lifecycle"];
3675
+ type ContentRevisionEventType = (typeof CONTENT_REVISION_EVENTS)[number];
3676
+ declare const CONTENT_REVISION_ERROR_CODES: readonly ["invalid-manifest", "invalid-schema", "invalid-version", "invalid-snapshot", "unknown-revision", "unknown-adapter", "hash-mismatch", "capability-denied", "pinned", "staging-failed", "activation-failed", "health-check-failed", "stale-health-check", "superseded", "destroyed", "adapter-missing", "asset-failed", "unsigned"];
3677
+ type ContentRevisionErrorCode = (typeof CONTENT_REVISION_ERROR_CODES)[number];
3678
+ type ContentRevisionDiagnostic = {
3679
+ code: ContentRevisionErrorCode | string;
3680
+ detail: string;
3681
+ path?: string;
3682
+ };
3683
+ type ContentRevisionAssetDecl = {
3684
+ id: string;
3685
+ kind: AssetKind;
3686
+ url: string;
3687
+ hash: string;
3688
+ alg: 'sha256';
3689
+ optional?: boolean;
3690
+ fallback?: {
3691
+ id: string;
3692
+ kind: AssetKind;
3693
+ url: string;
3694
+ hash: string;
3695
+ alg: 'sha256';
3696
+ };
3697
+ };
3698
+ type ContentRevisionCatalog = {
3699
+ contentId: string;
3700
+ revision: string;
3701
+ manifestVersion: typeof CONTENT_REVISION_MANIFEST_VERSION;
3702
+ publisher: string;
3703
+ source: string;
3704
+ adapterId: string;
3705
+ assets: ContentRevisionAssetDecl[];
3706
+ requestedGrants?: RemoteCartGrant[];
3707
+ capabilities?: CapabilityManifest;
3708
+ signature?: {
3709
+ id: string;
3710
+ alg: string;
3711
+ };
3712
+ };
3713
+ type ContentRevisionDescriptor = {
3714
+ contentId: string;
3715
+ revision: string;
3716
+ adapterId: string;
3717
+ publisher: string;
3718
+ source: string;
3719
+ };
3720
+ type ContentRevisionResource = {
3721
+ id: string;
3722
+ kind: AssetKind;
3723
+ ref: string;
3724
+ hash: string;
3725
+ url: string;
3726
+ optional: boolean;
3727
+ usedFallback: boolean;
3728
+ };
3729
+ type ContentRevisionBundle = {
3730
+ bundleId: string;
3731
+ contentId: string;
3732
+ revision: string;
3733
+ manifestVersion: typeof CONTENT_REVISION_MANIFEST_VERSION;
3734
+ publisher: string;
3735
+ source: string;
3736
+ adapterId: string;
3737
+ signature?: {
3738
+ id: string;
3739
+ alg: string;
3740
+ };
3741
+ resources: Record<string, ContentRevisionResource>;
3742
+ };
3743
+ type ContentRevisionStagingView = {
3744
+ contentId: string;
3745
+ revision: string;
3746
+ adapterId: string;
3747
+ bundleId: string;
3748
+ };
3749
+ type ContentRevisionInspect = {
3750
+ destroyed: boolean;
3751
+ pinned: boolean;
3752
+ active: ContentRevisionBundle | null;
3753
+ lastKnownGood: ContentRevisionBundle | null;
3754
+ staging: ContentRevisionStagingView | null;
3755
+ events: ContentRevisionEventType[];
3756
+ lastRejection: ContentRevisionDiagnostic[] | null;
3757
+ };
3758
+ type ContentRevisionSnapshot = {
3759
+ schemaVersion: typeof CONTENT_REVISION_SNAPSHOT_SCHEMA_VERSION;
3760
+ pinned: boolean;
3761
+ active: ContentRevisionBundle | null;
3762
+ lastKnownGood: ContentRevisionBundle | null;
3763
+ previous: ContentRevisionBundle | null;
3764
+ };
3765
+ type ContentRevisionMutationResult = {
3766
+ ok: true;
3767
+ bundle: ContentRevisionBundle | null;
3768
+ idempotent?: boolean;
3769
+ } | {
3770
+ ok: false;
3771
+ errors: ContentRevisionDiagnostic[];
3772
+ };
3773
+ type RestoreContentRevisionResult = {
3774
+ ok: true;
3775
+ snapshot: ContentRevisionSnapshot;
3776
+ } | {
3777
+ ok: false;
3778
+ errors: ContentRevisionDiagnostic[];
3779
+ };
3780
+ type ActivateContentRevisionRequest = {
3781
+ contentId: string;
3782
+ revision?: string;
3783
+ adapterId?: string;
3784
+ };
3785
+ type ContentRevisionFetchBytes = (url: string, signal?: AbortSignal) => Promise<Uint8Array | undefined>;
3786
+ type ContentRegistryAdapter = {
3787
+ readonly id: string;
3788
+ hasRevision(contentId: string, revision: string): boolean;
3789
+ discover(contentId: string): Promise<ContentRevisionDescriptor | undefined>;
3790
+ loadRevision(contentId: string, revision: string, signal?: AbortSignal): Promise<{
3791
+ ok: true;
3792
+ catalog: ContentRevisionCatalog;
3793
+ } | {
3794
+ ok: false;
3795
+ errors: ContentRevisionDiagnostic[];
3796
+ }>;
3797
+ fetchBytes: ContentRevisionFetchBytes;
3798
+ };
3799
+ type CreateStaticContentAdapterOptions = {
3800
+ id?: string;
3801
+ revisions: readonly ContentRevisionCatalog[];
3802
+ bytesByUrl: Readonly<Record<string, Uint8Array>>;
3803
+ fetchBytes?: ContentRevisionFetchBytes;
3804
+ };
3805
+ type CreateRemoteContentAdapterOptions = {
3806
+ id?: string;
3807
+ fetch: (url: string, signal?: AbortSignal) => Promise<unknown>;
3808
+ keys: Readonly<Record<string, string>>;
3809
+ bytesByUrl?: Readonly<Record<string, Uint8Array>>;
3810
+ fetchBytes?: ContentRevisionFetchBytes;
3811
+ catalogUrl?: (contentId: string, revision?: string) => string;
3812
+ known?: ReadonlyArray<{
3813
+ contentId: string;
3814
+ revision: string;
3815
+ }>;
3816
+ };
3817
+ type ContentRevisionHealthCheck = (bundle: ContentRevisionBundle) => boolean | Promise<boolean>;
3818
+ type CreateContentRevisionActivatorOptions = {
3819
+ adapters: readonly ContentRegistryAdapter[];
3820
+ pin?: boolean;
3821
+ grants?: HostGrantSet;
3822
+ hostCapabilities?: HostCapabilities;
3823
+ healthCheck?: ContentRevisionHealthCheck;
3824
+ router?: Pick<EventRouter, 'publish'>;
3825
+ onEvent?: (event: EventInput) => void;
3826
+ };
3827
+ type ContentRevisionActivator = {
3828
+ pin(frozen?: boolean): void;
3829
+ unpin(): void;
3830
+ isPinned(): boolean;
3831
+ discover(contentId: string, adapterId?: string): Promise<ContentRevisionDescriptor | undefined>;
3832
+ activate(request: ActivateContentRevisionRequest): Promise<ContentRevisionMutationResult>;
3833
+ rollback(): ContentRevisionMutationResult;
3834
+ inspect(): ContentRevisionInspect;
3835
+ activeBundle(): ContentRevisionBundle | null;
3836
+ snapshot(): ContentRevisionSnapshot;
3837
+ restore(input: unknown): RestoreContentRevisionResult;
3838
+ provenance(): SnapshotProvenance | undefined;
3839
+ destroy(): void;
3840
+ };
3841
+ declare function contentRevisionEventContracts(): EventContract[];
3842
+ declare function createStaticContentAdapter(options: CreateStaticContentAdapterOptions): ContentRegistryAdapter;
3843
+ declare function createRemoteContentAdapter(options: CreateRemoteContentAdapterOptions): ContentRegistryAdapter;
3844
+ declare function createContentRevisionActivator(options: CreateContentRevisionActivatorOptions): ContentRevisionActivator;
3845
+
3846
+ /**
3847
+ * Copyright (c) 2026 Aaron Boyarsky
3848
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3849
+ * See packages/engine/LICENSE
3850
+ *
3851
+ * Cart-agnostic update/render frame benchmark for CI and agent workflows.
3852
+ * Prefer this over ad-hoc vitest probes when evaluating hash / trait cost.
3853
+ */
3854
+
3855
+ type FrameBenchmarkOptions = {
3856
+ /** Measured frames after warmup. Default 30. */
3857
+ frames?: number;
3858
+ /** Discarded frames before measurement. Default 5. */
3859
+ warmupFrames?: number;
3860
+ /** Simulated frame advance in ms. Default 1000/60. */
3861
+ frameStepMs?: number;
3862
+ width?: number;
3863
+ height?: number;
3864
+ tokenId?: string;
3865
+ /**
3866
+ * Mutate state after `getDefaultState` (e.g. skip Tone init in jsdom by
3867
+ * setting `audioContextStarted = true`).
3868
+ */
3869
+ prepareState?: (state: unknown, featureState: unknown) => void;
3870
+ /** Optional stub drawing context; defaults to a no-op `putImageData`. */
3871
+ drawingContext?: CanvasRenderingContext2D;
3872
+ };
3873
+ type FrameBenchmarkResult = {
3874
+ frames: number;
3875
+ updateAvgMs: number;
3876
+ renderAvgMs: number;
3877
+ totalAvgMs: number;
3878
+ updateMaxMs: number;
3879
+ renderMaxMs: number;
3880
+ estFps: number;
3881
+ updatePct: number;
3882
+ renderPct: number;
3883
+ };
3884
+ /**
3885
+ * Run a cart's update/render loop headlessly and report average / max phase
3886
+ * timings. Does not start audio or mount a live AnimationManager — suitable
3887
+ * for jsdom vitest and agent hash probes.
3888
+ */
3889
+ declare function benchmarkCartFrames<T, TFeatureState = undefined>(cart: AnimationCart<T, TFeatureState>, hash: string, rawParams: number[], options?: FrameBenchmarkOptions): FrameBenchmarkResult;
3890
+ /** Round timing fields for stable console / snapshot logging. */
3891
+ declare function formatFrameBenchmarkResult(result: FrameBenchmarkResult, digits?: number): Record<string, number>;
3892
+
3893
+ /**
3894
+ * Copyright (c) 2026 Aaron Boyarsky
3895
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
3896
+ * See packages/engine/LICENSE
3897
+ *
3898
+ * Opt-in DOM/browser host harness. Mounts a caller-supplied host into a
3899
+ * viewport, optionally wires a runtime group and compositor, and dispatches
3900
+ * pointer/keyboard through layout coordinates. Does not import Node built-ins
3901
+ * and does not encode host-product event types or fixtures.
3902
+ */
3903
+
3904
+ type BrowserInputModality = 'pointer' | 'keyboard' | 'touch';
3905
+ type BrowserHarnessAction = {
3906
+ type: 'viewport';
3907
+ width: number;
3908
+ height: number;
3909
+ dpr: number;
3910
+ } | {
3911
+ type: 'click';
3912
+ x: number;
3913
+ y: number;
3914
+ selector?: string;
3915
+ } | {
3916
+ type: 'key';
3917
+ key: string;
3918
+ } | {
3919
+ type: 'step';
3920
+ frames: number;
3921
+ } | {
3922
+ type: 'advance';
3923
+ ms: number;
3924
+ } | {
3925
+ type: 'reducedMotion';
3926
+ value: boolean;
3927
+ } | {
3928
+ type: 'inputModality';
3929
+ value: BrowserInputModality;
3930
+ };
3931
+ type BrowserHarnessScreenshot = {
3932
+ imageData: ImageData | null;
3933
+ pngDataUrl: string | null;
3934
+ html: string;
3935
+ declaredOrder: string[];
3936
+ };
3937
+ type BrowserA11ySnapshot = {
3938
+ focus: {
3939
+ tag: string;
3940
+ id: string;
3941
+ role: string | null;
3942
+ name: string;
3943
+ };
3944
+ live: string;
3945
+ html: string;
3946
+ publishedRegions: Array<{
3947
+ id: string;
3948
+ geometryKinds: string[];
3949
+ name: string | null;
3950
+ role: string | null;
3951
+ }>;
3952
+ };
3953
+ type BrowserReproductionMetadata = {
3954
+ seed: string;
3955
+ viewport: {
3956
+ width: number;
3957
+ height: number;
3958
+ dpr: number;
3959
+ };
3960
+ reducedMotion: boolean;
3961
+ inputModality: BrowserInputModality;
3962
+ actions: BrowserHarnessAction[];
3963
+ };
3964
+ type BrowserHarnessInspect = {
3965
+ host: unknown;
3966
+ layout: PresentationLayout;
3967
+ events: EventEnvelope[];
3968
+ participantEvents: Record<string, HostEvent[]>;
3969
+ state: Record<string, unknown>;
3970
+ focus: BrowserA11ySnapshot['focus'];
3971
+ publishedRegions: BrowserA11ySnapshot['publishedRegions'];
3972
+ scrollTop: number;
3973
+ clock: {
3974
+ framesElapsed: number;
3975
+ };
3976
+ };
3977
+ type BrowserHarness = {
3978
+ readonly root: HTMLElement;
3979
+ readonly group: RuntimeGroup | undefined;
3980
+ readonly compositor: Compositor | undefined;
3981
+ readonly layout: PresentationLayout;
3982
+ readonly events: readonly EventEnvelope[];
3983
+ readonly geometry: GeometryDocument | undefined;
3984
+ goto(url?: string): void;
3985
+ setViewport(width: number, height: number, dpr?: number): void;
3986
+ setGeometry(next?: GeometryDocument): void;
3987
+ setReducedMotion(value: boolean): void;
3988
+ setInputModality(value: BrowserInputModality): void;
3989
+ click(selectorOrX: string | number, y?: number): void;
3990
+ key(key: string): void;
3991
+ focus(selector: string): void;
3992
+ step(frames?: number): Promise<void>;
3993
+ advance(ms: number): Promise<void>;
3994
+ screenshot(): BrowserHarnessScreenshot;
3995
+ accessibilitySnapshot(): BrowserA11ySnapshot;
3996
+ inspect(): Promise<BrowserHarnessInspect>;
3997
+ reproduction(): BrowserReproductionMetadata;
3998
+ captureComposedFrame(): ComposedFrame;
3999
+ destroy(): void;
4000
+ };
4001
+
4002
+ /**
4003
+ * Copyright (c) 2026 Aaron Boyarsky
4004
+ * SPDX-License-Identifier: LicenseRef-CyberArt-Engine
4005
+ * See packages/engine/LICENSE
4006
+ *
4007
+ * End-to-end production composition scenario harness. Composes the real
4008
+ * browser host, runtime group, compositor, visual/semantic layers, bindings,
4009
+ * sequences, headless audio, optional host-owned audio observation, snapshots,
4010
+ * and replay inspector. Does not introduce a second runtime. Authored
4011
+ * scenarios are JSON-serializable.
4012
+ */
4013
+
4014
+ declare const PRODUCTION_SCENARIO_SCHEMA_VERSION: 1;
4015
+ declare const PRODUCTION_SCENARIO_SNAPSHOT_SCHEMA_VERSION: 1;
4016
+ declare const PRODUCTION_SCENARIO_BOUNDARIES: readonly ["input", "reducer", "routing", "binding", "cue", "pixels", "caption", "audio", "save-replay"];
4017
+ type ProductionScenarioBoundary = (typeof PRODUCTION_SCENARIO_BOUNDARIES)[number];
4018
+ declare const PRODUCTION_SCENARIO_ERROR_CODES: readonly ["invalid-scenario", "invalid-schema", "unknown-field", "missing-field", "callbacks-forbidden", "missing-participant", "missing-layer", "destroyed", "assertion-failed", "invalid-host-audio", "invalid-audio-sidecar", "unsupported-preference", "invalid-geometry", "ambiguous-geometry", "stale-geometry"];
4019
+ type ProductionScenarioErrorCode = (typeof PRODUCTION_SCENARIO_ERROR_CODES)[number];
4020
+ declare const HOST_OWNED_AUDIO_EVENT_KINDS: readonly ["invoked", "completed", "failed", "skipped", "fallback"];
4021
+ type HostOwnedAudioEventKind = (typeof HOST_OWNED_AUDIO_EVENT_KINDS)[number];
4022
+ declare const PRODUCTION_SCENARIO_VIEWPORT_PRESETS: readonly ["desktop", "mobile"];
4023
+ type ProductionScenarioViewportPreset = (typeof PRODUCTION_SCENARIO_VIEWPORT_PRESETS)[number];
4024
+ declare const DEFAULT_PRODUCTION_SCENARIO_VIEWPORTS: {
4025
+ readonly desktop: {
4026
+ readonly width: 64;
4027
+ readonly height: 48;
4028
+ readonly deviceScaleFactor: 1;
4029
+ };
4030
+ readonly mobile: {
4031
+ readonly width: 48;
4032
+ readonly height: 64;
4033
+ readonly deviceScaleFactor: 2;
4034
+ };
4035
+ };
4036
+ type ProductionScenarioDiagnostic = {
4037
+ code: ProductionScenarioErrorCode | string;
4038
+ detail: string;
4039
+ path?: string;
4040
+ boundary?: ProductionScenarioBoundary;
4041
+ };
4042
+ type ProductionScenarioRequired = {
4043
+ participants: readonly string[];
4044
+ layers: readonly string[];
4045
+ };
4046
+ type ProductionScenarioMatrix = {
4047
+ viewport?: ProductionScenarioViewportPreset;
4048
+ width?: number;
4049
+ height?: number;
4050
+ dpr?: number;
4051
+ reducedMotion?: boolean;
4052
+ mute?: boolean;
4053
+ failedAssetIds?: readonly string[];
4054
+ fallback?: boolean;
4055
+ inputModality?: BrowserInputModality;
4056
+ };
4057
+ type ProductionScenarioStep = {
4058
+ type: 'click';
4059
+ selector?: string;
4060
+ x?: number;
4061
+ y?: number;
4062
+ } | {
4063
+ type: 'key';
4064
+ key: string;
4065
+ } | {
4066
+ type: 'focus';
4067
+ selector: string;
4068
+ } | {
4069
+ type: 'step';
4070
+ frames: number;
4071
+ } | {
4072
+ type: 'viewport';
4073
+ kind?: ProductionScenarioViewportPreset;
4074
+ width?: number;
4075
+ height?: number;
4076
+ dpr?: number;
4077
+ } | {
4078
+ type: 'reducedMotion';
4079
+ value: boolean;
4080
+ } | {
4081
+ type: 'mute';
4082
+ value: boolean;
4083
+ } | {
4084
+ type: 'failAsset';
4085
+ assetId: string;
4086
+ } | {
4087
+ type: 'save';
4088
+ } | {
4089
+ type: 'reload';
4090
+ } | {
4091
+ type: 'replay';
4092
+ };
4093
+ type ProductionScenarioDefinition = {
4094
+ id: string;
4095
+ schemaVersion: typeof PRODUCTION_SCENARIO_SCHEMA_VERSION;
4096
+ seed: string;
4097
+ required: ProductionScenarioRequired;
4098
+ matrix?: ProductionScenarioMatrix;
4099
+ steps?: readonly ProductionScenarioStep[];
4100
+ };
4101
+ type DefineProductionScenarioResult = {
4102
+ ok: true;
4103
+ scenario: ProductionScenarioDefinition;
4104
+ } | {
4105
+ ok: false;
4106
+ errors: ProductionScenarioDiagnostic[];
4107
+ };
4108
+ type ProductionScenarioReduceResult = {
4109
+ accepted: boolean;
4110
+ state: JsonObject;
4111
+ reason?: string;
4112
+ playSequence?: string;
4113
+ };
4114
+ type ProductionScenarioControl = {
4115
+ id: string;
4116
+ name?: string;
4117
+ role?: string;
4118
+ };
4119
+ type ProductionScenarioInputSurface = {
4120
+ controls: readonly ProductionScenarioControl[];
4121
+ geometry: GeometryDocument;
4122
+ };
4123
+ type ProductionScenarioHost = {
4124
+ initialState: JsonObject;
4125
+ reduce(state: JsonObject, intent: EventInput): ProductionScenarioReduceResult;
4126
+ project?(state: JsonObject): JsonObject;
4127
+ /**
4128
+ * Host-generic projection of the active input surface. After an accepted
4129
+ * reduce (and on reload) the runner rebuilds visible/focusable controls and
4130
+ * the geometry document from this result. Omit to keep construction-time
4131
+ * geometry and controls.
4132
+ */
4133
+ projectInputSurface?(state: JsonObject): ProductionScenarioInputSurface;
4134
+ };
4135
+ type HostOwnedAudioEvent = {
4136
+ kind: HostOwnedAudioEventKind;
4137
+ atFrame?: number;
4138
+ name?: string;
4139
+ caption?: string;
4140
+ assetId?: string;
4141
+ reason?: string;
4142
+ id?: string;
4143
+ correlationId?: string;
4144
+ causationId?: string;
4145
+ };
4146
+ type HostOwnedAudioSnapshot = {
4147
+ events: readonly HostOwnedAudioEvent[];
4148
+ captions?: readonly string[];
4149
+ muted?: boolean;
4150
+ };
4151
+ /**
4152
+ * Host-owned audio/presentation observer. The host already drives the
4153
+ * controller; the runner only snapshots evidence. Generic: no dialogue
4154
+ * product semantics. At least one of `snapshot` or `collect` is required.
4155
+ */
4156
+ type HostOwnedAudioObserver = {
4157
+ snapshot?(): HostOwnedAudioSnapshot;
4158
+ collect?(): HostOwnedAudioSnapshot;
4159
+ inspect?(): unknown;
4160
+ };
4161
+ type ProductionScenarioLocalization = {
4162
+ boundary: ProductionScenarioBoundary;
4163
+ code: ProductionScenarioErrorCode;
4164
+ detail: string;
4165
+ };
4166
+ declare const REDUCED_MOTION_ACTIVE_SEQUENCE_POLICY: "continue";
4167
+ type ReducedMotionActiveSequencePolicy = typeof REDUCED_MOTION_ACTIVE_SEQUENCE_POLICY;
4168
+ declare const REDUCED_MOTION_PARTICIPANT_IDS: readonly ["browser", "visual", "sequence", "audio", "semantic"];
4169
+ type ReducedMotionParticipantId = (typeof REDUCED_MOTION_PARTICIPANT_IDS)[number];
4170
+ type ReducedMotionParticipantReport = {
4171
+ id: ReducedMotionParticipantId;
4172
+ applied: boolean;
4173
+ reducedMotion?: boolean;
4174
+ reducedSensory?: boolean;
4175
+ reason?: string;
4176
+ };
4177
+ type ReducedMotionPropagation = {
4178
+ from: boolean;
4179
+ to: boolean;
4180
+ activeSequencePolicy: ReducedMotionActiveSequencePolicy;
4181
+ participants: ReducedMotionParticipantReport[];
4182
+ };
4183
+ type ProductionScenarioObservation = {
4184
+ inputDispatched: boolean;
4185
+ inputTarget?: string;
4186
+ reducerAccepted?: boolean;
4187
+ reducerRejected?: boolean;
4188
+ reducerReason?: string;
4189
+ routedTypes: string[];
4190
+ rejected: boolean;
4191
+ selectedBindingIds: string[];
4192
+ sequenceId?: string | null;
4193
+ sequencePhase?: string | null;
4194
+ captions: string[];
4195
+ declaredOrder: string[];
4196
+ requiredParticipantsPresent: boolean;
4197
+ requiredLayersPresent: boolean;
4198
+ missingParticipants: string[];
4199
+ missingLayers: string[];
4200
+ audioInvoked: boolean;
4201
+ audioFailed: boolean;
4202
+ muted: boolean;
4203
+ replayMatch?: boolean;
4204
+ snapshotOk?: boolean;
4205
+ audioRestoreOk?: boolean;
4206
+ reducedMotion?: boolean;
4207
+ reducedMotionPropagation?: ReducedMotionPropagation | null;
4208
+ activeControlIds: string[];
4209
+ };
4210
+ type ProductionScenarioExpectation = {
4211
+ inputDispatched?: boolean;
4212
+ reducerAccepted?: boolean;
4213
+ reducerRejected?: boolean;
4214
+ routedTypes?: readonly string[];
4215
+ selectedBindingIds?: readonly string[];
4216
+ sequenceId?: string;
4217
+ captions?: readonly string[];
4218
+ requiredParticipantsPresent?: boolean;
4219
+ requiredLayersPresent?: boolean;
4220
+ audioInvoked?: boolean;
4221
+ audioFailed?: boolean;
4222
+ replayMatch?: boolean;
4223
+ snapshotOk?: boolean;
4224
+ audioRestoreOk?: boolean;
4225
+ };
4226
+ type ProductionScenarioEvidenceBundle = {
4227
+ schemaVersion: typeof PRODUCTION_SCENARIO_SNAPSHOT_SCHEMA_VERSION;
4228
+ scenarioId: string;
4229
+ seed: string;
4230
+ matrix: Required<Pick<ProductionScenarioMatrix, 'viewport' | 'width' | 'height' | 'dpr'>> & ProductionScenarioMatrix;
4231
+ hashes: {
4232
+ pixels: string;
4233
+ semantic: string;
4234
+ a11y: string;
4235
+ trace: string;
4236
+ snapshot: string;
4237
+ assets: string;
4238
+ };
4239
+ revisions: {
4240
+ world: string | number | null;
4241
+ bindings: string | number | null;
4242
+ snapshot: number;
4243
+ };
4244
+ traces: {
4245
+ envelopes: EventEnvelope[];
4246
+ inspector: InspectorRecord[];
4247
+ audio: AudioCueEvent[];
4248
+ hostAudio: HostOwnedAudioEvent[];
4249
+ actions: ProductionScenarioStep[];
4250
+ };
4251
+ screenshot: {
4252
+ pngDataUrl: string | null;
4253
+ declaredOrder: string[];
4254
+ width: number;
4255
+ height: number;
4256
+ };
4257
+ semantic: SemanticPublishedRegion[];
4258
+ a11y: BrowserA11ySnapshot;
4259
+ firstBrokenBoundary: ProductionScenarioBoundary | null;
4260
+ localization: ProductionScenarioLocalization | null;
4261
+ participants: string[];
4262
+ layers: string[];
4263
+ observation: ProductionScenarioObservation;
4264
+ selectionTrace?: SelectionTraceExport | null;
4265
+ };
4266
+ type CreateProductionScenarioRunnerOptions = {
4267
+ scenario: ProductionScenarioDefinition | unknown;
4268
+ participants: RuntimeGroupParticipantConfig[];
4269
+ compositorLayers: CompositorLayerConfig[];
4270
+ visualLayers?: readonly VisualLayerDeclaration[];
4271
+ visualSources?: Readonly<Record<string, ImageData>>;
4272
+ semanticRegions?: readonly SemanticRegionDeclaration[];
4273
+ sequences?: readonly PresentationSequenceDefinition[];
4274
+ bindings?: PresentationBindingManifest | unknown;
4275
+ geometry?: GeometryDocument;
4276
+ host: ProductionScenarioHost;
4277
+ /**
4278
+ * Optional host-owned audio observer. When supplied, the runner records
4279
+ * invocation / completion / failure / skip / fallback evidence from this
4280
+ * adapter without requiring a presentation sequence for the same beat.
4281
+ * Invalid adapters fail closed at boundary `audio`.
4282
+ */
4283
+ hostAudio?: HostOwnedAudioObserver;
4284
+ sequenceBindings?: Readonly<Record<string, PresentationSequenceBindings>>;
4285
+ contentWidth?: number;
4286
+ contentHeight?: number;
4287
+ origin?: number;
4288
+ createId?: () => string;
4289
+ mapClick?: (hotspotId: string) => EventInput;
4290
+ mapKey?: (key: string) => EventInput | undefined;
4291
+ router?: Pick<EventRouter, 'publish'>;
4292
+ };
4293
+ type ProductionScenarioRunner = {
4294
+ readonly scenario: ProductionScenarioDefinition;
4295
+ readonly harness: BrowserHarness;
4296
+ readonly audio: HeadlessAudioAdapter;
4297
+ readonly inspector: ReplayInspector;
4298
+ goto(): void;
4299
+ click(selectorOrX: string | number, y?: number): void;
4300
+ key(key: string): void;
4301
+ focus(selector: string): void;
4302
+ setViewport(width: number, height: number, dpr?: number): void;
4303
+ setReducedMotion(value: boolean): void;
4304
+ mute(value?: boolean): void;
4305
+ failAsset(assetId: string): void;
4306
+ step(frames?: number): Promise<void>;
4307
+ applyHostIntent(intent: EventInput): ProductionScenarioReduceResult;
4308
+ playSequence(sequenceId: string, invocationId?: string): void;
4309
+ publish(event: EventInput): EventEnvelope | undefined;
4310
+ save(): SnapshotEnvelope;
4311
+ reload(snapshot?: SnapshotEnvelope): void;
4312
+ replay(): Promise<ReplayCompareResult>;
4313
+ run(steps?: readonly ProductionScenarioStep[]): Promise<ProductionScenarioEvidenceBundle>;
4314
+ captureEvidence(expected?: ProductionScenarioExpectation): ProductionScenarioEvidenceBundle;
4315
+ inspect(): {
4316
+ host: JsonObject;
4317
+ lastDecision: ProductionScenarioReduceResult | null;
4318
+ bindings: ReturnType<PresentationBindingRuntime['inspect']> | null;
4319
+ sequences: ReturnType<PresentationSequencePlayer['inspect']> | null;
4320
+ visual: ReturnType<VisualLayerController['inspect']> | null;
4321
+ semantic: ReturnType<SemanticLayerController['inspect']> | null;
4322
+ audio: ReturnType<HeadlessAudioAdapter['snapshot']>;
4323
+ hostAudio: HostOwnedAudioSnapshot | null;
4324
+ participants: string[];
4325
+ layers: string[];
4326
+ composition: ProductionScenarioLocalization | null;
4327
+ reducedMotion: boolean;
4328
+ reducedMotionPropagation: ReducedMotionPropagation | null;
4329
+ inputSurface: {
4330
+ controlIds: string[];
4331
+ geometry: GeometryDocument | null;
4332
+ };
4333
+ };
4334
+ destroy(): void;
4335
+ };
4336
+ declare function productionScenarioEventContracts(): EventContract[];
4337
+ declare function isHostOwnedAudioEventKind(value: unknown): value is HostOwnedAudioEventKind;
4338
+ declare function defineProductionScenario(input: unknown): DefineProductionScenarioResult;
4339
+ declare function fnv1aHex(data: string | Uint8Array): string;
4340
+ declare function localizeProductionScenarioFailure(observed: ProductionScenarioObservation, expected?: ProductionScenarioExpectation): ProductionScenarioLocalization | null;
4341
+ declare function createProductionScenarioRunner(options: CreateProductionScenarioRunnerOptions): ProductionScenarioRunner;
1757
4342
 
1758
4343
  /**
1759
4344
  * Copyright (c) 2026 Aaron Boyarsky
@@ -1775,4 +4360,4 @@ type WriteComposedFrameResult = ComposedFrame & {
1775
4360
  */
1776
4361
  declare function writeComposedFrame(compositor: Compositor, path?: string): Promise<WriteComposedFrameResult>;
1777
4362
 
1778
- export { type BoundReplaySession, type CausationTreeNode, type CreateHeadlessHarnessOptions, type CreateHeadlessMultiCartHarnessOptions, type CreateReplayInspectorOptions, DEFAULT_HEADLESS_HEIGHT, DEFAULT_HEADLESS_WIDTH, type FrameBenchmarkOptions, type FrameBenchmarkResult, type GlyphAtlas, HEADLESS_PNG_DATA_URL, type HeadlessAudioAdapter, type HeadlessCanvas2DSettings, type HeadlessFrameError, type HeadlessHarness, type HeadlessImageFixture, type HeadlessInspect, type HeadlessMultiCartHarness, HeadlessUnsupportedOperationError, type InspectorRecord, type InstallHeadlessCanvasOptions, type ReplayCompareResult, type ReplayInspector, type ReplayInspectorExport, type ReplayInspectorReport, type ReplayParticipantSummary, type ReplayTapeAction, type ReplayTraceFilter, UPDATE_GOLDEN_ENV, type VisualArtifactPaths, type VisualArtifacts, type VisualCompareOptions, type VisualCompareResult, type VisualLayerCapture, type VisualLayerController, type VisualLayerInspect, type WriteComposedFrameResult, assertPixelsEqual, assertPngDataUrlsEqual, attachHeadlessCanvas2D, benchmarkCartFrames, captureVisualLayers, compareImageData, compareReplayTraces, createDefaultGlyphAtlas, createHeadlessAudioAdapter, createHeadlessHarness, createHeadlessMultiCartHarness, createImageFixture, createReplayInspector, createVisualLayerController, decodePng, encodePng, encodePngDataUrl, formatFrameBenchmarkResult, getHeadlessSurface, imageDataFromPngDataUrl, installHeadlessCanvas, makeImageData, replayExportedTrace, setDefaultGlyphAtlas, shouldUpdateGolden, writeComposedFrame, writeVisualArtifacts };
4363
+ export { AUDIO_CUE_SNAPSHOT_SCHEMA_VERSION, type AudioCueDiagnostic, type BoundReplaySession, CONTENT_REVISION_ACTIVATED_EVENT, CONTENT_REVISION_SNAPSHOT_SCHEMA_VERSION, type CausationTreeNode, type ContentRevisionActivator, type ContentRevisionBundle, type ContentRevisionInspect, type ContentRevisionSnapshot, type CreateHeadlessHarnessOptions, type CreateHeadlessMultiCartHarnessOptions, type CreateProductionScenarioRunnerOptions, type CreateReplayInspectorOptions, type CreateSelectionTraceOptions, DEFAULT_HEADLESS_HEIGHT, DEFAULT_HEADLESS_WIDTH, DEFAULT_MAX_SELECTION_RECORDS, DEFAULT_PRODUCTION_SCENARIO_VIEWPORTS, type FrameBenchmarkOptions, type FrameBenchmarkResult, type GlyphAtlas, HEADLESS_PNG_DATA_URL, HOST_OWNED_AUDIO_EVENT_KINDS, type HeadlessAudioAdapter, type HeadlessAudioAdapterSnapshot, type HeadlessCanvas2DSettings, type HeadlessFrameError, type HeadlessHarness, type HeadlessImageFixture, type HeadlessInspect, type HeadlessJobWorker, type HeadlessMultiCartHarness, HeadlessUnsupportedOperationError, type HostGrantSet, type HostOwnedAudioEvent, type HostOwnedAudioEventKind, type HostOwnedAudioObserver, type HostOwnedAudioSnapshot, type InspectorRecord, type InstallHeadlessCanvasOptions, type JobCoordinator, type JobCoordinatorSnapshot, type JobInspect, PRESENTATION_BINDING_APPLIED_EVENT, PRESENTATION_BINDING_SNAPSHOT_SCHEMA_VERSION, PRODUCTION_SCENARIO_BOUNDARIES, PRODUCTION_SCENARIO_SCHEMA_VERSION, PRODUCTION_SCENARIO_SNAPSHOT_SCHEMA_VERSION, type PortalInspect, type PortalLifecycle, type PortalLifecycleSnapshot, type PresentationBindingInspect, type PresentationBindingManifest, type PresentationBindingRuntime, type PresentationBindingSnapshot, type PresentationSequenceDefinition, type PresentationSequenceInspect, type PresentationSequencePlayer, type PresentationSequenceSnapshot, type ProductionScenarioControl, type ProductionScenarioDefinition, type ProductionScenarioEvidenceBundle, type ProductionScenarioExpectation, type ProductionScenarioHost, type ProductionScenarioInputSurface, type ProductionScenarioLocalization, type ProductionScenarioObservation, type ProductionScenarioRunner, REDUCED_MOTION_ACTIVE_SEQUENCE_POLICY, REDUCED_MOTION_PARTICIPANT_IDS, type ReducedMotionActiveSequencePolicy, type ReducedMotionParticipantId, type ReducedMotionParticipantReport, type ReducedMotionPropagation, type RemoteCartInspect, type RemoteCartSandbox, type ReplayCompareResult, type ReplayInspector, type ReplayInspectorExport, type ReplayInspectorReport, type ReplayParticipantSummary, type ReplayTapeAction, type ReplayTraceFilter, type RestoreAudioCueResult, SELECTION_DECISION_KINDS, SELECTION_REASON_CODES, SELECTION_TRACE_SCHEMA_VERSION, SELECTION_TRACE_SENSITIVE_KEYS, type SelectionAssetResolution, type SelectionBindingEvaluation, type SelectionContentIdentity, type SelectionDecisionInput, type SelectionDecisionKind, type SelectionDecisionRecord, type SelectionPresentationDecision, type SelectionReasonCode, type SelectionSequenceDecision, type SelectionSnapshotProvenance, type SelectionStagingOutcome, type SelectionStagingResult, type SelectionTrace, type SelectionTraceExport, type SelectionTraceFilter, type SelectionTraceReport, type SemanticLayerController, type SemanticPublishedRegion, type SemanticRegionInspect, UPDATE_GOLDEN_ENV, type VisualArtifactPaths, type VisualArtifacts, type VisualCompareOptions, type VisualCompareResult, type VisualLayerCapture, type VisualLayerController, type VisualLayerInspect, WORLD_PATCH_ACCEPTED_EVENT, WORLD_PATCH_SNAPSHOT_SCHEMA_VERSION, type WorldGraph, type WorldGraphInspect, type WorldGraphProjection, type WorldGraphSnapshot, type WorldPatchApplier, type WorldPatchInspect, type WorldPatchSnapshot, type WorldPersistenceAdapter, type WriteComposedFrameResult, assertPixelsEqual, assertPngDataUrlsEqual, attachHeadlessCanvas2D, attachSelectionTrace, benchmarkCartFrames, cabinetPortal, captureVisualLayers, compareImageData, compareReplayTraces, contentRevisionEventContracts, createContentRevisionActivator, createDefaultGlyphAtlas, createHeadlessAudioAdapter, createHeadlessHarness, createHeadlessJobWorker, createHeadlessMultiCartHarness, createHostGrantSet, createImageFixture, createJobCoordinator, createMemoryJobPersistence, createMemoryWorldPersistence, createPortalLifecycle, createPresentationBindingRuntime, createPresentationSequencePlayer, createProductionScenarioRunner, createRemoteCartSandbox, createRemoteContentAdapter, createReplayInspector, createSelectionTrace, createSemanticLayerController, createStaticContentAdapter, createVisualLayerController, createWorldGraph, createWorldPatchApplier, decodePng, definePresentationBindings, definePresentationSequence, defineProductionScenario, encodePng, encodePngDataUrl, evaluatePresentationBindings, fnv1aHex, formatFrameBenchmarkResult, getHeadlessSurface, imageDataFromPngDataUrl, installHeadlessCanvas, isHostOwnedAudioEventKind, isSelectionDecisionKind, isSelectionReasonCode, jobEventContracts, localizeProductionScenarioFailure, makeImageData, paintingPortal, parseAudioCueSnapshot, presentationBindingEventContracts, presentationSequenceEventContracts, productionScenarioEventContracts, recordSelectionDecision, replayExportedTrace, setDefaultGlyphAtlas, shouldUpdateGolden, worldGraphEventContracts, worldPatchEventContracts, writeComposedFrame, writeVisualArtifacts };