@plasius/ai-game 0.3.0 → 0.5.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.js CHANGED
@@ -170,6 +170,9 @@ function createAiGameMartialTrainingSnapshot(input) {
170
170
  // src/player-system.ts
171
171
  var AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID = "isekai.player-system.core.enabled";
172
172
  var AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = "1.0";
173
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID = "isekai.player-system.guidance-nfr.enabled";
174
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES = 4096;
175
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE = 30;
173
176
  var AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [
174
177
  "ambient",
175
178
  "focused",
@@ -191,6 +194,38 @@ var AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [
191
194
  "normal",
192
195
  "low"
193
196
  ];
197
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES = [
198
+ "voice",
199
+ "narration",
200
+ "speech-capture"
201
+ ];
202
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS = [
203
+ "voice-unavailable",
204
+ "narration-unavailable",
205
+ "speech-capture-unavailable"
206
+ ];
207
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS = [
208
+ "touch-controls-and-text-summary",
209
+ "status-copy-and-live-region",
210
+ "manual-actions-stay-visible"
211
+ ];
212
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS = Object.freeze([
213
+ Object.freeze({
214
+ id: "voice-unavailable",
215
+ source: "voice",
216
+ behavior: "touch-controls-and-text-summary"
217
+ }),
218
+ Object.freeze({
219
+ id: "narration-unavailable",
220
+ source: "narration",
221
+ behavior: "status-copy-and-live-region"
222
+ }),
223
+ Object.freeze({
224
+ id: "speech-capture-unavailable",
225
+ source: "speech-capture",
226
+ behavior: "manual-actions-stay-visible"
227
+ })
228
+ ]);
194
229
  var AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [
195
230
  "combat",
196
231
  "exploration",
@@ -377,6 +412,63 @@ function isAiGamePlayerSystemModule(value) {
377
412
  function isAiGamePlayerSystemAlertPriority(value) {
378
413
  return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);
379
414
  }
415
+ function isAiGamePlayerSystemGuidanceCueSource(value) {
416
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES);
417
+ }
418
+ function isAiGamePlayerSystemGuidanceFallbackId(value) {
419
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS);
420
+ }
421
+ function isAiGamePlayerSystemGuidanceFallbackBehavior(value) {
422
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS);
423
+ }
424
+ function getAiGamePlayerSystemGuidanceFallbackContract(fallbackId) {
425
+ const contract = AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS.find(
426
+ (candidate) => candidate.id === fallbackId
427
+ );
428
+ if (!contract) {
429
+ throw new Error("fallbackId must identify a supported guidance fallback");
430
+ }
431
+ return contract;
432
+ }
433
+ function createAiGamePlayerSystemGuidanceCue(input) {
434
+ assertNonEmptyString2(input.cueId, "cueId");
435
+ assertContractVersion(
436
+ input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION
437
+ );
438
+ if (!isAiGamePlayerSystemAlertPriority(input.priority)) {
439
+ throw new Error("priority must be a supported Player System alert priority");
440
+ }
441
+ if (!isAiGamePlayerSystemGuidanceCueSource(input.source)) {
442
+ throw new Error("source must be a supported guidance cue source");
443
+ }
444
+ if (!isAiGamePlayerSystemGuidanceFallbackId(input.fallbackId)) {
445
+ throw new Error("fallbackId must identify a supported guidance fallback");
446
+ }
447
+ const fallback = getAiGamePlayerSystemGuidanceFallbackContract(input.fallbackId);
448
+ if (fallback.source !== input.source) {
449
+ throw new Error("fallbackId must match the guidance cue source");
450
+ }
451
+ if (!Number.isInteger(input.maxPayloadBytes) || input.maxPayloadBytes < 1 || input.maxPayloadBytes > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES) {
452
+ throw new Error(
453
+ `maxPayloadBytes must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES}`
454
+ );
455
+ }
456
+ if (!Number.isInteger(input.maxOccurrencesPerMinute) || input.maxOccurrencesPerMinute < 1 || input.maxOccurrencesPerMinute > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE) {
457
+ throw new Error(
458
+ `maxOccurrencesPerMinute must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE}`
459
+ );
460
+ }
461
+ return Object.freeze({
462
+ cueId: input.cueId,
463
+ contractVersion: input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
464
+ featureFlagId: AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
465
+ priority: input.priority,
466
+ source: input.source,
467
+ fallbackId: input.fallbackId,
468
+ maxPayloadBytes: input.maxPayloadBytes,
469
+ maxOccurrencesPerMinute: input.maxOccurrencesPerMinute
470
+ });
471
+ }
380
472
  function isAiGamePlayerSystemPreferenceKind(value) {
381
473
  return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);
382
474
  }
@@ -551,6 +643,435 @@ function createAiGamePlayerSystemSession(input) {
551
643
  });
552
644
  }
553
645
 
646
+ // src/missions.ts
647
+ var AI_GAME_MISSIONS_FEATURE_FLAG_ID = "isekai.player-system.missions.enabled";
648
+ var AI_GAME_MISSIONS_CONTRACT_VERSION = "1.0";
649
+ var AI_GAME_MISSION_CLASSES = [
650
+ "bootstrap",
651
+ "short-term",
652
+ "medium-term",
653
+ "long-horizon"
654
+ ];
655
+ var AI_GAME_MISSION_OBJECTIVE_STATUSES = [
656
+ "pending",
657
+ "active",
658
+ "completed",
659
+ "failed",
660
+ "abandoned"
661
+ ];
662
+ var AI_GAME_MISSION_PLAYER_RESPONSE_KINDS = [
663
+ "accepted",
664
+ "refused",
665
+ "ignored",
666
+ "declined",
667
+ "pinned",
668
+ "completed",
669
+ "failed",
670
+ "abandoned"
671
+ ];
672
+ var AI_GAME_MISSION_PREFERENCE_DIMENSIONS = [
673
+ "combat",
674
+ "exploration",
675
+ "crafting",
676
+ "social",
677
+ "governance"
678
+ ];
679
+ var AI_GAME_MISSION_CONFIDENCE_BANDS = [
680
+ "low",
681
+ "medium",
682
+ "high"
683
+ ];
684
+ var AI_GAME_MISSION_INFLUENCE_SOURCES = [
685
+ "mission-response",
686
+ "player-declared",
687
+ "world-observation",
688
+ "mcc-focus",
689
+ "world-pressure",
690
+ "bootstrap-policy"
691
+ ];
692
+ var AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING = [
693
+ "accumulate",
694
+ "cap-at-confidence",
695
+ "decay-duplicate",
696
+ "ignore-duplicate"
697
+ ];
698
+ var AI_GAME_MISSION_READINESS_BANDS = [
699
+ "bootstrap",
700
+ "ready",
701
+ "needs-prerequisites",
702
+ "institution-gated"
703
+ ];
704
+ var AI_GAME_MISSION_FEEDBACK_CHANNELS = [
705
+ "audio",
706
+ "visual"
707
+ ];
708
+ var AI_GAME_MISSION_REWARD_KINDS = [
709
+ "currency",
710
+ "item",
711
+ "recipe",
712
+ "temporary-modifier",
713
+ "knowledge-unlock"
714
+ ];
715
+ var AI_GAME_MISSION_REWARD_CAP_SEMANTICS = [
716
+ "hard-cap",
717
+ "soft-cap",
718
+ "non-stackable"
719
+ ];
720
+ function freezeReadonlyArray3(items) {
721
+ return Object.freeze([...items]);
722
+ }
723
+ function isMember2(value, members) {
724
+ return members.includes(value);
725
+ }
726
+ function assertNonEmptyString3(value, label) {
727
+ if (value.trim().length === 0) {
728
+ throw new Error(`${label} must be a non-empty string`);
729
+ }
730
+ }
731
+ function assertIsoTimestamp2(value, label) {
732
+ assertNonEmptyString3(value, label);
733
+ if (Number.isNaN(Date.parse(value))) {
734
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
735
+ }
736
+ }
737
+ function assertBoundedConfidence(value, label = "confidenceScore") {
738
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
739
+ throw new Error(`${label} must be between 0 and 1`);
740
+ }
741
+ }
742
+ function assertPositiveInteger(value, label) {
743
+ if (!Number.isInteger(value) || value <= 0) {
744
+ throw new Error(`${label} must be a positive integer`);
745
+ }
746
+ }
747
+ function assertNonNegativeInteger2(value, label) {
748
+ if (!Number.isInteger(value) || value < 0) {
749
+ throw new Error(`${label} must be a non-negative integer`);
750
+ }
751
+ }
752
+ function createStringArray(values, label) {
753
+ return freezeReadonlyArray3(
754
+ (values ?? []).map((value, index) => {
755
+ assertNonEmptyString3(value, `${label}[${index}]`);
756
+ return value;
757
+ })
758
+ );
759
+ }
760
+ function assertContractVersion2(value, label = "contractVersion") {
761
+ if (value !== AI_GAME_MISSIONS_CONTRACT_VERSION) {
762
+ throw new Error(`${label} must be ${AI_GAME_MISSIONS_CONTRACT_VERSION}`);
763
+ }
764
+ }
765
+ function assertFeedbackChannels(channels) {
766
+ const set = new Set(channels);
767
+ if (!set.has("audio") || !set.has("visual")) {
768
+ throw new Error("feedbackChannels must include both audio and visual");
769
+ }
770
+ }
771
+ function isAiGameMissionClass(value) {
772
+ return isMember2(value, AI_GAME_MISSION_CLASSES);
773
+ }
774
+ function isAiGameMissionObjectiveStatus(value) {
775
+ return isMember2(value, AI_GAME_MISSION_OBJECTIVE_STATUSES);
776
+ }
777
+ function isAiGameMissionPlayerResponseKind(value) {
778
+ return isMember2(value, AI_GAME_MISSION_PLAYER_RESPONSE_KINDS);
779
+ }
780
+ function isAiGameMissionPreferenceDimension(value) {
781
+ return isMember2(value, AI_GAME_MISSION_PREFERENCE_DIMENSIONS);
782
+ }
783
+ function isAiGameMissionConfidenceBand(value) {
784
+ return isMember2(value, AI_GAME_MISSION_CONFIDENCE_BANDS);
785
+ }
786
+ function isAiGameMissionInfluenceSource(value) {
787
+ return isMember2(value, AI_GAME_MISSION_INFLUENCE_SOURCES);
788
+ }
789
+ function isAiGameMissionRepeatedSignalHandling(value) {
790
+ return isMember2(value, AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING);
791
+ }
792
+ function isAiGameMissionReadinessBand(value) {
793
+ return isMember2(value, AI_GAME_MISSION_READINESS_BANDS);
794
+ }
795
+ function isAiGameMissionFeedbackChannel(value) {
796
+ return isMember2(value, AI_GAME_MISSION_FEEDBACK_CHANNELS);
797
+ }
798
+ function isAiGameMissionRewardKind(value) {
799
+ return isMember2(value, AI_GAME_MISSION_REWARD_KINDS);
800
+ }
801
+ function isAiGameMissionRewardCapSemantic(value) {
802
+ return isMember2(value, AI_GAME_MISSION_REWARD_CAP_SEMANTICS);
803
+ }
804
+ function resolveAiGameMissionConfidenceBand(confidenceScore) {
805
+ assertBoundedConfidence(confidenceScore);
806
+ if (confidenceScore < 0.34) {
807
+ return "low";
808
+ }
809
+ if (confidenceScore < 0.67) {
810
+ return "medium";
811
+ }
812
+ return "high";
813
+ }
814
+ function createAiGameMissionReadinessContext(input) {
815
+ if (!isAiGameMissionReadinessBand(input.readinessBand)) {
816
+ throw new Error("readinessBand must be a supported mission readiness band");
817
+ }
818
+ return Object.freeze({
819
+ readinessBand: input.readinessBand,
820
+ stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
821
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
822
+ });
823
+ }
824
+ function createAiGameMissionMccFocusInfluence(input) {
825
+ assertNonEmptyString3(input.targetCode, "targetCode");
826
+ assertBoundedConfidence(input.influenceWeight, "influenceWeight");
827
+ return Object.freeze({
828
+ targetCode: input.targetCode,
829
+ influenceWeight: input.influenceWeight,
830
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
831
+ });
832
+ }
833
+ function createAiGameMissionPlayerModelEvidence(input) {
834
+ assertNonEmptyString3(input.evidenceId, "evidenceId");
835
+ assertNonEmptyString3(input.sourceId, "sourceId");
836
+ assertIsoTimestamp2(input.capturedAtIso, "capturedAtIso");
837
+ assertPositiveInteger(input.repeatedSignalCount, "repeatedSignalCount");
838
+ return Object.freeze({
839
+ evidenceId: input.evidenceId,
840
+ sourceId: input.sourceId,
841
+ capturedAtIso: input.capturedAtIso,
842
+ repeatedSignalCount: input.repeatedSignalCount,
843
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
844
+ });
845
+ }
846
+ function createAiGameMissionPlayerModelInfluenceInput(input) {
847
+ assertNonEmptyString3(input.influenceId, "influenceId");
848
+ assertNonEmptyString3(input.missionId, "missionId");
849
+ if (!isAiGameMissionPreferenceDimension(input.preferenceDimension)) {
850
+ throw new Error(
851
+ "preferenceDimension must be a supported mission preference dimension"
852
+ );
853
+ }
854
+ if (!isAiGameMissionInfluenceSource(input.source)) {
855
+ throw new Error("source must be a supported mission influence source");
856
+ }
857
+ if (!isAiGameMissionRepeatedSignalHandling(input.repeatedSignalHandling)) {
858
+ throw new Error(
859
+ "repeatedSignalHandling must be a supported repeated signal handling mode"
860
+ );
861
+ }
862
+ assertBoundedConfidence(input.confidenceScore);
863
+ const confidenceBand = input.confidenceBand ?? resolveAiGameMissionConfidenceBand(input.confidenceScore);
864
+ if (!isAiGameMissionConfidenceBand(confidenceBand)) {
865
+ throw new Error("confidenceBand must be a supported mission confidence band");
866
+ }
867
+ if (confidenceBand !== resolveAiGameMissionConfidenceBand(input.confidenceScore)) {
868
+ throw new Error("confidenceBand must match confidenceScore");
869
+ }
870
+ return Object.freeze({
871
+ influenceId: input.influenceId,
872
+ missionId: input.missionId,
873
+ preferenceDimension: input.preferenceDimension,
874
+ source: input.source,
875
+ confidenceScore: input.confidenceScore,
876
+ confidenceBand,
877
+ evidence: createAiGameMissionPlayerModelEvidence(input.evidence),
878
+ repeatedSignalHandling: input.repeatedSignalHandling,
879
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
880
+ mccFocusInfluence: input.mccFocusInfluence ? createAiGameMissionMccFocusInfluence(input.mccFocusInfluence) : null,
881
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
882
+ });
883
+ }
884
+ function createAiGameMissionRewardBound(input) {
885
+ assertNonNegativeInteger2(input.minimum, "minimum");
886
+ assertNonNegativeInteger2(input.maximum, "maximum");
887
+ assertNonNegativeInteger2(input.cap, "cap");
888
+ if (!isAiGameMissionRewardCapSemantic(input.capSemantic)) {
889
+ throw new Error("capSemantic must be a supported mission reward cap semantic");
890
+ }
891
+ if (input.maximum < input.minimum) {
892
+ throw new Error("maximum must be greater than or equal to minimum");
893
+ }
894
+ if (input.cap < input.maximum) {
895
+ throw new Error("cap must be greater than or equal to maximum");
896
+ }
897
+ return Object.freeze({
898
+ minimum: input.minimum,
899
+ maximum: input.maximum,
900
+ cap: input.cap,
901
+ capSemantic: input.capSemantic
902
+ });
903
+ }
904
+ function createAiGameMissionRewardGrant(input) {
905
+ assertNonEmptyString3(input.rewardId, "rewardId");
906
+ assertNonEmptyString3(input.label, "label");
907
+ if (!isAiGameMissionRewardKind(input.kind)) {
908
+ throw new Error("kind must be a supported mission reward kind");
909
+ }
910
+ const cannotSkipReasonCodes = createStringArray(
911
+ input.cannotSkipReasonCodes,
912
+ "cannotSkipReasonCodes"
913
+ );
914
+ if (cannotSkipReasonCodes.length === 0) {
915
+ throw new Error("cannotSkipReasonCodes must contain at least one reason code");
916
+ }
917
+ const temporaryDurationMinutes = input.temporaryDurationMinutes ?? null;
918
+ if (temporaryDurationMinutes !== null) {
919
+ assertPositiveInteger(temporaryDurationMinutes, "temporaryDurationMinutes");
920
+ }
921
+ if (input.kind === "temporary-modifier" && temporaryDurationMinutes === null) {
922
+ throw new Error(
923
+ "temporaryDurationMinutes is required for temporary-modifier rewards"
924
+ );
925
+ }
926
+ return Object.freeze({
927
+ rewardId: input.rewardId,
928
+ kind: input.kind,
929
+ label: input.label,
930
+ bound: createAiGameMissionRewardBound(input.bound),
931
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
932
+ stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
933
+ cannotSkipReasonCodes,
934
+ temporaryDurationMinutes
935
+ });
936
+ }
937
+ function createAiGameMissionRewardEnvelope(input) {
938
+ assertNonEmptyString3(input.missionId, "missionId");
939
+ if (input.grants.length === 0) {
940
+ throw new Error("grants must contain at least one reward grant");
941
+ }
942
+ return Object.freeze({
943
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
944
+ missionId: input.missionId,
945
+ featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
946
+ progressionSafe: true,
947
+ accelerantOnly: true,
948
+ grants: freezeReadonlyArray3(
949
+ input.grants.map((grant) => createAiGameMissionRewardGrant(grant))
950
+ ),
951
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
952
+ });
953
+ }
954
+ function createAiGameMissionObjectiveState(input) {
955
+ assertNonEmptyString3(input.objectiveId, "objectiveId");
956
+ assertNonEmptyString3(input.objectiveCode, "objectiveCode");
957
+ assertNonEmptyString3(input.label, "label");
958
+ if (!isAiGameMissionObjectiveStatus(input.status)) {
959
+ throw new Error("status must be a supported mission objective status");
960
+ }
961
+ assertPositiveInteger(input.targetCount, "targetCount");
962
+ const currentCount = input.currentCount ?? 0;
963
+ assertNonNegativeInteger2(currentCount, "currentCount");
964
+ if (currentCount > input.targetCount) {
965
+ throw new Error("currentCount must be less than or equal to targetCount");
966
+ }
967
+ assertIsoTimestamp2(input.updatedAtIso, "updatedAtIso");
968
+ return Object.freeze({
969
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
970
+ objectiveId: input.objectiveId,
971
+ objectiveCode: input.objectiveCode,
972
+ label: input.label,
973
+ status: input.status,
974
+ targetCount: input.targetCount,
975
+ currentCount,
976
+ optional: input.optional ?? false,
977
+ updatedAtIso: input.updatedAtIso,
978
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
979
+ });
980
+ }
981
+ function createAiGameMissionDefinition(input) {
982
+ assertNonEmptyString3(input.missionId, "missionId");
983
+ assertNonEmptyString3(input.missionCode, "missionCode");
984
+ assertNonEmptyString3(input.title, "title");
985
+ assertNonEmptyString3(input.summary, "summary");
986
+ if (!isAiGameMissionClass(input.missionClass)) {
987
+ throw new Error("missionClass must be a supported mission class");
988
+ }
989
+ const feedbackChannels = freezeReadonlyArray3(
990
+ (input.feedbackChannels ?? AI_GAME_MISSION_FEEDBACK_CHANNELS).map((channel) => {
991
+ if (!isAiGameMissionFeedbackChannel(channel)) {
992
+ throw new Error("feedbackChannels must use supported mission channels");
993
+ }
994
+ return channel;
995
+ })
996
+ );
997
+ assertFeedbackChannels(feedbackChannels);
998
+ if (input.preferenceDimensions.length === 0) {
999
+ throw new Error(
1000
+ "preferenceDimensions must contain at least one mission preference dimension"
1001
+ );
1002
+ }
1003
+ const preferenceDimensions = freezeReadonlyArray3(
1004
+ input.preferenceDimensions.map((dimension) => {
1005
+ if (!isAiGameMissionPreferenceDimension(dimension)) {
1006
+ throw new Error(
1007
+ "preferenceDimensions must use supported mission preference dimensions"
1008
+ );
1009
+ }
1010
+ return dimension;
1011
+ })
1012
+ );
1013
+ if (input.objectiveStates.length === 0) {
1014
+ throw new Error("objectiveStates must contain at least one mission objective");
1015
+ }
1016
+ return Object.freeze({
1017
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1018
+ missionId: input.missionId,
1019
+ missionCode: input.missionCode,
1020
+ featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
1021
+ missionClass: input.missionClass,
1022
+ title: input.title,
1023
+ summary: input.summary,
1024
+ bootstrapSafe: input.bootstrapSafe ?? input.missionClass === "bootstrap",
1025
+ feedbackChannels,
1026
+ preferenceDimensions,
1027
+ nearbyOpportunityCodes: createStringArray(
1028
+ input.nearbyOpportunityCodes,
1029
+ "nearbyOpportunityCodes"
1030
+ ),
1031
+ worldPressureCodes: createStringArray(
1032
+ input.worldPressureCodes,
1033
+ "worldPressureCodes"
1034
+ ),
1035
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
1036
+ objectiveStates: freezeReadonlyArray3(
1037
+ input.objectiveStates.map(
1038
+ (objectiveState) => createAiGameMissionObjectiveState(objectiveState)
1039
+ )
1040
+ ),
1041
+ rewardEnvelope: createAiGameMissionRewardEnvelope(input.rewardEnvelope),
1042
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1043
+ });
1044
+ }
1045
+ function createAiGameMissionPlayerResponse(input) {
1046
+ assertNonEmptyString3(input.responseId, "responseId");
1047
+ assertNonEmptyString3(input.missionId, "missionId");
1048
+ assertIsoTimestamp2(input.respondedAtIso, "respondedAtIso");
1049
+ if (!isAiGameMissionPlayerResponseKind(input.responseKind)) {
1050
+ throw new Error("responseKind must be a supported mission player response kind");
1051
+ }
1052
+ return Object.freeze({
1053
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1054
+ responseId: input.responseId,
1055
+ missionId: input.missionId,
1056
+ responseKind: input.responseKind,
1057
+ respondedAtIso: input.respondedAtIso,
1058
+ objectiveStates: freezeReadonlyArray3(
1059
+ (input.objectiveStates ?? []).map(
1060
+ (objectiveState) => createAiGameMissionObjectiveState(objectiveState)
1061
+ )
1062
+ ),
1063
+ influenceInputs: freezeReadonlyArray3(
1064
+ (input.influenceInputs ?? []).map(
1065
+ (influenceInput) => createAiGameMissionPlayerModelInfluenceInput(influenceInput)
1066
+ )
1067
+ ),
1068
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1069
+ });
1070
+ }
1071
+ function assertAiGameMissionContractVersion(value) {
1072
+ assertContractVersion2(value);
1073
+ }
1074
+
554
1075
  // src/identity.ts
555
1076
  var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
556
1077
  var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
@@ -576,25 +1097,25 @@ var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
576
1097
  visibleTargets: "partial-or-full-by-knowledge",
577
1098
  occludedTargets: "partial-redacted"
578
1099
  });
579
- function freezeReadonlyArray3(items) {
1100
+ function freezeReadonlyArray4(items) {
580
1101
  return Object.freeze([...items]);
581
1102
  }
582
- function assertNonEmptyString3(value, label) {
1103
+ function assertNonEmptyString4(value, label) {
583
1104
  if (value.trim().length === 0) {
584
1105
  throw new Error(`${label} must be a non-empty string`);
585
1106
  }
586
1107
  }
587
- function assertContractVersion2(value, label = "contractVersion") {
1108
+ function assertContractVersion3(value, label = "contractVersion") {
588
1109
  if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
589
1110
  throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
590
1111
  }
591
1112
  }
592
- function isMember2(value, members) {
1113
+ function isMember3(value, members) {
593
1114
  return members.includes(value);
594
1115
  }
595
1116
  function createField(field) {
596
- assertNonEmptyString3(field.label, "field.label");
597
- assertNonEmptyString3(field.value, "field.value");
1117
+ assertNonEmptyString4(field.label, "field.label");
1118
+ assertNonEmptyString4(field.value, "field.value");
598
1119
  return Object.freeze({
599
1120
  contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
600
1121
  label: field.label,
@@ -610,38 +1131,38 @@ function redactField(field, value) {
610
1131
  });
611
1132
  }
612
1133
  function isAiGameIdentityProjectionRead(value) {
613
- return isMember2(value, AI_GAME_IDENTITY_PROJECTION_READS);
1134
+ return isMember3(value, AI_GAME_IDENTITY_PROJECTION_READS);
614
1135
  }
615
1136
  function isAiGameIdentityTargetCategory(value) {
616
- return isMember2(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
1137
+ return isMember3(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
617
1138
  }
618
1139
  function isAiGameIdentityKnowledgeState(value) {
619
- return isMember2(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
1140
+ return isMember3(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
620
1141
  }
621
1142
  function isAiGameIdentityVisibilityState(value) {
622
- return isMember2(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
1143
+ return isMember3(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
623
1144
  }
624
1145
  function resolveAiGameIdentityProjectionRead(input) {
625
1146
  return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
626
1147
  }
627
1148
  function createAiGameIdentitySelfProjection(input) {
628
- assertNonEmptyString3(input.entityId, "entityId");
629
- assertNonEmptyString3(input.label, "label");
630
- assertNonEmptyString3(input.summary, "summary");
1149
+ assertNonEmptyString4(input.entityId, "entityId");
1150
+ assertNonEmptyString4(input.label, "label");
1151
+ assertNonEmptyString4(input.summary, "summary");
631
1152
  return Object.freeze({
632
1153
  contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
633
1154
  entityId: input.entityId,
634
1155
  label: input.label,
635
1156
  projectionRead: "self",
636
1157
  summary: input.summary,
637
- fields: freezeReadonlyArray3(input.fields.map((field) => createField(field)))
1158
+ fields: freezeReadonlyArray4(input.fields.map((field) => createField(field)))
638
1159
  });
639
1160
  }
640
1161
  function createAiGameIdentityTargetProjection(input) {
641
- assertNonEmptyString3(input.targetId, "targetId");
642
- assertNonEmptyString3(input.label, "label");
643
- assertNonEmptyString3(input.summary, "summary");
644
- assertNonEmptyString3(input.combatSummary, "combatSummary");
1162
+ assertNonEmptyString4(input.targetId, "targetId");
1163
+ assertNonEmptyString4(input.label, "label");
1164
+ assertNonEmptyString4(input.summary, "summary");
1165
+ assertNonEmptyString4(input.combatSummary, "combatSummary");
645
1166
  if (!isAiGameIdentityTargetCategory(input.category)) {
646
1167
  throw new Error("category must be a supported identity target category");
647
1168
  }
@@ -664,17 +1185,17 @@ function createAiGameIdentityTargetProjection(input) {
664
1185
  projectionRead,
665
1186
  summary: input.summary,
666
1187
  combatSummary: input.combatSummary,
667
- fields: freezeReadonlyArray3(fields)
1188
+ fields: freezeReadonlyArray4(fields)
668
1189
  });
669
1190
  }
670
1191
  function selectAiGameVisibleIdentityTargets(targets) {
671
- return freezeReadonlyArray3(
1192
+ return freezeReadonlyArray4(
672
1193
  targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
673
1194
  );
674
1195
  }
675
1196
  function createAiGameIdentityProjectionContract(input) {
676
1197
  const self = createAiGameIdentitySelfProjection(input.self);
677
- const targets = freezeReadonlyArray3(
1198
+ const targets = freezeReadonlyArray4(
678
1199
  (input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
679
1200
  );
680
1201
  return Object.freeze({
@@ -688,7 +1209,7 @@ function createAiGameIdentityProjectionContract(input) {
688
1209
  });
689
1210
  }
690
1211
  function assertAiGameIdentityProjectionContractVersion(value) {
691
- assertContractVersion2(value);
1212
+ assertContractVersion3(value);
692
1213
  }
693
1214
 
694
1215
  // src/world-events.ts
@@ -842,7 +1363,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
842
1363
  "private-or-low-witness-evidence",
843
1364
  "costly-pressure-event"
844
1365
  ];
845
- function isMember3(value, members) {
1366
+ function isMember4(value, members) {
846
1367
  return members.includes(value);
847
1368
  }
848
1369
  function assertRecord(value, label) {
@@ -883,7 +1404,7 @@ function normalizeTimestamp(value, label) {
883
1404
  }
884
1405
  function normalizeMember(value, members, label) {
885
1406
  const normalized = normalizeNonEmptyString(value, label);
886
- if (!isMember3(normalized, members)) {
1407
+ if (!isMember4(normalized, members)) {
887
1408
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
888
1409
  }
889
1410
  return normalized;
@@ -1016,13 +1537,13 @@ function normalizeDominantReads(value) {
1016
1537
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
1017
1538
  }
1018
1539
  function isQuietMeasureAxis(value) {
1019
- return isMember3(value, QUIET_MEASURE_AXES);
1540
+ return isMember4(value, QUIET_MEASURE_AXES);
1020
1541
  }
1021
1542
  function isQuietMeasureMissionProbeMode(value) {
1022
- return isMember3(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1543
+ return isMember4(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1023
1544
  }
1024
1545
  function isQuietMeasureMissionResolutionShape(value) {
1025
- return isMember3(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1546
+ return isMember4(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1026
1547
  }
1027
1548
  function createQuietMeasureJudgmentEligibility(input = {}) {
1028
1549
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -1535,6 +2056,19 @@ export {
1535
2056
  AI_GAME_IDENTITY_TARGET_CATEGORIES,
1536
2057
  AI_GAME_IDENTITY_VISIBILITY_STATES,
1537
2058
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
2059
+ AI_GAME_MISSIONS_CONTRACT_VERSION,
2060
+ AI_GAME_MISSIONS_FEATURE_FLAG_ID,
2061
+ AI_GAME_MISSION_CLASSES,
2062
+ AI_GAME_MISSION_CONFIDENCE_BANDS,
2063
+ AI_GAME_MISSION_FEEDBACK_CHANNELS,
2064
+ AI_GAME_MISSION_INFLUENCE_SOURCES,
2065
+ AI_GAME_MISSION_OBJECTIVE_STATUSES,
2066
+ AI_GAME_MISSION_PLAYER_RESPONSE_KINDS,
2067
+ AI_GAME_MISSION_PREFERENCE_DIMENSIONS,
2068
+ AI_GAME_MISSION_READINESS_BANDS,
2069
+ AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
2070
+ AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
2071
+ AI_GAME_MISSION_REWARD_KINDS,
1538
2072
  AI_GAME_PACKAGE,
1539
2073
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
1540
2074
  AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
@@ -1543,6 +2077,13 @@ export {
1543
2077
  AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
1544
2078
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
1545
2079
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
2080
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE,
2081
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES,
2082
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES,
2083
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS,
2084
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS,
2085
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS,
2086
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
1546
2087
  AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
1547
2088
  AI_GAME_PLAYER_SYSTEM_MODULES,
1548
2089
  AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
@@ -1584,6 +2125,7 @@ export {
1584
2125
  QUIET_MEASURE_SIGNAL_BANDS,
1585
2126
  aiGameFeatureFlags,
1586
2127
  assertAiGameIdentityProjectionContractVersion,
2128
+ assertAiGameMissionContractVersion,
1587
2129
  classifyAiGameTask,
1588
2130
  createAiGameAcademicTrainingSnapshot,
1589
2131
  createAiGameIdentityProjectionContract,
@@ -1591,7 +2133,18 @@ export {
1591
2133
  createAiGameIdentityTargetProjection,
1592
2134
  createAiGameInstitutionEligibility,
1593
2135
  createAiGameMartialTrainingSnapshot,
2136
+ createAiGameMissionDefinition,
2137
+ createAiGameMissionMccFocusInfluence,
2138
+ createAiGameMissionObjectiveState,
2139
+ createAiGameMissionPlayerModelEvidence,
2140
+ createAiGameMissionPlayerModelInfluenceInput,
2141
+ createAiGameMissionPlayerResponse,
2142
+ createAiGameMissionReadinessContext,
2143
+ createAiGameMissionRewardBound,
2144
+ createAiGameMissionRewardEnvelope,
2145
+ createAiGameMissionRewardGrant,
1594
2146
  createAiGamePlayerSystemAlert,
2147
+ createAiGamePlayerSystemGuidanceCue,
1595
2148
  createAiGamePlayerSystemPreferenceConfidenceState,
1596
2149
  createAiGamePlayerSystemPreferenceInput,
1597
2150
  createAiGamePlayerSystemPreferenceProfile,
@@ -1607,15 +2160,30 @@ export {
1607
2160
  createQuietMeasureJudgmentResponse,
1608
2161
  gameEventFeatureFlags,
1609
2162
  getAiGamePlayerSystemFocusModeContract,
2163
+ getAiGamePlayerSystemGuidanceFallbackContract,
1610
2164
  getAiGamePlayerSystemModuleContract,
1611
2165
  isAiGameIdentityKnowledgeState,
1612
2166
  isAiGameIdentityProjectionRead,
1613
2167
  isAiGameIdentityTargetCategory,
1614
2168
  isAiGameIdentityVisibilityState,
2169
+ isAiGameMissionClass,
2170
+ isAiGameMissionConfidenceBand,
2171
+ isAiGameMissionFeedbackChannel,
2172
+ isAiGameMissionInfluenceSource,
2173
+ isAiGameMissionObjectiveStatus,
2174
+ isAiGameMissionPlayerResponseKind,
2175
+ isAiGameMissionPreferenceDimension,
2176
+ isAiGameMissionReadinessBand,
2177
+ isAiGameMissionRepeatedSignalHandling,
2178
+ isAiGameMissionRewardCapSemantic,
2179
+ isAiGameMissionRewardKind,
1615
2180
  isAiGamePlayerSystemAlertDeliverable,
1616
2181
  isAiGamePlayerSystemAlertPriority,
1617
2182
  isAiGamePlayerSystemConfidenceBand,
1618
2183
  isAiGamePlayerSystemFocusMode,
2184
+ isAiGamePlayerSystemGuidanceCueSource,
2185
+ isAiGamePlayerSystemGuidanceFallbackBehavior,
2186
+ isAiGamePlayerSystemGuidanceFallbackId,
1619
2187
  isAiGamePlayerSystemInputModality,
1620
2188
  isAiGamePlayerSystemModule,
1621
2189
  isAiGamePlayerSystemPreferenceKind,
@@ -1648,6 +2216,7 @@ export {
1648
2216
  packageDescriptor,
1649
2217
  projectTopicForAudience,
1650
2218
  resolveAiGameIdentityProjectionRead,
2219
+ resolveAiGameMissionConfidenceBand,
1651
2220
  resolveAiGamePlayerAddressText,
1652
2221
  resolveAiGamePlayerSystemConfidenceBand,
1653
2222
  resolveAiGameTaskBatch,