@plasius/ai-game 0.6.1 → 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
@@ -1809,6 +1809,267 @@ function createAiGameMccGuidanceSnapshot(input) {
1809
1809
  });
1810
1810
  }
1811
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
+
1812
2073
  // src/world-events.ts
1813
2074
  function isCanonicalWorldEvent(event) {
1814
2075
  return event.recordType === "canonical";
@@ -1960,7 +2221,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
1960
2221
  "private-or-low-witness-evidence",
1961
2222
  "costly-pressure-event"
1962
2223
  ];
1963
- function isMember6(value, members) {
2224
+ function isMember7(value, members) {
1964
2225
  return members.includes(value);
1965
2226
  }
1966
2227
  function assertRecord(value, label) {
@@ -2001,7 +2262,7 @@ function normalizeTimestamp(value, label) {
2001
2262
  }
2002
2263
  function normalizeMember(value, members, label) {
2003
2264
  const normalized = normalizeNonEmptyString(value, label);
2004
- if (!isMember6(normalized, members)) {
2265
+ if (!isMember7(normalized, members)) {
2005
2266
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
2006
2267
  }
2007
2268
  return normalized;
@@ -2134,13 +2395,13 @@ function normalizeDominantReads(value) {
2134
2395
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
2135
2396
  }
2136
2397
  function isQuietMeasureAxis(value) {
2137
- return isMember6(value, QUIET_MEASURE_AXES);
2398
+ return isMember7(value, QUIET_MEASURE_AXES);
2138
2399
  }
2139
2400
  function isQuietMeasureMissionProbeMode(value) {
2140
- return isMember6(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2401
+ return isMember7(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2141
2402
  }
2142
2403
  function isQuietMeasureMissionResolutionShape(value) {
2143
- return isMember6(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2404
+ return isMember7(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2144
2405
  }
2145
2406
  function createQuietMeasureJudgmentEligibility(input = {}) {
2146
2407
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -2737,6 +2998,15 @@ export {
2737
2998
  TRAINING_TECHNIQUE_MASTERY_STATES as AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES,
2738
2999
  TRAINING_TRUST_MARKER_SOURCES as AI_GAME_TRAINING_TRUST_MARKER_SOURCES,
2739
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,
2740
3010
  QUIET_MEASURE_AXES,
2741
3011
  QUIET_MEASURE_CONFIDENCE_BANDS,
2742
3012
  QUIET_MEASURE_DERIVED_READS,
@@ -2792,6 +3062,11 @@ export {
2792
3062
  createAiGameTrainingStateSnapshot,
2793
3063
  createTrainingTrackSelection as createAiGameTrainingTrackSelection,
2794
3064
  createAiGameTrainingTrustMarker,
3065
+ createAiGameTutorialPrerequisite,
3066
+ createAiGameTutorialProgressionState,
3067
+ createAiGameTutorialStep,
3068
+ createAiGameTutorialTrack,
3069
+ createAiGameTutorialTrigger,
2795
3070
  createQuietMeasureJudgmentEligibility,
2796
3071
  createQuietMeasureJudgmentResponse,
2797
3072
  gameEventFeatureFlags,
@@ -2853,6 +3128,10 @@ export {
2853
3128
  isAiGameTrainingStageGate,
2854
3129
  isTrainingTechniqueMasteryState as isAiGameTrainingTechniqueMasteryState,
2855
3130
  isTrainingTrustMarkerSource as isAiGameTrainingTrustMarkerSource,
3131
+ isAiGameTutorialCompletionState,
3132
+ isAiGameTutorialPrerequisiteKind,
3133
+ isAiGameTutorialStage,
3134
+ isAiGameTutorialTriggerKind,
2856
3135
  isCandidateWorldEvent,
2857
3136
  isCanonicalWorldEvent,
2858
3137
  isGossipTopicActive,