@plasius/ai-game 0.6.1 → 0.6.3
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/CHANGELOG.md +32 -0
- package/README.md +47 -0
- package/dist/index.cjs +580 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -1
- package/dist/index.d.ts +227 -1
- package/dist/index.js +547 -5
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0017-tutorial-contract-boundary.md +65 -0
- package/docs/adrs/adr-0018-apprenticeship-handoff-contract-boundary.md +58 -0
- package/docs/adrs/index.md +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1809,6 +1809,515 @@ 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
|
+
|
|
2073
|
+
// src/apprenticeship-handoffs.ts
|
|
2074
|
+
var AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID = "isekai.training.apprenticeship.enabled";
|
|
2075
|
+
var AI_GAME_APPRENTICESHIP_CONTRACT_VERSION = "1.0";
|
|
2076
|
+
var AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES = [
|
|
2077
|
+
"proposed",
|
|
2078
|
+
"active",
|
|
2079
|
+
"suspended",
|
|
2080
|
+
"completed",
|
|
2081
|
+
"revoked"
|
|
2082
|
+
];
|
|
2083
|
+
var AI_GAME_APPRENTICESHIP_SUPERVISION_MODES = [
|
|
2084
|
+
"direct",
|
|
2085
|
+
"delegated",
|
|
2086
|
+
"milestone"
|
|
2087
|
+
];
|
|
2088
|
+
var AI_GAME_APPRENTICESHIP_READINESS_STATES = [
|
|
2089
|
+
"ready",
|
|
2090
|
+
"needs-prerequisites",
|
|
2091
|
+
"institution-gated",
|
|
2092
|
+
"supervision-required",
|
|
2093
|
+
"blocked"
|
|
2094
|
+
];
|
|
2095
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS = [
|
|
2096
|
+
"spellcraft-system",
|
|
2097
|
+
"item-crafting-system",
|
|
2098
|
+
"dungeon-crafting-system"
|
|
2099
|
+
];
|
|
2100
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_KINDS = [
|
|
2101
|
+
"spellcraft",
|
|
2102
|
+
"item-crafting",
|
|
2103
|
+
"dungeon-crafting"
|
|
2104
|
+
];
|
|
2105
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS = [
|
|
2106
|
+
"learn",
|
|
2107
|
+
"practice",
|
|
2108
|
+
"refine",
|
|
2109
|
+
"commission"
|
|
2110
|
+
];
|
|
2111
|
+
var AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT = "request-only";
|
|
2112
|
+
var AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER = "player-system";
|
|
2113
|
+
function freezeReadonlyArray8(items) {
|
|
2114
|
+
return Object.freeze([...items]);
|
|
2115
|
+
}
|
|
2116
|
+
function assertNonEmptyString8(value, label) {
|
|
2117
|
+
if (value.trim().length === 0) {
|
|
2118
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
function assertIsoTimestamp4(value, label) {
|
|
2122
|
+
assertNonEmptyString8(value, label);
|
|
2123
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
2124
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
function assertIsoTimestampOrNull2(value, label) {
|
|
2128
|
+
if (value !== null) {
|
|
2129
|
+
assertIsoTimestamp4(value, label);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
function assertContractVersion7(value) {
|
|
2133
|
+
if (value !== AI_GAME_APPRENTICESHIP_CONTRACT_VERSION) {
|
|
2134
|
+
throw new Error(
|
|
2135
|
+
`contractVersion must be ${AI_GAME_APPRENTICESHIP_CONTRACT_VERSION}`
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function assertMember(value, values, label) {
|
|
2140
|
+
if (!values.includes(value)) {
|
|
2141
|
+
throw new Error(`${label} must be a supported apprenticeship value`);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
function createStringArray5(values, label) {
|
|
2145
|
+
values.forEach((value) => assertNonEmptyString8(value, `${label} entry`));
|
|
2146
|
+
return freezeReadonlyArray8(values);
|
|
2147
|
+
}
|
|
2148
|
+
function assertHandoffBase(input) {
|
|
2149
|
+
assertNonEmptyString8(input.handoffId, "handoffId");
|
|
2150
|
+
assertNonEmptyString8(input.requestId, "requestId");
|
|
2151
|
+
assertNonEmptyString8(input.apprenticeshipId, "apprenticeshipId");
|
|
2152
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2153
|
+
assertNonEmptyString8(input.supervisionId, "supervisionId");
|
|
2154
|
+
assertNonEmptyString8(input.readinessId, "readinessId");
|
|
2155
|
+
if (input.readinessState !== "ready") {
|
|
2156
|
+
throw new Error("readinessState must be ready for an apprenticeship handoff");
|
|
2157
|
+
}
|
|
2158
|
+
assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
|
|
2159
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2160
|
+
assertMember(
|
|
2161
|
+
input.intent,
|
|
2162
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
|
|
2163
|
+
"intent"
|
|
2164
|
+
);
|
|
2165
|
+
assertIsoTimestamp4(input.requestedAtIso, "requestedAtIso");
|
|
2166
|
+
}
|
|
2167
|
+
function isAiGameApprenticeshipReadinessState(value) {
|
|
2168
|
+
return AI_GAME_APPRENTICESHIP_READINESS_STATES.includes(value);
|
|
2169
|
+
}
|
|
2170
|
+
function createAiGameApprenticeshipSponsorship(input) {
|
|
2171
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2172
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2173
|
+
assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
|
|
2174
|
+
assertNonEmptyString8(input.sponsorSubjectId, "sponsorSubjectId");
|
|
2175
|
+
assertNonEmptyString8(input.institutionId, "institutionId");
|
|
2176
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2177
|
+
assertMember(
|
|
2178
|
+
input.status,
|
|
2179
|
+
AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
|
|
2180
|
+
"status"
|
|
2181
|
+
);
|
|
2182
|
+
assertIsoTimestamp4(input.issuedAtIso, "issuedAtIso");
|
|
2183
|
+
assertIsoTimestampOrNull2(input.expiresAtIso, "expiresAtIso");
|
|
2184
|
+
return Object.freeze({
|
|
2185
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2186
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2187
|
+
sponsorshipId: input.sponsorshipId,
|
|
2188
|
+
apprenticeSubjectId: input.apprenticeSubjectId,
|
|
2189
|
+
sponsorSubjectId: input.sponsorSubjectId,
|
|
2190
|
+
institutionId: input.institutionId,
|
|
2191
|
+
disciplineCode: input.disciplineCode,
|
|
2192
|
+
status: input.status,
|
|
2193
|
+
issuedAtIso: input.issuedAtIso,
|
|
2194
|
+
expiresAtIso: input.expiresAtIso,
|
|
2195
|
+
scopeCodes: createStringArray5(input.scopeCodes, "scopeCodes"),
|
|
2196
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
function createAiGameApprenticeshipSupervision(input) {
|
|
2200
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2201
|
+
assertNonEmptyString8(input.supervisionId, "supervisionId");
|
|
2202
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2203
|
+
assertNonEmptyString8(input.supervisorSubjectId, "supervisorSubjectId");
|
|
2204
|
+
assertMember(input.mode, AI_GAME_APPRENTICESHIP_SUPERVISION_MODES, "mode");
|
|
2205
|
+
assertIsoTimestamp4(input.startedAtIso, "startedAtIso");
|
|
2206
|
+
assertIsoTimestampOrNull2(input.endsAtIso, "endsAtIso");
|
|
2207
|
+
return Object.freeze({
|
|
2208
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2209
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2210
|
+
supervisionId: input.supervisionId,
|
|
2211
|
+
sponsorshipId: input.sponsorshipId,
|
|
2212
|
+
supervisorSubjectId: input.supervisorSubjectId,
|
|
2213
|
+
mode: input.mode,
|
|
2214
|
+
checkpointCodes: createStringArray5(input.checkpointCodes, "checkpointCodes"),
|
|
2215
|
+
startedAtIso: input.startedAtIso,
|
|
2216
|
+
endsAtIso: input.endsAtIso,
|
|
2217
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
function createAiGameApprenticeshipReadiness(input) {
|
|
2221
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2222
|
+
assertNonEmptyString8(input.readinessId, "readinessId");
|
|
2223
|
+
assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
|
|
2224
|
+
assertNonEmptyString8(input.disciplineCode, "disciplineCode");
|
|
2225
|
+
assertMember(input.state, AI_GAME_APPRENTICESHIP_READINESS_STATES, "state");
|
|
2226
|
+
if (!isTrainingTrustLevel(input.requiredTrustLevel)) {
|
|
2227
|
+
throw new Error("requiredTrustLevel must be a supported training trust level");
|
|
2228
|
+
}
|
|
2229
|
+
if (!isMccExpressionTrack(input.requiredTrack)) {
|
|
2230
|
+
throw new Error("requiredTrack must be a supported MCC expression track");
|
|
2231
|
+
}
|
|
2232
|
+
assertIsoTimestamp4(input.evaluatedAtIso, "evaluatedAtIso");
|
|
2233
|
+
if (input.state === "ready" && input.unmetPrerequisiteCodes.length > 0) {
|
|
2234
|
+
throw new Error("ready apprenticeship state cannot have unmet prerequisites");
|
|
2235
|
+
}
|
|
2236
|
+
return Object.freeze({
|
|
2237
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2238
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2239
|
+
readinessId: input.readinessId,
|
|
2240
|
+
sponsorshipId: input.sponsorshipId,
|
|
2241
|
+
disciplineCode: input.disciplineCode,
|
|
2242
|
+
state: input.state,
|
|
2243
|
+
requiredTrustLevel: input.requiredTrustLevel,
|
|
2244
|
+
requiredTrack: input.requiredTrack,
|
|
2245
|
+
supervisionRequired: input.supervisionRequired,
|
|
2246
|
+
unmetPrerequisiteCodes: createStringArray5(
|
|
2247
|
+
input.unmetPrerequisiteCodes,
|
|
2248
|
+
"unmetPrerequisiteCodes"
|
|
2249
|
+
),
|
|
2250
|
+
evaluatedAtIso: input.evaluatedAtIso,
|
|
2251
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
function createAiGameApprenticeshipHandoff(input) {
|
|
2255
|
+
assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
|
|
2256
|
+
assertHandoffBase(input);
|
|
2257
|
+
assertMember(input.kind, AI_GAME_APPRENTICESHIP_HANDOFF_KINDS, "kind");
|
|
2258
|
+
if (input.kind === "spellcraft") {
|
|
2259
|
+
if (!isMccExpressionTrack(input.requestedTrack)) {
|
|
2260
|
+
throw new Error("requestedTrack must be a supported MCC expression track");
|
|
2261
|
+
}
|
|
2262
|
+
if (input.recommendationId !== null && input.recommendationId !== void 0) {
|
|
2263
|
+
assertNonEmptyString8(input.recommendationId, "recommendationId");
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
if (input.kind === "item-crafting" && input.recipeFamilyCode !== null && input.recipeFamilyCode !== void 0) {
|
|
2267
|
+
assertNonEmptyString8(input.recipeFamilyCode, "recipeFamilyCode");
|
|
2268
|
+
}
|
|
2269
|
+
if (input.kind === "dungeon-crafting") {
|
|
2270
|
+
if (input.blueprintFamilyCode !== null && input.blueprintFamilyCode !== void 0) {
|
|
2271
|
+
assertNonEmptyString8(input.blueprintFamilyCode, "blueprintFamilyCode");
|
|
2272
|
+
}
|
|
2273
|
+
if (input.sealingObjectiveCode !== null && input.sealingObjectiveCode !== void 0) {
|
|
2274
|
+
assertNonEmptyString8(input.sealingObjectiveCode, "sealingObjectiveCode");
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
const base = {
|
|
2278
|
+
contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
2279
|
+
featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
2280
|
+
handoffId: input.handoffId,
|
|
2281
|
+
requestId: input.requestId,
|
|
2282
|
+
apprenticeshipId: input.apprenticeshipId,
|
|
2283
|
+
sponsorshipId: input.sponsorshipId,
|
|
2284
|
+
supervisionId: input.supervisionId,
|
|
2285
|
+
readinessId: input.readinessId,
|
|
2286
|
+
readinessState: input.readinessState,
|
|
2287
|
+
apprenticeSubjectId: input.apprenticeSubjectId,
|
|
2288
|
+
disciplineCode: input.disciplineCode,
|
|
2289
|
+
intent: input.intent,
|
|
2290
|
+
requestedAtIso: input.requestedAtIso,
|
|
2291
|
+
commitment: AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
|
|
2292
|
+
guidanceOwner: AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
|
|
2293
|
+
reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
|
|
2294
|
+
};
|
|
2295
|
+
if (input.kind === "spellcraft") {
|
|
2296
|
+
return Object.freeze({
|
|
2297
|
+
...base,
|
|
2298
|
+
kind: input.kind,
|
|
2299
|
+
targetSystem: "spellcraft-system",
|
|
2300
|
+
recommendationId: input.recommendationId ?? null,
|
|
2301
|
+
requestedTrack: input.requestedTrack
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
if (input.kind === "item-crafting") {
|
|
2305
|
+
return Object.freeze({
|
|
2306
|
+
...base,
|
|
2307
|
+
kind: input.kind,
|
|
2308
|
+
targetSystem: "item-crafting-system",
|
|
2309
|
+
recipeFamilyCode: input.recipeFamilyCode ?? null
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
return Object.freeze({
|
|
2313
|
+
...base,
|
|
2314
|
+
kind: input.kind,
|
|
2315
|
+
targetSystem: "dungeon-crafting-system",
|
|
2316
|
+
blueprintFamilyCode: input.blueprintFamilyCode ?? null,
|
|
2317
|
+
sealingObjectiveCode: input.sealingObjectiveCode ?? null
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
|
|
1812
2321
|
// src/world-events.ts
|
|
1813
2322
|
function isCanonicalWorldEvent(event) {
|
|
1814
2323
|
return event.recordType === "canonical";
|
|
@@ -1960,7 +2469,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
1960
2469
|
"private-or-low-witness-evidence",
|
|
1961
2470
|
"costly-pressure-event"
|
|
1962
2471
|
];
|
|
1963
|
-
function
|
|
2472
|
+
function isMember7(value, members) {
|
|
1964
2473
|
return members.includes(value);
|
|
1965
2474
|
}
|
|
1966
2475
|
function assertRecord(value, label) {
|
|
@@ -2001,7 +2510,7 @@ function normalizeTimestamp(value, label) {
|
|
|
2001
2510
|
}
|
|
2002
2511
|
function normalizeMember(value, members, label) {
|
|
2003
2512
|
const normalized = normalizeNonEmptyString(value, label);
|
|
2004
|
-
if (!
|
|
2513
|
+
if (!isMember7(normalized, members)) {
|
|
2005
2514
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
2006
2515
|
}
|
|
2007
2516
|
return normalized;
|
|
@@ -2134,13 +2643,13 @@ function normalizeDominantReads(value) {
|
|
|
2134
2643
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
2135
2644
|
}
|
|
2136
2645
|
function isQuietMeasureAxis(value) {
|
|
2137
|
-
return
|
|
2646
|
+
return isMember7(value, QUIET_MEASURE_AXES);
|
|
2138
2647
|
}
|
|
2139
2648
|
function isQuietMeasureMissionProbeMode(value) {
|
|
2140
|
-
return
|
|
2649
|
+
return isMember7(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
2141
2650
|
}
|
|
2142
2651
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
2143
|
-
return
|
|
2652
|
+
return isMember7(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
2144
2653
|
}
|
|
2145
2654
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
2146
2655
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -2638,6 +3147,16 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2638
3147
|
]);
|
|
2639
3148
|
export {
|
|
2640
3149
|
AI_GAME_ACTOR_ROLES,
|
|
3150
|
+
AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
|
|
3151
|
+
AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
|
|
3152
|
+
AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
|
|
3153
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
|
|
3154
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
|
|
3155
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_KINDS,
|
|
3156
|
+
AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS,
|
|
3157
|
+
AI_GAME_APPRENTICESHIP_READINESS_STATES,
|
|
3158
|
+
AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
|
|
3159
|
+
AI_GAME_APPRENTICESHIP_SUPERVISION_MODES,
|
|
2641
3160
|
AI_GAME_ENV_PREFIX,
|
|
2642
3161
|
AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,
|
|
2643
3162
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
@@ -2737,6 +3256,15 @@ export {
|
|
|
2737
3256
|
TRAINING_TECHNIQUE_MASTERY_STATES as AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES,
|
|
2738
3257
|
TRAINING_TRUST_MARKER_SOURCES as AI_GAME_TRAINING_TRUST_MARKER_SOURCES,
|
|
2739
3258
|
AI_GAME_TTS_CACHE_POLICIES,
|
|
3259
|
+
AI_GAME_TUTORIAL_COMPLETION_STATES,
|
|
3260
|
+
AI_GAME_TUTORIAL_CONTRACT_VERSION,
|
|
3261
|
+
AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
|
|
3262
|
+
AI_GAME_TUTORIAL_MAX_PREREQUISITES,
|
|
3263
|
+
AI_GAME_TUTORIAL_MAX_STEPS,
|
|
3264
|
+
AI_GAME_TUTORIAL_MAX_TRIGGERS,
|
|
3265
|
+
AI_GAME_TUTORIAL_PREREQUISITE_KINDS,
|
|
3266
|
+
AI_GAME_TUTORIAL_STAGES,
|
|
3267
|
+
AI_GAME_TUTORIAL_TRIGGER_KINDS,
|
|
2740
3268
|
QUIET_MEASURE_AXES,
|
|
2741
3269
|
QUIET_MEASURE_CONFIDENCE_BANDS,
|
|
2742
3270
|
QUIET_MEASURE_DERIVED_READS,
|
|
@@ -2754,6 +3282,10 @@ export {
|
|
|
2754
3282
|
assertAiGameObservedEventLogContractVersion,
|
|
2755
3283
|
classifyAiGameTask,
|
|
2756
3284
|
createAiGameAcademicTrainingSnapshot,
|
|
3285
|
+
createAiGameApprenticeshipHandoff,
|
|
3286
|
+
createAiGameApprenticeshipReadiness,
|
|
3287
|
+
createAiGameApprenticeshipSponsorship,
|
|
3288
|
+
createAiGameApprenticeshipSupervision,
|
|
2757
3289
|
createAiGameGossipExport,
|
|
2758
3290
|
createAiGameIdentityProjectionContract,
|
|
2759
3291
|
createAiGameIdentitySelfProjection,
|
|
@@ -2792,12 +3324,18 @@ export {
|
|
|
2792
3324
|
createAiGameTrainingStateSnapshot,
|
|
2793
3325
|
createTrainingTrackSelection as createAiGameTrainingTrackSelection,
|
|
2794
3326
|
createAiGameTrainingTrustMarker,
|
|
3327
|
+
createAiGameTutorialPrerequisite,
|
|
3328
|
+
createAiGameTutorialProgressionState,
|
|
3329
|
+
createAiGameTutorialStep,
|
|
3330
|
+
createAiGameTutorialTrack,
|
|
3331
|
+
createAiGameTutorialTrigger,
|
|
2795
3332
|
createQuietMeasureJudgmentEligibility,
|
|
2796
3333
|
createQuietMeasureJudgmentResponse,
|
|
2797
3334
|
gameEventFeatureFlags,
|
|
2798
3335
|
getAiGamePlayerSystemFocusModeContract,
|
|
2799
3336
|
getAiGamePlayerSystemGuidanceFallbackContract,
|
|
2800
3337
|
getAiGamePlayerSystemModuleContract,
|
|
3338
|
+
isAiGameApprenticeshipReadinessState,
|
|
2801
3339
|
isAiGameGossipExportAudience,
|
|
2802
3340
|
isAiGameIdentityKnowledgeState,
|
|
2803
3341
|
isAiGameIdentityProjectionRead,
|
|
@@ -2853,6 +3391,10 @@ export {
|
|
|
2853
3391
|
isAiGameTrainingStageGate,
|
|
2854
3392
|
isTrainingTechniqueMasteryState as isAiGameTrainingTechniqueMasteryState,
|
|
2855
3393
|
isTrainingTrustMarkerSource as isAiGameTrainingTrustMarkerSource,
|
|
3394
|
+
isAiGameTutorialCompletionState,
|
|
3395
|
+
isAiGameTutorialPrerequisiteKind,
|
|
3396
|
+
isAiGameTutorialStage,
|
|
3397
|
+
isAiGameTutorialTriggerKind,
|
|
2856
3398
|
isCandidateWorldEvent,
|
|
2857
3399
|
isCanonicalWorldEvent,
|
|
2858
3400
|
isGossipTopicActive,
|