@plasius/ai-game 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1499,6 +1499,577 @@ function assertAiGameObservedEventLogContractVersion(value) {
1499
1499
  assertContractVersion4(value);
1500
1500
  }
1501
1501
 
1502
+ // src/mcc-guidance.ts
1503
+ var AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID = "isekai.player-system.mcc-guidance.enabled";
1504
+ var AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION = "1.0";
1505
+ var AI_GAME_MCC_GROWTH_DIRECTIONS = [
1506
+ "internalized",
1507
+ "externalized",
1508
+ "hybrid"
1509
+ ];
1510
+ var AI_GAME_MCC_FOCUS_PRIORITIES = ["primary", "secondary"];
1511
+ var AI_GAME_MCC_READINESS_BANDS = [
1512
+ "stable",
1513
+ "pressured",
1514
+ "restricted"
1515
+ ];
1516
+ var AI_GAME_MCC_WARNING_STATES = [
1517
+ "clear",
1518
+ "advisory",
1519
+ "elevated",
1520
+ "critical"
1521
+ ];
1522
+ var AI_GAME_MCC_WARNING_KINDS = [
1523
+ "thermal",
1524
+ "fatigue",
1525
+ "chaos-pressure",
1526
+ "target-burden",
1527
+ "stage-gate",
1528
+ "death-impairment"
1529
+ ];
1530
+ var AI_GAME_SPELLCRAFT_RECOMMENDATION_KINDS = [
1531
+ "training",
1532
+ "material",
1533
+ "social-prerequisite",
1534
+ "refinement"
1535
+ ];
1536
+ var AI_GAME_SPELLCRAFT_VERDICTS = [
1537
+ "recommended",
1538
+ "conditional",
1539
+ "blocked"
1540
+ ];
1541
+ var AI_GAME_SPELLCRAFT_TARGET_MODES = [
1542
+ "self",
1543
+ "single-target",
1544
+ "area"
1545
+ ];
1546
+ var AI_GAME_SPELLCRAFT_COMPLEXITIES = ["low", "medium", "high"];
1547
+ var AI_GAME_SPELLCRAFT_CHAOS_PRESSURES = [
1548
+ "low",
1549
+ "elevated",
1550
+ "volatile"
1551
+ ];
1552
+ var AI_GAME_SPELLCRAFT_FATIGUE_STATES = [
1553
+ "steady",
1554
+ "strained",
1555
+ "exhausted"
1556
+ ];
1557
+ var AI_GAME_SPELLCRAFT_COMMITMENT = "preview-only";
1558
+ var AI_GAME_SPELLCRAFT_AUTHORITATIVE_OWNER = "spellcraft-system";
1559
+ var AI_GAME_MCC_GUIDANCE_MAX_FOCUS_TARGETS = 3;
1560
+ var AI_GAME_MCC_GUIDANCE_MAX_RECOMMENDATIONS = 5;
1561
+ function freezeReadonlyArray6(items) {
1562
+ return Object.freeze([...items]);
1563
+ }
1564
+ function createStringArray3(values, label) {
1565
+ const normalized = values ?? [];
1566
+ normalized.forEach((value) => assertNonEmptyString6(value, `${label} entry`));
1567
+ return freezeReadonlyArray6(normalized);
1568
+ }
1569
+ function assertNonEmptyString6(value, label) {
1570
+ if (value.trim().length === 0) {
1571
+ throw new Error(`${label} must be a non-empty string`);
1572
+ }
1573
+ }
1574
+ function assertContractVersion5(value, label = "contractVersion") {
1575
+ if (value !== AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION) {
1576
+ throw new Error(`${label} must be ${AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION}`);
1577
+ }
1578
+ }
1579
+ function assertBoundedFraction(value, label) {
1580
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
1581
+ throw new Error(`${label} must be between 0 and 1`);
1582
+ }
1583
+ }
1584
+ function isMember5(value, members) {
1585
+ return members.includes(value);
1586
+ }
1587
+ function getWarningStateRank(state) {
1588
+ return AI_GAME_MCC_WARNING_STATES.indexOf(state);
1589
+ }
1590
+ function resolveWarningState(warnings) {
1591
+ return warnings.reduce(
1592
+ (mostSevere, warning) => getWarningStateRank(warning.state) > getWarningStateRank(mostSevere) ? warning.state : mostSevere,
1593
+ "clear"
1594
+ );
1595
+ }
1596
+ function isAiGameMccGrowthDirection(value) {
1597
+ return isMccExpressionTrack(value);
1598
+ }
1599
+ function isAiGameMccFocusPriority(value) {
1600
+ return isMember5(value, AI_GAME_MCC_FOCUS_PRIORITIES);
1601
+ }
1602
+ function isAiGameMccReadinessBand(value) {
1603
+ return isMember5(value, AI_GAME_MCC_READINESS_BANDS);
1604
+ }
1605
+ function isAiGameMccWarningState(value) {
1606
+ return isMember5(value, AI_GAME_MCC_WARNING_STATES);
1607
+ }
1608
+ function isAiGameMccWarningKind(value) {
1609
+ return isMember5(value, AI_GAME_MCC_WARNING_KINDS);
1610
+ }
1611
+ function isAiGameSpellcraftRecommendationKind(value) {
1612
+ return isMember5(value, AI_GAME_SPELLCRAFT_RECOMMENDATION_KINDS);
1613
+ }
1614
+ function isAiGameSpellcraftVerdict(value) {
1615
+ return isMember5(value, AI_GAME_SPELLCRAFT_VERDICTS);
1616
+ }
1617
+ function isAiGameSpellcraftTargetMode(value) {
1618
+ return isMember5(value, AI_GAME_SPELLCRAFT_TARGET_MODES);
1619
+ }
1620
+ function isAiGameSpellcraftComplexity(value) {
1621
+ return isMember5(value, AI_GAME_SPELLCRAFT_COMPLEXITIES);
1622
+ }
1623
+ function isAiGameSpellcraftChaosPressure(value) {
1624
+ return isMember5(value, AI_GAME_SPELLCRAFT_CHAOS_PRESSURES);
1625
+ }
1626
+ function isAiGameSpellcraftFatigueState(value) {
1627
+ return isMember5(value, AI_GAME_SPELLCRAFT_FATIGUE_STATES);
1628
+ }
1629
+ function createAiGameMccFocusTarget(input) {
1630
+ assertNonEmptyString6(input.targetId, "targetId");
1631
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1632
+ if (!isAiGameMccGrowthDirection(input.growthDirection)) {
1633
+ throw new Error("growthDirection must be a supported MCC growth direction");
1634
+ }
1635
+ if (!isAiGameMccFocusPriority(input.priority)) {
1636
+ throw new Error("priority must be a supported MCC focus priority");
1637
+ }
1638
+ assertNonEmptyString6(input.label, "label");
1639
+ assertNonEmptyString6(input.summary, "summary");
1640
+ assertBoundedFraction(input.influenceWeight, "influenceWeight");
1641
+ return Object.freeze({
1642
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1643
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1644
+ targetId: input.targetId,
1645
+ growthDirection: input.growthDirection,
1646
+ label: input.label,
1647
+ summary: input.summary,
1648
+ priority: input.priority,
1649
+ influenceWeight: input.influenceWeight,
1650
+ reasonCodes: createStringArray3(input.reasonCodes, "reasonCodes")
1651
+ });
1652
+ }
1653
+ function createAiGameMccWarning(input) {
1654
+ assertNonEmptyString6(input.warningId, "warningId");
1655
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1656
+ if (!isAiGameMccWarningKind(input.kind)) {
1657
+ throw new Error("kind must be a supported MCC warning kind");
1658
+ }
1659
+ if (!isAiGameMccWarningState(input.state) || input.state === "clear") {
1660
+ throw new Error("state must be an active MCC warning state");
1661
+ }
1662
+ assertNonEmptyString6(input.summary, "summary");
1663
+ return Object.freeze({
1664
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1665
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1666
+ warningId: input.warningId,
1667
+ kind: input.kind,
1668
+ state: input.state,
1669
+ summary: input.summary,
1670
+ reasonCodes: createStringArray3(input.reasonCodes, "reasonCodes")
1671
+ });
1672
+ }
1673
+ function createAiGameMccReadinessState(input) {
1674
+ assertNonEmptyString6(input.readinessId, "readinessId");
1675
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1676
+ if (!isAiGameMccReadinessBand(input.band)) {
1677
+ throw new Error("band must be a supported MCC readiness band");
1678
+ }
1679
+ const warnings = freezeReadonlyArray6(
1680
+ input.warnings.map((warning) => createAiGameMccWarning(warning))
1681
+ );
1682
+ const derivedWarningState = resolveWarningState(warnings);
1683
+ const warningState = input.warningState ?? derivedWarningState;
1684
+ if (!isAiGameMccWarningState(warningState)) {
1685
+ throw new Error("warningState must be a supported MCC warning state");
1686
+ }
1687
+ if (warningState !== derivedWarningState) {
1688
+ throw new Error("warningState must match the most severe warning");
1689
+ }
1690
+ return Object.freeze({
1691
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1692
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1693
+ readinessId: input.readinessId,
1694
+ band: input.band,
1695
+ warningState,
1696
+ warnings,
1697
+ reasonCodes: createStringArray3(input.reasonCodes, "reasonCodes")
1698
+ });
1699
+ }
1700
+ function createAiGameSpellcraftRecommendation(input) {
1701
+ assertNonEmptyString6(input.recommendationId, "recommendationId");
1702
+ assertNonEmptyString6(input.focusTargetId, "focusTargetId");
1703
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1704
+ if (!isAiGameSpellcraftRecommendationKind(input.kind)) {
1705
+ throw new Error("kind must be a supported spellcraft recommendation kind");
1706
+ }
1707
+ assertNonEmptyString6(input.title, "title");
1708
+ assertNonEmptyString6(input.summary, "summary");
1709
+ if (!isAiGameMccReadinessBand(input.readinessBand)) {
1710
+ throw new Error("readinessBand must be a supported MCC readiness band");
1711
+ }
1712
+ return Object.freeze({
1713
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1714
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1715
+ recommendationId: input.recommendationId,
1716
+ kind: input.kind,
1717
+ focusTargetId: input.focusTargetId,
1718
+ title: input.title,
1719
+ summary: input.summary,
1720
+ readinessBand: input.readinessBand,
1721
+ prerequisiteCodes: createStringArray3(input.prerequisiteCodes, "prerequisiteCodes"),
1722
+ reasonCodes: createStringArray3(input.reasonCodes, "reasonCodes")
1723
+ });
1724
+ }
1725
+ function createAiGameSpellcraftAdvisory(input) {
1726
+ assertNonEmptyString6(input.advisoryId, "advisoryId");
1727
+ assertNonEmptyString6(input.recommendationId, "recommendationId");
1728
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1729
+ if (!isAiGameSpellcraftVerdict(input.verdict)) {
1730
+ throw new Error("verdict must be a supported spellcraft verdict");
1731
+ }
1732
+ if (!isAiGameSpellcraftTargetMode(input.targetMode)) {
1733
+ throw new Error("targetMode must be a supported spellcraft target mode");
1734
+ }
1735
+ if (!isAiGameSpellcraftComplexity(input.complexity)) {
1736
+ throw new Error("complexity must be a supported spellcraft complexity");
1737
+ }
1738
+ if (!isAiGameSpellcraftChaosPressure(input.chaosPressure)) {
1739
+ throw new Error("chaosPressure must be a supported spellcraft chaos pressure");
1740
+ }
1741
+ if (!isAiGameSpellcraftFatigueState(input.fatigueState)) {
1742
+ throw new Error("fatigueState must be a supported spellcraft fatigue state");
1743
+ }
1744
+ if (!isAiGameMccReadinessBand(input.readinessBand)) {
1745
+ throw new Error("readinessBand must be a supported MCC readiness band");
1746
+ }
1747
+ assertNonEmptyString6(input.summary, "summary");
1748
+ return Object.freeze({
1749
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1750
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1751
+ advisoryId: input.advisoryId,
1752
+ recommendationId: input.recommendationId,
1753
+ verdict: input.verdict,
1754
+ targetMode: input.targetMode,
1755
+ complexity: input.complexity,
1756
+ chaosPressure: input.chaosPressure,
1757
+ fatigueState: input.fatigueState,
1758
+ readinessBand: input.readinessBand,
1759
+ prerequisiteCodes: createStringArray3(input.prerequisiteCodes, "prerequisiteCodes"),
1760
+ warningCodes: createStringArray3(input.warningCodes, "warningCodes"),
1761
+ summary: input.summary,
1762
+ reasonCodes: createStringArray3(input.reasonCodes, "reasonCodes"),
1763
+ commitment: AI_GAME_SPELLCRAFT_COMMITMENT,
1764
+ authoritativeOwner: AI_GAME_SPELLCRAFT_AUTHORITATIVE_OWNER
1765
+ });
1766
+ }
1767
+ function createAiGameMccGuidanceSnapshot(input) {
1768
+ assertNonEmptyString6(input.guidanceId, "guidanceId");
1769
+ assertContractVersion5(input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION);
1770
+ if (input.focusTargets.length === 0 || input.focusTargets.length > AI_GAME_MCC_GUIDANCE_MAX_FOCUS_TARGETS) {
1771
+ throw new Error(
1772
+ `focusTargets must contain between 1 and ${AI_GAME_MCC_GUIDANCE_MAX_FOCUS_TARGETS} targets`
1773
+ );
1774
+ }
1775
+ if (input.recommendations.length === 0 || input.recommendations.length > AI_GAME_MCC_GUIDANCE_MAX_RECOMMENDATIONS) {
1776
+ throw new Error(
1777
+ `recommendations must contain between 1 and ${AI_GAME_MCC_GUIDANCE_MAX_RECOMMENDATIONS} items`
1778
+ );
1779
+ }
1780
+ const focusTargets = freezeReadonlyArray6(
1781
+ input.focusTargets.map((target) => createAiGameMccFocusTarget(target))
1782
+ );
1783
+ const focusTargetIds = new Set(focusTargets.map((target) => target.targetId));
1784
+ if (focusTargetIds.size !== focusTargets.length) {
1785
+ throw new Error("focusTargets must have unique targetId values");
1786
+ }
1787
+ const readiness = createAiGameMccReadinessState(input.readiness);
1788
+ const recommendations = freezeReadonlyArray6(
1789
+ input.recommendations.map((recommendation) => {
1790
+ const created = createAiGameSpellcraftRecommendation(recommendation);
1791
+ if (!focusTargetIds.has(created.focusTargetId)) {
1792
+ throw new Error("focusTargetId must reference a supplied focus target");
1793
+ }
1794
+ return created;
1795
+ })
1796
+ );
1797
+ const advisory = createAiGameSpellcraftAdvisory(input.advisory);
1798
+ if (!recommendations.some((recommendation) => recommendation.recommendationId === advisory.recommendationId)) {
1799
+ throw new Error("advisory recommendationId must reference a supplied recommendation");
1800
+ }
1801
+ return Object.freeze({
1802
+ contractVersion: input.contractVersion ?? AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
1803
+ featureFlagId: AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
1804
+ guidanceId: input.guidanceId,
1805
+ focusTargets,
1806
+ readiness,
1807
+ recommendations,
1808
+ advisory
1809
+ });
1810
+ }
1811
+
1812
+ // src/tutorial.ts
1813
+ var AI_GAME_TUTORIAL_FEATURE_FLAG_ID = "isekai.player-system.tutorial.enabled";
1814
+ var AI_GAME_TUTORIAL_CONTRACT_VERSION = "1.0";
1815
+ var AI_GAME_TUTORIAL_STAGES = [
1816
+ "stage-1",
1817
+ "stage-2",
1818
+ "stage-3",
1819
+ "stage-4",
1820
+ "stage-5"
1821
+ ];
1822
+ var AI_GAME_TUTORIAL_TRIGGER_KINDS = [
1823
+ "awakening",
1824
+ "first-action",
1825
+ "explicit-request",
1826
+ "progression-gated"
1827
+ ];
1828
+ var AI_GAME_TUTORIAL_PREREQUISITE_KINDS = [
1829
+ "school-access",
1830
+ "apprenticeship",
1831
+ "academy-admission",
1832
+ "guild-standing",
1833
+ "divine-progression",
1834
+ "spellcraft-readiness"
1835
+ ];
1836
+ var AI_GAME_TUTORIAL_COMPLETION_STATES = [
1837
+ "not-started",
1838
+ "active",
1839
+ "dormant",
1840
+ "completed",
1841
+ "declined"
1842
+ ];
1843
+ var AI_GAME_TUTORIAL_MAX_STEPS = 20;
1844
+ var AI_GAME_TUTORIAL_MAX_PREREQUISITES = 12;
1845
+ var AI_GAME_TUTORIAL_MAX_TRIGGERS = 8;
1846
+ function freezeReadonlyArray7(items) {
1847
+ return Object.freeze([...items]);
1848
+ }
1849
+ function createStringArray4(values, label) {
1850
+ const normalized = values ?? [];
1851
+ normalized.forEach((value) => assertNonEmptyString7(value, `${label} entry`));
1852
+ return freezeReadonlyArray7(normalized);
1853
+ }
1854
+ function assertNonEmptyString7(value, label) {
1855
+ if (value.trim().length === 0) {
1856
+ throw new Error(`${label} must be a non-empty string`);
1857
+ }
1858
+ }
1859
+ function assertContractVersion6(value) {
1860
+ if (value !== AI_GAME_TUTORIAL_CONTRACT_VERSION) {
1861
+ throw new Error(`contractVersion must be ${AI_GAME_TUTORIAL_CONTRACT_VERSION}`);
1862
+ }
1863
+ }
1864
+ function assertPositiveInteger2(value, label) {
1865
+ if (!Number.isInteger(value) || value <= 0) {
1866
+ throw new Error(`${label} must be a positive integer`);
1867
+ }
1868
+ }
1869
+ function assertNonNegativeInteger3(value, label) {
1870
+ if (!Number.isInteger(value) || value < 0) {
1871
+ throw new Error(`${label} must be a non-negative integer`);
1872
+ }
1873
+ }
1874
+ function assertIsoTimestampOrNull(value, label) {
1875
+ if (value !== null && Number.isNaN(Date.parse(value))) {
1876
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
1877
+ }
1878
+ }
1879
+ function isMember6(value, members) {
1880
+ return members.includes(value);
1881
+ }
1882
+ function assertUniqueIds2(values, label) {
1883
+ if (new Set(values).size !== values.length) {
1884
+ throw new Error(`${label} must have unique IDs`);
1885
+ }
1886
+ }
1887
+ function isAiGameTutorialStage(value) {
1888
+ return isMember6(value, AI_GAME_TUTORIAL_STAGES);
1889
+ }
1890
+ function isAiGameTutorialTriggerKind(value) {
1891
+ return isMember6(value, AI_GAME_TUTORIAL_TRIGGER_KINDS);
1892
+ }
1893
+ function isAiGameTutorialPrerequisiteKind(value) {
1894
+ return isMember6(value, AI_GAME_TUTORIAL_PREREQUISITE_KINDS);
1895
+ }
1896
+ function isAiGameTutorialCompletionState(value) {
1897
+ return isMember6(value, AI_GAME_TUTORIAL_COMPLETION_STATES);
1898
+ }
1899
+ function createAiGameTutorialPrerequisite(input) {
1900
+ assertNonEmptyString7(input.markerId, "markerId");
1901
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
1902
+ if (!isAiGameTutorialPrerequisiteKind(input.kind)) {
1903
+ throw new Error("kind must be a supported tutorial prerequisite kind");
1904
+ }
1905
+ assertNonEmptyString7(input.label, "label");
1906
+ return Object.freeze({
1907
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
1908
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
1909
+ markerId: input.markerId,
1910
+ kind: input.kind,
1911
+ label: input.label,
1912
+ satisfied: input.satisfied,
1913
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
1914
+ });
1915
+ }
1916
+ function createAiGameTutorialTrigger(input) {
1917
+ assertNonEmptyString7(input.triggerId, "triggerId");
1918
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
1919
+ if (!isAiGameTutorialTriggerKind(input.kind)) {
1920
+ throw new Error("kind must be a supported tutorial trigger kind");
1921
+ }
1922
+ assertNonEmptyString7(input.capabilityCode, "capabilityCode");
1923
+ return Object.freeze({
1924
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
1925
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
1926
+ triggerId: input.triggerId,
1927
+ kind: input.kind,
1928
+ capabilityCode: input.capabilityCode,
1929
+ firstUseOnly: input.firstUseOnly,
1930
+ safeInCombat: input.safeInCombat,
1931
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
1932
+ });
1933
+ }
1934
+ function createAiGameTutorialStep(input) {
1935
+ assertNonEmptyString7(input.stepId, "stepId");
1936
+ assertNonEmptyString7(input.trackId, "trackId");
1937
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
1938
+ if (!isAiGameTutorialStage(input.stage)) {
1939
+ throw new Error("stage must be a supported tutorial stage");
1940
+ }
1941
+ assertPositiveInteger2(input.sequence, "sequence");
1942
+ assertNonEmptyString7(input.title, "title");
1943
+ assertNonEmptyString7(input.summary, "summary");
1944
+ assertNonEmptyString7(input.capabilityCode, "capabilityCode");
1945
+ if (input.triggerKinds.length === 0) {
1946
+ throw new Error("triggerKinds must contain at least one trigger kind");
1947
+ }
1948
+ input.triggerKinds.forEach((kind) => {
1949
+ if (!isAiGameTutorialTriggerKind(kind)) {
1950
+ throw new Error("triggerKinds must use supported tutorial trigger kinds");
1951
+ }
1952
+ });
1953
+ return Object.freeze({
1954
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
1955
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
1956
+ stepId: input.stepId,
1957
+ trackId: input.trackId,
1958
+ stage: input.stage,
1959
+ sequence: input.sequence,
1960
+ title: input.title,
1961
+ summary: input.summary,
1962
+ capabilityCode: input.capabilityCode,
1963
+ triggerKinds: freezeReadonlyArray7(input.triggerKinds),
1964
+ prerequisiteIds: createStringArray4(input.prerequisiteIds, "prerequisiteIds"),
1965
+ safeInCombat: input.safeInCombat,
1966
+ replayable: input.replayable,
1967
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
1968
+ });
1969
+ }
1970
+ function createAiGameTutorialProgressionState(input) {
1971
+ assertNonEmptyString7(input.trackId, "trackId");
1972
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
1973
+ if (!isAiGameTutorialCompletionState(input.status)) {
1974
+ throw new Error("status must be a supported tutorial completion state");
1975
+ }
1976
+ if (input.currentStepId !== null) {
1977
+ assertNonEmptyString7(input.currentStepId, "currentStepId");
1978
+ }
1979
+ const completedStepIds = createStringArray4(input.completedStepIds, "completedStepIds");
1980
+ assertUniqueIds2(completedStepIds, "completedStepIds");
1981
+ assertNonNegativeInteger3(input.refusalCount, "refusalCount");
1982
+ assertNonNegativeInteger3(input.replayCount, "replayCount");
1983
+ assertIsoTimestampOrNull(input.lastTriggeredAtIso, "lastTriggeredAtIso");
1984
+ assertIsoTimestampOrNull(input.lastReplayedAtIso, "lastReplayedAtIso");
1985
+ if (input.status === "completed" && input.currentStepId !== null) {
1986
+ throw new Error("completed tutorials cannot have a currentStepId");
1987
+ }
1988
+ return Object.freeze({
1989
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
1990
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
1991
+ trackId: input.trackId,
1992
+ status: input.status,
1993
+ currentStepId: input.currentStepId,
1994
+ completedStepIds,
1995
+ refusalCount: input.refusalCount,
1996
+ replayCount: input.replayCount,
1997
+ replayable: input.replayable,
1998
+ lastTriggeredAtIso: input.lastTriggeredAtIso,
1999
+ lastReplayedAtIso: input.lastReplayedAtIso,
2000
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2001
+ });
2002
+ }
2003
+ function createAiGameTutorialTrack(input) {
2004
+ assertNonEmptyString7(input.trackId, "trackId");
2005
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2006
+ assertNonEmptyString7(input.title, "title");
2007
+ assertNonEmptyString7(input.summary, "summary");
2008
+ if (input.steps.length === 0 || input.steps.length > AI_GAME_TUTORIAL_MAX_STEPS) {
2009
+ throw new Error(
2010
+ `steps must contain between 1 and ${AI_GAME_TUTORIAL_MAX_STEPS} steps`
2011
+ );
2012
+ }
2013
+ if (input.prerequisites.length > AI_GAME_TUTORIAL_MAX_PREREQUISITES) {
2014
+ throw new Error(
2015
+ `prerequisites cannot contain more than ${AI_GAME_TUTORIAL_MAX_PREREQUISITES} markers`
2016
+ );
2017
+ }
2018
+ if (input.triggers.length === 0 || input.triggers.length > AI_GAME_TUTORIAL_MAX_TRIGGERS) {
2019
+ throw new Error(
2020
+ `triggers must contain between 1 and ${AI_GAME_TUTORIAL_MAX_TRIGGERS} triggers`
2021
+ );
2022
+ }
2023
+ const steps = freezeReadonlyArray7(
2024
+ input.steps.map((step) => createAiGameTutorialStep(step))
2025
+ );
2026
+ const prerequisites = freezeReadonlyArray7(
2027
+ input.prerequisites.map((marker) => createAiGameTutorialPrerequisite(marker))
2028
+ );
2029
+ const triggers = freezeReadonlyArray7(
2030
+ input.triggers.map((trigger) => createAiGameTutorialTrigger(trigger))
2031
+ );
2032
+ const progression = createAiGameTutorialProgressionState(input.progression);
2033
+ assertUniqueIds2(steps.map((step) => step.stepId), "steps");
2034
+ assertUniqueIds2(prerequisites.map((marker) => marker.markerId), "prerequisites");
2035
+ assertUniqueIds2(triggers.map((trigger) => trigger.triggerId), "triggers");
2036
+ if (progression.trackId !== input.trackId) {
2037
+ throw new Error("progression trackId must match the tutorial track");
2038
+ }
2039
+ const stepIds = new Set(steps.map((step) => step.stepId));
2040
+ const prerequisiteIds = new Set(prerequisites.map((marker) => marker.markerId));
2041
+ const triggerKinds = new Set(triggers.map((trigger) => trigger.kind));
2042
+ if (progression.currentStepId !== null && !stepIds.has(progression.currentStepId)) {
2043
+ throw new Error("currentStepId must reference a supplied tutorial step");
2044
+ }
2045
+ if (progression.completedStepIds.some((stepId) => !stepIds.has(stepId))) {
2046
+ throw new Error("completedStepIds must reference supplied tutorial steps");
2047
+ }
2048
+ steps.forEach((step) => {
2049
+ if (step.trackId !== input.trackId) {
2050
+ throw new Error("step trackId must match the tutorial track");
2051
+ }
2052
+ if (step.prerequisiteIds.some((markerId) => !prerequisiteIds.has(markerId))) {
2053
+ throw new Error("prerequisiteIds must reference supplied prerequisites");
2054
+ }
2055
+ if (step.triggerKinds.some((kind) => !triggerKinds.has(kind))) {
2056
+ throw new Error("triggerKinds must reference supplied triggers");
2057
+ }
2058
+ });
2059
+ return Object.freeze({
2060
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2061
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2062
+ trackId: input.trackId,
2063
+ title: input.title,
2064
+ summary: input.summary,
2065
+ steps,
2066
+ prerequisites,
2067
+ triggers,
2068
+ progression,
2069
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2070
+ });
2071
+ }
2072
+
1502
2073
  // src/world-events.ts
1503
2074
  function isCanonicalWorldEvent(event) {
1504
2075
  return event.recordType === "canonical";
@@ -1650,7 +2221,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
1650
2221
  "private-or-low-witness-evidence",
1651
2222
  "costly-pressure-event"
1652
2223
  ];
1653
- function isMember5(value, members) {
2224
+ function isMember7(value, members) {
1654
2225
  return members.includes(value);
1655
2226
  }
1656
2227
  function assertRecord(value, label) {
@@ -1691,7 +2262,7 @@ function normalizeTimestamp(value, label) {
1691
2262
  }
1692
2263
  function normalizeMember(value, members, label) {
1693
2264
  const normalized = normalizeNonEmptyString(value, label);
1694
- if (!isMember5(normalized, members)) {
2265
+ if (!isMember7(normalized, members)) {
1695
2266
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
1696
2267
  }
1697
2268
  return normalized;
@@ -1824,13 +2395,13 @@ function normalizeDominantReads(value) {
1824
2395
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
1825
2396
  }
1826
2397
  function isQuietMeasureAxis(value) {
1827
- return isMember5(value, QUIET_MEASURE_AXES);
2398
+ return isMember7(value, QUIET_MEASURE_AXES);
1828
2399
  }
1829
2400
  function isQuietMeasureMissionProbeMode(value) {
1830
- return isMember5(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2401
+ return isMember7(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1831
2402
  }
1832
2403
  function isQuietMeasureMissionResolutionShape(value) {
1833
- return isMember5(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2404
+ return isMember7(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1834
2405
  }
1835
2406
  function createQuietMeasureJudgmentEligibility(input = {}) {
1836
2407
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -2344,6 +2915,15 @@ export {
2344
2915
  AI_GAME_IDENTITY_TARGET_CATEGORIES,
2345
2916
  AI_GAME_IDENTITY_VISIBILITY_STATES,
2346
2917
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
2918
+ AI_GAME_MCC_FOCUS_PRIORITIES,
2919
+ AI_GAME_MCC_GROWTH_DIRECTIONS,
2920
+ AI_GAME_MCC_GUIDANCE_CONTRACT_VERSION,
2921
+ AI_GAME_MCC_GUIDANCE_FEATURE_FLAG_ID,
2922
+ AI_GAME_MCC_GUIDANCE_MAX_FOCUS_TARGETS,
2923
+ AI_GAME_MCC_GUIDANCE_MAX_RECOMMENDATIONS,
2924
+ AI_GAME_MCC_READINESS_BANDS,
2925
+ AI_GAME_MCC_WARNING_KINDS,
2926
+ AI_GAME_MCC_WARNING_STATES,
2347
2927
  AI_GAME_MISSIONS_CONTRACT_VERSION,
2348
2928
  AI_GAME_MISSIONS_FEATURE_FLAG_ID,
2349
2929
  AI_GAME_MISSION_CLASSES,
@@ -2388,6 +2968,14 @@ export {
2388
2968
  AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS,
2389
2969
  AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES,
2390
2970
  AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
2971
+ AI_GAME_SPELLCRAFT_AUTHORITATIVE_OWNER,
2972
+ AI_GAME_SPELLCRAFT_CHAOS_PRESSURES,
2973
+ AI_GAME_SPELLCRAFT_COMMITMENT,
2974
+ AI_GAME_SPELLCRAFT_COMPLEXITIES,
2975
+ AI_GAME_SPELLCRAFT_FATIGUE_STATES,
2976
+ AI_GAME_SPELLCRAFT_RECOMMENDATION_KINDS,
2977
+ AI_GAME_SPELLCRAFT_TARGET_MODES,
2978
+ AI_GAME_SPELLCRAFT_VERDICTS,
2391
2979
  AI_GAME_TASK_AUTHORITY_BOUNDARIES,
2392
2980
  AI_GAME_TASK_DECISIONS,
2393
2981
  AI_GAME_TASK_KINDS,
@@ -2410,6 +2998,15 @@ export {
2410
2998
  TRAINING_TECHNIQUE_MASTERY_STATES as AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES,
2411
2999
  TRAINING_TRUST_MARKER_SOURCES as AI_GAME_TRAINING_TRUST_MARKER_SOURCES,
2412
3000
  AI_GAME_TTS_CACHE_POLICIES,
3001
+ AI_GAME_TUTORIAL_COMPLETION_STATES,
3002
+ AI_GAME_TUTORIAL_CONTRACT_VERSION,
3003
+ AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
3004
+ AI_GAME_TUTORIAL_MAX_PREREQUISITES,
3005
+ AI_GAME_TUTORIAL_MAX_STEPS,
3006
+ AI_GAME_TUTORIAL_MAX_TRIGGERS,
3007
+ AI_GAME_TUTORIAL_PREREQUISITE_KINDS,
3008
+ AI_GAME_TUTORIAL_STAGES,
3009
+ AI_GAME_TUTORIAL_TRIGGER_KINDS,
2413
3010
  QUIET_MEASURE_AXES,
2414
3011
  QUIET_MEASURE_CONFIDENCE_BANDS,
2415
3012
  QUIET_MEASURE_DERIVED_READS,
@@ -2433,6 +3030,10 @@ export {
2433
3030
  createAiGameIdentityTargetProjection,
2434
3031
  createAiGameInstitutionEligibility,
2435
3032
  createAiGameMartialTrainingSnapshot,
3033
+ createAiGameMccFocusTarget,
3034
+ createAiGameMccGuidanceSnapshot,
3035
+ createAiGameMccReadinessState,
3036
+ createAiGameMccWarning,
2436
3037
  createAiGameMissionDefinition,
2437
3038
  createAiGameMissionMccFocusInfluence,
2438
3039
  createAiGameMissionObjectiveState,
@@ -2453,12 +3054,19 @@ export {
2453
3054
  createAiGamePlayerSystemPreferenceProfile,
2454
3055
  createAiGamePlayerSystemSession,
2455
3056
  createAiGameSpecializationRecommendation,
3057
+ createAiGameSpellcraftAdvisory,
3058
+ createAiGameSpellcraftRecommendation,
2456
3059
  createTrainingAcademicMissionPrerequisite as createAiGameTrainingAcademicMissionPrerequisite,
2457
3060
  createTrainingAcademyAdmission as createAiGameTrainingAcademyAdmission,
2458
3061
  createTrainingSchoolProgression as createAiGameTrainingSchoolProgression,
2459
3062
  createAiGameTrainingStateSnapshot,
2460
3063
  createTrainingTrackSelection as createAiGameTrainingTrackSelection,
2461
3064
  createAiGameTrainingTrustMarker,
3065
+ createAiGameTutorialPrerequisite,
3066
+ createAiGameTutorialProgressionState,
3067
+ createAiGameTutorialStep,
3068
+ createAiGameTutorialTrack,
3069
+ createAiGameTutorialTrigger,
2462
3070
  createQuietMeasureJudgmentEligibility,
2463
3071
  createQuietMeasureJudgmentResponse,
2464
3072
  gameEventFeatureFlags,
@@ -2470,6 +3078,11 @@ export {
2470
3078
  isAiGameIdentityProjectionRead,
2471
3079
  isAiGameIdentityTargetCategory,
2472
3080
  isAiGameIdentityVisibilityState,
3081
+ isAiGameMccFocusPriority,
3082
+ isAiGameMccGrowthDirection,
3083
+ isAiGameMccReadinessBand,
3084
+ isAiGameMccWarningKind,
3085
+ isAiGameMccWarningState,
2473
3086
  isAiGameMissionClass,
2474
3087
  isAiGameMissionConfidenceBand,
2475
3088
  isAiGameMissionFeedbackChannel,
@@ -2496,6 +3109,12 @@ export {
2496
3109
  isAiGamePlayerSystemModule,
2497
3110
  isAiGamePlayerSystemPreferenceKind,
2498
3111
  isAiGamePlayerSystemPreferenceSource,
3112
+ isAiGameSpellcraftChaosPressure,
3113
+ isAiGameSpellcraftComplexity,
3114
+ isAiGameSpellcraftFatigueState,
3115
+ isAiGameSpellcraftRecommendationKind,
3116
+ isAiGameSpellcraftTargetMode,
3117
+ isAiGameSpellcraftVerdict,
2499
3118
  isTrainingAcademicProgressStage as isAiGameTrainingAcademicProgressStage,
2500
3119
  isTrainingAcademyAdmissionDecision as isAiGameTrainingAcademyAdmissionDecision,
2501
3120
  isTrainingAntiSpellCounterWindow as isAiGameTrainingAntiSpellCounterWindow,
@@ -2509,6 +3128,10 @@ export {
2509
3128
  isAiGameTrainingStageGate,
2510
3129
  isTrainingTechniqueMasteryState as isAiGameTrainingTechniqueMasteryState,
2511
3130
  isTrainingTrustMarkerSource as isAiGameTrainingTrustMarkerSource,
3131
+ isAiGameTutorialCompletionState,
3132
+ isAiGameTutorialPrerequisiteKind,
3133
+ isAiGameTutorialStage,
3134
+ isAiGameTutorialTriggerKind,
2512
3135
  isCandidateWorldEvent,
2513
3136
  isCanonicalWorldEvent,
2514
3137
  isGossipTopicActive,