@plasius/ai-game
v0.6.5
Published
Game-domain AI contracts for player action validation, NPC actions, gossip, and feedback.
Maintainers
Readme
@plasius/ai-game
Game-domain AI contracts for player action validation, adaptive System missions, NPC actions, gossip, observed event logs, Quiet Measure mission probes, Judgment disclosure surfaces, MCC guidance, and Player System-readable training recommendations.
Scope
This package is part of the layered @plasius/ai-* package family. It exports canonical public contracts for adaptive System missions, world events, world-event ingestion, incident impact state, gossip topic projection, Quiet Measure hidden-runtime integration surfaces, and the Player System bridge layer that consumes @plasius/training.
Install
npm install @plasius/ai-gameExports
import {
AI_GAME_PACKAGE,
AI_GAME_FEATURE_FLAG_ID,
AI_GAME_TRAINING_INSTITUTIONS_FEATURE_FLAG_ID,
aiGameFeatureFlags,
packageDescriptor,
AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
type AiGameTrainingState,
type AiGameInstitutionEligibility,
type AiGameSpecializationRecommendation,
type GameWorldEvent,
type WorldEventIngestionPort,
type WorldIncidentThread,
type GossipTopic,
type GossipPerspectiveProjection,
type QuietMeasureAxisSummary,
type QuietMeasureMissionProbe,
type QuietMeasureJudgmentResponse
} from "@plasius/ai-game";Training bridge contracts
The training surface intentionally reuses @plasius/training as the authority for institutions, trust tiers, and specialization tracks.
AiGameTrainingStatere-exports the canonical progression record from@plasius/training.AiGameInstitutionEligibilitymakes stage-gated institutional availability explicit for Player System consumers.AiGameTrainingTrustMarkercarries trust evidence without copying broader profile state.AiGameTrainingAcademicMissionPrerequisite,AiGameTrainingSchoolProgression,AiGameTrainingAcademyAdmission, andAiGameTrainingTrackSelectionre-export the academy authority contracts from@plasius/training.AiGameSpecializationRecommendationkeeps leaning and recommended-track output inside the canonicalinternalized/externalized/hybridMCC doctrine.createAiGameTrainingStateSnapshotfreezes a Player System-readable bundle of progression, institution, eligibility, trust-marker, and recommendation data.createAiGameAcademicTrainingSnapshotpackages school-stage progress, academy admissions, track-selection authority, and Player System recommendations into one frozen bridge payload.
Martial training bridge contracts
The martial slice remains a bridge surface over the published
@plasius/training authority package rather than a second source of truth.
AI_GAME_TRAINING_MARTIAL_FEATURE_FLAG_IDre-exports the inheritedisekai.training.martial.enabledrollout key.AI_GAME_TRAINING_BARRACKS_DRILL_DELIVERY_MODES,AI_GAME_TRAINING_MARTIAL_TECHNIQUE_FAMILIES, andAI_GAME_TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIESexpose the canonical barracks and bounded anti-spell vocabulary to ai-game consumers.AiGameTrainingBarracksDrill,AiGameTrainingMissionTechniqueUnlock,AiGameTrainingMartialTechnique, andAiGameTrainingAntiSpellFieldcraftDisciplinere-export the authoritative training contracts directly.createAiGameMartialTrainingSnapshotfreezes a Player System-readable bundle of barracks drills, mission-earned unlocks, martial techniques, and bounded anti-spell fieldcraft without redefining those authority models locally.
Player System core contracts
The Player System core contracts are dependency-free shared boundaries under
isekai.player-system.core.enabled. They provide:
- versioned ambient, focused, and combat-safe focus-mode contracts;
- module descriptors for identity, missions, guild quests, event logs, MCC, tutorials, and the points store;
- alert priorities with combat-safe delivery filtering that preserves critical and high-priority alerts; and
- privacy-safe preference-learning inputs with bounded confidence scores, confidence bands, and immutable session profiles.
Use createAiGamePlayerSystemSession(),
createAiGamePlayerSystemPreferenceProfile(), and
selectAiGamePlayerSystemAlertsForFocusMode() at package boundaries. The
contracts intentionally contain no account identifiers, credentials, or raw
player telemetry.
Guidance cue contracts
Guidance cues reuse the core alert-priority vocabulary while adding explicit
multimodal fallback identifiers and bounded delivery assumptions under
isekai.player-system.guidance-nfr.enabled:
createAiGamePlayerSystemGuidanceCue()validates cue source/fallback pairs.maxPayloadBytesis capped at 4,096 bytes andmaxOccurrencesPerMinuteis capped at 30 to make client performance assumptions machine-checkable.- Voice, narration, and speech-capture failures map to touch/text summaries, live-region status copy, and visible manual actions respectively.
Adaptive mission contracts
Adaptive System missions are versioned, dependency-free shared contracts under
isekai.player-system.missions.enabled. They keep the Player System's internal
mission vocabulary portable while preserving progression safety.
AiGameMissionDefinitioncaptures bootstrap, short-term, medium-term, and long-horizon mission guidance with explicit readiness context, nearby opportunity codes, world-pressure codes, and dualaudio/visualfeedback channels.AiGameMissionObjectiveStatefreezes bounded progress snapshots for mission objectives without leaking host runtime internals.AiGameMissionPlayerResponseexplicitly models acceptance, refusal, ignored or declined outcomes, pinning, completion, failure, and abandonment so those events can feed the player model safely.AiGameMissionPlayerModelInfluenceInputcarries preference dimensions, bounded confidence, evidence metadata, repeated-signal handling, MCC focus influence, and readiness or gate context.AiGameMissionRewardEnvelopeencodes progression-safe accelerants only: bounded currencies, items, recipes, temporary modifiers, and knowledge unlocks with minimum, maximum, cap, cap semantic, readiness context, stage gates, and explicitcannotSkipReasonCodes.
Use createAiGameMissionDefinition(),
createAiGameMissionPlayerResponse(), and
createAiGameMissionRewardEnvelope() at package boundaries. The mission
surface intentionally avoids raw telemetry, progression writes, and
authority-owned tuning data.
MCC guidance contracts
MCC guidance contracts provide a bounded Player System bridge under
isekai.player-system.mcc-guidance.enabled:
AiGameMccFocusTargetcarries a declaredinternalized,externalized, orhybridgrowth direction with bounded mission influence.AiGameMccReadinessStateexposesstable,pressured, orrestrictedreadiness plus explicit thermal, fatigue, chaos-pressure, target-burden, stage-gate, and death-impairment warnings.AiGameSpellcraftRecommendationdescribes training, material, social-prerequisite, or refinement guidance without becoming an authority write.AiGameSpellcraftAdvisoryis explicitlypreview-onlyand points to thespellcraft-systemas the authoritative owner for feasibility and authoring.createAiGameMccGuidanceSnapshot()validates references, bounds collection sizes, and freezes the complete payload for transport.
The growth-direction vocabulary is validated through the published
@plasius/training authority package. MCC feasibility, spell grammar, risk
validation, and state mutation remain outside @plasius/ai-game.
Tutorial contracts
Tutorial contracts provide dormant, contextual Player System coaching under
isekai.player-system.tutorial.enabled:
AiGameTutorialStepdescribes a per-action capability, canonical evolution stage, trigger kinds, prerequisite markers, replayability, and combat-safe presentation.AiGameTutorialProgressionStaterecords active, dormant, completed, and declined state together with completed steps, refusal count, replay count, and trigger/replay timestamps.AiGameTutorialPrerequisitedefines bounded markers for school access, apprenticeship, academy admission, guild standing, divine progression, and spellcraft readiness without becoming the authority for those systems.AiGameTutorialTriggersupports awakening, first-action, explicit-request, and progression-gated resurfacing.createAiGameTutorialTrack()validates all step, prerequisite, trigger, and progression references and freezes the complete transport payload.
Tutorial tracks are foregrounded for first contact, dormant by default after onboarding, replayable after unlock, and reduced to safe cues during active combat unless the player explicitly enters a safe tutorial scenario.
Guild-quest synchronization contracts
Guild quests are externally authored by guild authorities and synchronized
into the Player System under isekai.player-system.guild-quests.enabled.
AiGameGuildQuestContract.guildTruthowns the guild contract identity, status, objective progress, failure details, authority revision, and preview-only reward data.AiGameGuildQuestContract.systemAnnotationsis advisory only. It contains recommendation, synergy, linked-mission, and reason-code metadata without guild authority fields or reward grants.AiGameGuildQuestSyncPayloadcarries revisioned quest upserts and explicit tombstones so consumers can remove quests without treating a partial sync as an authoritative empty set.- Reward previews are not grants. The guild remains the authority for claim eligibility, rewards, rank gates, consequences, and final resolution.
Use createAiGameGuildQuest() and
createAiGameGuildQuestSyncPayload() at package boundaries. The factories
validate progress bounds, failure-state requirements, unique identifiers,
guild ownership, and sync revision metadata, and return frozen payloads.
Quiet Measure contracts
The Quiet Measure surface is intentionally structured as a hidden-runtime contract, not a turnkey morality meter.
- Axis and derived-read contracts expose bounded summaries, confidence bands, evidence windows, and perspective scope without publishing host-specific raw score storage.
- Mission probe contracts model
Clarify,Tempt, andReinforcemodes plusRestorative,Dominant,Detached, and optionalPerformativeresolution shapes. - Judgment contracts model request, eligibility, insufficient-evidence, and verdict responses with
title-and-verdict-onlydisclosure as the default public output. - Runtime helpers validate and defensively copy public Quiet Measure request, title, dominant-read, and reason-code payloads so malformed host input fails closed without leaking hidden-score internals.
- Evaluation fixtures for hero, villain, counterfeit, tyrant, and redemption regression cases belong in
@plasius/ai-evals, not this package.
Identity projection contracts
Identity projections are versioned, projection-only payloads under
isekai.player-system.identity.enabled. The identity-card boundary remains the
authority of record; @plasius/ai-game only defines portable consumer
contracts.
- Self projections are full reads.
- Visible targets are full only when both line of sight and full knowledge are present; otherwise fields are redacted into a partial read.
- Occluded targets always become partial reads with
Withheldfield values. - Target categories are
allied,neutral,unknown, andunfriendly.
Use createAiGameIdentityProjectionContract() to build an immutable payload
and selectAiGameVisibleIdentityTargets() before rendering line-of-sight
surfaces. The contract does not carry hidden truth or authority-owned mutation
data.
Observed event log and gossip export contracts
Observed event contracts provide a shared, privacy-safe basis for Player System
logs and gossip transport under isekai.player-system.logs.enabled:
AiGameObservedEventcarries bounded domain references, summaries, visibility, significance, and tags without raw player telemetry or account identifiers.AiGameObservedEventRecencyWindowvalidates that events fall inside a single time-bounded window.AiGameObservedEventHighlightSummaryreferences event IDs from its source window rather than copying event truth.AiGameGossipExportpackages one recency window and validated highlights for a declared player, NPC, or public audience.
Use createAiGameObservedEvent(),
createAiGameObservedEventRecencyWindow(),
createAiGameObservedEventHighlightSummary(), and
createAiGameGossipExport() at package boundaries. Audience authorization,
feature-flag evaluation, persistence, and gossip generation remain the
responsibility of consuming services.
Development
npm install
npm run build
npm test
npm run test:coverage
npm run pack:checkApprenticeship handoff contracts
The apprenticeship bridge is enabled by isekai.training.apprenticeship.enabled
and keeps authority separated across the Player System, training, and crafting
contexts.
createAiGameApprenticeshipSponsorshipmodels the institution and sponsor relationship using opaque subject identifiers and bounded scope codes.createAiGameApprenticeshipSupervisionmodels direct, delegated, or milestone supervision and its checkpoints.createAiGameApprenticeshipReadinesscarries trust, MCC track, and prerequisite evidence. Areadyrecord cannot contain unmet prerequisites.createAiGameApprenticeshipHandoffemits request-only payloads forspellcraft-system,item-crafting-system, ordungeon-crafting-system, and only accepts areadyreadiness state.
The Player System may guide and route a request, but the target system remains authoritative for validation, authorization, execution, and outcome. Handoff payloads contain no secrets or hidden System state. See ADR-0018 for the boundary and rollback rules.
Feature flags
ai.game.event-recorder.contracts.enabledai.game.event-recorder.ingestion.enabledai.game.event-recorder.impact.enabledai.game.npc-gossip.topics.enabledai.game.npc-gossip.perspective.enabledai.game.npc-gossip.lifecycle.enabledisekai.player-system.quiet-measure.enabledisekai.player-system.core.enabledisekai.player-system.guidance-nfr.enabledisekai.player-system.mcc-guidance.enabledisekai.player-system.tutorial.enabledisekai.player-system.identity.enabledisekai.player-system.logs.enabledisekai.player-system.guild-quests.enabledisekai.training.institutions.enabledisekai.training.academies.enabledisekai.training.martial.enabledisekai.training.apprenticeship.enabled
Governance
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- ADRs: docs/adrs
- CLA and legal docs: legal
License
Apache-2.0
