@plasius/ai-game 0.3.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 +15 -0
- package/README.md +31 -2
- package/dist/index.cjs +528 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -1
- package/dist/index.d.ts +232 -1
- package/dist/index.js +492 -27
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0013-adaptive-mission-contract-boundary.md +63 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -551,6 +551,435 @@ 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
|
+
|
|
554
983
|
// src/identity.ts
|
|
555
984
|
var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
|
|
556
985
|
var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
|
|
@@ -576,25 +1005,25 @@ var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
|
|
|
576
1005
|
visibleTargets: "partial-or-full-by-knowledge",
|
|
577
1006
|
occludedTargets: "partial-redacted"
|
|
578
1007
|
});
|
|
579
|
-
function
|
|
1008
|
+
function freezeReadonlyArray4(items) {
|
|
580
1009
|
return Object.freeze([...items]);
|
|
581
1010
|
}
|
|
582
|
-
function
|
|
1011
|
+
function assertNonEmptyString4(value, label) {
|
|
583
1012
|
if (value.trim().length === 0) {
|
|
584
1013
|
throw new Error(`${label} must be a non-empty string`);
|
|
585
1014
|
}
|
|
586
1015
|
}
|
|
587
|
-
function
|
|
1016
|
+
function assertContractVersion3(value, label = "contractVersion") {
|
|
588
1017
|
if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
|
|
589
1018
|
throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
|
|
590
1019
|
}
|
|
591
1020
|
}
|
|
592
|
-
function
|
|
1021
|
+
function isMember3(value, members) {
|
|
593
1022
|
return members.includes(value);
|
|
594
1023
|
}
|
|
595
1024
|
function createField(field) {
|
|
596
|
-
|
|
597
|
-
|
|
1025
|
+
assertNonEmptyString4(field.label, "field.label");
|
|
1026
|
+
assertNonEmptyString4(field.value, "field.value");
|
|
598
1027
|
return Object.freeze({
|
|
599
1028
|
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
600
1029
|
label: field.label,
|
|
@@ -610,38 +1039,38 @@ function redactField(field, value) {
|
|
|
610
1039
|
});
|
|
611
1040
|
}
|
|
612
1041
|
function isAiGameIdentityProjectionRead(value) {
|
|
613
|
-
return
|
|
1042
|
+
return isMember3(value, AI_GAME_IDENTITY_PROJECTION_READS);
|
|
614
1043
|
}
|
|
615
1044
|
function isAiGameIdentityTargetCategory(value) {
|
|
616
|
-
return
|
|
1045
|
+
return isMember3(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
|
|
617
1046
|
}
|
|
618
1047
|
function isAiGameIdentityKnowledgeState(value) {
|
|
619
|
-
return
|
|
1048
|
+
return isMember3(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
|
|
620
1049
|
}
|
|
621
1050
|
function isAiGameIdentityVisibilityState(value) {
|
|
622
|
-
return
|
|
1051
|
+
return isMember3(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
|
|
623
1052
|
}
|
|
624
1053
|
function resolveAiGameIdentityProjectionRead(input) {
|
|
625
1054
|
return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
|
|
626
1055
|
}
|
|
627
1056
|
function createAiGameIdentitySelfProjection(input) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1057
|
+
assertNonEmptyString4(input.entityId, "entityId");
|
|
1058
|
+
assertNonEmptyString4(input.label, "label");
|
|
1059
|
+
assertNonEmptyString4(input.summary, "summary");
|
|
631
1060
|
return Object.freeze({
|
|
632
1061
|
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
633
1062
|
entityId: input.entityId,
|
|
634
1063
|
label: input.label,
|
|
635
1064
|
projectionRead: "self",
|
|
636
1065
|
summary: input.summary,
|
|
637
|
-
fields:
|
|
1066
|
+
fields: freezeReadonlyArray4(input.fields.map((field) => createField(field)))
|
|
638
1067
|
});
|
|
639
1068
|
}
|
|
640
1069
|
function createAiGameIdentityTargetProjection(input) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1070
|
+
assertNonEmptyString4(input.targetId, "targetId");
|
|
1071
|
+
assertNonEmptyString4(input.label, "label");
|
|
1072
|
+
assertNonEmptyString4(input.summary, "summary");
|
|
1073
|
+
assertNonEmptyString4(input.combatSummary, "combatSummary");
|
|
645
1074
|
if (!isAiGameIdentityTargetCategory(input.category)) {
|
|
646
1075
|
throw new Error("category must be a supported identity target category");
|
|
647
1076
|
}
|
|
@@ -664,17 +1093,17 @@ function createAiGameIdentityTargetProjection(input) {
|
|
|
664
1093
|
projectionRead,
|
|
665
1094
|
summary: input.summary,
|
|
666
1095
|
combatSummary: input.combatSummary,
|
|
667
|
-
fields:
|
|
1096
|
+
fields: freezeReadonlyArray4(fields)
|
|
668
1097
|
});
|
|
669
1098
|
}
|
|
670
1099
|
function selectAiGameVisibleIdentityTargets(targets) {
|
|
671
|
-
return
|
|
1100
|
+
return freezeReadonlyArray4(
|
|
672
1101
|
targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
|
|
673
1102
|
);
|
|
674
1103
|
}
|
|
675
1104
|
function createAiGameIdentityProjectionContract(input) {
|
|
676
1105
|
const self = createAiGameIdentitySelfProjection(input.self);
|
|
677
|
-
const targets =
|
|
1106
|
+
const targets = freezeReadonlyArray4(
|
|
678
1107
|
(input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
|
|
679
1108
|
);
|
|
680
1109
|
return Object.freeze({
|
|
@@ -688,7 +1117,7 @@ function createAiGameIdentityProjectionContract(input) {
|
|
|
688
1117
|
});
|
|
689
1118
|
}
|
|
690
1119
|
function assertAiGameIdentityProjectionContractVersion(value) {
|
|
691
|
-
|
|
1120
|
+
assertContractVersion3(value);
|
|
692
1121
|
}
|
|
693
1122
|
|
|
694
1123
|
// src/world-events.ts
|
|
@@ -842,7 +1271,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
842
1271
|
"private-or-low-witness-evidence",
|
|
843
1272
|
"costly-pressure-event"
|
|
844
1273
|
];
|
|
845
|
-
function
|
|
1274
|
+
function isMember4(value, members) {
|
|
846
1275
|
return members.includes(value);
|
|
847
1276
|
}
|
|
848
1277
|
function assertRecord(value, label) {
|
|
@@ -883,7 +1312,7 @@ function normalizeTimestamp(value, label) {
|
|
|
883
1312
|
}
|
|
884
1313
|
function normalizeMember(value, members, label) {
|
|
885
1314
|
const normalized = normalizeNonEmptyString(value, label);
|
|
886
|
-
if (!
|
|
1315
|
+
if (!isMember4(normalized, members)) {
|
|
887
1316
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
888
1317
|
}
|
|
889
1318
|
return normalized;
|
|
@@ -1016,13 +1445,13 @@ function normalizeDominantReads(value) {
|
|
|
1016
1445
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
1017
1446
|
}
|
|
1018
1447
|
function isQuietMeasureAxis(value) {
|
|
1019
|
-
return
|
|
1448
|
+
return isMember4(value, QUIET_MEASURE_AXES);
|
|
1020
1449
|
}
|
|
1021
1450
|
function isQuietMeasureMissionProbeMode(value) {
|
|
1022
|
-
return
|
|
1451
|
+
return isMember4(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
1023
1452
|
}
|
|
1024
1453
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
1025
|
-
return
|
|
1454
|
+
return isMember4(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
1026
1455
|
}
|
|
1027
1456
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
1028
1457
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -1535,6 +1964,19 @@ export {
|
|
|
1535
1964
|
AI_GAME_IDENTITY_TARGET_CATEGORIES,
|
|
1536
1965
|
AI_GAME_IDENTITY_VISIBILITY_STATES,
|
|
1537
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,
|
|
1538
1980
|
AI_GAME_PACKAGE,
|
|
1539
1981
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
1540
1982
|
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
@@ -1584,6 +2026,7 @@ export {
|
|
|
1584
2026
|
QUIET_MEASURE_SIGNAL_BANDS,
|
|
1585
2027
|
aiGameFeatureFlags,
|
|
1586
2028
|
assertAiGameIdentityProjectionContractVersion,
|
|
2029
|
+
assertAiGameMissionContractVersion,
|
|
1587
2030
|
classifyAiGameTask,
|
|
1588
2031
|
createAiGameAcademicTrainingSnapshot,
|
|
1589
2032
|
createAiGameIdentityProjectionContract,
|
|
@@ -1591,6 +2034,16 @@ export {
|
|
|
1591
2034
|
createAiGameIdentityTargetProjection,
|
|
1592
2035
|
createAiGameInstitutionEligibility,
|
|
1593
2036
|
createAiGameMartialTrainingSnapshot,
|
|
2037
|
+
createAiGameMissionDefinition,
|
|
2038
|
+
createAiGameMissionMccFocusInfluence,
|
|
2039
|
+
createAiGameMissionObjectiveState,
|
|
2040
|
+
createAiGameMissionPlayerModelEvidence,
|
|
2041
|
+
createAiGameMissionPlayerModelInfluenceInput,
|
|
2042
|
+
createAiGameMissionPlayerResponse,
|
|
2043
|
+
createAiGameMissionReadinessContext,
|
|
2044
|
+
createAiGameMissionRewardBound,
|
|
2045
|
+
createAiGameMissionRewardEnvelope,
|
|
2046
|
+
createAiGameMissionRewardGrant,
|
|
1594
2047
|
createAiGamePlayerSystemAlert,
|
|
1595
2048
|
createAiGamePlayerSystemPreferenceConfidenceState,
|
|
1596
2049
|
createAiGamePlayerSystemPreferenceInput,
|
|
@@ -1612,6 +2065,17 @@ export {
|
|
|
1612
2065
|
isAiGameIdentityProjectionRead,
|
|
1613
2066
|
isAiGameIdentityTargetCategory,
|
|
1614
2067
|
isAiGameIdentityVisibilityState,
|
|
2068
|
+
isAiGameMissionClass,
|
|
2069
|
+
isAiGameMissionConfidenceBand,
|
|
2070
|
+
isAiGameMissionFeedbackChannel,
|
|
2071
|
+
isAiGameMissionInfluenceSource,
|
|
2072
|
+
isAiGameMissionObjectiveStatus,
|
|
2073
|
+
isAiGameMissionPlayerResponseKind,
|
|
2074
|
+
isAiGameMissionPreferenceDimension,
|
|
2075
|
+
isAiGameMissionReadinessBand,
|
|
2076
|
+
isAiGameMissionRepeatedSignalHandling,
|
|
2077
|
+
isAiGameMissionRewardCapSemantic,
|
|
2078
|
+
isAiGameMissionRewardKind,
|
|
1615
2079
|
isAiGamePlayerSystemAlertDeliverable,
|
|
1616
2080
|
isAiGamePlayerSystemAlertPriority,
|
|
1617
2081
|
isAiGamePlayerSystemConfidenceBand,
|
|
@@ -1648,6 +2112,7 @@ export {
|
|
|
1648
2112
|
packageDescriptor,
|
|
1649
2113
|
projectTopicForAudience,
|
|
1650
2114
|
resolveAiGameIdentityProjectionRead,
|
|
2115
|
+
resolveAiGameMissionConfidenceBand,
|
|
1651
2116
|
resolveAiGamePlayerAddressText,
|
|
1652
2117
|
resolveAiGamePlayerSystemConfidenceBand,
|
|
1653
2118
|
resolveAiGameTaskBatch,
|