@plasius/ai-game 0.1.13 → 0.3.0

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
@@ -28,9 +28,27 @@ __export(index_exports, {
28
28
  AI_GAME_FEATURE_FLAG_ID: () => AI_GAME_FEATURE_FLAG_ID,
29
29
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
30
30
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
31
+ AI_GAME_IDENTITY_CONTRACT_VERSION: () => AI_GAME_IDENTITY_CONTRACT_VERSION,
32
+ AI_GAME_IDENTITY_DISCLOSURE_POLICY: () => AI_GAME_IDENTITY_DISCLOSURE_POLICY,
33
+ AI_GAME_IDENTITY_FEATURE_FLAG_ID: () => AI_GAME_IDENTITY_FEATURE_FLAG_ID,
34
+ AI_GAME_IDENTITY_KNOWLEDGE_STATES: () => AI_GAME_IDENTITY_KNOWLEDGE_STATES,
35
+ AI_GAME_IDENTITY_PROJECTION_READS: () => AI_GAME_IDENTITY_PROJECTION_READS,
36
+ AI_GAME_IDENTITY_TARGET_CATEGORIES: () => AI_GAME_IDENTITY_TARGET_CATEGORIES,
37
+ AI_GAME_IDENTITY_VISIBILITY_STATES: () => AI_GAME_IDENTITY_VISIBILITY_STATES,
31
38
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID: () => AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
32
39
  AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
33
40
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
41
+ AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES: () => AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
42
+ AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS: () => AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS,
43
+ AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION: () => AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
44
+ AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID: () => AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
45
+ AI_GAME_PLAYER_SYSTEM_FOCUS_MODES: () => AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
46
+ AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS: () => AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
47
+ AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES: () => AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
48
+ AI_GAME_PLAYER_SYSTEM_MODULES: () => AI_GAME_PLAYER_SYSTEM_MODULES,
49
+ AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS: () => AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
50
+ AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS: () => AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS,
51
+ AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES: () => AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES,
34
52
  AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID: () => AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
35
53
  AI_GAME_TASK_AUTHORITY_BOUNDARIES: () => AI_GAME_TASK_AUTHORITY_BOUNDARIES,
36
54
  AI_GAME_TASK_DECISIONS: () => AI_GAME_TASK_DECISIONS,
@@ -66,10 +84,19 @@ __export(index_exports, {
66
84
  QUIET_MEASURE_PERSPECTIVES: () => QUIET_MEASURE_PERSPECTIVES,
67
85
  QUIET_MEASURE_SIGNAL_BANDS: () => QUIET_MEASURE_SIGNAL_BANDS,
68
86
  aiGameFeatureFlags: () => aiGameFeatureFlags,
87
+ assertAiGameIdentityProjectionContractVersion: () => assertAiGameIdentityProjectionContractVersion,
69
88
  classifyAiGameTask: () => classifyAiGameTask,
70
89
  createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
90
+ createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
91
+ createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
92
+ createAiGameIdentityTargetProjection: () => createAiGameIdentityTargetProjection,
71
93
  createAiGameInstitutionEligibility: () => createAiGameInstitutionEligibility,
72
94
  createAiGameMartialTrainingSnapshot: () => createAiGameMartialTrainingSnapshot,
95
+ createAiGamePlayerSystemAlert: () => createAiGamePlayerSystemAlert,
96
+ createAiGamePlayerSystemPreferenceConfidenceState: () => createAiGamePlayerSystemPreferenceConfidenceState,
97
+ createAiGamePlayerSystemPreferenceInput: () => createAiGamePlayerSystemPreferenceInput,
98
+ createAiGamePlayerSystemPreferenceProfile: () => createAiGamePlayerSystemPreferenceProfile,
99
+ createAiGamePlayerSystemSession: () => createAiGamePlayerSystemSession,
73
100
  createAiGameSpecializationRecommendation: () => createAiGameSpecializationRecommendation,
74
101
  createAiGameTrainingAcademicMissionPrerequisite: () => import_training.createTrainingAcademicMissionPrerequisite,
75
102
  createAiGameTrainingAcademyAdmission: () => import_training.createTrainingAcademyAdmission,
@@ -80,6 +107,20 @@ __export(index_exports, {
80
107
  createQuietMeasureJudgmentEligibility: () => createQuietMeasureJudgmentEligibility,
81
108
  createQuietMeasureJudgmentResponse: () => createQuietMeasureJudgmentResponse,
82
109
  gameEventFeatureFlags: () => gameEventFeatureFlags,
110
+ getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
111
+ getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
112
+ isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
113
+ isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
114
+ isAiGameIdentityTargetCategory: () => isAiGameIdentityTargetCategory,
115
+ isAiGameIdentityVisibilityState: () => isAiGameIdentityVisibilityState,
116
+ isAiGamePlayerSystemAlertDeliverable: () => isAiGamePlayerSystemAlertDeliverable,
117
+ isAiGamePlayerSystemAlertPriority: () => isAiGamePlayerSystemAlertPriority,
118
+ isAiGamePlayerSystemConfidenceBand: () => isAiGamePlayerSystemConfidenceBand,
119
+ isAiGamePlayerSystemFocusMode: () => isAiGamePlayerSystemFocusMode,
120
+ isAiGamePlayerSystemInputModality: () => isAiGamePlayerSystemInputModality,
121
+ isAiGamePlayerSystemModule: () => isAiGamePlayerSystemModule,
122
+ isAiGamePlayerSystemPreferenceKind: () => isAiGamePlayerSystemPreferenceKind,
123
+ isAiGamePlayerSystemPreferenceSource: () => isAiGamePlayerSystemPreferenceSource,
83
124
  isAiGameTrainingAcademicProgressStage: () => import_training.isTrainingAcademicProgressStage,
84
125
  isAiGameTrainingAcademyAdmissionDecision: () => import_training.isTrainingAcademyAdmissionDecision,
85
126
  isAiGameTrainingAntiSpellCounterWindow: () => import_training.isTrainingAntiSpellCounterWindow,
@@ -107,8 +148,12 @@ __export(index_exports, {
107
148
  normalizeIncidentImpactVector: () => normalizeIncidentImpactVector,
108
149
  packageDescriptor: () => packageDescriptor,
109
150
  projectTopicForAudience: () => projectTopicForAudience,
151
+ resolveAiGameIdentityProjectionRead: () => resolveAiGameIdentityProjectionRead,
110
152
  resolveAiGamePlayerAddressText: () => resolveAiGamePlayerAddressText,
111
- resolveAiGameTaskBatch: () => resolveAiGameTaskBatch
153
+ resolveAiGamePlayerSystemConfidenceBand: () => resolveAiGamePlayerSystemConfidenceBand,
154
+ resolveAiGameTaskBatch: () => resolveAiGameTaskBatch,
155
+ selectAiGamePlayerSystemAlertsForFocusMode: () => selectAiGamePlayerSystemAlertsForFocusMode,
156
+ selectAiGameVisibleIdentityTargets: () => selectAiGameVisibleIdentityTargets
112
157
  });
113
158
  module.exports = __toCommonJS(index_exports);
114
159
 
@@ -244,6 +289,530 @@ function createAiGameMartialTrainingSnapshot(input) {
244
289
  });
245
290
  }
246
291
 
292
+ // src/player-system.ts
293
+ var AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID = "isekai.player-system.core.enabled";
294
+ var AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = "1.0";
295
+ var AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [
296
+ "ambient",
297
+ "focused",
298
+ "combat-safe"
299
+ ];
300
+ var AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES = ["voice", "touch"];
301
+ var AI_GAME_PLAYER_SYSTEM_MODULES = [
302
+ "identity",
303
+ "missions",
304
+ "guild-quests",
305
+ "event-log",
306
+ "mcc",
307
+ "tutorial",
308
+ "points-store"
309
+ ];
310
+ var AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [
311
+ "critical",
312
+ "high",
313
+ "normal",
314
+ "low"
315
+ ];
316
+ var AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [
317
+ "combat",
318
+ "exploration",
319
+ "crafting",
320
+ "social",
321
+ "governance"
322
+ ];
323
+ var AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES = [
324
+ "explicit",
325
+ "observed"
326
+ ];
327
+ var AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS = [
328
+ "low",
329
+ "medium",
330
+ "high"
331
+ ];
332
+ var DEFAULT_FOCUS_MODE_CONTRACTS = Object.freeze({
333
+ ambient: Object.freeze({
334
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
335
+ mode: "ambient",
336
+ acceptsInputModalities: Object.freeze([]),
337
+ allowsFullNavigation: false,
338
+ maximumVisibleModules: 1,
339
+ deliverableAlertPriorities: Object.freeze([
340
+ "critical",
341
+ "high",
342
+ "normal",
343
+ "low"
344
+ ])
345
+ }),
346
+ focused: Object.freeze({
347
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
348
+ mode: "focused",
349
+ acceptsInputModalities: Object.freeze([
350
+ "voice",
351
+ "touch"
352
+ ]),
353
+ allowsFullNavigation: true,
354
+ maximumVisibleModules: 3,
355
+ deliverableAlertPriorities: Object.freeze([
356
+ "critical",
357
+ "high",
358
+ "normal",
359
+ "low"
360
+ ])
361
+ }),
362
+ "combat-safe": Object.freeze({
363
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
364
+ mode: "combat-safe",
365
+ acceptsInputModalities: Object.freeze([
366
+ "voice",
367
+ "touch"
368
+ ]),
369
+ allowsFullNavigation: false,
370
+ maximumVisibleModules: 1,
371
+ deliverableAlertPriorities: Object.freeze([
372
+ "critical",
373
+ "high"
374
+ ])
375
+ })
376
+ });
377
+ var DEFAULT_MODULE_CONTRACTS = Object.freeze({
378
+ identity: Object.freeze({
379
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
380
+ module: "identity",
381
+ requiresFocusedMode: false,
382
+ availableInCombatSafeMode: true,
383
+ supportedInputModalities: Object.freeze([
384
+ "voice",
385
+ "touch"
386
+ ])
387
+ }),
388
+ missions: Object.freeze({
389
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
390
+ module: "missions",
391
+ requiresFocusedMode: true,
392
+ availableInCombatSafeMode: false,
393
+ supportedInputModalities: Object.freeze([
394
+ "voice",
395
+ "touch"
396
+ ])
397
+ }),
398
+ "guild-quests": Object.freeze({
399
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
400
+ module: "guild-quests",
401
+ requiresFocusedMode: true,
402
+ availableInCombatSafeMode: false,
403
+ supportedInputModalities: Object.freeze([
404
+ "voice",
405
+ "touch"
406
+ ])
407
+ }),
408
+ "event-log": Object.freeze({
409
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
410
+ module: "event-log",
411
+ requiresFocusedMode: true,
412
+ availableInCombatSafeMode: false,
413
+ supportedInputModalities: Object.freeze([
414
+ "voice",
415
+ "touch"
416
+ ])
417
+ }),
418
+ mcc: Object.freeze({
419
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
420
+ module: "mcc",
421
+ requiresFocusedMode: true,
422
+ availableInCombatSafeMode: false,
423
+ supportedInputModalities: Object.freeze([
424
+ "voice",
425
+ "touch"
426
+ ])
427
+ }),
428
+ tutorial: Object.freeze({
429
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
430
+ module: "tutorial",
431
+ requiresFocusedMode: true,
432
+ availableInCombatSafeMode: false,
433
+ supportedInputModalities: Object.freeze([
434
+ "voice",
435
+ "touch"
436
+ ])
437
+ }),
438
+ "points-store": Object.freeze({
439
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
440
+ module: "points-store",
441
+ requiresFocusedMode: true,
442
+ availableInCombatSafeMode: false,
443
+ supportedInputModalities: Object.freeze([
444
+ "voice",
445
+ "touch"
446
+ ])
447
+ })
448
+ });
449
+ var DEFAULT_SESSION_MODULES = Object.freeze([DEFAULT_MODULE_CONTRACTS.identity]);
450
+ var AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS = Object.freeze(
451
+ AI_GAME_PLAYER_SYSTEM_FOCUS_MODES.map(
452
+ (mode) => DEFAULT_FOCUS_MODE_CONTRACTS[mode]
453
+ )
454
+ );
455
+ var AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS = Object.freeze(
456
+ AI_GAME_PLAYER_SYSTEM_MODULES.map((module2) => DEFAULT_MODULE_CONTRACTS[module2])
457
+ );
458
+ function freezeReadonlyArray2(items) {
459
+ return Object.freeze([...items]);
460
+ }
461
+ function assertNonEmptyString2(value, label) {
462
+ if (value.trim().length === 0) {
463
+ throw new Error(`${label} must be a non-empty string`);
464
+ }
465
+ }
466
+ function assertContractVersion(value, label = "contractVersion") {
467
+ if (value !== AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION) {
468
+ throw new Error(`${label} must be ${AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION}`);
469
+ }
470
+ }
471
+ function assertIsoTimestamp(value, label) {
472
+ assertNonEmptyString2(value, label);
473
+ if (Number.isNaN(Date.parse(value))) {
474
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
475
+ }
476
+ }
477
+ function assertConfidenceScore(value, label = "confidenceScore") {
478
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
479
+ throw new Error(`${label} must be between 0 and 1`);
480
+ }
481
+ }
482
+ function assertNonNegativeInteger(value, label) {
483
+ if (!Number.isInteger(value) || value < 0) {
484
+ throw new Error(`${label} must be a non-negative integer`);
485
+ }
486
+ }
487
+ function isMember(value, members) {
488
+ return members.includes(value);
489
+ }
490
+ function isAiGamePlayerSystemFocusMode(value) {
491
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_FOCUS_MODES);
492
+ }
493
+ function isAiGamePlayerSystemInputModality(value) {
494
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES);
495
+ }
496
+ function isAiGamePlayerSystemModule(value) {
497
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_MODULES);
498
+ }
499
+ function isAiGamePlayerSystemAlertPriority(value) {
500
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);
501
+ }
502
+ function isAiGamePlayerSystemPreferenceKind(value) {
503
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);
504
+ }
505
+ function isAiGamePlayerSystemPreferenceSource(value) {
506
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES);
507
+ }
508
+ function isAiGamePlayerSystemConfidenceBand(value) {
509
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS);
510
+ }
511
+ function getAiGamePlayerSystemFocusModeContract(mode) {
512
+ return DEFAULT_FOCUS_MODE_CONTRACTS[mode];
513
+ }
514
+ function getAiGamePlayerSystemModuleContract(module2) {
515
+ return DEFAULT_MODULE_CONTRACTS[module2];
516
+ }
517
+ function isAiGamePlayerSystemAlertDeliverable(alert, mode) {
518
+ return getAiGamePlayerSystemFocusModeContract(mode).deliverableAlertPriorities.includes(
519
+ alert.priority
520
+ );
521
+ }
522
+ function selectAiGamePlayerSystemAlertsForFocusMode(alerts, mode) {
523
+ return freezeReadonlyArray2(
524
+ alerts.filter((alert) => isAiGamePlayerSystemAlertDeliverable(alert, mode))
525
+ );
526
+ }
527
+ function createAiGamePlayerSystemAlert(input) {
528
+ assertNonEmptyString2(input.alertId, "alertId");
529
+ assertNonEmptyString2(input.title, "title");
530
+ assertNonEmptyString2(input.message, "message");
531
+ assertIsoTimestamp(input.createdAtIso, "createdAtIso");
532
+ assertContractVersion(input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION);
533
+ if (!isAiGamePlayerSystemAlertPriority(input.priority)) {
534
+ throw new Error("priority must be a supported Player System alert priority");
535
+ }
536
+ if (!isAiGamePlayerSystemModule(input.sourceModule)) {
537
+ throw new Error("sourceModule must be a supported Player System module");
538
+ }
539
+ return Object.freeze({
540
+ ...input,
541
+ contractVersion: input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION
542
+ });
543
+ }
544
+ function resolveAiGamePlayerSystemConfidenceBand(confidenceScore) {
545
+ assertConfidenceScore(confidenceScore);
546
+ if (confidenceScore >= 0.67) {
547
+ return "high";
548
+ }
549
+ if (confidenceScore >= 0.34) {
550
+ return "medium";
551
+ }
552
+ return "low";
553
+ }
554
+ function createAiGamePlayerSystemPreferenceInput(input) {
555
+ assertNonEmptyString2(input.inputId, "inputId");
556
+ assertIsoTimestamp(input.capturedAtIso, "capturedAtIso");
557
+ assertConfidenceScore(input.confidenceScore);
558
+ if (!isAiGamePlayerSystemPreferenceKind(input.kind)) {
559
+ throw new Error("kind must be a supported Player System preference kind");
560
+ }
561
+ if (!isAiGamePlayerSystemPreferenceSource(input.source)) {
562
+ throw new Error("source must be a supported Player System preference source");
563
+ }
564
+ return Object.freeze({
565
+ ...input,
566
+ reasonCodes: freezeReadonlyArray2(input.reasonCodes ?? [])
567
+ });
568
+ }
569
+ function createAiGamePlayerSystemPreferenceConfidenceState(input) {
570
+ assertConfidenceScore(input.confidenceScore);
571
+ assertNonNegativeInteger(input.sampleCount, "sampleCount");
572
+ assertIsoTimestamp(input.lastUpdatedAtIso, "lastUpdatedAtIso");
573
+ const confidenceBand = resolveAiGamePlayerSystemConfidenceBand(
574
+ input.confidenceScore
575
+ );
576
+ if (input.confidenceBand !== void 0 && input.confidenceBand !== confidenceBand) {
577
+ throw new Error("confidenceBand must match confidenceScore");
578
+ }
579
+ return Object.freeze({
580
+ confidenceScore: input.confidenceScore,
581
+ confidenceBand,
582
+ sampleCount: input.sampleCount,
583
+ lastUpdatedAtIso: input.lastUpdatedAtIso
584
+ });
585
+ }
586
+ function createAiGamePlayerSystemPreferenceProfile(input) {
587
+ assertNonEmptyString2(input.profileId, "profileId");
588
+ const inputs = (input.inputs ?? []).map(
589
+ (preferenceInput) => createAiGamePlayerSystemPreferenceInput(preferenceInput)
590
+ );
591
+ const lastUpdatedAtIso = input.confidence?.lastUpdatedAtIso ?? (/* @__PURE__ */ new Date(0)).toISOString();
592
+ const confidenceScore = input.confidence?.confidenceScore ?? (inputs.length === 0 ? 0 : inputs.reduce((total, preferenceInput) => total + preferenceInput.confidenceScore, 0) / inputs.length);
593
+ const confidence = createAiGamePlayerSystemPreferenceConfidenceState({
594
+ confidenceScore,
595
+ sampleCount: input.confidence?.sampleCount ?? inputs.length,
596
+ lastUpdatedAtIso,
597
+ confidenceBand: input.confidence?.confidenceBand
598
+ });
599
+ return Object.freeze({
600
+ profileId: input.profileId,
601
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
602
+ inputs: freezeReadonlyArray2(inputs),
603
+ confidence
604
+ });
605
+ }
606
+ function createAiGamePlayerSystemSession(input) {
607
+ assertNonEmptyString2(input.sessionId, "sessionId");
608
+ if (!isAiGamePlayerSystemFocusMode(input.focusMode)) {
609
+ throw new Error("focusMode must be a supported Player System focus mode");
610
+ }
611
+ if (input.activeModule !== null && input.activeModule !== void 0 && !isAiGamePlayerSystemModule(input.activeModule)) {
612
+ throw new Error("activeModule must be a supported Player System module");
613
+ }
614
+ const modeContract = getAiGamePlayerSystemFocusModeContract(input.focusMode);
615
+ const modules = freezeReadonlyArray2(
616
+ (input.modules ?? DEFAULT_SESSION_MODULES).map(
617
+ (moduleContract) => Object.freeze({
618
+ ...moduleContract,
619
+ supportedInputModalities: freezeReadonlyArray2(
620
+ moduleContract.supportedInputModalities
621
+ )
622
+ })
623
+ )
624
+ );
625
+ const acceptedInputModalities = freezeReadonlyArray2(
626
+ input.acceptedInputModalities ?? modeContract.acceptsInputModalities
627
+ );
628
+ const pendingAlerts = freezeReadonlyArray2(
629
+ (input.pendingAlerts ?? []).map((alert) => createAiGamePlayerSystemAlert(alert))
630
+ );
631
+ if (modules.length > modeContract.maximumVisibleModules) {
632
+ throw new Error("modules exceed the focus mode visibility limit");
633
+ }
634
+ for (const modality of acceptedInputModalities) {
635
+ if (!isAiGamePlayerSystemInputModality(modality)) {
636
+ throw new Error("acceptedInputModalities contains an unsupported modality");
637
+ }
638
+ }
639
+ if (input.focusMode === "focused" && (!acceptedInputModalities.includes("voice") || !acceptedInputModalities.includes("touch"))) {
640
+ throw new Error("focused sessions must accept both voice and touch input");
641
+ }
642
+ for (const moduleContract of modules) {
643
+ assertContractVersion(moduleContract.contractVersion, "module contractVersion");
644
+ if (!isAiGamePlayerSystemModule(moduleContract.module)) {
645
+ throw new Error("modules contains an unsupported Player System module");
646
+ }
647
+ for (const modality of moduleContract.supportedInputModalities) {
648
+ if (!isAiGamePlayerSystemInputModality(modality)) {
649
+ throw new Error("modules contains an unsupported input modality");
650
+ }
651
+ }
652
+ if (input.focusMode === "combat-safe" && !moduleContract.availableInCombatSafeMode) {
653
+ throw new Error("combat-safe sessions cannot expose unsafe modules");
654
+ }
655
+ }
656
+ if (input.activeModule !== null && input.activeModule !== void 0 && !modules.some((moduleContract) => moduleContract.module === input.activeModule)) {
657
+ throw new Error("activeModule must be included in modules");
658
+ }
659
+ return Object.freeze({
660
+ sessionId: input.sessionId,
661
+ contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
662
+ featureFlagId: AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
663
+ focusMode: input.focusMode,
664
+ activeModule: input.activeModule ?? null,
665
+ modules,
666
+ acceptedInputModalities,
667
+ pendingAlerts,
668
+ preferenceProfile: createAiGamePlayerSystemPreferenceProfile({
669
+ profileId: input.preferenceProfile.profileId,
670
+ inputs: input.preferenceProfile.inputs,
671
+ confidence: input.preferenceProfile.confidence
672
+ })
673
+ });
674
+ }
675
+
676
+ // src/identity.ts
677
+ var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
678
+ var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
679
+ var AI_GAME_IDENTITY_PROJECTION_READS = [
680
+ "self",
681
+ "partial",
682
+ "full"
683
+ ];
684
+ var AI_GAME_IDENTITY_TARGET_CATEGORIES = [
685
+ "allied",
686
+ "neutral",
687
+ "unknown",
688
+ "unfriendly"
689
+ ];
690
+ var AI_GAME_IDENTITY_KNOWLEDGE_STATES = [
691
+ "unknown",
692
+ "partial",
693
+ "full"
694
+ ];
695
+ var AI_GAME_IDENTITY_VISIBILITY_STATES = ["visible", "occluded"];
696
+ var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
697
+ self: "full",
698
+ visibleTargets: "partial-or-full-by-knowledge",
699
+ occludedTargets: "partial-redacted"
700
+ });
701
+ function freezeReadonlyArray3(items) {
702
+ return Object.freeze([...items]);
703
+ }
704
+ function assertNonEmptyString3(value, label) {
705
+ if (value.trim().length === 0) {
706
+ throw new Error(`${label} must be a non-empty string`);
707
+ }
708
+ }
709
+ function assertContractVersion2(value, label = "contractVersion") {
710
+ if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
711
+ throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
712
+ }
713
+ }
714
+ function isMember2(value, members) {
715
+ return members.includes(value);
716
+ }
717
+ function createField(field) {
718
+ assertNonEmptyString3(field.label, "field.label");
719
+ assertNonEmptyString3(field.value, "field.value");
720
+ return Object.freeze({
721
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
722
+ label: field.label,
723
+ value: field.value,
724
+ redacted: field.redacted ?? false
725
+ });
726
+ }
727
+ function redactField(field, value) {
728
+ return createField({
729
+ label: field.label,
730
+ value,
731
+ redacted: true
732
+ });
733
+ }
734
+ function isAiGameIdentityProjectionRead(value) {
735
+ return isMember2(value, AI_GAME_IDENTITY_PROJECTION_READS);
736
+ }
737
+ function isAiGameIdentityTargetCategory(value) {
738
+ return isMember2(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
739
+ }
740
+ function isAiGameIdentityKnowledgeState(value) {
741
+ return isMember2(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
742
+ }
743
+ function isAiGameIdentityVisibilityState(value) {
744
+ return isMember2(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
745
+ }
746
+ function resolveAiGameIdentityProjectionRead(input) {
747
+ return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
748
+ }
749
+ function createAiGameIdentitySelfProjection(input) {
750
+ assertNonEmptyString3(input.entityId, "entityId");
751
+ assertNonEmptyString3(input.label, "label");
752
+ assertNonEmptyString3(input.summary, "summary");
753
+ return Object.freeze({
754
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
755
+ entityId: input.entityId,
756
+ label: input.label,
757
+ projectionRead: "self",
758
+ summary: input.summary,
759
+ fields: freezeReadonlyArray3(input.fields.map((field) => createField(field)))
760
+ });
761
+ }
762
+ function createAiGameIdentityTargetProjection(input) {
763
+ assertNonEmptyString3(input.targetId, "targetId");
764
+ assertNonEmptyString3(input.label, "label");
765
+ assertNonEmptyString3(input.summary, "summary");
766
+ assertNonEmptyString3(input.combatSummary, "combatSummary");
767
+ if (!isAiGameIdentityTargetCategory(input.category)) {
768
+ throw new Error("category must be a supported identity target category");
769
+ }
770
+ if (!isAiGameIdentityKnowledgeState(input.knowledgeState)) {
771
+ throw new Error("knowledgeState must be a supported identity knowledge state");
772
+ }
773
+ const projectionRead = resolveAiGameIdentityProjectionRead(input);
774
+ const visibility = input.lineOfSight ? "visible" : "occluded";
775
+ const fields = input.fields.map(
776
+ (field) => projectionRead === "full" ? createField(field) : redactField(field, input.lineOfSight ? "Unknown" : "Withheld")
777
+ );
778
+ return Object.freeze({
779
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
780
+ targetId: input.targetId,
781
+ label: input.label,
782
+ category: input.category,
783
+ knowledgeState: input.knowledgeState,
784
+ visibility,
785
+ lineOfSight: input.lineOfSight,
786
+ projectionRead,
787
+ summary: input.summary,
788
+ combatSummary: input.combatSummary,
789
+ fields: freezeReadonlyArray3(fields)
790
+ });
791
+ }
792
+ function selectAiGameVisibleIdentityTargets(targets) {
793
+ return freezeReadonlyArray3(
794
+ targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
795
+ );
796
+ }
797
+ function createAiGameIdentityProjectionContract(input) {
798
+ const self = createAiGameIdentitySelfProjection(input.self);
799
+ const targets = freezeReadonlyArray3(
800
+ (input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
801
+ );
802
+ return Object.freeze({
803
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
804
+ featureFlagId: AI_GAME_IDENTITY_FEATURE_FLAG_ID,
805
+ authorityOwner: "identity-card",
806
+ authorityMode: "projection-only",
807
+ disclosurePolicy: AI_GAME_IDENTITY_DISCLOSURE_POLICY,
808
+ self,
809
+ targets
810
+ });
811
+ }
812
+ function assertAiGameIdentityProjectionContractVersion(value) {
813
+ assertContractVersion2(value);
814
+ }
815
+
247
816
  // src/world-events.ts
248
817
  function isCanonicalWorldEvent(event) {
249
818
  return event.recordType === "canonical";
@@ -395,7 +964,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
395
964
  "private-or-low-witness-evidence",
396
965
  "costly-pressure-event"
397
966
  ];
398
- function isMember(value, members) {
967
+ function isMember3(value, members) {
399
968
  return members.includes(value);
400
969
  }
401
970
  function assertRecord(value, label) {
@@ -436,7 +1005,7 @@ function normalizeTimestamp(value, label) {
436
1005
  }
437
1006
  function normalizeMember(value, members, label) {
438
1007
  const normalized = normalizeNonEmptyString(value, label);
439
- if (!isMember(normalized, members)) {
1008
+ if (!isMember3(normalized, members)) {
440
1009
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
441
1010
  }
442
1011
  return normalized;
@@ -569,13 +1138,13 @@ function normalizeDominantReads(value) {
569
1138
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
570
1139
  }
571
1140
  function isQuietMeasureAxis(value) {
572
- return isMember(value, QUIET_MEASURE_AXES);
1141
+ return isMember3(value, QUIET_MEASURE_AXES);
573
1142
  }
574
1143
  function isQuietMeasureMissionProbeMode(value) {
575
- return isMember(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1144
+ return isMember3(value, QUIET_MEASURE_MISSION_PROBE_MODES);
576
1145
  }
577
1146
  function isQuietMeasureMissionResolutionShape(value) {
578
- return isMember(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1147
+ return isMember3(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
579
1148
  }
580
1149
  function createQuietMeasureJudgmentEligibility(input = {}) {
581
1150
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -1081,9 +1650,27 @@ var gameEventFeatureFlags = Object.freeze([
1081
1650
  AI_GAME_FEATURE_FLAG_ID,
1082
1651
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
1083
1652
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
1653
+ AI_GAME_IDENTITY_CONTRACT_VERSION,
1654
+ AI_GAME_IDENTITY_DISCLOSURE_POLICY,
1655
+ AI_GAME_IDENTITY_FEATURE_FLAG_ID,
1656
+ AI_GAME_IDENTITY_KNOWLEDGE_STATES,
1657
+ AI_GAME_IDENTITY_PROJECTION_READS,
1658
+ AI_GAME_IDENTITY_TARGET_CATEGORIES,
1659
+ AI_GAME_IDENTITY_VISIBILITY_STATES,
1084
1660
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
1085
1661
  AI_GAME_PACKAGE,
1086
1662
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
1663
+ AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
1664
+ AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS,
1665
+ AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
1666
+ AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
1667
+ AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
1668
+ AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
1669
+ AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
1670
+ AI_GAME_PLAYER_SYSTEM_MODULES,
1671
+ AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
1672
+ AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS,
1673
+ AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES,
1087
1674
  AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
1088
1675
  AI_GAME_TASK_AUTHORITY_BOUNDARIES,
1089
1676
  AI_GAME_TASK_DECISIONS,
@@ -1119,10 +1706,19 @@ var gameEventFeatureFlags = Object.freeze([
1119
1706
  QUIET_MEASURE_PERSPECTIVES,
1120
1707
  QUIET_MEASURE_SIGNAL_BANDS,
1121
1708
  aiGameFeatureFlags,
1709
+ assertAiGameIdentityProjectionContractVersion,
1122
1710
  classifyAiGameTask,
1123
1711
  createAiGameAcademicTrainingSnapshot,
1712
+ createAiGameIdentityProjectionContract,
1713
+ createAiGameIdentitySelfProjection,
1714
+ createAiGameIdentityTargetProjection,
1124
1715
  createAiGameInstitutionEligibility,
1125
1716
  createAiGameMartialTrainingSnapshot,
1717
+ createAiGamePlayerSystemAlert,
1718
+ createAiGamePlayerSystemPreferenceConfidenceState,
1719
+ createAiGamePlayerSystemPreferenceInput,
1720
+ createAiGamePlayerSystemPreferenceProfile,
1721
+ createAiGamePlayerSystemSession,
1126
1722
  createAiGameSpecializationRecommendation,
1127
1723
  createAiGameTrainingAcademicMissionPrerequisite,
1128
1724
  createAiGameTrainingAcademyAdmission,
@@ -1133,6 +1729,20 @@ var gameEventFeatureFlags = Object.freeze([
1133
1729
  createQuietMeasureJudgmentEligibility,
1134
1730
  createQuietMeasureJudgmentResponse,
1135
1731
  gameEventFeatureFlags,
1732
+ getAiGamePlayerSystemFocusModeContract,
1733
+ getAiGamePlayerSystemModuleContract,
1734
+ isAiGameIdentityKnowledgeState,
1735
+ isAiGameIdentityProjectionRead,
1736
+ isAiGameIdentityTargetCategory,
1737
+ isAiGameIdentityVisibilityState,
1738
+ isAiGamePlayerSystemAlertDeliverable,
1739
+ isAiGamePlayerSystemAlertPriority,
1740
+ isAiGamePlayerSystemConfidenceBand,
1741
+ isAiGamePlayerSystemFocusMode,
1742
+ isAiGamePlayerSystemInputModality,
1743
+ isAiGamePlayerSystemModule,
1744
+ isAiGamePlayerSystemPreferenceKind,
1745
+ isAiGamePlayerSystemPreferenceSource,
1136
1746
  isAiGameTrainingAcademicProgressStage,
1137
1747
  isAiGameTrainingAcademyAdmissionDecision,
1138
1748
  isAiGameTrainingAntiSpellCounterWindow,
@@ -1160,7 +1770,11 @@ var gameEventFeatureFlags = Object.freeze([
1160
1770
  normalizeIncidentImpactVector,
1161
1771
  packageDescriptor,
1162
1772
  projectTopicForAudience,
1773
+ resolveAiGameIdentityProjectionRead,
1163
1774
  resolveAiGamePlayerAddressText,
1164
- resolveAiGameTaskBatch
1775
+ resolveAiGamePlayerSystemConfidenceBand,
1776
+ resolveAiGameTaskBatch,
1777
+ selectAiGamePlayerSystemAlertsForFocusMode,
1778
+ selectAiGameVisibleIdentityTargets
1165
1779
  });
1166
1780
  //# sourceMappingURL=index.cjs.map