@plasius/ai-game 0.2.0 → 0.4.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,7 +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,
39
+ AI_GAME_MISSIONS_CONTRACT_VERSION: () => AI_GAME_MISSIONS_CONTRACT_VERSION,
40
+ AI_GAME_MISSIONS_FEATURE_FLAG_ID: () => AI_GAME_MISSIONS_FEATURE_FLAG_ID,
41
+ AI_GAME_MISSION_CLASSES: () => AI_GAME_MISSION_CLASSES,
42
+ AI_GAME_MISSION_CONFIDENCE_BANDS: () => AI_GAME_MISSION_CONFIDENCE_BANDS,
43
+ AI_GAME_MISSION_FEEDBACK_CHANNELS: () => AI_GAME_MISSION_FEEDBACK_CHANNELS,
44
+ AI_GAME_MISSION_INFLUENCE_SOURCES: () => AI_GAME_MISSION_INFLUENCE_SOURCES,
45
+ AI_GAME_MISSION_OBJECTIVE_STATUSES: () => AI_GAME_MISSION_OBJECTIVE_STATUSES,
46
+ AI_GAME_MISSION_PLAYER_RESPONSE_KINDS: () => AI_GAME_MISSION_PLAYER_RESPONSE_KINDS,
47
+ AI_GAME_MISSION_PREFERENCE_DIMENSIONS: () => AI_GAME_MISSION_PREFERENCE_DIMENSIONS,
48
+ AI_GAME_MISSION_READINESS_BANDS: () => AI_GAME_MISSION_READINESS_BANDS,
49
+ AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING: () => AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
50
+ AI_GAME_MISSION_REWARD_CAP_SEMANTICS: () => AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
51
+ AI_GAME_MISSION_REWARD_KINDS: () => AI_GAME_MISSION_REWARD_KINDS,
32
52
  AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
33
53
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
34
54
  AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES: () => AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
@@ -77,10 +97,25 @@ __export(index_exports, {
77
97
  QUIET_MEASURE_PERSPECTIVES: () => QUIET_MEASURE_PERSPECTIVES,
78
98
  QUIET_MEASURE_SIGNAL_BANDS: () => QUIET_MEASURE_SIGNAL_BANDS,
79
99
  aiGameFeatureFlags: () => aiGameFeatureFlags,
100
+ assertAiGameIdentityProjectionContractVersion: () => assertAiGameIdentityProjectionContractVersion,
101
+ assertAiGameMissionContractVersion: () => assertAiGameMissionContractVersion,
80
102
  classifyAiGameTask: () => classifyAiGameTask,
81
103
  createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
104
+ createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
105
+ createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
106
+ createAiGameIdentityTargetProjection: () => createAiGameIdentityTargetProjection,
82
107
  createAiGameInstitutionEligibility: () => createAiGameInstitutionEligibility,
83
108
  createAiGameMartialTrainingSnapshot: () => createAiGameMartialTrainingSnapshot,
109
+ createAiGameMissionDefinition: () => createAiGameMissionDefinition,
110
+ createAiGameMissionMccFocusInfluence: () => createAiGameMissionMccFocusInfluence,
111
+ createAiGameMissionObjectiveState: () => createAiGameMissionObjectiveState,
112
+ createAiGameMissionPlayerModelEvidence: () => createAiGameMissionPlayerModelEvidence,
113
+ createAiGameMissionPlayerModelInfluenceInput: () => createAiGameMissionPlayerModelInfluenceInput,
114
+ createAiGameMissionPlayerResponse: () => createAiGameMissionPlayerResponse,
115
+ createAiGameMissionReadinessContext: () => createAiGameMissionReadinessContext,
116
+ createAiGameMissionRewardBound: () => createAiGameMissionRewardBound,
117
+ createAiGameMissionRewardEnvelope: () => createAiGameMissionRewardEnvelope,
118
+ createAiGameMissionRewardGrant: () => createAiGameMissionRewardGrant,
84
119
  createAiGamePlayerSystemAlert: () => createAiGamePlayerSystemAlert,
85
120
  createAiGamePlayerSystemPreferenceConfidenceState: () => createAiGamePlayerSystemPreferenceConfidenceState,
86
121
  createAiGamePlayerSystemPreferenceInput: () => createAiGamePlayerSystemPreferenceInput,
@@ -98,6 +133,21 @@ __export(index_exports, {
98
133
  gameEventFeatureFlags: () => gameEventFeatureFlags,
99
134
  getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
100
135
  getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
136
+ isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
137
+ isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
138
+ isAiGameIdentityTargetCategory: () => isAiGameIdentityTargetCategory,
139
+ isAiGameIdentityVisibilityState: () => isAiGameIdentityVisibilityState,
140
+ isAiGameMissionClass: () => isAiGameMissionClass,
141
+ isAiGameMissionConfidenceBand: () => isAiGameMissionConfidenceBand,
142
+ isAiGameMissionFeedbackChannel: () => isAiGameMissionFeedbackChannel,
143
+ isAiGameMissionInfluenceSource: () => isAiGameMissionInfluenceSource,
144
+ isAiGameMissionObjectiveStatus: () => isAiGameMissionObjectiveStatus,
145
+ isAiGameMissionPlayerResponseKind: () => isAiGameMissionPlayerResponseKind,
146
+ isAiGameMissionPreferenceDimension: () => isAiGameMissionPreferenceDimension,
147
+ isAiGameMissionReadinessBand: () => isAiGameMissionReadinessBand,
148
+ isAiGameMissionRepeatedSignalHandling: () => isAiGameMissionRepeatedSignalHandling,
149
+ isAiGameMissionRewardCapSemantic: () => isAiGameMissionRewardCapSemantic,
150
+ isAiGameMissionRewardKind: () => isAiGameMissionRewardKind,
101
151
  isAiGamePlayerSystemAlertDeliverable: () => isAiGamePlayerSystemAlertDeliverable,
102
152
  isAiGamePlayerSystemAlertPriority: () => isAiGamePlayerSystemAlertPriority,
103
153
  isAiGamePlayerSystemConfidenceBand: () => isAiGamePlayerSystemConfidenceBand,
@@ -133,10 +183,13 @@ __export(index_exports, {
133
183
  normalizeIncidentImpactVector: () => normalizeIncidentImpactVector,
134
184
  packageDescriptor: () => packageDescriptor,
135
185
  projectTopicForAudience: () => projectTopicForAudience,
186
+ resolveAiGameIdentityProjectionRead: () => resolveAiGameIdentityProjectionRead,
187
+ resolveAiGameMissionConfidenceBand: () => resolveAiGameMissionConfidenceBand,
136
188
  resolveAiGamePlayerAddressText: () => resolveAiGamePlayerAddressText,
137
189
  resolveAiGamePlayerSystemConfidenceBand: () => resolveAiGamePlayerSystemConfidenceBand,
138
190
  resolveAiGameTaskBatch: () => resolveAiGameTaskBatch,
139
- selectAiGamePlayerSystemAlertsForFocusMode: () => selectAiGamePlayerSystemAlertsForFocusMode
191
+ selectAiGamePlayerSystemAlertsForFocusMode: () => selectAiGamePlayerSystemAlertsForFocusMode,
192
+ selectAiGameVisibleIdentityTargets: () => selectAiGameVisibleIdentityTargets
140
193
  });
141
194
  module.exports = __toCommonJS(index_exports);
142
195
 
@@ -656,6 +709,575 @@ function createAiGamePlayerSystemSession(input) {
656
709
  });
657
710
  }
658
711
 
712
+ // src/missions.ts
713
+ var AI_GAME_MISSIONS_FEATURE_FLAG_ID = "isekai.player-system.missions.enabled";
714
+ var AI_GAME_MISSIONS_CONTRACT_VERSION = "1.0";
715
+ var AI_GAME_MISSION_CLASSES = [
716
+ "bootstrap",
717
+ "short-term",
718
+ "medium-term",
719
+ "long-horizon"
720
+ ];
721
+ var AI_GAME_MISSION_OBJECTIVE_STATUSES = [
722
+ "pending",
723
+ "active",
724
+ "completed",
725
+ "failed",
726
+ "abandoned"
727
+ ];
728
+ var AI_GAME_MISSION_PLAYER_RESPONSE_KINDS = [
729
+ "accepted",
730
+ "refused",
731
+ "ignored",
732
+ "declined",
733
+ "pinned",
734
+ "completed",
735
+ "failed",
736
+ "abandoned"
737
+ ];
738
+ var AI_GAME_MISSION_PREFERENCE_DIMENSIONS = [
739
+ "combat",
740
+ "exploration",
741
+ "crafting",
742
+ "social",
743
+ "governance"
744
+ ];
745
+ var AI_GAME_MISSION_CONFIDENCE_BANDS = [
746
+ "low",
747
+ "medium",
748
+ "high"
749
+ ];
750
+ var AI_GAME_MISSION_INFLUENCE_SOURCES = [
751
+ "mission-response",
752
+ "player-declared",
753
+ "world-observation",
754
+ "mcc-focus",
755
+ "world-pressure",
756
+ "bootstrap-policy"
757
+ ];
758
+ var AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING = [
759
+ "accumulate",
760
+ "cap-at-confidence",
761
+ "decay-duplicate",
762
+ "ignore-duplicate"
763
+ ];
764
+ var AI_GAME_MISSION_READINESS_BANDS = [
765
+ "bootstrap",
766
+ "ready",
767
+ "needs-prerequisites",
768
+ "institution-gated"
769
+ ];
770
+ var AI_GAME_MISSION_FEEDBACK_CHANNELS = [
771
+ "audio",
772
+ "visual"
773
+ ];
774
+ var AI_GAME_MISSION_REWARD_KINDS = [
775
+ "currency",
776
+ "item",
777
+ "recipe",
778
+ "temporary-modifier",
779
+ "knowledge-unlock"
780
+ ];
781
+ var AI_GAME_MISSION_REWARD_CAP_SEMANTICS = [
782
+ "hard-cap",
783
+ "soft-cap",
784
+ "non-stackable"
785
+ ];
786
+ function freezeReadonlyArray3(items) {
787
+ return Object.freeze([...items]);
788
+ }
789
+ function isMember2(value, members) {
790
+ return members.includes(value);
791
+ }
792
+ function assertNonEmptyString3(value, label) {
793
+ if (value.trim().length === 0) {
794
+ throw new Error(`${label} must be a non-empty string`);
795
+ }
796
+ }
797
+ function assertIsoTimestamp2(value, label) {
798
+ assertNonEmptyString3(value, label);
799
+ if (Number.isNaN(Date.parse(value))) {
800
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
801
+ }
802
+ }
803
+ function assertBoundedConfidence(value, label = "confidenceScore") {
804
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
805
+ throw new Error(`${label} must be between 0 and 1`);
806
+ }
807
+ }
808
+ function assertPositiveInteger(value, label) {
809
+ if (!Number.isInteger(value) || value <= 0) {
810
+ throw new Error(`${label} must be a positive integer`);
811
+ }
812
+ }
813
+ function assertNonNegativeInteger2(value, label) {
814
+ if (!Number.isInteger(value) || value < 0) {
815
+ throw new Error(`${label} must be a non-negative integer`);
816
+ }
817
+ }
818
+ function createStringArray(values, label) {
819
+ return freezeReadonlyArray3(
820
+ (values ?? []).map((value, index) => {
821
+ assertNonEmptyString3(value, `${label}[${index}]`);
822
+ return value;
823
+ })
824
+ );
825
+ }
826
+ function assertContractVersion2(value, label = "contractVersion") {
827
+ if (value !== AI_GAME_MISSIONS_CONTRACT_VERSION) {
828
+ throw new Error(`${label} must be ${AI_GAME_MISSIONS_CONTRACT_VERSION}`);
829
+ }
830
+ }
831
+ function assertFeedbackChannels(channels) {
832
+ const set = new Set(channels);
833
+ if (!set.has("audio") || !set.has("visual")) {
834
+ throw new Error("feedbackChannels must include both audio and visual");
835
+ }
836
+ }
837
+ function isAiGameMissionClass(value) {
838
+ return isMember2(value, AI_GAME_MISSION_CLASSES);
839
+ }
840
+ function isAiGameMissionObjectiveStatus(value) {
841
+ return isMember2(value, AI_GAME_MISSION_OBJECTIVE_STATUSES);
842
+ }
843
+ function isAiGameMissionPlayerResponseKind(value) {
844
+ return isMember2(value, AI_GAME_MISSION_PLAYER_RESPONSE_KINDS);
845
+ }
846
+ function isAiGameMissionPreferenceDimension(value) {
847
+ return isMember2(value, AI_GAME_MISSION_PREFERENCE_DIMENSIONS);
848
+ }
849
+ function isAiGameMissionConfidenceBand(value) {
850
+ return isMember2(value, AI_GAME_MISSION_CONFIDENCE_BANDS);
851
+ }
852
+ function isAiGameMissionInfluenceSource(value) {
853
+ return isMember2(value, AI_GAME_MISSION_INFLUENCE_SOURCES);
854
+ }
855
+ function isAiGameMissionRepeatedSignalHandling(value) {
856
+ return isMember2(value, AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING);
857
+ }
858
+ function isAiGameMissionReadinessBand(value) {
859
+ return isMember2(value, AI_GAME_MISSION_READINESS_BANDS);
860
+ }
861
+ function isAiGameMissionFeedbackChannel(value) {
862
+ return isMember2(value, AI_GAME_MISSION_FEEDBACK_CHANNELS);
863
+ }
864
+ function isAiGameMissionRewardKind(value) {
865
+ return isMember2(value, AI_GAME_MISSION_REWARD_KINDS);
866
+ }
867
+ function isAiGameMissionRewardCapSemantic(value) {
868
+ return isMember2(value, AI_GAME_MISSION_REWARD_CAP_SEMANTICS);
869
+ }
870
+ function resolveAiGameMissionConfidenceBand(confidenceScore) {
871
+ assertBoundedConfidence(confidenceScore);
872
+ if (confidenceScore < 0.34) {
873
+ return "low";
874
+ }
875
+ if (confidenceScore < 0.67) {
876
+ return "medium";
877
+ }
878
+ return "high";
879
+ }
880
+ function createAiGameMissionReadinessContext(input) {
881
+ if (!isAiGameMissionReadinessBand(input.readinessBand)) {
882
+ throw new Error("readinessBand must be a supported mission readiness band");
883
+ }
884
+ return Object.freeze({
885
+ readinessBand: input.readinessBand,
886
+ stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
887
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
888
+ });
889
+ }
890
+ function createAiGameMissionMccFocusInfluence(input) {
891
+ assertNonEmptyString3(input.targetCode, "targetCode");
892
+ assertBoundedConfidence(input.influenceWeight, "influenceWeight");
893
+ return Object.freeze({
894
+ targetCode: input.targetCode,
895
+ influenceWeight: input.influenceWeight,
896
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
897
+ });
898
+ }
899
+ function createAiGameMissionPlayerModelEvidence(input) {
900
+ assertNonEmptyString3(input.evidenceId, "evidenceId");
901
+ assertNonEmptyString3(input.sourceId, "sourceId");
902
+ assertIsoTimestamp2(input.capturedAtIso, "capturedAtIso");
903
+ assertPositiveInteger(input.repeatedSignalCount, "repeatedSignalCount");
904
+ return Object.freeze({
905
+ evidenceId: input.evidenceId,
906
+ sourceId: input.sourceId,
907
+ capturedAtIso: input.capturedAtIso,
908
+ repeatedSignalCount: input.repeatedSignalCount,
909
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
910
+ });
911
+ }
912
+ function createAiGameMissionPlayerModelInfluenceInput(input) {
913
+ assertNonEmptyString3(input.influenceId, "influenceId");
914
+ assertNonEmptyString3(input.missionId, "missionId");
915
+ if (!isAiGameMissionPreferenceDimension(input.preferenceDimension)) {
916
+ throw new Error(
917
+ "preferenceDimension must be a supported mission preference dimension"
918
+ );
919
+ }
920
+ if (!isAiGameMissionInfluenceSource(input.source)) {
921
+ throw new Error("source must be a supported mission influence source");
922
+ }
923
+ if (!isAiGameMissionRepeatedSignalHandling(input.repeatedSignalHandling)) {
924
+ throw new Error(
925
+ "repeatedSignalHandling must be a supported repeated signal handling mode"
926
+ );
927
+ }
928
+ assertBoundedConfidence(input.confidenceScore);
929
+ const confidenceBand = input.confidenceBand ?? resolveAiGameMissionConfidenceBand(input.confidenceScore);
930
+ if (!isAiGameMissionConfidenceBand(confidenceBand)) {
931
+ throw new Error("confidenceBand must be a supported mission confidence band");
932
+ }
933
+ if (confidenceBand !== resolveAiGameMissionConfidenceBand(input.confidenceScore)) {
934
+ throw new Error("confidenceBand must match confidenceScore");
935
+ }
936
+ return Object.freeze({
937
+ influenceId: input.influenceId,
938
+ missionId: input.missionId,
939
+ preferenceDimension: input.preferenceDimension,
940
+ source: input.source,
941
+ confidenceScore: input.confidenceScore,
942
+ confidenceBand,
943
+ evidence: createAiGameMissionPlayerModelEvidence(input.evidence),
944
+ repeatedSignalHandling: input.repeatedSignalHandling,
945
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
946
+ mccFocusInfluence: input.mccFocusInfluence ? createAiGameMissionMccFocusInfluence(input.mccFocusInfluence) : null,
947
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
948
+ });
949
+ }
950
+ function createAiGameMissionRewardBound(input) {
951
+ assertNonNegativeInteger2(input.minimum, "minimum");
952
+ assertNonNegativeInteger2(input.maximum, "maximum");
953
+ assertNonNegativeInteger2(input.cap, "cap");
954
+ if (!isAiGameMissionRewardCapSemantic(input.capSemantic)) {
955
+ throw new Error("capSemantic must be a supported mission reward cap semantic");
956
+ }
957
+ if (input.maximum < input.minimum) {
958
+ throw new Error("maximum must be greater than or equal to minimum");
959
+ }
960
+ if (input.cap < input.maximum) {
961
+ throw new Error("cap must be greater than or equal to maximum");
962
+ }
963
+ return Object.freeze({
964
+ minimum: input.minimum,
965
+ maximum: input.maximum,
966
+ cap: input.cap,
967
+ capSemantic: input.capSemantic
968
+ });
969
+ }
970
+ function createAiGameMissionRewardGrant(input) {
971
+ assertNonEmptyString3(input.rewardId, "rewardId");
972
+ assertNonEmptyString3(input.label, "label");
973
+ if (!isAiGameMissionRewardKind(input.kind)) {
974
+ throw new Error("kind must be a supported mission reward kind");
975
+ }
976
+ const cannotSkipReasonCodes = createStringArray(
977
+ input.cannotSkipReasonCodes,
978
+ "cannotSkipReasonCodes"
979
+ );
980
+ if (cannotSkipReasonCodes.length === 0) {
981
+ throw new Error("cannotSkipReasonCodes must contain at least one reason code");
982
+ }
983
+ const temporaryDurationMinutes = input.temporaryDurationMinutes ?? null;
984
+ if (temporaryDurationMinutes !== null) {
985
+ assertPositiveInteger(temporaryDurationMinutes, "temporaryDurationMinutes");
986
+ }
987
+ if (input.kind === "temporary-modifier" && temporaryDurationMinutes === null) {
988
+ throw new Error(
989
+ "temporaryDurationMinutes is required for temporary-modifier rewards"
990
+ );
991
+ }
992
+ return Object.freeze({
993
+ rewardId: input.rewardId,
994
+ kind: input.kind,
995
+ label: input.label,
996
+ bound: createAiGameMissionRewardBound(input.bound),
997
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
998
+ stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
999
+ cannotSkipReasonCodes,
1000
+ temporaryDurationMinutes
1001
+ });
1002
+ }
1003
+ function createAiGameMissionRewardEnvelope(input) {
1004
+ assertNonEmptyString3(input.missionId, "missionId");
1005
+ if (input.grants.length === 0) {
1006
+ throw new Error("grants must contain at least one reward grant");
1007
+ }
1008
+ return Object.freeze({
1009
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1010
+ missionId: input.missionId,
1011
+ featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
1012
+ progressionSafe: true,
1013
+ accelerantOnly: true,
1014
+ grants: freezeReadonlyArray3(
1015
+ input.grants.map((grant) => createAiGameMissionRewardGrant(grant))
1016
+ ),
1017
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1018
+ });
1019
+ }
1020
+ function createAiGameMissionObjectiveState(input) {
1021
+ assertNonEmptyString3(input.objectiveId, "objectiveId");
1022
+ assertNonEmptyString3(input.objectiveCode, "objectiveCode");
1023
+ assertNonEmptyString3(input.label, "label");
1024
+ if (!isAiGameMissionObjectiveStatus(input.status)) {
1025
+ throw new Error("status must be a supported mission objective status");
1026
+ }
1027
+ assertPositiveInteger(input.targetCount, "targetCount");
1028
+ const currentCount = input.currentCount ?? 0;
1029
+ assertNonNegativeInteger2(currentCount, "currentCount");
1030
+ if (currentCount > input.targetCount) {
1031
+ throw new Error("currentCount must be less than or equal to targetCount");
1032
+ }
1033
+ assertIsoTimestamp2(input.updatedAtIso, "updatedAtIso");
1034
+ return Object.freeze({
1035
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1036
+ objectiveId: input.objectiveId,
1037
+ objectiveCode: input.objectiveCode,
1038
+ label: input.label,
1039
+ status: input.status,
1040
+ targetCount: input.targetCount,
1041
+ currentCount,
1042
+ optional: input.optional ?? false,
1043
+ updatedAtIso: input.updatedAtIso,
1044
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1045
+ });
1046
+ }
1047
+ function createAiGameMissionDefinition(input) {
1048
+ assertNonEmptyString3(input.missionId, "missionId");
1049
+ assertNonEmptyString3(input.missionCode, "missionCode");
1050
+ assertNonEmptyString3(input.title, "title");
1051
+ assertNonEmptyString3(input.summary, "summary");
1052
+ if (!isAiGameMissionClass(input.missionClass)) {
1053
+ throw new Error("missionClass must be a supported mission class");
1054
+ }
1055
+ const feedbackChannels = freezeReadonlyArray3(
1056
+ (input.feedbackChannels ?? AI_GAME_MISSION_FEEDBACK_CHANNELS).map((channel) => {
1057
+ if (!isAiGameMissionFeedbackChannel(channel)) {
1058
+ throw new Error("feedbackChannels must use supported mission channels");
1059
+ }
1060
+ return channel;
1061
+ })
1062
+ );
1063
+ assertFeedbackChannels(feedbackChannels);
1064
+ if (input.preferenceDimensions.length === 0) {
1065
+ throw new Error(
1066
+ "preferenceDimensions must contain at least one mission preference dimension"
1067
+ );
1068
+ }
1069
+ const preferenceDimensions = freezeReadonlyArray3(
1070
+ input.preferenceDimensions.map((dimension) => {
1071
+ if (!isAiGameMissionPreferenceDimension(dimension)) {
1072
+ throw new Error(
1073
+ "preferenceDimensions must use supported mission preference dimensions"
1074
+ );
1075
+ }
1076
+ return dimension;
1077
+ })
1078
+ );
1079
+ if (input.objectiveStates.length === 0) {
1080
+ throw new Error("objectiveStates must contain at least one mission objective");
1081
+ }
1082
+ return Object.freeze({
1083
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1084
+ missionId: input.missionId,
1085
+ missionCode: input.missionCode,
1086
+ featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
1087
+ missionClass: input.missionClass,
1088
+ title: input.title,
1089
+ summary: input.summary,
1090
+ bootstrapSafe: input.bootstrapSafe ?? input.missionClass === "bootstrap",
1091
+ feedbackChannels,
1092
+ preferenceDimensions,
1093
+ nearbyOpportunityCodes: createStringArray(
1094
+ input.nearbyOpportunityCodes,
1095
+ "nearbyOpportunityCodes"
1096
+ ),
1097
+ worldPressureCodes: createStringArray(
1098
+ input.worldPressureCodes,
1099
+ "worldPressureCodes"
1100
+ ),
1101
+ readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
1102
+ objectiveStates: freezeReadonlyArray3(
1103
+ input.objectiveStates.map(
1104
+ (objectiveState) => createAiGameMissionObjectiveState(objectiveState)
1105
+ )
1106
+ ),
1107
+ rewardEnvelope: createAiGameMissionRewardEnvelope(input.rewardEnvelope),
1108
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1109
+ });
1110
+ }
1111
+ function createAiGameMissionPlayerResponse(input) {
1112
+ assertNonEmptyString3(input.responseId, "responseId");
1113
+ assertNonEmptyString3(input.missionId, "missionId");
1114
+ assertIsoTimestamp2(input.respondedAtIso, "respondedAtIso");
1115
+ if (!isAiGameMissionPlayerResponseKind(input.responseKind)) {
1116
+ throw new Error("responseKind must be a supported mission player response kind");
1117
+ }
1118
+ return Object.freeze({
1119
+ contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
1120
+ responseId: input.responseId,
1121
+ missionId: input.missionId,
1122
+ responseKind: input.responseKind,
1123
+ respondedAtIso: input.respondedAtIso,
1124
+ objectiveStates: freezeReadonlyArray3(
1125
+ (input.objectiveStates ?? []).map(
1126
+ (objectiveState) => createAiGameMissionObjectiveState(objectiveState)
1127
+ )
1128
+ ),
1129
+ influenceInputs: freezeReadonlyArray3(
1130
+ (input.influenceInputs ?? []).map(
1131
+ (influenceInput) => createAiGameMissionPlayerModelInfluenceInput(influenceInput)
1132
+ )
1133
+ ),
1134
+ reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
1135
+ });
1136
+ }
1137
+ function assertAiGameMissionContractVersion(value) {
1138
+ assertContractVersion2(value);
1139
+ }
1140
+
1141
+ // src/identity.ts
1142
+ var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
1143
+ var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
1144
+ var AI_GAME_IDENTITY_PROJECTION_READS = [
1145
+ "self",
1146
+ "partial",
1147
+ "full"
1148
+ ];
1149
+ var AI_GAME_IDENTITY_TARGET_CATEGORIES = [
1150
+ "allied",
1151
+ "neutral",
1152
+ "unknown",
1153
+ "unfriendly"
1154
+ ];
1155
+ var AI_GAME_IDENTITY_KNOWLEDGE_STATES = [
1156
+ "unknown",
1157
+ "partial",
1158
+ "full"
1159
+ ];
1160
+ var AI_GAME_IDENTITY_VISIBILITY_STATES = ["visible", "occluded"];
1161
+ var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
1162
+ self: "full",
1163
+ visibleTargets: "partial-or-full-by-knowledge",
1164
+ occludedTargets: "partial-redacted"
1165
+ });
1166
+ function freezeReadonlyArray4(items) {
1167
+ return Object.freeze([...items]);
1168
+ }
1169
+ function assertNonEmptyString4(value, label) {
1170
+ if (value.trim().length === 0) {
1171
+ throw new Error(`${label} must be a non-empty string`);
1172
+ }
1173
+ }
1174
+ function assertContractVersion3(value, label = "contractVersion") {
1175
+ if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
1176
+ throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
1177
+ }
1178
+ }
1179
+ function isMember3(value, members) {
1180
+ return members.includes(value);
1181
+ }
1182
+ function createField(field) {
1183
+ assertNonEmptyString4(field.label, "field.label");
1184
+ assertNonEmptyString4(field.value, "field.value");
1185
+ return Object.freeze({
1186
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
1187
+ label: field.label,
1188
+ value: field.value,
1189
+ redacted: field.redacted ?? false
1190
+ });
1191
+ }
1192
+ function redactField(field, value) {
1193
+ return createField({
1194
+ label: field.label,
1195
+ value,
1196
+ redacted: true
1197
+ });
1198
+ }
1199
+ function isAiGameIdentityProjectionRead(value) {
1200
+ return isMember3(value, AI_GAME_IDENTITY_PROJECTION_READS);
1201
+ }
1202
+ function isAiGameIdentityTargetCategory(value) {
1203
+ return isMember3(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
1204
+ }
1205
+ function isAiGameIdentityKnowledgeState(value) {
1206
+ return isMember3(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
1207
+ }
1208
+ function isAiGameIdentityVisibilityState(value) {
1209
+ return isMember3(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
1210
+ }
1211
+ function resolveAiGameIdentityProjectionRead(input) {
1212
+ return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
1213
+ }
1214
+ function createAiGameIdentitySelfProjection(input) {
1215
+ assertNonEmptyString4(input.entityId, "entityId");
1216
+ assertNonEmptyString4(input.label, "label");
1217
+ assertNonEmptyString4(input.summary, "summary");
1218
+ return Object.freeze({
1219
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
1220
+ entityId: input.entityId,
1221
+ label: input.label,
1222
+ projectionRead: "self",
1223
+ summary: input.summary,
1224
+ fields: freezeReadonlyArray4(input.fields.map((field) => createField(field)))
1225
+ });
1226
+ }
1227
+ function createAiGameIdentityTargetProjection(input) {
1228
+ assertNonEmptyString4(input.targetId, "targetId");
1229
+ assertNonEmptyString4(input.label, "label");
1230
+ assertNonEmptyString4(input.summary, "summary");
1231
+ assertNonEmptyString4(input.combatSummary, "combatSummary");
1232
+ if (!isAiGameIdentityTargetCategory(input.category)) {
1233
+ throw new Error("category must be a supported identity target category");
1234
+ }
1235
+ if (!isAiGameIdentityKnowledgeState(input.knowledgeState)) {
1236
+ throw new Error("knowledgeState must be a supported identity knowledge state");
1237
+ }
1238
+ const projectionRead = resolveAiGameIdentityProjectionRead(input);
1239
+ const visibility = input.lineOfSight ? "visible" : "occluded";
1240
+ const fields = input.fields.map(
1241
+ (field) => projectionRead === "full" ? createField(field) : redactField(field, input.lineOfSight ? "Unknown" : "Withheld")
1242
+ );
1243
+ return Object.freeze({
1244
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
1245
+ targetId: input.targetId,
1246
+ label: input.label,
1247
+ category: input.category,
1248
+ knowledgeState: input.knowledgeState,
1249
+ visibility,
1250
+ lineOfSight: input.lineOfSight,
1251
+ projectionRead,
1252
+ summary: input.summary,
1253
+ combatSummary: input.combatSummary,
1254
+ fields: freezeReadonlyArray4(fields)
1255
+ });
1256
+ }
1257
+ function selectAiGameVisibleIdentityTargets(targets) {
1258
+ return freezeReadonlyArray4(
1259
+ targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
1260
+ );
1261
+ }
1262
+ function createAiGameIdentityProjectionContract(input) {
1263
+ const self = createAiGameIdentitySelfProjection(input.self);
1264
+ const targets = freezeReadonlyArray4(
1265
+ (input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
1266
+ );
1267
+ return Object.freeze({
1268
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
1269
+ featureFlagId: AI_GAME_IDENTITY_FEATURE_FLAG_ID,
1270
+ authorityOwner: "identity-card",
1271
+ authorityMode: "projection-only",
1272
+ disclosurePolicy: AI_GAME_IDENTITY_DISCLOSURE_POLICY,
1273
+ self,
1274
+ targets
1275
+ });
1276
+ }
1277
+ function assertAiGameIdentityProjectionContractVersion(value) {
1278
+ assertContractVersion3(value);
1279
+ }
1280
+
659
1281
  // src/world-events.ts
660
1282
  function isCanonicalWorldEvent(event) {
661
1283
  return event.recordType === "canonical";
@@ -807,7 +1429,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
807
1429
  "private-or-low-witness-evidence",
808
1430
  "costly-pressure-event"
809
1431
  ];
810
- function isMember2(value, members) {
1432
+ function isMember4(value, members) {
811
1433
  return members.includes(value);
812
1434
  }
813
1435
  function assertRecord(value, label) {
@@ -848,7 +1470,7 @@ function normalizeTimestamp(value, label) {
848
1470
  }
849
1471
  function normalizeMember(value, members, label) {
850
1472
  const normalized = normalizeNonEmptyString(value, label);
851
- if (!isMember2(normalized, members)) {
1473
+ if (!isMember4(normalized, members)) {
852
1474
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
853
1475
  }
854
1476
  return normalized;
@@ -981,13 +1603,13 @@ function normalizeDominantReads(value) {
981
1603
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
982
1604
  }
983
1605
  function isQuietMeasureAxis(value) {
984
- return isMember2(value, QUIET_MEASURE_AXES);
1606
+ return isMember4(value, QUIET_MEASURE_AXES);
985
1607
  }
986
1608
  function isQuietMeasureMissionProbeMode(value) {
987
- return isMember2(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1609
+ return isMember4(value, QUIET_MEASURE_MISSION_PROBE_MODES);
988
1610
  }
989
1611
  function isQuietMeasureMissionResolutionShape(value) {
990
- return isMember2(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1612
+ return isMember4(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
991
1613
  }
992
1614
  function createQuietMeasureJudgmentEligibility(input = {}) {
993
1615
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -1493,7 +2115,27 @@ var gameEventFeatureFlags = Object.freeze([
1493
2115
  AI_GAME_FEATURE_FLAG_ID,
1494
2116
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
1495
2117
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
2118
+ AI_GAME_IDENTITY_CONTRACT_VERSION,
2119
+ AI_GAME_IDENTITY_DISCLOSURE_POLICY,
2120
+ AI_GAME_IDENTITY_FEATURE_FLAG_ID,
2121
+ AI_GAME_IDENTITY_KNOWLEDGE_STATES,
2122
+ AI_GAME_IDENTITY_PROJECTION_READS,
2123
+ AI_GAME_IDENTITY_TARGET_CATEGORIES,
2124
+ AI_GAME_IDENTITY_VISIBILITY_STATES,
1496
2125
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
2126
+ AI_GAME_MISSIONS_CONTRACT_VERSION,
2127
+ AI_GAME_MISSIONS_FEATURE_FLAG_ID,
2128
+ AI_GAME_MISSION_CLASSES,
2129
+ AI_GAME_MISSION_CONFIDENCE_BANDS,
2130
+ AI_GAME_MISSION_FEEDBACK_CHANNELS,
2131
+ AI_GAME_MISSION_INFLUENCE_SOURCES,
2132
+ AI_GAME_MISSION_OBJECTIVE_STATUSES,
2133
+ AI_GAME_MISSION_PLAYER_RESPONSE_KINDS,
2134
+ AI_GAME_MISSION_PREFERENCE_DIMENSIONS,
2135
+ AI_GAME_MISSION_READINESS_BANDS,
2136
+ AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
2137
+ AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
2138
+ AI_GAME_MISSION_REWARD_KINDS,
1497
2139
  AI_GAME_PACKAGE,
1498
2140
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
1499
2141
  AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
@@ -1542,10 +2184,25 @@ var gameEventFeatureFlags = Object.freeze([
1542
2184
  QUIET_MEASURE_PERSPECTIVES,
1543
2185
  QUIET_MEASURE_SIGNAL_BANDS,
1544
2186
  aiGameFeatureFlags,
2187
+ assertAiGameIdentityProjectionContractVersion,
2188
+ assertAiGameMissionContractVersion,
1545
2189
  classifyAiGameTask,
1546
2190
  createAiGameAcademicTrainingSnapshot,
2191
+ createAiGameIdentityProjectionContract,
2192
+ createAiGameIdentitySelfProjection,
2193
+ createAiGameIdentityTargetProjection,
1547
2194
  createAiGameInstitutionEligibility,
1548
2195
  createAiGameMartialTrainingSnapshot,
2196
+ createAiGameMissionDefinition,
2197
+ createAiGameMissionMccFocusInfluence,
2198
+ createAiGameMissionObjectiveState,
2199
+ createAiGameMissionPlayerModelEvidence,
2200
+ createAiGameMissionPlayerModelInfluenceInput,
2201
+ createAiGameMissionPlayerResponse,
2202
+ createAiGameMissionReadinessContext,
2203
+ createAiGameMissionRewardBound,
2204
+ createAiGameMissionRewardEnvelope,
2205
+ createAiGameMissionRewardGrant,
1549
2206
  createAiGamePlayerSystemAlert,
1550
2207
  createAiGamePlayerSystemPreferenceConfidenceState,
1551
2208
  createAiGamePlayerSystemPreferenceInput,
@@ -1563,6 +2220,21 @@ var gameEventFeatureFlags = Object.freeze([
1563
2220
  gameEventFeatureFlags,
1564
2221
  getAiGamePlayerSystemFocusModeContract,
1565
2222
  getAiGamePlayerSystemModuleContract,
2223
+ isAiGameIdentityKnowledgeState,
2224
+ isAiGameIdentityProjectionRead,
2225
+ isAiGameIdentityTargetCategory,
2226
+ isAiGameIdentityVisibilityState,
2227
+ isAiGameMissionClass,
2228
+ isAiGameMissionConfidenceBand,
2229
+ isAiGameMissionFeedbackChannel,
2230
+ isAiGameMissionInfluenceSource,
2231
+ isAiGameMissionObjectiveStatus,
2232
+ isAiGameMissionPlayerResponseKind,
2233
+ isAiGameMissionPreferenceDimension,
2234
+ isAiGameMissionReadinessBand,
2235
+ isAiGameMissionRepeatedSignalHandling,
2236
+ isAiGameMissionRewardCapSemantic,
2237
+ isAiGameMissionRewardKind,
1566
2238
  isAiGamePlayerSystemAlertDeliverable,
1567
2239
  isAiGamePlayerSystemAlertPriority,
1568
2240
  isAiGamePlayerSystemConfidenceBand,
@@ -1598,9 +2270,12 @@ var gameEventFeatureFlags = Object.freeze([
1598
2270
  normalizeIncidentImpactVector,
1599
2271
  packageDescriptor,
1600
2272
  projectTopicForAudience,
2273
+ resolveAiGameIdentityProjectionRead,
2274
+ resolveAiGameMissionConfidenceBand,
1601
2275
  resolveAiGamePlayerAddressText,
1602
2276
  resolveAiGamePlayerSystemConfidenceBand,
1603
2277
  resolveAiGameTaskBatch,
1604
- selectAiGamePlayerSystemAlertsForFocusMode
2278
+ selectAiGamePlayerSystemAlertsForFocusMode,
2279
+ selectAiGameVisibleIdentityTargets
1605
2280
  });
1606
2281
  //# sourceMappingURL=index.cjs.map