@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/CHANGELOG.md +31 -0
- package/README.md +50 -2
- package/dist/index.cjs +682 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +323 -1
- package/dist/index.d.ts +323 -1
- package/dist/index.js +628 -6
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0012-identity-projection-contract-boundary.md +55 -0
- package/docs/adrs/adr-0013-adaptive-mission-contract-boundary.md +63 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -551,6 +551,575 @@ function createAiGamePlayerSystemSession(input) {
|
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
// src/missions.ts
|
|
555
|
+
var AI_GAME_MISSIONS_FEATURE_FLAG_ID = "isekai.player-system.missions.enabled";
|
|
556
|
+
var AI_GAME_MISSIONS_CONTRACT_VERSION = "1.0";
|
|
557
|
+
var AI_GAME_MISSION_CLASSES = [
|
|
558
|
+
"bootstrap",
|
|
559
|
+
"short-term",
|
|
560
|
+
"medium-term",
|
|
561
|
+
"long-horizon"
|
|
562
|
+
];
|
|
563
|
+
var AI_GAME_MISSION_OBJECTIVE_STATUSES = [
|
|
564
|
+
"pending",
|
|
565
|
+
"active",
|
|
566
|
+
"completed",
|
|
567
|
+
"failed",
|
|
568
|
+
"abandoned"
|
|
569
|
+
];
|
|
570
|
+
var AI_GAME_MISSION_PLAYER_RESPONSE_KINDS = [
|
|
571
|
+
"accepted",
|
|
572
|
+
"refused",
|
|
573
|
+
"ignored",
|
|
574
|
+
"declined",
|
|
575
|
+
"pinned",
|
|
576
|
+
"completed",
|
|
577
|
+
"failed",
|
|
578
|
+
"abandoned"
|
|
579
|
+
];
|
|
580
|
+
var AI_GAME_MISSION_PREFERENCE_DIMENSIONS = [
|
|
581
|
+
"combat",
|
|
582
|
+
"exploration",
|
|
583
|
+
"crafting",
|
|
584
|
+
"social",
|
|
585
|
+
"governance"
|
|
586
|
+
];
|
|
587
|
+
var AI_GAME_MISSION_CONFIDENCE_BANDS = [
|
|
588
|
+
"low",
|
|
589
|
+
"medium",
|
|
590
|
+
"high"
|
|
591
|
+
];
|
|
592
|
+
var AI_GAME_MISSION_INFLUENCE_SOURCES = [
|
|
593
|
+
"mission-response",
|
|
594
|
+
"player-declared",
|
|
595
|
+
"world-observation",
|
|
596
|
+
"mcc-focus",
|
|
597
|
+
"world-pressure",
|
|
598
|
+
"bootstrap-policy"
|
|
599
|
+
];
|
|
600
|
+
var AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING = [
|
|
601
|
+
"accumulate",
|
|
602
|
+
"cap-at-confidence",
|
|
603
|
+
"decay-duplicate",
|
|
604
|
+
"ignore-duplicate"
|
|
605
|
+
];
|
|
606
|
+
var AI_GAME_MISSION_READINESS_BANDS = [
|
|
607
|
+
"bootstrap",
|
|
608
|
+
"ready",
|
|
609
|
+
"needs-prerequisites",
|
|
610
|
+
"institution-gated"
|
|
611
|
+
];
|
|
612
|
+
var AI_GAME_MISSION_FEEDBACK_CHANNELS = [
|
|
613
|
+
"audio",
|
|
614
|
+
"visual"
|
|
615
|
+
];
|
|
616
|
+
var AI_GAME_MISSION_REWARD_KINDS = [
|
|
617
|
+
"currency",
|
|
618
|
+
"item",
|
|
619
|
+
"recipe",
|
|
620
|
+
"temporary-modifier",
|
|
621
|
+
"knowledge-unlock"
|
|
622
|
+
];
|
|
623
|
+
var AI_GAME_MISSION_REWARD_CAP_SEMANTICS = [
|
|
624
|
+
"hard-cap",
|
|
625
|
+
"soft-cap",
|
|
626
|
+
"non-stackable"
|
|
627
|
+
];
|
|
628
|
+
function freezeReadonlyArray3(items) {
|
|
629
|
+
return Object.freeze([...items]);
|
|
630
|
+
}
|
|
631
|
+
function isMember2(value, members) {
|
|
632
|
+
return members.includes(value);
|
|
633
|
+
}
|
|
634
|
+
function assertNonEmptyString3(value, label) {
|
|
635
|
+
if (value.trim().length === 0) {
|
|
636
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function assertIsoTimestamp2(value, label) {
|
|
640
|
+
assertNonEmptyString3(value, label);
|
|
641
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
642
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function assertBoundedConfidence(value, label = "confidenceScore") {
|
|
646
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
647
|
+
throw new Error(`${label} must be between 0 and 1`);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
function assertPositiveInteger(value, label) {
|
|
651
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
652
|
+
throw new Error(`${label} must be a positive integer`);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function assertNonNegativeInteger2(value, label) {
|
|
656
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
657
|
+
throw new Error(`${label} must be a non-negative integer`);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function createStringArray(values, label) {
|
|
661
|
+
return freezeReadonlyArray3(
|
|
662
|
+
(values ?? []).map((value, index) => {
|
|
663
|
+
assertNonEmptyString3(value, `${label}[${index}]`);
|
|
664
|
+
return value;
|
|
665
|
+
})
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
function assertContractVersion2(value, label = "contractVersion") {
|
|
669
|
+
if (value !== AI_GAME_MISSIONS_CONTRACT_VERSION) {
|
|
670
|
+
throw new Error(`${label} must be ${AI_GAME_MISSIONS_CONTRACT_VERSION}`);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function assertFeedbackChannels(channels) {
|
|
674
|
+
const set = new Set(channels);
|
|
675
|
+
if (!set.has("audio") || !set.has("visual")) {
|
|
676
|
+
throw new Error("feedbackChannels must include both audio and visual");
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function isAiGameMissionClass(value) {
|
|
680
|
+
return isMember2(value, AI_GAME_MISSION_CLASSES);
|
|
681
|
+
}
|
|
682
|
+
function isAiGameMissionObjectiveStatus(value) {
|
|
683
|
+
return isMember2(value, AI_GAME_MISSION_OBJECTIVE_STATUSES);
|
|
684
|
+
}
|
|
685
|
+
function isAiGameMissionPlayerResponseKind(value) {
|
|
686
|
+
return isMember2(value, AI_GAME_MISSION_PLAYER_RESPONSE_KINDS);
|
|
687
|
+
}
|
|
688
|
+
function isAiGameMissionPreferenceDimension(value) {
|
|
689
|
+
return isMember2(value, AI_GAME_MISSION_PREFERENCE_DIMENSIONS);
|
|
690
|
+
}
|
|
691
|
+
function isAiGameMissionConfidenceBand(value) {
|
|
692
|
+
return isMember2(value, AI_GAME_MISSION_CONFIDENCE_BANDS);
|
|
693
|
+
}
|
|
694
|
+
function isAiGameMissionInfluenceSource(value) {
|
|
695
|
+
return isMember2(value, AI_GAME_MISSION_INFLUENCE_SOURCES);
|
|
696
|
+
}
|
|
697
|
+
function isAiGameMissionRepeatedSignalHandling(value) {
|
|
698
|
+
return isMember2(value, AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING);
|
|
699
|
+
}
|
|
700
|
+
function isAiGameMissionReadinessBand(value) {
|
|
701
|
+
return isMember2(value, AI_GAME_MISSION_READINESS_BANDS);
|
|
702
|
+
}
|
|
703
|
+
function isAiGameMissionFeedbackChannel(value) {
|
|
704
|
+
return isMember2(value, AI_GAME_MISSION_FEEDBACK_CHANNELS);
|
|
705
|
+
}
|
|
706
|
+
function isAiGameMissionRewardKind(value) {
|
|
707
|
+
return isMember2(value, AI_GAME_MISSION_REWARD_KINDS);
|
|
708
|
+
}
|
|
709
|
+
function isAiGameMissionRewardCapSemantic(value) {
|
|
710
|
+
return isMember2(value, AI_GAME_MISSION_REWARD_CAP_SEMANTICS);
|
|
711
|
+
}
|
|
712
|
+
function resolveAiGameMissionConfidenceBand(confidenceScore) {
|
|
713
|
+
assertBoundedConfidence(confidenceScore);
|
|
714
|
+
if (confidenceScore < 0.34) {
|
|
715
|
+
return "low";
|
|
716
|
+
}
|
|
717
|
+
if (confidenceScore < 0.67) {
|
|
718
|
+
return "medium";
|
|
719
|
+
}
|
|
720
|
+
return "high";
|
|
721
|
+
}
|
|
722
|
+
function createAiGameMissionReadinessContext(input) {
|
|
723
|
+
if (!isAiGameMissionReadinessBand(input.readinessBand)) {
|
|
724
|
+
throw new Error("readinessBand must be a supported mission readiness band");
|
|
725
|
+
}
|
|
726
|
+
return Object.freeze({
|
|
727
|
+
readinessBand: input.readinessBand,
|
|
728
|
+
stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
|
|
729
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function createAiGameMissionMccFocusInfluence(input) {
|
|
733
|
+
assertNonEmptyString3(input.targetCode, "targetCode");
|
|
734
|
+
assertBoundedConfidence(input.influenceWeight, "influenceWeight");
|
|
735
|
+
return Object.freeze({
|
|
736
|
+
targetCode: input.targetCode,
|
|
737
|
+
influenceWeight: input.influenceWeight,
|
|
738
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
function createAiGameMissionPlayerModelEvidence(input) {
|
|
742
|
+
assertNonEmptyString3(input.evidenceId, "evidenceId");
|
|
743
|
+
assertNonEmptyString3(input.sourceId, "sourceId");
|
|
744
|
+
assertIsoTimestamp2(input.capturedAtIso, "capturedAtIso");
|
|
745
|
+
assertPositiveInteger(input.repeatedSignalCount, "repeatedSignalCount");
|
|
746
|
+
return Object.freeze({
|
|
747
|
+
evidenceId: input.evidenceId,
|
|
748
|
+
sourceId: input.sourceId,
|
|
749
|
+
capturedAtIso: input.capturedAtIso,
|
|
750
|
+
repeatedSignalCount: input.repeatedSignalCount,
|
|
751
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
function createAiGameMissionPlayerModelInfluenceInput(input) {
|
|
755
|
+
assertNonEmptyString3(input.influenceId, "influenceId");
|
|
756
|
+
assertNonEmptyString3(input.missionId, "missionId");
|
|
757
|
+
if (!isAiGameMissionPreferenceDimension(input.preferenceDimension)) {
|
|
758
|
+
throw new Error(
|
|
759
|
+
"preferenceDimension must be a supported mission preference dimension"
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
if (!isAiGameMissionInfluenceSource(input.source)) {
|
|
763
|
+
throw new Error("source must be a supported mission influence source");
|
|
764
|
+
}
|
|
765
|
+
if (!isAiGameMissionRepeatedSignalHandling(input.repeatedSignalHandling)) {
|
|
766
|
+
throw new Error(
|
|
767
|
+
"repeatedSignalHandling must be a supported repeated signal handling mode"
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
assertBoundedConfidence(input.confidenceScore);
|
|
771
|
+
const confidenceBand = input.confidenceBand ?? resolveAiGameMissionConfidenceBand(input.confidenceScore);
|
|
772
|
+
if (!isAiGameMissionConfidenceBand(confidenceBand)) {
|
|
773
|
+
throw new Error("confidenceBand must be a supported mission confidence band");
|
|
774
|
+
}
|
|
775
|
+
if (confidenceBand !== resolveAiGameMissionConfidenceBand(input.confidenceScore)) {
|
|
776
|
+
throw new Error("confidenceBand must match confidenceScore");
|
|
777
|
+
}
|
|
778
|
+
return Object.freeze({
|
|
779
|
+
influenceId: input.influenceId,
|
|
780
|
+
missionId: input.missionId,
|
|
781
|
+
preferenceDimension: input.preferenceDimension,
|
|
782
|
+
source: input.source,
|
|
783
|
+
confidenceScore: input.confidenceScore,
|
|
784
|
+
confidenceBand,
|
|
785
|
+
evidence: createAiGameMissionPlayerModelEvidence(input.evidence),
|
|
786
|
+
repeatedSignalHandling: input.repeatedSignalHandling,
|
|
787
|
+
readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
|
|
788
|
+
mccFocusInfluence: input.mccFocusInfluence ? createAiGameMissionMccFocusInfluence(input.mccFocusInfluence) : null,
|
|
789
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
function createAiGameMissionRewardBound(input) {
|
|
793
|
+
assertNonNegativeInteger2(input.minimum, "minimum");
|
|
794
|
+
assertNonNegativeInteger2(input.maximum, "maximum");
|
|
795
|
+
assertNonNegativeInteger2(input.cap, "cap");
|
|
796
|
+
if (!isAiGameMissionRewardCapSemantic(input.capSemantic)) {
|
|
797
|
+
throw new Error("capSemantic must be a supported mission reward cap semantic");
|
|
798
|
+
}
|
|
799
|
+
if (input.maximum < input.minimum) {
|
|
800
|
+
throw new Error("maximum must be greater than or equal to minimum");
|
|
801
|
+
}
|
|
802
|
+
if (input.cap < input.maximum) {
|
|
803
|
+
throw new Error("cap must be greater than or equal to maximum");
|
|
804
|
+
}
|
|
805
|
+
return Object.freeze({
|
|
806
|
+
minimum: input.minimum,
|
|
807
|
+
maximum: input.maximum,
|
|
808
|
+
cap: input.cap,
|
|
809
|
+
capSemantic: input.capSemantic
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function createAiGameMissionRewardGrant(input) {
|
|
813
|
+
assertNonEmptyString3(input.rewardId, "rewardId");
|
|
814
|
+
assertNonEmptyString3(input.label, "label");
|
|
815
|
+
if (!isAiGameMissionRewardKind(input.kind)) {
|
|
816
|
+
throw new Error("kind must be a supported mission reward kind");
|
|
817
|
+
}
|
|
818
|
+
const cannotSkipReasonCodes = createStringArray(
|
|
819
|
+
input.cannotSkipReasonCodes,
|
|
820
|
+
"cannotSkipReasonCodes"
|
|
821
|
+
);
|
|
822
|
+
if (cannotSkipReasonCodes.length === 0) {
|
|
823
|
+
throw new Error("cannotSkipReasonCodes must contain at least one reason code");
|
|
824
|
+
}
|
|
825
|
+
const temporaryDurationMinutes = input.temporaryDurationMinutes ?? null;
|
|
826
|
+
if (temporaryDurationMinutes !== null) {
|
|
827
|
+
assertPositiveInteger(temporaryDurationMinutes, "temporaryDurationMinutes");
|
|
828
|
+
}
|
|
829
|
+
if (input.kind === "temporary-modifier" && temporaryDurationMinutes === null) {
|
|
830
|
+
throw new Error(
|
|
831
|
+
"temporaryDurationMinutes is required for temporary-modifier rewards"
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
return Object.freeze({
|
|
835
|
+
rewardId: input.rewardId,
|
|
836
|
+
kind: input.kind,
|
|
837
|
+
label: input.label,
|
|
838
|
+
bound: createAiGameMissionRewardBound(input.bound),
|
|
839
|
+
readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
|
|
840
|
+
stageGateRefs: createStringArray(input.stageGateRefs, "stageGateRefs"),
|
|
841
|
+
cannotSkipReasonCodes,
|
|
842
|
+
temporaryDurationMinutes
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
function createAiGameMissionRewardEnvelope(input) {
|
|
846
|
+
assertNonEmptyString3(input.missionId, "missionId");
|
|
847
|
+
if (input.grants.length === 0) {
|
|
848
|
+
throw new Error("grants must contain at least one reward grant");
|
|
849
|
+
}
|
|
850
|
+
return Object.freeze({
|
|
851
|
+
contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
|
|
852
|
+
missionId: input.missionId,
|
|
853
|
+
featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
|
|
854
|
+
progressionSafe: true,
|
|
855
|
+
accelerantOnly: true,
|
|
856
|
+
grants: freezeReadonlyArray3(
|
|
857
|
+
input.grants.map((grant) => createAiGameMissionRewardGrant(grant))
|
|
858
|
+
),
|
|
859
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
function createAiGameMissionObjectiveState(input) {
|
|
863
|
+
assertNonEmptyString3(input.objectiveId, "objectiveId");
|
|
864
|
+
assertNonEmptyString3(input.objectiveCode, "objectiveCode");
|
|
865
|
+
assertNonEmptyString3(input.label, "label");
|
|
866
|
+
if (!isAiGameMissionObjectiveStatus(input.status)) {
|
|
867
|
+
throw new Error("status must be a supported mission objective status");
|
|
868
|
+
}
|
|
869
|
+
assertPositiveInteger(input.targetCount, "targetCount");
|
|
870
|
+
const currentCount = input.currentCount ?? 0;
|
|
871
|
+
assertNonNegativeInteger2(currentCount, "currentCount");
|
|
872
|
+
if (currentCount > input.targetCount) {
|
|
873
|
+
throw new Error("currentCount must be less than or equal to targetCount");
|
|
874
|
+
}
|
|
875
|
+
assertIsoTimestamp2(input.updatedAtIso, "updatedAtIso");
|
|
876
|
+
return Object.freeze({
|
|
877
|
+
contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
|
|
878
|
+
objectiveId: input.objectiveId,
|
|
879
|
+
objectiveCode: input.objectiveCode,
|
|
880
|
+
label: input.label,
|
|
881
|
+
status: input.status,
|
|
882
|
+
targetCount: input.targetCount,
|
|
883
|
+
currentCount,
|
|
884
|
+
optional: input.optional ?? false,
|
|
885
|
+
updatedAtIso: input.updatedAtIso,
|
|
886
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function createAiGameMissionDefinition(input) {
|
|
890
|
+
assertNonEmptyString3(input.missionId, "missionId");
|
|
891
|
+
assertNonEmptyString3(input.missionCode, "missionCode");
|
|
892
|
+
assertNonEmptyString3(input.title, "title");
|
|
893
|
+
assertNonEmptyString3(input.summary, "summary");
|
|
894
|
+
if (!isAiGameMissionClass(input.missionClass)) {
|
|
895
|
+
throw new Error("missionClass must be a supported mission class");
|
|
896
|
+
}
|
|
897
|
+
const feedbackChannels = freezeReadonlyArray3(
|
|
898
|
+
(input.feedbackChannels ?? AI_GAME_MISSION_FEEDBACK_CHANNELS).map((channel) => {
|
|
899
|
+
if (!isAiGameMissionFeedbackChannel(channel)) {
|
|
900
|
+
throw new Error("feedbackChannels must use supported mission channels");
|
|
901
|
+
}
|
|
902
|
+
return channel;
|
|
903
|
+
})
|
|
904
|
+
);
|
|
905
|
+
assertFeedbackChannels(feedbackChannels);
|
|
906
|
+
if (input.preferenceDimensions.length === 0) {
|
|
907
|
+
throw new Error(
|
|
908
|
+
"preferenceDimensions must contain at least one mission preference dimension"
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
const preferenceDimensions = freezeReadonlyArray3(
|
|
912
|
+
input.preferenceDimensions.map((dimension) => {
|
|
913
|
+
if (!isAiGameMissionPreferenceDimension(dimension)) {
|
|
914
|
+
throw new Error(
|
|
915
|
+
"preferenceDimensions must use supported mission preference dimensions"
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
return dimension;
|
|
919
|
+
})
|
|
920
|
+
);
|
|
921
|
+
if (input.objectiveStates.length === 0) {
|
|
922
|
+
throw new Error("objectiveStates must contain at least one mission objective");
|
|
923
|
+
}
|
|
924
|
+
return Object.freeze({
|
|
925
|
+
contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
|
|
926
|
+
missionId: input.missionId,
|
|
927
|
+
missionCode: input.missionCode,
|
|
928
|
+
featureFlagId: AI_GAME_MISSIONS_FEATURE_FLAG_ID,
|
|
929
|
+
missionClass: input.missionClass,
|
|
930
|
+
title: input.title,
|
|
931
|
+
summary: input.summary,
|
|
932
|
+
bootstrapSafe: input.bootstrapSafe ?? input.missionClass === "bootstrap",
|
|
933
|
+
feedbackChannels,
|
|
934
|
+
preferenceDimensions,
|
|
935
|
+
nearbyOpportunityCodes: createStringArray(
|
|
936
|
+
input.nearbyOpportunityCodes,
|
|
937
|
+
"nearbyOpportunityCodes"
|
|
938
|
+
),
|
|
939
|
+
worldPressureCodes: createStringArray(
|
|
940
|
+
input.worldPressureCodes,
|
|
941
|
+
"worldPressureCodes"
|
|
942
|
+
),
|
|
943
|
+
readinessContext: createAiGameMissionReadinessContext(input.readinessContext),
|
|
944
|
+
objectiveStates: freezeReadonlyArray3(
|
|
945
|
+
input.objectiveStates.map(
|
|
946
|
+
(objectiveState) => createAiGameMissionObjectiveState(objectiveState)
|
|
947
|
+
)
|
|
948
|
+
),
|
|
949
|
+
rewardEnvelope: createAiGameMissionRewardEnvelope(input.rewardEnvelope),
|
|
950
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
function createAiGameMissionPlayerResponse(input) {
|
|
954
|
+
assertNonEmptyString3(input.responseId, "responseId");
|
|
955
|
+
assertNonEmptyString3(input.missionId, "missionId");
|
|
956
|
+
assertIsoTimestamp2(input.respondedAtIso, "respondedAtIso");
|
|
957
|
+
if (!isAiGameMissionPlayerResponseKind(input.responseKind)) {
|
|
958
|
+
throw new Error("responseKind must be a supported mission player response kind");
|
|
959
|
+
}
|
|
960
|
+
return Object.freeze({
|
|
961
|
+
contractVersion: AI_GAME_MISSIONS_CONTRACT_VERSION,
|
|
962
|
+
responseId: input.responseId,
|
|
963
|
+
missionId: input.missionId,
|
|
964
|
+
responseKind: input.responseKind,
|
|
965
|
+
respondedAtIso: input.respondedAtIso,
|
|
966
|
+
objectiveStates: freezeReadonlyArray3(
|
|
967
|
+
(input.objectiveStates ?? []).map(
|
|
968
|
+
(objectiveState) => createAiGameMissionObjectiveState(objectiveState)
|
|
969
|
+
)
|
|
970
|
+
),
|
|
971
|
+
influenceInputs: freezeReadonlyArray3(
|
|
972
|
+
(input.influenceInputs ?? []).map(
|
|
973
|
+
(influenceInput) => createAiGameMissionPlayerModelInfluenceInput(influenceInput)
|
|
974
|
+
)
|
|
975
|
+
),
|
|
976
|
+
reasonCodes: createStringArray(input.reasonCodes, "reasonCodes")
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
function assertAiGameMissionContractVersion(value) {
|
|
980
|
+
assertContractVersion2(value);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/identity.ts
|
|
984
|
+
var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
|
|
985
|
+
var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
|
|
986
|
+
var AI_GAME_IDENTITY_PROJECTION_READS = [
|
|
987
|
+
"self",
|
|
988
|
+
"partial",
|
|
989
|
+
"full"
|
|
990
|
+
];
|
|
991
|
+
var AI_GAME_IDENTITY_TARGET_CATEGORIES = [
|
|
992
|
+
"allied",
|
|
993
|
+
"neutral",
|
|
994
|
+
"unknown",
|
|
995
|
+
"unfriendly"
|
|
996
|
+
];
|
|
997
|
+
var AI_GAME_IDENTITY_KNOWLEDGE_STATES = [
|
|
998
|
+
"unknown",
|
|
999
|
+
"partial",
|
|
1000
|
+
"full"
|
|
1001
|
+
];
|
|
1002
|
+
var AI_GAME_IDENTITY_VISIBILITY_STATES = ["visible", "occluded"];
|
|
1003
|
+
var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
|
|
1004
|
+
self: "full",
|
|
1005
|
+
visibleTargets: "partial-or-full-by-knowledge",
|
|
1006
|
+
occludedTargets: "partial-redacted"
|
|
1007
|
+
});
|
|
1008
|
+
function freezeReadonlyArray4(items) {
|
|
1009
|
+
return Object.freeze([...items]);
|
|
1010
|
+
}
|
|
1011
|
+
function assertNonEmptyString4(value, label) {
|
|
1012
|
+
if (value.trim().length === 0) {
|
|
1013
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
function assertContractVersion3(value, label = "contractVersion") {
|
|
1017
|
+
if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
|
|
1018
|
+
throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function isMember3(value, members) {
|
|
1022
|
+
return members.includes(value);
|
|
1023
|
+
}
|
|
1024
|
+
function createField(field) {
|
|
1025
|
+
assertNonEmptyString4(field.label, "field.label");
|
|
1026
|
+
assertNonEmptyString4(field.value, "field.value");
|
|
1027
|
+
return Object.freeze({
|
|
1028
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1029
|
+
label: field.label,
|
|
1030
|
+
value: field.value,
|
|
1031
|
+
redacted: field.redacted ?? false
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
function redactField(field, value) {
|
|
1035
|
+
return createField({
|
|
1036
|
+
label: field.label,
|
|
1037
|
+
value,
|
|
1038
|
+
redacted: true
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
function isAiGameIdentityProjectionRead(value) {
|
|
1042
|
+
return isMember3(value, AI_GAME_IDENTITY_PROJECTION_READS);
|
|
1043
|
+
}
|
|
1044
|
+
function isAiGameIdentityTargetCategory(value) {
|
|
1045
|
+
return isMember3(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
|
|
1046
|
+
}
|
|
1047
|
+
function isAiGameIdentityKnowledgeState(value) {
|
|
1048
|
+
return isMember3(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
|
|
1049
|
+
}
|
|
1050
|
+
function isAiGameIdentityVisibilityState(value) {
|
|
1051
|
+
return isMember3(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
|
|
1052
|
+
}
|
|
1053
|
+
function resolveAiGameIdentityProjectionRead(input) {
|
|
1054
|
+
return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
|
|
1055
|
+
}
|
|
1056
|
+
function createAiGameIdentitySelfProjection(input) {
|
|
1057
|
+
assertNonEmptyString4(input.entityId, "entityId");
|
|
1058
|
+
assertNonEmptyString4(input.label, "label");
|
|
1059
|
+
assertNonEmptyString4(input.summary, "summary");
|
|
1060
|
+
return Object.freeze({
|
|
1061
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1062
|
+
entityId: input.entityId,
|
|
1063
|
+
label: input.label,
|
|
1064
|
+
projectionRead: "self",
|
|
1065
|
+
summary: input.summary,
|
|
1066
|
+
fields: freezeReadonlyArray4(input.fields.map((field) => createField(field)))
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
function createAiGameIdentityTargetProjection(input) {
|
|
1070
|
+
assertNonEmptyString4(input.targetId, "targetId");
|
|
1071
|
+
assertNonEmptyString4(input.label, "label");
|
|
1072
|
+
assertNonEmptyString4(input.summary, "summary");
|
|
1073
|
+
assertNonEmptyString4(input.combatSummary, "combatSummary");
|
|
1074
|
+
if (!isAiGameIdentityTargetCategory(input.category)) {
|
|
1075
|
+
throw new Error("category must be a supported identity target category");
|
|
1076
|
+
}
|
|
1077
|
+
if (!isAiGameIdentityKnowledgeState(input.knowledgeState)) {
|
|
1078
|
+
throw new Error("knowledgeState must be a supported identity knowledge state");
|
|
1079
|
+
}
|
|
1080
|
+
const projectionRead = resolveAiGameIdentityProjectionRead(input);
|
|
1081
|
+
const visibility = input.lineOfSight ? "visible" : "occluded";
|
|
1082
|
+
const fields = input.fields.map(
|
|
1083
|
+
(field) => projectionRead === "full" ? createField(field) : redactField(field, input.lineOfSight ? "Unknown" : "Withheld")
|
|
1084
|
+
);
|
|
1085
|
+
return Object.freeze({
|
|
1086
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1087
|
+
targetId: input.targetId,
|
|
1088
|
+
label: input.label,
|
|
1089
|
+
category: input.category,
|
|
1090
|
+
knowledgeState: input.knowledgeState,
|
|
1091
|
+
visibility,
|
|
1092
|
+
lineOfSight: input.lineOfSight,
|
|
1093
|
+
projectionRead,
|
|
1094
|
+
summary: input.summary,
|
|
1095
|
+
combatSummary: input.combatSummary,
|
|
1096
|
+
fields: freezeReadonlyArray4(fields)
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
function selectAiGameVisibleIdentityTargets(targets) {
|
|
1100
|
+
return freezeReadonlyArray4(
|
|
1101
|
+
targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
function createAiGameIdentityProjectionContract(input) {
|
|
1105
|
+
const self = createAiGameIdentitySelfProjection(input.self);
|
|
1106
|
+
const targets = freezeReadonlyArray4(
|
|
1107
|
+
(input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
|
|
1108
|
+
);
|
|
1109
|
+
return Object.freeze({
|
|
1110
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1111
|
+
featureFlagId: AI_GAME_IDENTITY_FEATURE_FLAG_ID,
|
|
1112
|
+
authorityOwner: "identity-card",
|
|
1113
|
+
authorityMode: "projection-only",
|
|
1114
|
+
disclosurePolicy: AI_GAME_IDENTITY_DISCLOSURE_POLICY,
|
|
1115
|
+
self,
|
|
1116
|
+
targets
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
function assertAiGameIdentityProjectionContractVersion(value) {
|
|
1120
|
+
assertContractVersion3(value);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
554
1123
|
// src/world-events.ts
|
|
555
1124
|
function isCanonicalWorldEvent(event) {
|
|
556
1125
|
return event.recordType === "canonical";
|
|
@@ -702,7 +1271,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
702
1271
|
"private-or-low-witness-evidence",
|
|
703
1272
|
"costly-pressure-event"
|
|
704
1273
|
];
|
|
705
|
-
function
|
|
1274
|
+
function isMember4(value, members) {
|
|
706
1275
|
return members.includes(value);
|
|
707
1276
|
}
|
|
708
1277
|
function assertRecord(value, label) {
|
|
@@ -743,7 +1312,7 @@ function normalizeTimestamp(value, label) {
|
|
|
743
1312
|
}
|
|
744
1313
|
function normalizeMember(value, members, label) {
|
|
745
1314
|
const normalized = normalizeNonEmptyString(value, label);
|
|
746
|
-
if (!
|
|
1315
|
+
if (!isMember4(normalized, members)) {
|
|
747
1316
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
748
1317
|
}
|
|
749
1318
|
return normalized;
|
|
@@ -876,13 +1445,13 @@ function normalizeDominantReads(value) {
|
|
|
876
1445
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
877
1446
|
}
|
|
878
1447
|
function isQuietMeasureAxis(value) {
|
|
879
|
-
return
|
|
1448
|
+
return isMember4(value, QUIET_MEASURE_AXES);
|
|
880
1449
|
}
|
|
881
1450
|
function isQuietMeasureMissionProbeMode(value) {
|
|
882
|
-
return
|
|
1451
|
+
return isMember4(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
883
1452
|
}
|
|
884
1453
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
885
|
-
return
|
|
1454
|
+
return isMember4(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
886
1455
|
}
|
|
887
1456
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
888
1457
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -1387,7 +1956,27 @@ export {
|
|
|
1387
1956
|
AI_GAME_FEATURE_FLAG_ID,
|
|
1388
1957
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
1389
1958
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
1959
|
+
AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1960
|
+
AI_GAME_IDENTITY_DISCLOSURE_POLICY,
|
|
1961
|
+
AI_GAME_IDENTITY_FEATURE_FLAG_ID,
|
|
1962
|
+
AI_GAME_IDENTITY_KNOWLEDGE_STATES,
|
|
1963
|
+
AI_GAME_IDENTITY_PROJECTION_READS,
|
|
1964
|
+
AI_GAME_IDENTITY_TARGET_CATEGORIES,
|
|
1965
|
+
AI_GAME_IDENTITY_VISIBILITY_STATES,
|
|
1390
1966
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
1967
|
+
AI_GAME_MISSIONS_CONTRACT_VERSION,
|
|
1968
|
+
AI_GAME_MISSIONS_FEATURE_FLAG_ID,
|
|
1969
|
+
AI_GAME_MISSION_CLASSES,
|
|
1970
|
+
AI_GAME_MISSION_CONFIDENCE_BANDS,
|
|
1971
|
+
AI_GAME_MISSION_FEEDBACK_CHANNELS,
|
|
1972
|
+
AI_GAME_MISSION_INFLUENCE_SOURCES,
|
|
1973
|
+
AI_GAME_MISSION_OBJECTIVE_STATUSES,
|
|
1974
|
+
AI_GAME_MISSION_PLAYER_RESPONSE_KINDS,
|
|
1975
|
+
AI_GAME_MISSION_PREFERENCE_DIMENSIONS,
|
|
1976
|
+
AI_GAME_MISSION_READINESS_BANDS,
|
|
1977
|
+
AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
|
|
1978
|
+
AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
|
|
1979
|
+
AI_GAME_MISSION_REWARD_KINDS,
|
|
1391
1980
|
AI_GAME_PACKAGE,
|
|
1392
1981
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
1393
1982
|
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
@@ -1436,10 +2025,25 @@ export {
|
|
|
1436
2025
|
QUIET_MEASURE_PERSPECTIVES,
|
|
1437
2026
|
QUIET_MEASURE_SIGNAL_BANDS,
|
|
1438
2027
|
aiGameFeatureFlags,
|
|
2028
|
+
assertAiGameIdentityProjectionContractVersion,
|
|
2029
|
+
assertAiGameMissionContractVersion,
|
|
1439
2030
|
classifyAiGameTask,
|
|
1440
2031
|
createAiGameAcademicTrainingSnapshot,
|
|
2032
|
+
createAiGameIdentityProjectionContract,
|
|
2033
|
+
createAiGameIdentitySelfProjection,
|
|
2034
|
+
createAiGameIdentityTargetProjection,
|
|
1441
2035
|
createAiGameInstitutionEligibility,
|
|
1442
2036
|
createAiGameMartialTrainingSnapshot,
|
|
2037
|
+
createAiGameMissionDefinition,
|
|
2038
|
+
createAiGameMissionMccFocusInfluence,
|
|
2039
|
+
createAiGameMissionObjectiveState,
|
|
2040
|
+
createAiGameMissionPlayerModelEvidence,
|
|
2041
|
+
createAiGameMissionPlayerModelInfluenceInput,
|
|
2042
|
+
createAiGameMissionPlayerResponse,
|
|
2043
|
+
createAiGameMissionReadinessContext,
|
|
2044
|
+
createAiGameMissionRewardBound,
|
|
2045
|
+
createAiGameMissionRewardEnvelope,
|
|
2046
|
+
createAiGameMissionRewardGrant,
|
|
1443
2047
|
createAiGamePlayerSystemAlert,
|
|
1444
2048
|
createAiGamePlayerSystemPreferenceConfidenceState,
|
|
1445
2049
|
createAiGamePlayerSystemPreferenceInput,
|
|
@@ -1457,6 +2061,21 @@ export {
|
|
|
1457
2061
|
gameEventFeatureFlags,
|
|
1458
2062
|
getAiGamePlayerSystemFocusModeContract,
|
|
1459
2063
|
getAiGamePlayerSystemModuleContract,
|
|
2064
|
+
isAiGameIdentityKnowledgeState,
|
|
2065
|
+
isAiGameIdentityProjectionRead,
|
|
2066
|
+
isAiGameIdentityTargetCategory,
|
|
2067
|
+
isAiGameIdentityVisibilityState,
|
|
2068
|
+
isAiGameMissionClass,
|
|
2069
|
+
isAiGameMissionConfidenceBand,
|
|
2070
|
+
isAiGameMissionFeedbackChannel,
|
|
2071
|
+
isAiGameMissionInfluenceSource,
|
|
2072
|
+
isAiGameMissionObjectiveStatus,
|
|
2073
|
+
isAiGameMissionPlayerResponseKind,
|
|
2074
|
+
isAiGameMissionPreferenceDimension,
|
|
2075
|
+
isAiGameMissionReadinessBand,
|
|
2076
|
+
isAiGameMissionRepeatedSignalHandling,
|
|
2077
|
+
isAiGameMissionRewardCapSemantic,
|
|
2078
|
+
isAiGameMissionRewardKind,
|
|
1460
2079
|
isAiGamePlayerSystemAlertDeliverable,
|
|
1461
2080
|
isAiGamePlayerSystemAlertPriority,
|
|
1462
2081
|
isAiGamePlayerSystemConfidenceBand,
|
|
@@ -1492,9 +2111,12 @@ export {
|
|
|
1492
2111
|
normalizeIncidentImpactVector,
|
|
1493
2112
|
packageDescriptor,
|
|
1494
2113
|
projectTopicForAudience,
|
|
2114
|
+
resolveAiGameIdentityProjectionRead,
|
|
2115
|
+
resolveAiGameMissionConfidenceBand,
|
|
1495
2116
|
resolveAiGamePlayerAddressText,
|
|
1496
2117
|
resolveAiGamePlayerSystemConfidenceBand,
|
|
1497
2118
|
resolveAiGameTaskBatch,
|
|
1498
|
-
selectAiGamePlayerSystemAlertsForFocusMode
|
|
2119
|
+
selectAiGamePlayerSystemAlertsForFocusMode,
|
|
2120
|
+
selectAiGameVisibleIdentityTargets
|
|
1499
2121
|
};
|
|
1500
2122
|
//# sourceMappingURL=index.js.map
|