@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/dist/index.cjs CHANGED
@@ -21,6 +21,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AI_GAME_ACTOR_ROLES: () => AI_GAME_ACTOR_ROLES,
24
+ AI_GAME_APPRENTICESHIP_CONTRACT_VERSION: () => AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
25
+ AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID: () => AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
26
+ AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER: () => AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
27
+ AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT: () => AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
28
+ AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS: () => AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
29
+ AI_GAME_APPRENTICESHIP_HANDOFF_KINDS: () => AI_GAME_APPRENTICESHIP_HANDOFF_KINDS,
30
+ AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS: () => AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS,
31
+ AI_GAME_APPRENTICESHIP_READINESS_STATES: () => AI_GAME_APPRENTICESHIP_READINESS_STATES,
32
+ AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES: () => AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
33
+ AI_GAME_APPRENTICESHIP_SUPERVISION_MODES: () => AI_GAME_APPRENTICESHIP_SUPERVISION_MODES,
24
34
  AI_GAME_ENV_PREFIX: () => AI_GAME_ENV_PREFIX,
25
35
  AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID: () => AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,
26
36
  AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID: () => AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
@@ -120,6 +130,15 @@ __export(index_exports, {
120
130
  AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES: () => import_training.TRAINING_TECHNIQUE_MASTERY_STATES,
121
131
  AI_GAME_TRAINING_TRUST_MARKER_SOURCES: () => import_training.TRAINING_TRUST_MARKER_SOURCES,
122
132
  AI_GAME_TTS_CACHE_POLICIES: () => AI_GAME_TTS_CACHE_POLICIES,
133
+ AI_GAME_TUTORIAL_COMPLETION_STATES: () => AI_GAME_TUTORIAL_COMPLETION_STATES,
134
+ AI_GAME_TUTORIAL_CONTRACT_VERSION: () => AI_GAME_TUTORIAL_CONTRACT_VERSION,
135
+ AI_GAME_TUTORIAL_FEATURE_FLAG_ID: () => AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
136
+ AI_GAME_TUTORIAL_MAX_PREREQUISITES: () => AI_GAME_TUTORIAL_MAX_PREREQUISITES,
137
+ AI_GAME_TUTORIAL_MAX_STEPS: () => AI_GAME_TUTORIAL_MAX_STEPS,
138
+ AI_GAME_TUTORIAL_MAX_TRIGGERS: () => AI_GAME_TUTORIAL_MAX_TRIGGERS,
139
+ AI_GAME_TUTORIAL_PREREQUISITE_KINDS: () => AI_GAME_TUTORIAL_PREREQUISITE_KINDS,
140
+ AI_GAME_TUTORIAL_STAGES: () => AI_GAME_TUTORIAL_STAGES,
141
+ AI_GAME_TUTORIAL_TRIGGER_KINDS: () => AI_GAME_TUTORIAL_TRIGGER_KINDS,
123
142
  QUIET_MEASURE_AXES: () => QUIET_MEASURE_AXES,
124
143
  QUIET_MEASURE_CONFIDENCE_BANDS: () => QUIET_MEASURE_CONFIDENCE_BANDS,
125
144
  QUIET_MEASURE_DERIVED_READS: () => QUIET_MEASURE_DERIVED_READS,
@@ -137,6 +156,10 @@ __export(index_exports, {
137
156
  assertAiGameObservedEventLogContractVersion: () => assertAiGameObservedEventLogContractVersion,
138
157
  classifyAiGameTask: () => classifyAiGameTask,
139
158
  createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
159
+ createAiGameApprenticeshipHandoff: () => createAiGameApprenticeshipHandoff,
160
+ createAiGameApprenticeshipReadiness: () => createAiGameApprenticeshipReadiness,
161
+ createAiGameApprenticeshipSponsorship: () => createAiGameApprenticeshipSponsorship,
162
+ createAiGameApprenticeshipSupervision: () => createAiGameApprenticeshipSupervision,
140
163
  createAiGameGossipExport: () => createAiGameGossipExport,
141
164
  createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
142
165
  createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
@@ -175,12 +198,18 @@ __export(index_exports, {
175
198
  createAiGameTrainingStateSnapshot: () => createAiGameTrainingStateSnapshot,
176
199
  createAiGameTrainingTrackSelection: () => import_training.createTrainingTrackSelection,
177
200
  createAiGameTrainingTrustMarker: () => createAiGameTrainingTrustMarker,
201
+ createAiGameTutorialPrerequisite: () => createAiGameTutorialPrerequisite,
202
+ createAiGameTutorialProgressionState: () => createAiGameTutorialProgressionState,
203
+ createAiGameTutorialStep: () => createAiGameTutorialStep,
204
+ createAiGameTutorialTrack: () => createAiGameTutorialTrack,
205
+ createAiGameTutorialTrigger: () => createAiGameTutorialTrigger,
178
206
  createQuietMeasureJudgmentEligibility: () => createQuietMeasureJudgmentEligibility,
179
207
  createQuietMeasureJudgmentResponse: () => createQuietMeasureJudgmentResponse,
180
208
  gameEventFeatureFlags: () => gameEventFeatureFlags,
181
209
  getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
182
210
  getAiGamePlayerSystemGuidanceFallbackContract: () => getAiGamePlayerSystemGuidanceFallbackContract,
183
211
  getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
212
+ isAiGameApprenticeshipReadinessState: () => isAiGameApprenticeshipReadinessState,
184
213
  isAiGameGossipExportAudience: () => isAiGameGossipExportAudience,
185
214
  isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
186
215
  isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
@@ -236,6 +265,10 @@ __export(index_exports, {
236
265
  isAiGameTrainingStageGate: () => isAiGameTrainingStageGate,
237
266
  isAiGameTrainingTechniqueMasteryState: () => import_training.isTrainingTechniqueMasteryState,
238
267
  isAiGameTrainingTrustMarkerSource: () => import_training.isTrainingTrustMarkerSource,
268
+ isAiGameTutorialCompletionState: () => isAiGameTutorialCompletionState,
269
+ isAiGameTutorialPrerequisiteKind: () => isAiGameTutorialPrerequisiteKind,
270
+ isAiGameTutorialStage: () => isAiGameTutorialStage,
271
+ isAiGameTutorialTriggerKind: () => isAiGameTutorialTriggerKind,
239
272
  isCandidateWorldEvent: () => isCandidateWorldEvent,
240
273
  isCanonicalWorldEvent: () => isCanonicalWorldEvent,
241
274
  isGossipTopicActive: () => isGossipTopicActive,
@@ -2034,6 +2067,515 @@ function createAiGameMccGuidanceSnapshot(input) {
2034
2067
  });
2035
2068
  }
2036
2069
 
2070
+ // src/tutorial.ts
2071
+ var AI_GAME_TUTORIAL_FEATURE_FLAG_ID = "isekai.player-system.tutorial.enabled";
2072
+ var AI_GAME_TUTORIAL_CONTRACT_VERSION = "1.0";
2073
+ var AI_GAME_TUTORIAL_STAGES = [
2074
+ "stage-1",
2075
+ "stage-2",
2076
+ "stage-3",
2077
+ "stage-4",
2078
+ "stage-5"
2079
+ ];
2080
+ var AI_GAME_TUTORIAL_TRIGGER_KINDS = [
2081
+ "awakening",
2082
+ "first-action",
2083
+ "explicit-request",
2084
+ "progression-gated"
2085
+ ];
2086
+ var AI_GAME_TUTORIAL_PREREQUISITE_KINDS = [
2087
+ "school-access",
2088
+ "apprenticeship",
2089
+ "academy-admission",
2090
+ "guild-standing",
2091
+ "divine-progression",
2092
+ "spellcraft-readiness"
2093
+ ];
2094
+ var AI_GAME_TUTORIAL_COMPLETION_STATES = [
2095
+ "not-started",
2096
+ "active",
2097
+ "dormant",
2098
+ "completed",
2099
+ "declined"
2100
+ ];
2101
+ var AI_GAME_TUTORIAL_MAX_STEPS = 20;
2102
+ var AI_GAME_TUTORIAL_MAX_PREREQUISITES = 12;
2103
+ var AI_GAME_TUTORIAL_MAX_TRIGGERS = 8;
2104
+ function freezeReadonlyArray7(items) {
2105
+ return Object.freeze([...items]);
2106
+ }
2107
+ function createStringArray4(values, label) {
2108
+ const normalized = values ?? [];
2109
+ normalized.forEach((value) => assertNonEmptyString7(value, `${label} entry`));
2110
+ return freezeReadonlyArray7(normalized);
2111
+ }
2112
+ function assertNonEmptyString7(value, label) {
2113
+ if (value.trim().length === 0) {
2114
+ throw new Error(`${label} must be a non-empty string`);
2115
+ }
2116
+ }
2117
+ function assertContractVersion6(value) {
2118
+ if (value !== AI_GAME_TUTORIAL_CONTRACT_VERSION) {
2119
+ throw new Error(`contractVersion must be ${AI_GAME_TUTORIAL_CONTRACT_VERSION}`);
2120
+ }
2121
+ }
2122
+ function assertPositiveInteger2(value, label) {
2123
+ if (!Number.isInteger(value) || value <= 0) {
2124
+ throw new Error(`${label} must be a positive integer`);
2125
+ }
2126
+ }
2127
+ function assertNonNegativeInteger3(value, label) {
2128
+ if (!Number.isInteger(value) || value < 0) {
2129
+ throw new Error(`${label} must be a non-negative integer`);
2130
+ }
2131
+ }
2132
+ function assertIsoTimestampOrNull(value, label) {
2133
+ if (value !== null && Number.isNaN(Date.parse(value))) {
2134
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
2135
+ }
2136
+ }
2137
+ function isMember6(value, members) {
2138
+ return members.includes(value);
2139
+ }
2140
+ function assertUniqueIds2(values, label) {
2141
+ if (new Set(values).size !== values.length) {
2142
+ throw new Error(`${label} must have unique IDs`);
2143
+ }
2144
+ }
2145
+ function isAiGameTutorialStage(value) {
2146
+ return isMember6(value, AI_GAME_TUTORIAL_STAGES);
2147
+ }
2148
+ function isAiGameTutorialTriggerKind(value) {
2149
+ return isMember6(value, AI_GAME_TUTORIAL_TRIGGER_KINDS);
2150
+ }
2151
+ function isAiGameTutorialPrerequisiteKind(value) {
2152
+ return isMember6(value, AI_GAME_TUTORIAL_PREREQUISITE_KINDS);
2153
+ }
2154
+ function isAiGameTutorialCompletionState(value) {
2155
+ return isMember6(value, AI_GAME_TUTORIAL_COMPLETION_STATES);
2156
+ }
2157
+ function createAiGameTutorialPrerequisite(input) {
2158
+ assertNonEmptyString7(input.markerId, "markerId");
2159
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2160
+ if (!isAiGameTutorialPrerequisiteKind(input.kind)) {
2161
+ throw new Error("kind must be a supported tutorial prerequisite kind");
2162
+ }
2163
+ assertNonEmptyString7(input.label, "label");
2164
+ return Object.freeze({
2165
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2166
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2167
+ markerId: input.markerId,
2168
+ kind: input.kind,
2169
+ label: input.label,
2170
+ satisfied: input.satisfied,
2171
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2172
+ });
2173
+ }
2174
+ function createAiGameTutorialTrigger(input) {
2175
+ assertNonEmptyString7(input.triggerId, "triggerId");
2176
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2177
+ if (!isAiGameTutorialTriggerKind(input.kind)) {
2178
+ throw new Error("kind must be a supported tutorial trigger kind");
2179
+ }
2180
+ assertNonEmptyString7(input.capabilityCode, "capabilityCode");
2181
+ return Object.freeze({
2182
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2183
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2184
+ triggerId: input.triggerId,
2185
+ kind: input.kind,
2186
+ capabilityCode: input.capabilityCode,
2187
+ firstUseOnly: input.firstUseOnly,
2188
+ safeInCombat: input.safeInCombat,
2189
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2190
+ });
2191
+ }
2192
+ function createAiGameTutorialStep(input) {
2193
+ assertNonEmptyString7(input.stepId, "stepId");
2194
+ assertNonEmptyString7(input.trackId, "trackId");
2195
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2196
+ if (!isAiGameTutorialStage(input.stage)) {
2197
+ throw new Error("stage must be a supported tutorial stage");
2198
+ }
2199
+ assertPositiveInteger2(input.sequence, "sequence");
2200
+ assertNonEmptyString7(input.title, "title");
2201
+ assertNonEmptyString7(input.summary, "summary");
2202
+ assertNonEmptyString7(input.capabilityCode, "capabilityCode");
2203
+ if (input.triggerKinds.length === 0) {
2204
+ throw new Error("triggerKinds must contain at least one trigger kind");
2205
+ }
2206
+ input.triggerKinds.forEach((kind) => {
2207
+ if (!isAiGameTutorialTriggerKind(kind)) {
2208
+ throw new Error("triggerKinds must use supported tutorial trigger kinds");
2209
+ }
2210
+ });
2211
+ return Object.freeze({
2212
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2213
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2214
+ stepId: input.stepId,
2215
+ trackId: input.trackId,
2216
+ stage: input.stage,
2217
+ sequence: input.sequence,
2218
+ title: input.title,
2219
+ summary: input.summary,
2220
+ capabilityCode: input.capabilityCode,
2221
+ triggerKinds: freezeReadonlyArray7(input.triggerKinds),
2222
+ prerequisiteIds: createStringArray4(input.prerequisiteIds, "prerequisiteIds"),
2223
+ safeInCombat: input.safeInCombat,
2224
+ replayable: input.replayable,
2225
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2226
+ });
2227
+ }
2228
+ function createAiGameTutorialProgressionState(input) {
2229
+ assertNonEmptyString7(input.trackId, "trackId");
2230
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2231
+ if (!isAiGameTutorialCompletionState(input.status)) {
2232
+ throw new Error("status must be a supported tutorial completion state");
2233
+ }
2234
+ if (input.currentStepId !== null) {
2235
+ assertNonEmptyString7(input.currentStepId, "currentStepId");
2236
+ }
2237
+ const completedStepIds = createStringArray4(input.completedStepIds, "completedStepIds");
2238
+ assertUniqueIds2(completedStepIds, "completedStepIds");
2239
+ assertNonNegativeInteger3(input.refusalCount, "refusalCount");
2240
+ assertNonNegativeInteger3(input.replayCount, "replayCount");
2241
+ assertIsoTimestampOrNull(input.lastTriggeredAtIso, "lastTriggeredAtIso");
2242
+ assertIsoTimestampOrNull(input.lastReplayedAtIso, "lastReplayedAtIso");
2243
+ if (input.status === "completed" && input.currentStepId !== null) {
2244
+ throw new Error("completed tutorials cannot have a currentStepId");
2245
+ }
2246
+ return Object.freeze({
2247
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2248
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2249
+ trackId: input.trackId,
2250
+ status: input.status,
2251
+ currentStepId: input.currentStepId,
2252
+ completedStepIds,
2253
+ refusalCount: input.refusalCount,
2254
+ replayCount: input.replayCount,
2255
+ replayable: input.replayable,
2256
+ lastTriggeredAtIso: input.lastTriggeredAtIso,
2257
+ lastReplayedAtIso: input.lastReplayedAtIso,
2258
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2259
+ });
2260
+ }
2261
+ function createAiGameTutorialTrack(input) {
2262
+ assertNonEmptyString7(input.trackId, "trackId");
2263
+ assertContractVersion6(input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION);
2264
+ assertNonEmptyString7(input.title, "title");
2265
+ assertNonEmptyString7(input.summary, "summary");
2266
+ if (input.steps.length === 0 || input.steps.length > AI_GAME_TUTORIAL_MAX_STEPS) {
2267
+ throw new Error(
2268
+ `steps must contain between 1 and ${AI_GAME_TUTORIAL_MAX_STEPS} steps`
2269
+ );
2270
+ }
2271
+ if (input.prerequisites.length > AI_GAME_TUTORIAL_MAX_PREREQUISITES) {
2272
+ throw new Error(
2273
+ `prerequisites cannot contain more than ${AI_GAME_TUTORIAL_MAX_PREREQUISITES} markers`
2274
+ );
2275
+ }
2276
+ if (input.triggers.length === 0 || input.triggers.length > AI_GAME_TUTORIAL_MAX_TRIGGERS) {
2277
+ throw new Error(
2278
+ `triggers must contain between 1 and ${AI_GAME_TUTORIAL_MAX_TRIGGERS} triggers`
2279
+ );
2280
+ }
2281
+ const steps = freezeReadonlyArray7(
2282
+ input.steps.map((step) => createAiGameTutorialStep(step))
2283
+ );
2284
+ const prerequisites = freezeReadonlyArray7(
2285
+ input.prerequisites.map((marker) => createAiGameTutorialPrerequisite(marker))
2286
+ );
2287
+ const triggers = freezeReadonlyArray7(
2288
+ input.triggers.map((trigger) => createAiGameTutorialTrigger(trigger))
2289
+ );
2290
+ const progression = createAiGameTutorialProgressionState(input.progression);
2291
+ assertUniqueIds2(steps.map((step) => step.stepId), "steps");
2292
+ assertUniqueIds2(prerequisites.map((marker) => marker.markerId), "prerequisites");
2293
+ assertUniqueIds2(triggers.map((trigger) => trigger.triggerId), "triggers");
2294
+ if (progression.trackId !== input.trackId) {
2295
+ throw new Error("progression trackId must match the tutorial track");
2296
+ }
2297
+ const stepIds = new Set(steps.map((step) => step.stepId));
2298
+ const prerequisiteIds = new Set(prerequisites.map((marker) => marker.markerId));
2299
+ const triggerKinds = new Set(triggers.map((trigger) => trigger.kind));
2300
+ if (progression.currentStepId !== null && !stepIds.has(progression.currentStepId)) {
2301
+ throw new Error("currentStepId must reference a supplied tutorial step");
2302
+ }
2303
+ if (progression.completedStepIds.some((stepId) => !stepIds.has(stepId))) {
2304
+ throw new Error("completedStepIds must reference supplied tutorial steps");
2305
+ }
2306
+ steps.forEach((step) => {
2307
+ if (step.trackId !== input.trackId) {
2308
+ throw new Error("step trackId must match the tutorial track");
2309
+ }
2310
+ if (step.prerequisiteIds.some((markerId) => !prerequisiteIds.has(markerId))) {
2311
+ throw new Error("prerequisiteIds must reference supplied prerequisites");
2312
+ }
2313
+ if (step.triggerKinds.some((kind) => !triggerKinds.has(kind))) {
2314
+ throw new Error("triggerKinds must reference supplied triggers");
2315
+ }
2316
+ });
2317
+ return Object.freeze({
2318
+ contractVersion: input.contractVersion ?? AI_GAME_TUTORIAL_CONTRACT_VERSION,
2319
+ featureFlagId: AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
2320
+ trackId: input.trackId,
2321
+ title: input.title,
2322
+ summary: input.summary,
2323
+ steps,
2324
+ prerequisites,
2325
+ triggers,
2326
+ progression,
2327
+ reasonCodes: createStringArray4(input.reasonCodes, "reasonCodes")
2328
+ });
2329
+ }
2330
+
2331
+ // src/apprenticeship-handoffs.ts
2332
+ var AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID = "isekai.training.apprenticeship.enabled";
2333
+ var AI_GAME_APPRENTICESHIP_CONTRACT_VERSION = "1.0";
2334
+ var AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES = [
2335
+ "proposed",
2336
+ "active",
2337
+ "suspended",
2338
+ "completed",
2339
+ "revoked"
2340
+ ];
2341
+ var AI_GAME_APPRENTICESHIP_SUPERVISION_MODES = [
2342
+ "direct",
2343
+ "delegated",
2344
+ "milestone"
2345
+ ];
2346
+ var AI_GAME_APPRENTICESHIP_READINESS_STATES = [
2347
+ "ready",
2348
+ "needs-prerequisites",
2349
+ "institution-gated",
2350
+ "supervision-required",
2351
+ "blocked"
2352
+ ];
2353
+ var AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS = [
2354
+ "spellcraft-system",
2355
+ "item-crafting-system",
2356
+ "dungeon-crafting-system"
2357
+ ];
2358
+ var AI_GAME_APPRENTICESHIP_HANDOFF_KINDS = [
2359
+ "spellcraft",
2360
+ "item-crafting",
2361
+ "dungeon-crafting"
2362
+ ];
2363
+ var AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS = [
2364
+ "learn",
2365
+ "practice",
2366
+ "refine",
2367
+ "commission"
2368
+ ];
2369
+ var AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT = "request-only";
2370
+ var AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER = "player-system";
2371
+ function freezeReadonlyArray8(items) {
2372
+ return Object.freeze([...items]);
2373
+ }
2374
+ function assertNonEmptyString8(value, label) {
2375
+ if (value.trim().length === 0) {
2376
+ throw new Error(`${label} must be a non-empty string`);
2377
+ }
2378
+ }
2379
+ function assertIsoTimestamp4(value, label) {
2380
+ assertNonEmptyString8(value, label);
2381
+ if (Number.isNaN(Date.parse(value))) {
2382
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
2383
+ }
2384
+ }
2385
+ function assertIsoTimestampOrNull2(value, label) {
2386
+ if (value !== null) {
2387
+ assertIsoTimestamp4(value, label);
2388
+ }
2389
+ }
2390
+ function assertContractVersion7(value) {
2391
+ if (value !== AI_GAME_APPRENTICESHIP_CONTRACT_VERSION) {
2392
+ throw new Error(
2393
+ `contractVersion must be ${AI_GAME_APPRENTICESHIP_CONTRACT_VERSION}`
2394
+ );
2395
+ }
2396
+ }
2397
+ function assertMember(value, values, label) {
2398
+ if (!values.includes(value)) {
2399
+ throw new Error(`${label} must be a supported apprenticeship value`);
2400
+ }
2401
+ }
2402
+ function createStringArray5(values, label) {
2403
+ values.forEach((value) => assertNonEmptyString8(value, `${label} entry`));
2404
+ return freezeReadonlyArray8(values);
2405
+ }
2406
+ function assertHandoffBase(input) {
2407
+ assertNonEmptyString8(input.handoffId, "handoffId");
2408
+ assertNonEmptyString8(input.requestId, "requestId");
2409
+ assertNonEmptyString8(input.apprenticeshipId, "apprenticeshipId");
2410
+ assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
2411
+ assertNonEmptyString8(input.supervisionId, "supervisionId");
2412
+ assertNonEmptyString8(input.readinessId, "readinessId");
2413
+ if (input.readinessState !== "ready") {
2414
+ throw new Error("readinessState must be ready for an apprenticeship handoff");
2415
+ }
2416
+ assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
2417
+ assertNonEmptyString8(input.disciplineCode, "disciplineCode");
2418
+ assertMember(
2419
+ input.intent,
2420
+ AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
2421
+ "intent"
2422
+ );
2423
+ assertIsoTimestamp4(input.requestedAtIso, "requestedAtIso");
2424
+ }
2425
+ function isAiGameApprenticeshipReadinessState(value) {
2426
+ return AI_GAME_APPRENTICESHIP_READINESS_STATES.includes(value);
2427
+ }
2428
+ function createAiGameApprenticeshipSponsorship(input) {
2429
+ assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
2430
+ assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
2431
+ assertNonEmptyString8(input.apprenticeSubjectId, "apprenticeSubjectId");
2432
+ assertNonEmptyString8(input.sponsorSubjectId, "sponsorSubjectId");
2433
+ assertNonEmptyString8(input.institutionId, "institutionId");
2434
+ assertNonEmptyString8(input.disciplineCode, "disciplineCode");
2435
+ assertMember(
2436
+ input.status,
2437
+ AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
2438
+ "status"
2439
+ );
2440
+ assertIsoTimestamp4(input.issuedAtIso, "issuedAtIso");
2441
+ assertIsoTimestampOrNull2(input.expiresAtIso, "expiresAtIso");
2442
+ return Object.freeze({
2443
+ contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
2444
+ featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
2445
+ sponsorshipId: input.sponsorshipId,
2446
+ apprenticeSubjectId: input.apprenticeSubjectId,
2447
+ sponsorSubjectId: input.sponsorSubjectId,
2448
+ institutionId: input.institutionId,
2449
+ disciplineCode: input.disciplineCode,
2450
+ status: input.status,
2451
+ issuedAtIso: input.issuedAtIso,
2452
+ expiresAtIso: input.expiresAtIso,
2453
+ scopeCodes: createStringArray5(input.scopeCodes, "scopeCodes"),
2454
+ reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
2455
+ });
2456
+ }
2457
+ function createAiGameApprenticeshipSupervision(input) {
2458
+ assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
2459
+ assertNonEmptyString8(input.supervisionId, "supervisionId");
2460
+ assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
2461
+ assertNonEmptyString8(input.supervisorSubjectId, "supervisorSubjectId");
2462
+ assertMember(input.mode, AI_GAME_APPRENTICESHIP_SUPERVISION_MODES, "mode");
2463
+ assertIsoTimestamp4(input.startedAtIso, "startedAtIso");
2464
+ assertIsoTimestampOrNull2(input.endsAtIso, "endsAtIso");
2465
+ return Object.freeze({
2466
+ contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
2467
+ featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
2468
+ supervisionId: input.supervisionId,
2469
+ sponsorshipId: input.sponsorshipId,
2470
+ supervisorSubjectId: input.supervisorSubjectId,
2471
+ mode: input.mode,
2472
+ checkpointCodes: createStringArray5(input.checkpointCodes, "checkpointCodes"),
2473
+ startedAtIso: input.startedAtIso,
2474
+ endsAtIso: input.endsAtIso,
2475
+ reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
2476
+ });
2477
+ }
2478
+ function createAiGameApprenticeshipReadiness(input) {
2479
+ assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
2480
+ assertNonEmptyString8(input.readinessId, "readinessId");
2481
+ assertNonEmptyString8(input.sponsorshipId, "sponsorshipId");
2482
+ assertNonEmptyString8(input.disciplineCode, "disciplineCode");
2483
+ assertMember(input.state, AI_GAME_APPRENTICESHIP_READINESS_STATES, "state");
2484
+ if (!(0, import_training.isTrainingTrustLevel)(input.requiredTrustLevel)) {
2485
+ throw new Error("requiredTrustLevel must be a supported training trust level");
2486
+ }
2487
+ if (!(0, import_training.isMccExpressionTrack)(input.requiredTrack)) {
2488
+ throw new Error("requiredTrack must be a supported MCC expression track");
2489
+ }
2490
+ assertIsoTimestamp4(input.evaluatedAtIso, "evaluatedAtIso");
2491
+ if (input.state === "ready" && input.unmetPrerequisiteCodes.length > 0) {
2492
+ throw new Error("ready apprenticeship state cannot have unmet prerequisites");
2493
+ }
2494
+ return Object.freeze({
2495
+ contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
2496
+ featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
2497
+ readinessId: input.readinessId,
2498
+ sponsorshipId: input.sponsorshipId,
2499
+ disciplineCode: input.disciplineCode,
2500
+ state: input.state,
2501
+ requiredTrustLevel: input.requiredTrustLevel,
2502
+ requiredTrack: input.requiredTrack,
2503
+ supervisionRequired: input.supervisionRequired,
2504
+ unmetPrerequisiteCodes: createStringArray5(
2505
+ input.unmetPrerequisiteCodes,
2506
+ "unmetPrerequisiteCodes"
2507
+ ),
2508
+ evaluatedAtIso: input.evaluatedAtIso,
2509
+ reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
2510
+ });
2511
+ }
2512
+ function createAiGameApprenticeshipHandoff(input) {
2513
+ assertContractVersion7(input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION);
2514
+ assertHandoffBase(input);
2515
+ assertMember(input.kind, AI_GAME_APPRENTICESHIP_HANDOFF_KINDS, "kind");
2516
+ if (input.kind === "spellcraft") {
2517
+ if (!(0, import_training.isMccExpressionTrack)(input.requestedTrack)) {
2518
+ throw new Error("requestedTrack must be a supported MCC expression track");
2519
+ }
2520
+ if (input.recommendationId !== null && input.recommendationId !== void 0) {
2521
+ assertNonEmptyString8(input.recommendationId, "recommendationId");
2522
+ }
2523
+ }
2524
+ if (input.kind === "item-crafting" && input.recipeFamilyCode !== null && input.recipeFamilyCode !== void 0) {
2525
+ assertNonEmptyString8(input.recipeFamilyCode, "recipeFamilyCode");
2526
+ }
2527
+ if (input.kind === "dungeon-crafting") {
2528
+ if (input.blueprintFamilyCode !== null && input.blueprintFamilyCode !== void 0) {
2529
+ assertNonEmptyString8(input.blueprintFamilyCode, "blueprintFamilyCode");
2530
+ }
2531
+ if (input.sealingObjectiveCode !== null && input.sealingObjectiveCode !== void 0) {
2532
+ assertNonEmptyString8(input.sealingObjectiveCode, "sealingObjectiveCode");
2533
+ }
2534
+ }
2535
+ const base = {
2536
+ contractVersion: input.contractVersion ?? AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
2537
+ featureFlagId: AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
2538
+ handoffId: input.handoffId,
2539
+ requestId: input.requestId,
2540
+ apprenticeshipId: input.apprenticeshipId,
2541
+ sponsorshipId: input.sponsorshipId,
2542
+ supervisionId: input.supervisionId,
2543
+ readinessId: input.readinessId,
2544
+ readinessState: input.readinessState,
2545
+ apprenticeSubjectId: input.apprenticeSubjectId,
2546
+ disciplineCode: input.disciplineCode,
2547
+ intent: input.intent,
2548
+ requestedAtIso: input.requestedAtIso,
2549
+ commitment: AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
2550
+ guidanceOwner: AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
2551
+ reasonCodes: createStringArray5(input.reasonCodes, "reasonCodes")
2552
+ };
2553
+ if (input.kind === "spellcraft") {
2554
+ return Object.freeze({
2555
+ ...base,
2556
+ kind: input.kind,
2557
+ targetSystem: "spellcraft-system",
2558
+ recommendationId: input.recommendationId ?? null,
2559
+ requestedTrack: input.requestedTrack
2560
+ });
2561
+ }
2562
+ if (input.kind === "item-crafting") {
2563
+ return Object.freeze({
2564
+ ...base,
2565
+ kind: input.kind,
2566
+ targetSystem: "item-crafting-system",
2567
+ recipeFamilyCode: input.recipeFamilyCode ?? null
2568
+ });
2569
+ }
2570
+ return Object.freeze({
2571
+ ...base,
2572
+ kind: input.kind,
2573
+ targetSystem: "dungeon-crafting-system",
2574
+ blueprintFamilyCode: input.blueprintFamilyCode ?? null,
2575
+ sealingObjectiveCode: input.sealingObjectiveCode ?? null
2576
+ });
2577
+ }
2578
+
2037
2579
  // src/world-events.ts
2038
2580
  function isCanonicalWorldEvent(event) {
2039
2581
  return event.recordType === "canonical";
@@ -2185,7 +2727,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
2185
2727
  "private-or-low-witness-evidence",
2186
2728
  "costly-pressure-event"
2187
2729
  ];
2188
- function isMember6(value, members) {
2730
+ function isMember7(value, members) {
2189
2731
  return members.includes(value);
2190
2732
  }
2191
2733
  function assertRecord(value, label) {
@@ -2226,7 +2768,7 @@ function normalizeTimestamp(value, label) {
2226
2768
  }
2227
2769
  function normalizeMember(value, members, label) {
2228
2770
  const normalized = normalizeNonEmptyString(value, label);
2229
- if (!isMember6(normalized, members)) {
2771
+ if (!isMember7(normalized, members)) {
2230
2772
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
2231
2773
  }
2232
2774
  return normalized;
@@ -2359,13 +2901,13 @@ function normalizeDominantReads(value) {
2359
2901
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
2360
2902
  }
2361
2903
  function isQuietMeasureAxis(value) {
2362
- return isMember6(value, QUIET_MEASURE_AXES);
2904
+ return isMember7(value, QUIET_MEASURE_AXES);
2363
2905
  }
2364
2906
  function isQuietMeasureMissionProbeMode(value) {
2365
- return isMember6(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2907
+ return isMember7(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2366
2908
  }
2367
2909
  function isQuietMeasureMissionResolutionShape(value) {
2368
- return isMember6(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2910
+ return isMember7(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2369
2911
  }
2370
2912
  function createQuietMeasureJudgmentEligibility(input = {}) {
2371
2913
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -2864,6 +3406,16 @@ var gameEventFeatureFlags = Object.freeze([
2864
3406
  // Annotate the CommonJS export names for ESM import in node:
2865
3407
  0 && (module.exports = {
2866
3408
  AI_GAME_ACTOR_ROLES,
3409
+ AI_GAME_APPRENTICESHIP_CONTRACT_VERSION,
3410
+ AI_GAME_APPRENTICESHIP_FEATURE_FLAG_ID,
3411
+ AI_GAME_APPRENTICESHIP_GUIDANCE_OWNER,
3412
+ AI_GAME_APPRENTICESHIP_HANDOFF_COMMITMENT,
3413
+ AI_GAME_APPRENTICESHIP_HANDOFF_INTENTS,
3414
+ AI_GAME_APPRENTICESHIP_HANDOFF_KINDS,
3415
+ AI_GAME_APPRENTICESHIP_HANDOFF_TARGETS,
3416
+ AI_GAME_APPRENTICESHIP_READINESS_STATES,
3417
+ AI_GAME_APPRENTICESHIP_SPONSORSHIP_STATUSES,
3418
+ AI_GAME_APPRENTICESHIP_SUPERVISION_MODES,
2867
3419
  AI_GAME_ENV_PREFIX,
2868
3420
  AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,
2869
3421
  AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
@@ -2963,6 +3515,15 @@ var gameEventFeatureFlags = Object.freeze([
2963
3515
  AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES,
2964
3516
  AI_GAME_TRAINING_TRUST_MARKER_SOURCES,
2965
3517
  AI_GAME_TTS_CACHE_POLICIES,
3518
+ AI_GAME_TUTORIAL_COMPLETION_STATES,
3519
+ AI_GAME_TUTORIAL_CONTRACT_VERSION,
3520
+ AI_GAME_TUTORIAL_FEATURE_FLAG_ID,
3521
+ AI_GAME_TUTORIAL_MAX_PREREQUISITES,
3522
+ AI_GAME_TUTORIAL_MAX_STEPS,
3523
+ AI_GAME_TUTORIAL_MAX_TRIGGERS,
3524
+ AI_GAME_TUTORIAL_PREREQUISITE_KINDS,
3525
+ AI_GAME_TUTORIAL_STAGES,
3526
+ AI_GAME_TUTORIAL_TRIGGER_KINDS,
2966
3527
  QUIET_MEASURE_AXES,
2967
3528
  QUIET_MEASURE_CONFIDENCE_BANDS,
2968
3529
  QUIET_MEASURE_DERIVED_READS,
@@ -2980,6 +3541,10 @@ var gameEventFeatureFlags = Object.freeze([
2980
3541
  assertAiGameObservedEventLogContractVersion,
2981
3542
  classifyAiGameTask,
2982
3543
  createAiGameAcademicTrainingSnapshot,
3544
+ createAiGameApprenticeshipHandoff,
3545
+ createAiGameApprenticeshipReadiness,
3546
+ createAiGameApprenticeshipSponsorship,
3547
+ createAiGameApprenticeshipSupervision,
2983
3548
  createAiGameGossipExport,
2984
3549
  createAiGameIdentityProjectionContract,
2985
3550
  createAiGameIdentitySelfProjection,
@@ -3018,12 +3583,18 @@ var gameEventFeatureFlags = Object.freeze([
3018
3583
  createAiGameTrainingStateSnapshot,
3019
3584
  createAiGameTrainingTrackSelection,
3020
3585
  createAiGameTrainingTrustMarker,
3586
+ createAiGameTutorialPrerequisite,
3587
+ createAiGameTutorialProgressionState,
3588
+ createAiGameTutorialStep,
3589
+ createAiGameTutorialTrack,
3590
+ createAiGameTutorialTrigger,
3021
3591
  createQuietMeasureJudgmentEligibility,
3022
3592
  createQuietMeasureJudgmentResponse,
3023
3593
  gameEventFeatureFlags,
3024
3594
  getAiGamePlayerSystemFocusModeContract,
3025
3595
  getAiGamePlayerSystemGuidanceFallbackContract,
3026
3596
  getAiGamePlayerSystemModuleContract,
3597
+ isAiGameApprenticeshipReadinessState,
3027
3598
  isAiGameGossipExportAudience,
3028
3599
  isAiGameIdentityKnowledgeState,
3029
3600
  isAiGameIdentityProjectionRead,
@@ -3079,6 +3650,10 @@ var gameEventFeatureFlags = Object.freeze([
3079
3650
  isAiGameTrainingStageGate,
3080
3651
  isAiGameTrainingTechniqueMasteryState,
3081
3652
  isAiGameTrainingTrustMarkerSource,
3653
+ isAiGameTutorialCompletionState,
3654
+ isAiGameTutorialPrerequisiteKind,
3655
+ isAiGameTutorialStage,
3656
+ isAiGameTutorialTriggerKind,
3082
3657
  isCandidateWorldEvent,
3083
3658
  isCanonicalWorldEvent,
3084
3659
  isGossipTopicActive,