@plasius/ai-game 0.1.3 → 0.1.6
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 +8 -7
- package/README.md +24 -3
- package/dist/index.cjs +197 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -2
- package/dist/index.d.ts +81 -2
- package/dist/index.js +185 -2
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0009-protected-main-release-preparation-and-version-reconciliation.md +57 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
5
|
The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/)**, and this project adheres to **[Semantic Versioning](https://semver.org/spec/v2.0.0.html)**.
|
|
6
|
-
|
|
7
6
|
## [Unreleased]
|
|
8
|
-
|
|
9
7
|
- **Added**
|
|
10
8
|
- (placeholder)
|
|
11
9
|
|
|
@@ -17,8 +15,7 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
17
15
|
|
|
18
16
|
- **Security**
|
|
19
17
|
- (placeholder)
|
|
20
|
-
|
|
21
|
-
## [0.1.3] - 2026-06-01
|
|
18
|
+
## [0.1.6] - 2026-06-13
|
|
22
19
|
|
|
23
20
|
- **Added**
|
|
24
21
|
- Implemented canonical world event contracts with candidate and canonical envelopes, taxonomy, payload typing, and visibility classes.
|
|
@@ -26,12 +23,16 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
26
23
|
- Added incident lifecycle, resolution link, and impact vector models.
|
|
27
24
|
- Added structured gossip topic contracts with lifecycle, confidence, and perspective projection projections.
|
|
28
25
|
- Documented the public `@plasius/ai-game` contract boundary for Quiet Measure hidden-character inference, mission probes, and Judgment verdict models while keeping raw runtime scores host-private by default.
|
|
26
|
+
- Added Player System Points Store ledger, spend-policy, authority-boundary, and proto-social devolution contracts for `PP`, `ESP`, `TIS`, and `DIS`.
|
|
29
27
|
|
|
30
28
|
- **Changed**
|
|
31
|
-
- Extended public package surface to include all world-event and
|
|
29
|
+
- Extended public package surface to include all world-event, gossip, and points-store contract families needed by `ai-game` and Player System consumers.
|
|
30
|
+
- Moved npm publication to a protected-main-safe release-prep PR workflow with reconciled package, tag, and npm version state.
|
|
32
31
|
|
|
33
32
|
- **Fixed**
|
|
34
|
-
-
|
|
33
|
+
- Preserved release-branch version and changelog edits so protected-main publish runs can complete from prepared metadata on `main`.
|
|
34
|
+
- Detected unpublished prepared releases from `main` metadata instead of merge-commit titles so merged release PRs actually publish.
|
|
35
|
+
- Promoted `Unreleased` changelog entries into versioned release sections through a tested helper instead of fragile inline shell parsing.
|
|
35
36
|
|
|
36
37
|
- **Security**
|
|
37
38
|
- (placeholder)
|
|
@@ -58,4 +59,4 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
58
59
|
|
|
59
60
|
[0.1.1]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.1
|
|
60
61
|
[0.1.2]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.2
|
|
61
|
-
[0.1.
|
|
62
|
+
[0.1.6]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.6
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @plasius/ai-game
|
|
2
2
|
|
|
3
|
-
Game-domain AI contracts for player action validation, NPC actions, gossip, and
|
|
3
|
+
Game-domain AI contracts for player action validation, NPC actions, gossip, feedback, and points-store authority seams.
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
-
This package is part of the layered `@plasius/ai-*` package family. It exports canonical public contracts for world events, world-event ingestion, incident impact state,
|
|
7
|
+
This package is part of the layered `@plasius/ai-*` package family. It exports canonical public contracts for world events, world-event ingestion, incident impact state, gossip topic projection, and Player System points-store ledgers and spend policies.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -18,13 +18,17 @@ npm install @plasius/ai-game
|
|
|
18
18
|
import {
|
|
19
19
|
AI_GAME_PACKAGE,
|
|
20
20
|
AI_GAME_FEATURE_FLAG_ID,
|
|
21
|
+
AI_GAME_POINTS_STORE_FEATURE_FLAG_ID,
|
|
21
22
|
aiGameFeatureFlags,
|
|
23
|
+
getAiGameProtoSocialDevolutionPolicy,
|
|
24
|
+
getDefaultAiGamePointsSpendPolicies,
|
|
22
25
|
packageDescriptor,
|
|
23
26
|
type GameWorldEvent,
|
|
24
27
|
type WorldEventIngestionPort,
|
|
25
28
|
type WorldIncidentThread,
|
|
26
29
|
type GossipTopic,
|
|
27
|
-
type GossipPerspectiveProjection
|
|
30
|
+
type GossipPerspectiveProjection,
|
|
31
|
+
type AiGamePointsLedgerSnapshot
|
|
28
32
|
} from "@plasius/ai-game";
|
|
29
33
|
```
|
|
30
34
|
|
|
@@ -38,6 +42,15 @@ npm run test:coverage
|
|
|
38
42
|
npm run pack:check
|
|
39
43
|
```
|
|
40
44
|
|
|
45
|
+
## Release Workflow
|
|
46
|
+
|
|
47
|
+
Protected `main` releases use a two-step flow:
|
|
48
|
+
|
|
49
|
+
1. Run `.github/workflows/cd.yml` with `bump=patch|minor|major` to push a `release/vX.Y.Z` prep branch and, when repository settings allow it, open the matching PR from `main`. The workflow creates that branch before committing the versioned `package.json` and `CHANGELOG.md` updates, and a tested helper promotes the current `Unreleased` section into the matching version header so the release metadata is preserved for review and publish.
|
|
50
|
+
2. Merge that PR to `main` so the next `main` push can detect the unpublished versioned metadata, tag the release, publish to npm, and publish the GitHub release.
|
|
51
|
+
|
|
52
|
+
If a release version is already prepared on `main` and only publication remains, rerun `.github/workflows/cd.yml` with `bump=none` to publish the current version from `main` without creating a new release branch.
|
|
53
|
+
|
|
41
54
|
## Feature flags
|
|
42
55
|
|
|
43
56
|
- `ai.game.event-recorder.contracts.enabled`
|
|
@@ -46,6 +59,14 @@ npm run pack:check
|
|
|
46
59
|
- `ai.game.npc-gossip.topics.enabled`
|
|
47
60
|
- `ai.game.npc-gossip.perspective.enabled`
|
|
48
61
|
- `ai.game.npc-gossip.lifecycle.enabled`
|
|
62
|
+
- `isekai.player-system.points-store.enabled`
|
|
63
|
+
|
|
64
|
+
## Points Store contracts
|
|
65
|
+
|
|
66
|
+
- `AI_GAME_POINTS_LEDGER_IDS` exports the canonical `PP`, `ESP`, `TIS`, and `DIS` ledger IDs as `pp`, `esp`, `tis`, and `dis`.
|
|
67
|
+
- `resolveAiGamePointsAuthorityBoundary()` maps each ledger to its public authority band and owning external system.
|
|
68
|
+
- `getDefaultAiGamePointsSpendPolicies()` describes the documented spend-policy surface for each ledger.
|
|
69
|
+
- `getAiGameProtoSocialDevolutionPolicy()` and `evaluateAiGameProtoSocialDevolutionEligibility()` define the one-time proto-social PP devolution window and its closure after social-form lock.
|
|
49
70
|
|
|
50
71
|
## Governance
|
|
51
72
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,11 @@ __export(index_exports, {
|
|
|
31
31
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID: () => AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
32
32
|
AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
|
|
33
33
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
34
|
+
AI_GAME_PLAYER_EVOLUTION_STAGES: () => AI_GAME_PLAYER_EVOLUTION_STAGES,
|
|
35
|
+
AI_GAME_POINTS_AUTHORITY_BANDS: () => AI_GAME_POINTS_AUTHORITY_BANDS,
|
|
36
|
+
AI_GAME_POINTS_AUTHORITY_SYSTEMS: () => AI_GAME_POINTS_AUTHORITY_SYSTEMS,
|
|
37
|
+
AI_GAME_POINTS_LEDGER_IDS: () => AI_GAME_POINTS_LEDGER_IDS,
|
|
38
|
+
AI_GAME_POINTS_STORE_FEATURE_FLAG_ID: () => AI_GAME_POINTS_STORE_FEATURE_FLAG_ID,
|
|
34
39
|
AI_GAME_TASK_AUTHORITY_BOUNDARIES: () => AI_GAME_TASK_AUTHORITY_BOUNDARIES,
|
|
35
40
|
AI_GAME_TASK_DECISIONS: () => AI_GAME_TASK_DECISIONS,
|
|
36
41
|
AI_GAME_TASK_KINDS: () => AI_GAME_TASK_KINDS,
|
|
@@ -39,7 +44,13 @@ __export(index_exports, {
|
|
|
39
44
|
AI_GAME_TTS_CACHE_POLICIES: () => AI_GAME_TTS_CACHE_POLICIES,
|
|
40
45
|
aiGameFeatureFlags: () => aiGameFeatureFlags,
|
|
41
46
|
classifyAiGameTask: () => classifyAiGameTask,
|
|
47
|
+
createAiGamePointsLedgerSnapshot: () => createAiGamePointsLedgerSnapshot,
|
|
48
|
+
evaluateAiGameProtoSocialDevolutionEligibility: () => evaluateAiGameProtoSocialDevolutionEligibility,
|
|
42
49
|
gameEventFeatureFlags: () => gameEventFeatureFlags,
|
|
50
|
+
getAiGameProtoSocialDevolutionPolicy: () => getAiGameProtoSocialDevolutionPolicy,
|
|
51
|
+
getDefaultAiGamePointsSpendPolicies: () => getDefaultAiGamePointsSpendPolicies,
|
|
52
|
+
isAiGamePlayerEvolutionStage: () => isAiGamePlayerEvolutionStage,
|
|
53
|
+
isAiGamePointsLedgerId: () => isAiGamePointsLedgerId,
|
|
43
54
|
isCandidateWorldEvent: () => isCandidateWorldEvent,
|
|
44
55
|
isCanonicalWorldEvent: () => isCanonicalWorldEvent,
|
|
45
56
|
isGossipTopicActive: () => isGossipTopicActive,
|
|
@@ -49,10 +60,180 @@ __export(index_exports, {
|
|
|
49
60
|
packageDescriptor: () => packageDescriptor,
|
|
50
61
|
projectTopicForAudience: () => projectTopicForAudience,
|
|
51
62
|
resolveAiGamePlayerAddressText: () => resolveAiGamePlayerAddressText,
|
|
63
|
+
resolveAiGamePointsAuthorityBoundary: () => resolveAiGamePointsAuthorityBoundary,
|
|
52
64
|
resolveAiGameTaskBatch: () => resolveAiGameTaskBatch
|
|
53
65
|
});
|
|
54
66
|
module.exports = __toCommonJS(index_exports);
|
|
55
67
|
|
|
68
|
+
// src/points-store.ts
|
|
69
|
+
var AI_GAME_POINTS_STORE_FEATURE_FLAG_ID = "isekai.player-system.points-store.enabled";
|
|
70
|
+
var AI_GAME_POINTS_LEDGER_IDS = ["pp", "esp", "tis", "dis"];
|
|
71
|
+
var AI_GAME_PLAYER_EVOLUTION_STAGES = ["proto-social", "social-lock"];
|
|
72
|
+
var AI_GAME_POINTS_AUTHORITY_BANDS = [
|
|
73
|
+
"self",
|
|
74
|
+
"frontier",
|
|
75
|
+
"civic",
|
|
76
|
+
"divine"
|
|
77
|
+
];
|
|
78
|
+
var AI_GAME_POINTS_AUTHORITY_SYSTEMS = [
|
|
79
|
+
"player-system",
|
|
80
|
+
"exploration-system",
|
|
81
|
+
"territorial-influence-system",
|
|
82
|
+
"divine-influence-system"
|
|
83
|
+
];
|
|
84
|
+
var AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER = Object.freeze({
|
|
85
|
+
pp: Object.freeze({
|
|
86
|
+
ledgerId: "pp",
|
|
87
|
+
authorityBand: "self",
|
|
88
|
+
authoritySystem: "player-system",
|
|
89
|
+
requiresWorldAuthority: false,
|
|
90
|
+
combatSafeOnly: false
|
|
91
|
+
}),
|
|
92
|
+
esp: Object.freeze({
|
|
93
|
+
ledgerId: "esp",
|
|
94
|
+
authorityBand: "frontier",
|
|
95
|
+
authoritySystem: "exploration-system",
|
|
96
|
+
requiresWorldAuthority: false,
|
|
97
|
+
combatSafeOnly: true
|
|
98
|
+
}),
|
|
99
|
+
tis: Object.freeze({
|
|
100
|
+
ledgerId: "tis",
|
|
101
|
+
authorityBand: "civic",
|
|
102
|
+
authoritySystem: "territorial-influence-system",
|
|
103
|
+
requiresWorldAuthority: true,
|
|
104
|
+
combatSafeOnly: false
|
|
105
|
+
}),
|
|
106
|
+
dis: Object.freeze({
|
|
107
|
+
ledgerId: "dis",
|
|
108
|
+
authorityBand: "divine",
|
|
109
|
+
authoritySystem: "divine-influence-system",
|
|
110
|
+
requiresWorldAuthority: true,
|
|
111
|
+
combatSafeOnly: false
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
var AI_GAME_DEFAULT_POINTS_SPEND_POLICIES = Object.freeze([
|
|
115
|
+
Object.freeze({
|
|
116
|
+
policyId: "pp-personal-respec",
|
|
117
|
+
ledgerId: "pp",
|
|
118
|
+
authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,
|
|
119
|
+
actions: Object.freeze([
|
|
120
|
+
Object.freeze({
|
|
121
|
+
actionId: "return-to-slime",
|
|
122
|
+
title: "Return to slime",
|
|
123
|
+
cost: 12,
|
|
124
|
+
prerequisiteCodes: Object.freeze(["proto-social-window-open", "single-use-remaining"]),
|
|
125
|
+
consequenceCodes: Object.freeze(["reset-social-form", "consume-pp-balance"])
|
|
126
|
+
})
|
|
127
|
+
])
|
|
128
|
+
}),
|
|
129
|
+
Object.freeze({
|
|
130
|
+
policyId: "esp-exploration-routing",
|
|
131
|
+
ledgerId: "esp",
|
|
132
|
+
authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.esp,
|
|
133
|
+
actions: Object.freeze([
|
|
134
|
+
Object.freeze({
|
|
135
|
+
actionId: "fast-travel-upgrade",
|
|
136
|
+
title: "Unlock frontier fast travel",
|
|
137
|
+
cost: 8,
|
|
138
|
+
prerequisiteCodes: Object.freeze(["frontier-route-discovered", "out-of-combat-only"]),
|
|
139
|
+
consequenceCodes: Object.freeze(["reduce-route-friction"])
|
|
140
|
+
})
|
|
141
|
+
])
|
|
142
|
+
}),
|
|
143
|
+
Object.freeze({
|
|
144
|
+
policyId: "tis-civic-investment",
|
|
145
|
+
ledgerId: "tis",
|
|
146
|
+
authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.tis,
|
|
147
|
+
actions: Object.freeze([
|
|
148
|
+
Object.freeze({
|
|
149
|
+
actionId: "district-favor",
|
|
150
|
+
title: "Commit district influence favor",
|
|
151
|
+
cost: 5,
|
|
152
|
+
prerequisiteCodes: Object.freeze(["civic-authority-approval"]),
|
|
153
|
+
consequenceCodes: Object.freeze(["alter-territorial-standing"])
|
|
154
|
+
})
|
|
155
|
+
])
|
|
156
|
+
}),
|
|
157
|
+
Object.freeze({
|
|
158
|
+
policyId: "dis-divine-covenant",
|
|
159
|
+
ledgerId: "dis",
|
|
160
|
+
authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.dis,
|
|
161
|
+
actions: Object.freeze([
|
|
162
|
+
Object.freeze({
|
|
163
|
+
actionId: "divine-oath",
|
|
164
|
+
title: "Bind a divine covenant",
|
|
165
|
+
cost: 3,
|
|
166
|
+
prerequisiteCodes: Object.freeze(["divine-clearance-granted"]),
|
|
167
|
+
consequenceCodes: Object.freeze(["alter-divine-standing"])
|
|
168
|
+
})
|
|
169
|
+
])
|
|
170
|
+
})
|
|
171
|
+
]);
|
|
172
|
+
var AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY = Object.freeze({
|
|
173
|
+
actionId: "return-to-slime",
|
|
174
|
+
ledgerId: "pp",
|
|
175
|
+
cost: 12,
|
|
176
|
+
requiredEvolutionStage: "proto-social",
|
|
177
|
+
closesAtEvolutionStage: "social-lock",
|
|
178
|
+
singleUse: true,
|
|
179
|
+
authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,
|
|
180
|
+
prerequisiteCodes: Object.freeze(["proto-social-window-open", "single-use-remaining"]),
|
|
181
|
+
consequenceCodes: Object.freeze(["reset-social-form", "consume-pp-balance"])
|
|
182
|
+
});
|
|
183
|
+
function normalizeNonNegativeInteger(value) {
|
|
184
|
+
if (!Number.isFinite(value)) {
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
return Math.max(0, Math.trunc(value));
|
|
188
|
+
}
|
|
189
|
+
function isAiGamePointsLedgerId(value) {
|
|
190
|
+
return AI_GAME_POINTS_LEDGER_IDS.includes(value);
|
|
191
|
+
}
|
|
192
|
+
function isAiGamePlayerEvolutionStage(value) {
|
|
193
|
+
return AI_GAME_PLAYER_EVOLUTION_STAGES.includes(value);
|
|
194
|
+
}
|
|
195
|
+
function resolveAiGamePointsAuthorityBoundary(ledgerId) {
|
|
196
|
+
return AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER[ledgerId];
|
|
197
|
+
}
|
|
198
|
+
function createAiGamePointsLedgerSnapshot(input) {
|
|
199
|
+
return Object.freeze({
|
|
200
|
+
ledgerId: input.ledgerId,
|
|
201
|
+
balance: normalizeNonNegativeInteger(input.balance),
|
|
202
|
+
earnedTotal: normalizeNonNegativeInteger(input.earnedTotal),
|
|
203
|
+
spentTotal: normalizeNonNegativeInteger(input.spentTotal),
|
|
204
|
+
committedTotal: normalizeNonNegativeInteger(input.committedTotal),
|
|
205
|
+
asOfEpochMs: input.asOfEpochMs
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function getDefaultAiGamePointsSpendPolicies() {
|
|
209
|
+
return AI_GAME_DEFAULT_POINTS_SPEND_POLICIES;
|
|
210
|
+
}
|
|
211
|
+
function getAiGameProtoSocialDevolutionPolicy() {
|
|
212
|
+
return AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;
|
|
213
|
+
}
|
|
214
|
+
function evaluateAiGameProtoSocialDevolutionEligibility(input) {
|
|
215
|
+
const reasonCodes = [];
|
|
216
|
+
const policy = AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;
|
|
217
|
+
const currentBalance = normalizeNonNegativeInteger(input.currentBalance);
|
|
218
|
+
if (input.evolutionStage !== policy.requiredEvolutionStage) {
|
|
219
|
+
reasonCodes.push("devolution-window-closed");
|
|
220
|
+
}
|
|
221
|
+
if (input.alreadyUsed) {
|
|
222
|
+
reasonCodes.push("devolution-already-used");
|
|
223
|
+
}
|
|
224
|
+
if (currentBalance < policy.cost) {
|
|
225
|
+
reasonCodes.push("insufficient-pp-balance");
|
|
226
|
+
}
|
|
227
|
+
if (reasonCodes.length === 0) {
|
|
228
|
+
reasonCodes.push("devolution-allowed");
|
|
229
|
+
}
|
|
230
|
+
return Object.freeze({
|
|
231
|
+
available: reasonCodes.length === 1 && reasonCodes[0] === "devolution-allowed",
|
|
232
|
+
reasonCodes: Object.freeze(reasonCodes),
|
|
233
|
+
policy
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
56
237
|
// src/world-events.ts
|
|
57
238
|
function isCanonicalWorldEvent(event) {
|
|
58
239
|
return event.recordType === "canonical";
|
|
@@ -551,7 +732,8 @@ var aiGameFeatureFlags = Object.freeze({
|
|
|
551
732
|
incident: AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
552
733
|
gossipTopics: AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
553
734
|
gossipPerspective: AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
554
|
-
gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID
|
|
735
|
+
gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
736
|
+
pointsStore: AI_GAME_POINTS_STORE_FEATURE_FLAG_ID
|
|
555
737
|
});
|
|
556
738
|
var gameEventFeatureFlags = Object.freeze([
|
|
557
739
|
aiGameFeatureFlags.contract,
|
|
@@ -559,7 +741,8 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
559
741
|
aiGameFeatureFlags.incident,
|
|
560
742
|
aiGameFeatureFlags.gossipTopics,
|
|
561
743
|
aiGameFeatureFlags.gossipPerspective,
|
|
562
|
-
aiGameFeatureFlags.gossipLifecycle
|
|
744
|
+
aiGameFeatureFlags.gossipLifecycle,
|
|
745
|
+
aiGameFeatureFlags.pointsStore
|
|
563
746
|
]);
|
|
564
747
|
// Annotate the CommonJS export names for ESM import in node:
|
|
565
748
|
0 && (module.exports = {
|
|
@@ -574,6 +757,11 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
574
757
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
575
758
|
AI_GAME_PACKAGE,
|
|
576
759
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
760
|
+
AI_GAME_PLAYER_EVOLUTION_STAGES,
|
|
761
|
+
AI_GAME_POINTS_AUTHORITY_BANDS,
|
|
762
|
+
AI_GAME_POINTS_AUTHORITY_SYSTEMS,
|
|
763
|
+
AI_GAME_POINTS_LEDGER_IDS,
|
|
764
|
+
AI_GAME_POINTS_STORE_FEATURE_FLAG_ID,
|
|
577
765
|
AI_GAME_TASK_AUTHORITY_BOUNDARIES,
|
|
578
766
|
AI_GAME_TASK_DECISIONS,
|
|
579
767
|
AI_GAME_TASK_KINDS,
|
|
@@ -582,7 +770,13 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
582
770
|
AI_GAME_TTS_CACHE_POLICIES,
|
|
583
771
|
aiGameFeatureFlags,
|
|
584
772
|
classifyAiGameTask,
|
|
773
|
+
createAiGamePointsLedgerSnapshot,
|
|
774
|
+
evaluateAiGameProtoSocialDevolutionEligibility,
|
|
585
775
|
gameEventFeatureFlags,
|
|
776
|
+
getAiGameProtoSocialDevolutionPolicy,
|
|
777
|
+
getDefaultAiGamePointsSpendPolicies,
|
|
778
|
+
isAiGamePlayerEvolutionStage,
|
|
779
|
+
isAiGamePointsLedgerId,
|
|
586
780
|
isCandidateWorldEvent,
|
|
587
781
|
isCanonicalWorldEvent,
|
|
588
782
|
isGossipTopicActive,
|
|
@@ -592,6 +786,7 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
592
786
|
packageDescriptor,
|
|
593
787
|
projectTopicForAudience,
|
|
594
788
|
resolveAiGamePlayerAddressText,
|
|
789
|
+
resolveAiGamePointsAuthorityBoundary,
|
|
595
790
|
resolveAiGameTaskBatch
|
|
596
791
|
});
|
|
597
792
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/world-events.ts","../src/gossip.ts"],"sourcesContent":["export interface AiPackageDescriptor {\n readonly packageName: string;\n readonly featureFlagId: string;\n readonly envPrefix: string;\n readonly summary: string;\n}\n\nexport const AI_GAME_PACKAGE = \"@plasius/ai-game\";\nexport const AI_GAME_ENV_PREFIX = \"AI_GAME\";\nexport const AI_GAME_FEATURE_FLAG_ID = \"ai.game.enabled\";\nexport const AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID = \"ai.game.event-recorder.contracts.enabled\";\nexport const AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID = \"ai.game.event-recorder.ingestion.enabled\";\nexport const AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID = \"ai.game.event-recorder.impact.enabled\";\nexport const AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID = \"ai.game.npc-gossip.topics.enabled\";\nexport const AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.perspective.enabled\";\nexport const AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.lifecycle.enabled\";\n\nexport const AI_GAME_FEATURE_FLAGS = {\n workloads: AI_GAME_FEATURE_FLAG_ID,\n ttsCacheEnabled: \"ai.tts.cache.enabled\",\n ttsNearReuseEnabled: \"ai.tts.near-reuse.enabled\",\n} as const;\n\nexport type AiGameFeatureFlagKey =\n (typeof AI_GAME_FEATURE_FLAGS)[keyof typeof AI_GAME_FEATURE_FLAGS];\n\nexport type AiGameFeatureFlagSnapshot = Partial<Record<AiGameFeatureFlagKey, boolean>>;\n\nexport const AI_GAME_TASK_KINDS = [\n \"player-action-validation\",\n \"npc-action\",\n \"npc-dialogue\",\n \"gossip\",\n \"governance-feedback\",\n \"feedback\",\n \"unknown\",\n] as const;\n\nexport type AiGameTaskKind = (typeof AI_GAME_TASK_KINDS)[number];\n\nexport const AI_GAME_TASK_RISK_CLASSES = [\n \"low\",\n \"medium\",\n \"high\",\n \"critical\",\n] as const;\n\nexport type AiGameTaskRiskClass = (typeof AI_GAME_TASK_RISK_CLASSES)[number];\n\nexport const AI_GAME_TASK_AUTHORITY_BOUNDARIES = [\n \"deterministic\",\n \"human-review\",\n \"operator-review\",\n \"blocked\",\n] as const;\n\nexport type AiGameAuthorityBoundary =\n (typeof AI_GAME_TASK_AUTHORITY_BOUNDARIES)[number];\n\nexport const AI_GAME_TASK_DECISIONS = [\"allow\", \"operator-review\", \"blocked\"] as const;\n\nexport type AiGameTaskDecisionResult =\n (typeof AI_GAME_TASK_DECISIONS)[number];\n\nexport const AI_GAME_TASK_RESULTS = [\"allow\", \"defer\", \"deny\"] as const;\n\nexport type AiGameTaskResult = (typeof AI_GAME_TASK_RESULTS)[number];\n\nexport const AI_GAME_TTS_CACHE_POLICIES = [\n \"exact-cache\",\n \"near-cache\",\n \"no-cache\",\n] as const;\n\nexport type AiGameTtsCachePolicy =\n (typeof AI_GAME_TTS_CACHE_POLICIES)[number];\n\nexport const AI_GAME_ACTOR_ROLES = [\"player\", \"npc\", \"operator\", \"system\"] as const;\n\nexport type AiGameActorRole = (typeof AI_GAME_ACTOR_ROLES)[number];\n\nexport interface AiGameTaskRequest {\n readonly taskId: string;\n readonly taskText: string;\n readonly taskKind?: AiGameTaskKind;\n}\n\nexport interface AiGameTaskDecision {\n readonly taskId: string;\n readonly taskKind: AiGameTaskKind;\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly decision: AiGameTaskDecisionResult;\n readonly needsOperatorReview: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGamePolicyAuditBase {\n readonly policyId: string;\n readonly policyVersion: string;\n readonly correlationId: string;\n readonly requestId?: string;\n readonly actorId?: string;\n readonly actorRole: AiGameActorRole;\n readonly evaluatedAtUtc: string;\n}\n\nexport interface ResolveAiGameTaskInput {\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly requests: readonly AiGameTaskRequest[];\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface AiGameTaskResolution {\n readonly requestedTasks: readonly string[];\n readonly taskDecisions: readonly AiGameTaskDecision[];\n readonly allowedTaskIds: readonly string[];\n readonly reviewTaskIds: readonly string[];\n readonly blockedTaskIds: readonly string[];\n readonly needsOperatorReview: boolean;\n readonly featureEnabled: boolean;\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly result: AiGameTaskResult;\n };\n}\n\nexport interface ResolveAiGamePlayerAddressInput {\n readonly playerAddressText: string;\n readonly playerAlias?: string;\n readonly accountAlias?: string;\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface ResolveAiGamePlayerAddressResult {\n readonly sourceText: string;\n readonly renderText: string;\n readonly ttsCachePolicy: AiGameTtsCachePolicy;\n readonly reasonCodes: readonly string[];\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly cachePolicy: AiGameTtsCachePolicy;\n };\n}\n\ninterface AiGameTaskProfile {\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly keywords: readonly string[];\n}\n\nconst AI_GAME_TASK_PROFILE_BY_KIND: Record<AiGameTaskKind, AiGameTaskProfile> = {\n \"player-action-validation\": {\n riskClass: \"medium\",\n authorityBoundary: \"human-review\",\n keywords: [\"move\", \"attack\", \"collect\", \"use\", \"open\", \"pick\", \"trade\", \"target\"],\n },\n \"npc-action\": {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"summon\", \"kill\", \"ban\", \"spawn\", \"eject\", \"resurrect\", \"npc action\", \"npc-action\"],\n },\n \"npc-dialogue\": {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"say\", \"says\", \"reply\", \"chat\", \"dialogue\", \"greet\", \"warn\", \"request\"],\n },\n gossip: {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"rumor\", \"rumors\", \"gossip\", \"hearsay\", \"whisper\", \"spread\", \"denounce\"],\n },\n \"governance-feedback\": {\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n keywords: [\"punish\", \"expel\", \"revoke\", \"ban\", \"forbid\", \"seize\"],\n },\n feedback: {\n riskClass: \"low\",\n authorityBoundary: \"operator-review\",\n keywords: [\"feedback\", \"rating\", \"report\", \"score\", \"review\", \"complaint\"],\n },\n unknown: {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"\"],\n },\n};\n\nconst AI_GAME_TASK_KEYWORD_PATTERNS: Readonly<Record<AiGameTaskKind, RegExp>> = {\n \"player-action-validation\": buildTaskPattern(\n AI_GAME_TASK_PROFILE_BY_KIND[\"player-action-validation\"].keywords,\n ),\n \"npc-action\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-action\"].keywords),\n \"npc-dialogue\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-dialogue\"].keywords),\n gossip: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.gossip.keywords),\n \"governance-feedback\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"governance-feedback\"].keywords),\n feedback: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.feedback.keywords),\n unknown: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.unknown.keywords),\n};\n\nfunction nowIsoString(): string {\n return new Date().toISOString();\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction normalizeToken(value: string): string {\n return value.trim().replace(/\\s+/g, \" \");\n}\n\nfunction buildTaskPattern(keywords: readonly string[]): RegExp {\n return new RegExp(\n keywords.filter((keyword) => keyword.length > 0).map((keyword) => `\\\\b${escapeRegExp(keyword)}\\\\b`).join(\"|\") || \"^$\",\n \"i\",\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n return Array.from(new Set(values.filter((value) => value.length > 0)));\n}\n\nfunction isFeatureEnabled(\n featureFlag: AiGameFeatureFlagKey,\n snapshot: AiGameFeatureFlagSnapshot = {},\n): boolean {\n return snapshot[featureFlag] === true;\n}\n\nfunction normalizeTaskText(value: string): string {\n return value.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\nfunction isActorRole(role?: AiGameActorRole): AiGameActorRole {\n return role ?? \"player\";\n}\n\nfunction normalizeTaskKind(taskKind?: AiGameTaskKind): AiGameTaskKind | undefined {\n if (!taskKind) {\n return undefined;\n }\n\n return (AI_GAME_TASK_KINDS as readonly string[]).includes(taskKind)\n ? taskKind\n : \"unknown\";\n}\n\nexport function classifyAiGameTask(taskText: string): AiGameTaskKind {\n const normalized = normalizeTaskText(taskText);\n\n if (!normalized) {\n return \"unknown\";\n }\n\n for (const taskKind of AI_GAME_TASK_KINDS) {\n if (AI_GAME_TASK_KEYWORD_PATTERNS[taskKind].test(normalized)) {\n return taskKind;\n }\n }\n\n return \"unknown\";\n}\n\nfunction resolveTaskAuthority(taskKind: AiGameTaskKind): AiGameTaskProfile {\n return AI_GAME_TASK_PROFILE_BY_KIND[taskKind];\n}\n\nfunction resolveTaskDecision(\n taskKind: AiGameTaskKind,\n profile: AiGameTaskProfile,\n actorRole: AiGameActorRole,\n): Omit<AiGameTaskDecision, \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"> {\n if (profile.authorityBoundary === \"blocked\") {\n return {\n decision: \"blocked\",\n needsOperatorReview: actorRole !== \"system\",\n };\n }\n\n if (profile.authorityBoundary === \"deterministic\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n if (actorRole === \"system\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n return {\n decision: \"operator-review\",\n needsOperatorReview: true,\n };\n}\n\nfunction buildRequestIds(requests: readonly AiGameTaskRequest[]): string[] {\n return uniqueStrings(requests.map((request) => request.taskId.trim()).filter(Boolean));\n}\n\n/**\n * Resolve game AI task contracts for player actions, NPC actions, gossip, and governance.\n */\nexport function resolveAiGameTaskBatch(\n input: ResolveAiGameTaskInput,\n): AiGameTaskResolution {\n const actorRole = isActorRole(input.actorRole);\n const featureEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.workloads,\n input.featureFlags,\n );\n const reasonCodes = [...(input.reasonCodes ?? [])];\n type ResolvedAiGameTaskRequest = AiGameTaskRequest & { taskKind: AiGameTaskKind };\n const requests: ResolvedAiGameTaskRequest[] = input.requests.map((request): ResolvedAiGameTaskRequest => ({\n ...request,\n taskKind: normalizeTaskKind(request.taskKind) ?? classifyAiGameTask(request.taskText),\n }));\n\n if (!featureEnabled) {\n reasonCodes.push(\"game-feature-disabled\");\n const requestIds = buildRequestIds(requests);\n\n return {\n requestedTasks: requestIds,\n taskDecisions: Object.freeze(\n requestIds.map<AiGameTaskDecision>((taskId) => ({\n taskId,\n taskKind: \"unknown\",\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n decision: \"blocked\",\n needsOperatorReview: false,\n reasonCodes: [\"feature-disabled\"],\n })),\n ),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze(requestIds),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"deny\",\n },\n };\n }\n\n if (requests.length === 0) {\n reasonCodes.push(\"game-task-empty-request\");\n\n return {\n requestedTasks: Object.freeze([] as const),\n taskDecisions: Object.freeze([] as const),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze([] as const),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"allow\",\n },\n };\n }\n const taskDecisions: AiGameTaskDecision[] = [];\n for (const request of requests) {\n const taskKind: AiGameTaskKind = request.taskKind;\n const profile = resolveTaskAuthority(taskKind);\n const decision: Omit<\n AiGameTaskDecision,\n \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"\n > = resolveTaskDecision(taskKind, profile, actorRole);\n\n taskDecisions.push({\n taskId: request.taskId,\n taskKind,\n riskClass: profile.riskClass,\n authorityBoundary: profile.authorityBoundary,\n ...decision,\n reasonCodes: [`task-${taskKind}-${decision.decision}`],\n });\n }\n\n const allowedTaskIds: string[] = [];\n const reviewTaskIds: string[] = [];\n const blockedTaskIds: string[] = [];\n\n for (const decision of taskDecisions) {\n if (decision.decision === \"allow\") {\n allowedTaskIds.push(decision.taskId);\n } else if (decision.decision === \"operator-review\") {\n reviewTaskIds.push(decision.taskId);\n } else {\n blockedTaskIds.push(decision.taskId);\n }\n\n reasonCodes.push(...decision.reasonCodes);\n }\n\n const hasBlockedTasks = blockedTaskIds.length > 0;\n const needsOperatorReview = taskDecisions.some((decision) => decision.needsOperatorReview);\n\n return {\n requestedTasks: Object.freeze(buildRequestIds(requests)),\n taskDecisions: Object.freeze(taskDecisions),\n allowedTaskIds: Object.freeze(uniqueStrings(allowedTaskIds)),\n reviewTaskIds: Object.freeze(uniqueStrings(reviewTaskIds)),\n blockedTaskIds: Object.freeze(uniqueStrings(blockedTaskIds)),\n needsOperatorReview,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: hasBlockedTasks ? \"deny\" : needsOperatorReview ? \"defer\" : \"allow\",\n },\n };\n}\n\n/**\n * Resolve cache policy for player-account text before speech rendering.\n */\nexport function resolveAiGamePlayerAddressText(\n input: ResolveAiGamePlayerAddressInput,\n): ResolveAiGamePlayerAddressResult {\n const actorRole = isActorRole(input.actorRole);\n const cacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n input.featureFlags,\n );\n const sourceText = normalizeToken(input.playerAddressText);\n const reasonCodes = [...(input.reasonCodes ?? [])];\n\n if (!sourceText) {\n reasonCodes.push(\"tts-empty-text\");\n\n return {\n sourceText,\n renderText: \"\",\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const aliasEntries = [\n ...uniqueStrings([normalizeToken(input.playerAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: false,\n })),\n ...uniqueStrings([normalizeToken(input.accountAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: true,\n })),\n ];\n\n let renderText = sourceText;\n let replaced = false;\n\n for (const alias of aliasEntries) {\n const pattern = new RegExp(`\\\\b${escapeRegExp(alias.alias)}\\\\b`, \"gi\");\n\n if (pattern.test(renderText)) {\n renderText = renderText.replace(pattern, alias.isAccountAlias ? \"[ACCOUNT]\" : \"[PLAYER]\");\n replaced = true;\n reasonCodes.push(`tts-redacted-${alias.alias.toLowerCase()}`);\n }\n }\n\n const nearCacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled,\n input.featureFlags,\n );\n\n if (!cacheEnabled) {\n reasonCodes.push(\"tts-cache-disabled\");\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const cachePolicy: AiGameTtsCachePolicy =\n !replaced\n ? \"exact-cache\"\n : nearCacheEnabled\n ? \"near-cache\"\n : \"no-cache\";\n\n if (cachePolicy === \"exact-cache\") {\n reasonCodes.push(\"tts-cache-exact\");\n }\n\n if (cachePolicy === \"near-cache\") {\n reasonCodes.push(\"tts-cache-near\");\n }\n\n if (cachePolicy === \"no-cache\") {\n reasonCodes.push(\"tts-cache-not-available\");\n }\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: cachePolicy,\n reasonCodes,\n enabledFeatureFlags: Object.freeze([\n AI_GAME_FEATURE_FLAGS.workloads,\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n ...(nearCacheEnabled ? [AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled] : []),\n ]),\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy,\n },\n };\n}\n\nexport const packageDescriptor: AiPackageDescriptor = Object.freeze({\n packageName: AI_GAME_PACKAGE,\n featureFlagId: AI_GAME_FEATURE_FLAG_ID,\n envPrefix: AI_GAME_ENV_PREFIX,\n summary: \"Game-domain AI contracts for event recorder, canonical world-state, and NPC gossip projections.\",\n});\n\nexport const aiGameFeatureFlags = Object.freeze({\n contract: AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,\n ingestion: AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,\n incident: AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,\n gossipTopics: AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,\n gossipPerspective: AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,\n gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,\n});\n\nexport const gameEventFeatureFlags = Object.freeze([\n aiGameFeatureFlags.contract,\n aiGameFeatureFlags.ingestion,\n aiGameFeatureFlags.incident,\n aiGameFeatureFlags.gossipTopics,\n aiGameFeatureFlags.gossipPerspective,\n aiGameFeatureFlags.gossipLifecycle,\n]);\n\nexport {\n isCanonicalWorldEvent,\n isCandidateWorldEvent,\n isIncidentResolved,\n normalizeIncidentImpactVector,\n} from \"./world-events.js\";\n\nexport {\n isGossipTopicActive,\n isGossipTopicCorrected,\n projectTopicForAudience,\n} from \"./gossip.js\";\n\nexport * from \"./world-events.js\";\nexport * from \"./gossip.js\";\n","export type Version = string;\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type GameWorldEventType =\n | \"monster.spawned\"\n | \"monster.killed\"\n | \"dungeon.created\"\n | \"dungeon.cleared\"\n | \"war.declared\"\n | \"war.resolved\"\n | \"famine.started\"\n | \"surplus.updated\"\n | \"system.checkpoint\";\n\nexport type GameEventVisibilityClass = \"global\" | \"regional\" | \"local\" | \"faction\" | \"secret\";\nexport type GameEventRecordType = \"candidate\" | \"canonical\";\nexport type GameEventSubmissionChannel = \"player\" | \"system\" | \"admin\" | \"simulation\";\nexport type GameEventActorKind = \"player\" | \"npc\" | \"monster\" | \"system\" | \"faction\" | \"environment\";\nexport type GameEventParticipantRole = \"causer\" | \"target\" | \"witness\" | \"owner\" | \"observer\";\nexport type GameEventSeverity = \"info\" | \"warning\" | \"critical\";\n\nexport interface GameEventActor {\n readonly kind: GameEventActorKind;\n readonly subjectRef: string;\n}\n\nexport interface GameEventParticipant {\n readonly role: GameEventParticipantRole;\n readonly actor: GameEventActor;\n}\n\nexport interface GameEventLocation {\n readonly world: string;\n readonly zone: string;\n readonly x?: number;\n readonly y?: number;\n readonly radiusMeters?: number;\n}\n\nexport interface GameEventCausation {\n readonly rootEventId?: string;\n readonly parentEventIds: readonly string[];\n readonly correlationId?: string;\n}\n\nexport interface GameWorldEventPayloadBase {\n readonly eventKind: GameEventSeverity;\n readonly summary: string;\n}\n\nexport interface MonsterSpawnedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.spawned\";\n readonly monsterType: string;\n readonly monsterRef: string;\n}\n\nexport interface MonsterKilledPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.killed\";\n readonly monsterRef: string;\n readonly killerRef?: string;\n readonly encounterResult: \"vanquished\" | \"escaped\" | \"failed\";\n}\n\nexport interface DungeonCreatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.created\";\n readonly dungeonRef: string;\n readonly dungeonType: string;\n readonly difficulty: number;\n}\n\nexport interface DungeonClearedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.cleared\";\n readonly dungeonRef: string;\n readonly clearedByPartyRef: string;\n readonly durationSeconds: number;\n}\n\nexport interface WarDeclaredPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.declared\";\n readonly aggressorFactionRef: string;\n readonly defenderFactionRef: string;\n readonly disputedZone: string;\n}\n\nexport interface WarResolvedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.resolved\";\n readonly warEventRef: string;\n readonly outcome: \"ceasefire\" | \"victory\" | \"loss\" | \"draw\";\n readonly winnerFactionRef?: string;\n}\n\nexport interface FamineStartedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"famine.started\";\n readonly zoneRef: string;\n readonly severity: \"low\" | \"moderate\" | \"high\" | \"critical\";\n}\n\nexport interface SurplusUpdatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"surplus.updated\";\n readonly commodity: string;\n readonly region: string;\n readonly previousBalance: number;\n readonly delta: number;\n}\n\nexport interface SystemCheckpointPayload extends GameWorldEventPayloadBase {\n readonly kind: \"system.checkpoint\";\n readonly sequence: string;\n readonly checkpointState: JsonValue;\n}\n\nexport type GameWorldEventPayload =\n | MonsterSpawnedPayload\n | MonsterKilledPayload\n | DungeonCreatedPayload\n | DungeonClearedPayload\n | WarDeclaredPayload\n | WarResolvedPayload\n | FamineStartedPayload\n | SurplusUpdatedPayload\n | SystemCheckpointPayload;\n\nexport interface GameWorldEventEnvelope {\n readonly eventId: string;\n readonly eventType: GameWorldEventType;\n readonly occurredAtEpochMs: number;\n readonly recordedAtEpochMs: number;\n readonly schemaVersion: string;\n readonly visibility: GameEventVisibilityClass;\n readonly location: GameEventLocation;\n readonly participants: readonly GameEventParticipant[];\n readonly causation: GameEventCausation;\n readonly source: string;\n readonly payload: GameWorldEventPayload;\n readonly tags: readonly string[];\n}\n\nexport interface GameWorldEventCandidate extends GameWorldEventEnvelope {\n readonly recordType: \"candidate\";\n readonly candidateId: string;\n readonly submittedBy?: GameEventActor;\n readonly submittedAtEpochMs: number;\n readonly submissionChannel: GameEventSubmissionChannel;\n}\n\nexport interface GameWorldEventCanonical extends GameWorldEventEnvelope {\n readonly recordType: \"canonical\";\n readonly canonicalEventId: string;\n readonly sourceCandidateId?: string;\n readonly approvedBy: string;\n readonly approvedAtEpochMs: number;\n}\n\nexport type GameWorldEvent = GameWorldEventCandidate | GameWorldEventCanonical;\n\nexport interface GameEventValidationIssue {\n readonly field: string;\n readonly message: string;\n readonly severity: GameEventSeverity;\n}\n\nexport interface GameEventValidationResult {\n readonly valid: boolean;\n readonly issues: readonly GameEventValidationIssue[];\n}\n\nexport interface GameEventSubmissionReceipt {\n readonly accepted: boolean;\n readonly candidateId: string;\n readonly eventId: string;\n readonly notes: readonly string[];\n}\n\nexport interface GameEventCommitReceipt {\n readonly committed: boolean;\n readonly eventId: string;\n readonly sequence: string;\n}\n\nexport interface ProjectionProjectorCheckpoint {\n readonly streamId: string;\n readonly lastAppliedEventOffset: number;\n readonly lastAppliedEventId: string;\n readonly eventVersion: Version;\n readonly updatedAtEpochMs: number;\n}\n\nexport interface ProjectionCheckpointStore {\n getCheckpoint(streamId: string): Promise<ProjectionProjectorCheckpoint | null>;\n setCheckpoint(checkpoint: ProjectionProjectorCheckpoint): Promise<void>;\n}\n\nexport interface WorldEventIngestionPort {\n submitCandidate(candidate: GameWorldEventCandidate): Promise<GameEventSubmissionReceipt>;\n commitCanonical(event: GameWorldEventCanonical): Promise<GameEventCommitReceipt>;\n validateCandidate(candidate: GameWorldEventCandidate): GameEventValidationResult;\n}\n\nexport interface WorldEventProjectorPort {\n readonly streamId: string;\n readonly checkpointStore: ProjectionCheckpointStore;\n project(event: GameWorldEventCanonical): Promise<void>;\n}\n\nexport type WorldIncidentImpactKey = \"security\" | \"economy\" | \"ecology\" | \"politics\" | \"morale\" | \"magic\" | \"population\";\n\nexport type WorldIncidentScope = \"local\" | \"regional\" | \"global\";\n\nexport type WorldIncidentLifecycle = \"active\" | \"resolved\" | \"superseded\" | \"expired\";\n\nexport interface WorldIncidentImpactVector {\n readonly security: number;\n readonly economy: number;\n readonly ecology: number;\n readonly politics: number;\n readonly morale: number;\n readonly magic: number;\n readonly population: number;\n}\n\nexport interface WorldIncidentResolution {\n readonly resolvedAtEpochMs: number;\n readonly closingEventRef: string;\n readonly summary: string;\n}\n\nexport interface WorldIncidentThread {\n readonly incidentId: string;\n readonly scope: WorldIncidentScope;\n readonly lifecycle: WorldIncidentLifecycle;\n readonly causeEventRef: string;\n readonly impact: WorldIncidentImpactVector;\n readonly openedAtEpochMs: number;\n readonly updatedAtEpochMs: number;\n readonly supersededBy?: string;\n readonly resolution?: WorldIncidentResolution;\n readonly affectedEventRefs: readonly string[];\n}\n\nexport interface WorldIncidentRegistry {\n readonly incidents: readonly WorldIncidentThread[];\n readonly activeCount: number;\n}\n\nexport function isCanonicalWorldEvent(event: GameWorldEvent): event is GameWorldEventCanonical {\n return event.recordType === \"canonical\";\n}\n\nexport function isCandidateWorldEvent(event: GameWorldEvent): event is GameWorldEventCandidate {\n return event.recordType === \"candidate\";\n}\n\nconst WORLD_IMPACT_SCALE_LIMIT = 100;\n\nfunction clampImpactValue(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n return Math.max(0, Math.min(WORLD_IMPACT_SCALE_LIMIT, value));\n}\n\nexport function normalizeIncidentImpactVector(\n impact: Partial<WorldIncidentImpactVector> | Record<string, number>,\n): Readonly<WorldIncidentImpactVector> {\n return Object.freeze({\n security: clampImpactValue(Number(impact.security ?? 0)),\n economy: clampImpactValue(Number(impact.economy ?? 0)),\n ecology: clampImpactValue(Number(impact.ecology ?? 0)),\n politics: clampImpactValue(Number(impact.politics ?? 0)),\n morale: clampImpactValue(Number(impact.morale ?? 0)),\n magic: clampImpactValue(Number(impact.magic ?? 0)),\n population: clampImpactValue(Number(impact.population ?? 0)),\n });\n}\n\nexport function isIncidentResolved(incident: WorldIncidentThread): boolean {\n return incident.lifecycle === \"resolved\" || incident.lifecycle === \"expired\";\n}\n","export type GossipSalience = \"low\" | \"medium\" | \"high\" | \"critical\";\nexport type GossipConfidence = \"uncertain\" | \"possible\" | \"strong\" | \"verified\";\nexport type GossipTopicStatus = \"active\" | \"corrected\" | \"resolved\" | \"stale\";\nexport type GossipAudienceSegment = \"player\" | \"npc\" | \"public\";\nexport type GossipProjectionMode = \"segment-level\" | \"npc-level\";\n\nexport interface EventSourceLink {\n readonly sourceType: \"event\" | \"incident\";\n readonly sourceId: string;\n}\n\nexport interface GossipSpeechHint {\n readonly sentenceTone: \"whisper\" | \"formal\" | \"urgent\";\n readonly localizedHintKey: string;\n}\n\nexport interface GossipTopicPayload {\n readonly factSummary: string;\n readonly certainty: number;\n readonly salience: GossipSalience;\n readonly evidenceRefs: readonly EventSourceLink[];\n readonly speechHint: GossipSpeechHint;\n}\n\nexport interface GossipTopic {\n readonly topicId: string;\n readonly status: GossipTopicStatus;\n readonly emittedAtEpochMs: number;\n readonly expiresAtEpochMs: number;\n readonly sourceLink: EventSourceLink;\n readonly sourceEventRef: string;\n readonly lineageOf?: string;\n readonly replacedBy?: string;\n readonly payload: GossipTopicPayload;\n readonly confidenceLevel: GossipConfidence;\n readonly audienceScope: \"faction\" | \"region\" | \"public\";\n}\n\nexport interface WitnessChannel {\n readonly witnessRef: string;\n readonly seenAtEpochMs: number;\n readonly confidenceWeight: number;\n}\n\nexport interface PerspectiveRule {\n readonly locality: readonly string[];\n readonly factions: readonly string[];\n readonly relationshipScore: number;\n}\n\nexport interface KnowledgeSource {\n readonly sourceType: \"segment\" | \"npc\";\n readonly sourceRef: string;\n readonly relationshipToAudience?: number;\n}\n\nexport interface GossipPerspectiveProjection {\n readonly projectionMode: GossipProjectionMode;\n readonly audienceSegment: GossipAudienceSegment;\n readonly requestedByNpcRef?: string;\n readonly locality: string;\n readonly faction: string;\n readonly segmentRules: readonly PerspectiveRule[];\n readonly witnessChannels: readonly WitnessChannel[];\n}\n\nexport interface ProjectedGossipEnvelope {\n readonly topicId: string;\n readonly visible: boolean;\n readonly redactedPayload?: GossipTopicPayload;\n readonly reasons: readonly string[];\n}\n\nexport interface GossipLifecyclePort {\n readonly topicId: string;\n load(): Promise<GossipTopic | null>;\n applyCorrection(next: GossipTopic): Promise<void>;\n markResolved(topicId: string, replacementTopicId?: string): Promise<void>;\n}\n\nexport interface GossipTopicEnvelope {\n readonly topic: GossipTopic;\n readonly topics: readonly EventSourceLink[];\n}\n\nexport function isGossipTopicActive(topic: GossipTopic, nowEpochMs = Date.now()): boolean {\n return topic.status === \"active\" && topic.expiresAtEpochMs > nowEpochMs && topic.payload.certainty >= 0.35;\n}\n\nexport function isGossipTopicCorrected(topic: GossipTopic): boolean {\n return topic.status === \"corrected\";\n}\n\nfunction matchSegmentAudience(\n sourceValue: readonly string[], targetValue: readonly string[], fallback: boolean,\n): boolean {\n if (sourceValue.length === 0 || targetValue.length === 0) {\n return fallback;\n }\n\n return sourceValue.some((value) => targetValue.includes(value));\n}\n\nexport function projectTopicForAudience(\n topic: GossipTopic,\n projection: GossipPerspectiveProjection,\n nowEpochMs = Date.now(),\n): ProjectedGossipEnvelope {\n if (!isGossipTopicActive(topic, nowEpochMs)) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"inactive-or-expired-topic\"],\n };\n }\n\n const hasMatchingRule = projection.segmentRules.some((rule) =>\n matchSegmentAudience(rule.locality, [projection.locality], true) &&\n matchSegmentAudience(rule.factions, [projection.faction], false)\n );\n\n if (!hasMatchingRule) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"audience-not-authorized\"],\n };\n }\n\n if (projection.projectionMode === \"segment-level\" && topic.audienceScope === \"public\") {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"segment-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope === \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope !== \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"scope-constraints\"],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0PO,SAAS,sBAAsB,OAAyD;AAC7F,SAAO,MAAM,eAAe;AAC9B;AAEO,SAAS,sBAAsB,OAAyD;AAC7F,SAAO,MAAM,eAAe;AAC9B;AAEA,IAAM,2BAA2B;AAEjC,SAAS,iBAAiB,OAAuB;AAC/C,MAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,WAAO;AAAA,EACT;AACA,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,0BAA0B,KAAK,CAAC;AAC9D;AAEO,SAAS,8BACd,QACqC;AACrC,SAAO,OAAO,OAAO;AAAA,IACnB,UAAU,iBAAiB,OAAO,OAAO,YAAY,CAAC,CAAC;AAAA,IACvD,SAAS,iBAAiB,OAAO,OAAO,WAAW,CAAC,CAAC;AAAA,IACrD,SAAS,iBAAiB,OAAO,OAAO,WAAW,CAAC,CAAC;AAAA,IACrD,UAAU,iBAAiB,OAAO,OAAO,YAAY,CAA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AA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,GAAI,mBAAmB,CAAC,sBAAsB,mBAAmB,IAAI,CAAC;AAAA,IACxE,CAAC;AAAA,IACD,QAAQ;AAAA,IACR,OAAO;AAAA,MACL,UAAU,MAAM,YAAY;AAAA,MAC5B,eAAe,MAAM,iBAAiB;AAAA,MACtC,eAAe,MAAM,iBAAiB,OAAO,WAAW;AAAA,MACxD,WAAW,MAAM;AAAA,MACjB,SAAS,MAAM;AAAA,MACf;AAAA,MACA,gBAAgB,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,oBAAyC,OAAO,OAAO;AAAA,EAClE,aAAa;AAAA,EACb,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AACX,CAAC;AAEM,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,CAAC;AAEM,IAAM,wBAAwB,OAAO,OAAO;AAAA,EACjD,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/points-store.ts","../src/world-events.ts","../src/gossip.ts"],"sourcesContent":["import { AI_GAME_POINTS_STORE_FEATURE_FLAG_ID } from \"./points-store.js\";\n\nexport interface AiPackageDescriptor {\n readonly packageName: string;\n readonly featureFlagId: string;\n readonly envPrefix: string;\n readonly summary: string;\n}\n\nexport const AI_GAME_PACKAGE = \"@plasius/ai-game\";\nexport const AI_GAME_ENV_PREFIX = \"AI_GAME\";\nexport const AI_GAME_FEATURE_FLAG_ID = \"ai.game.enabled\";\nexport const AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID = \"ai.game.event-recorder.contracts.enabled\";\nexport const AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID = \"ai.game.event-recorder.ingestion.enabled\";\nexport const AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID = \"ai.game.event-recorder.impact.enabled\";\nexport const AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID = \"ai.game.npc-gossip.topics.enabled\";\nexport const AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.perspective.enabled\";\nexport const AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.lifecycle.enabled\";\n\nexport const AI_GAME_FEATURE_FLAGS = {\n workloads: AI_GAME_FEATURE_FLAG_ID,\n ttsCacheEnabled: \"ai.tts.cache.enabled\",\n ttsNearReuseEnabled: \"ai.tts.near-reuse.enabled\",\n} as const;\n\nexport type AiGameFeatureFlagKey =\n (typeof AI_GAME_FEATURE_FLAGS)[keyof typeof AI_GAME_FEATURE_FLAGS];\n\nexport type AiGameFeatureFlagSnapshot = Partial<Record<AiGameFeatureFlagKey, boolean>>;\n\nexport const AI_GAME_TASK_KINDS = [\n \"player-action-validation\",\n \"npc-action\",\n \"npc-dialogue\",\n \"gossip\",\n \"governance-feedback\",\n \"feedback\",\n \"unknown\",\n] as const;\n\nexport type AiGameTaskKind = (typeof AI_GAME_TASK_KINDS)[number];\n\nexport const AI_GAME_TASK_RISK_CLASSES = [\n \"low\",\n \"medium\",\n \"high\",\n \"critical\",\n] as const;\n\nexport type AiGameTaskRiskClass = (typeof AI_GAME_TASK_RISK_CLASSES)[number];\n\nexport const AI_GAME_TASK_AUTHORITY_BOUNDARIES = [\n \"deterministic\",\n \"human-review\",\n \"operator-review\",\n \"blocked\",\n] as const;\n\nexport type AiGameAuthorityBoundary =\n (typeof AI_GAME_TASK_AUTHORITY_BOUNDARIES)[number];\n\nexport const AI_GAME_TASK_DECISIONS = [\"allow\", \"operator-review\", \"blocked\"] as const;\n\nexport type AiGameTaskDecisionResult =\n (typeof AI_GAME_TASK_DECISIONS)[number];\n\nexport const AI_GAME_TASK_RESULTS = [\"allow\", \"defer\", \"deny\"] as const;\n\nexport type AiGameTaskResult = (typeof AI_GAME_TASK_RESULTS)[number];\n\nexport const AI_GAME_TTS_CACHE_POLICIES = [\n \"exact-cache\",\n \"near-cache\",\n \"no-cache\",\n] as const;\n\nexport type AiGameTtsCachePolicy =\n (typeof AI_GAME_TTS_CACHE_POLICIES)[number];\n\nexport const AI_GAME_ACTOR_ROLES = [\"player\", \"npc\", \"operator\", \"system\"] as const;\n\nexport type AiGameActorRole = (typeof AI_GAME_ACTOR_ROLES)[number];\n\nexport interface AiGameTaskRequest {\n readonly taskId: string;\n readonly taskText: string;\n readonly taskKind?: AiGameTaskKind;\n}\n\nexport interface AiGameTaskDecision {\n readonly taskId: string;\n readonly taskKind: AiGameTaskKind;\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly decision: AiGameTaskDecisionResult;\n readonly needsOperatorReview: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGamePolicyAuditBase {\n readonly policyId: string;\n readonly policyVersion: string;\n readonly correlationId: string;\n readonly requestId?: string;\n readonly actorId?: string;\n readonly actorRole: AiGameActorRole;\n readonly evaluatedAtUtc: string;\n}\n\nexport interface ResolveAiGameTaskInput {\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly requests: readonly AiGameTaskRequest[];\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface AiGameTaskResolution {\n readonly requestedTasks: readonly string[];\n readonly taskDecisions: readonly AiGameTaskDecision[];\n readonly allowedTaskIds: readonly string[];\n readonly reviewTaskIds: readonly string[];\n readonly blockedTaskIds: readonly string[];\n readonly needsOperatorReview: boolean;\n readonly featureEnabled: boolean;\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly result: AiGameTaskResult;\n };\n}\n\nexport interface ResolveAiGamePlayerAddressInput {\n readonly playerAddressText: string;\n readonly playerAlias?: string;\n readonly accountAlias?: string;\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface ResolveAiGamePlayerAddressResult {\n readonly sourceText: string;\n readonly renderText: string;\n readonly ttsCachePolicy: AiGameTtsCachePolicy;\n readonly reasonCodes: readonly string[];\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly cachePolicy: AiGameTtsCachePolicy;\n };\n}\n\ninterface AiGameTaskProfile {\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly keywords: readonly string[];\n}\n\nconst AI_GAME_TASK_PROFILE_BY_KIND: Record<AiGameTaskKind, AiGameTaskProfile> = {\n \"player-action-validation\": {\n riskClass: \"medium\",\n authorityBoundary: \"human-review\",\n keywords: [\"move\", \"attack\", \"collect\", \"use\", \"open\", \"pick\", \"trade\", \"target\"],\n },\n \"npc-action\": {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"summon\", \"kill\", \"ban\", \"spawn\", \"eject\", \"resurrect\", \"npc action\", \"npc-action\"],\n },\n \"npc-dialogue\": {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"say\", \"says\", \"reply\", \"chat\", \"dialogue\", \"greet\", \"warn\", \"request\"],\n },\n gossip: {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"rumor\", \"rumors\", \"gossip\", \"hearsay\", \"whisper\", \"spread\", \"denounce\"],\n },\n \"governance-feedback\": {\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n keywords: [\"punish\", \"expel\", \"revoke\", \"ban\", \"forbid\", \"seize\"],\n },\n feedback: {\n riskClass: \"low\",\n authorityBoundary: \"operator-review\",\n keywords: [\"feedback\", \"rating\", \"report\", \"score\", \"review\", \"complaint\"],\n },\n unknown: {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"\"],\n },\n};\n\nconst AI_GAME_TASK_KEYWORD_PATTERNS: Readonly<Record<AiGameTaskKind, RegExp>> = {\n \"player-action-validation\": buildTaskPattern(\n AI_GAME_TASK_PROFILE_BY_KIND[\"player-action-validation\"].keywords,\n ),\n \"npc-action\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-action\"].keywords),\n \"npc-dialogue\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-dialogue\"].keywords),\n gossip: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.gossip.keywords),\n \"governance-feedback\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"governance-feedback\"].keywords),\n feedback: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.feedback.keywords),\n unknown: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.unknown.keywords),\n};\n\nfunction nowIsoString(): string {\n return new Date().toISOString();\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction normalizeToken(value: string): string {\n return value.trim().replace(/\\s+/g, \" \");\n}\n\nfunction buildTaskPattern(keywords: readonly string[]): RegExp {\n return new RegExp(\n keywords.filter((keyword) => keyword.length > 0).map((keyword) => `\\\\b${escapeRegExp(keyword)}\\\\b`).join(\"|\") || \"^$\",\n \"i\",\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n return Array.from(new Set(values.filter((value) => value.length > 0)));\n}\n\nfunction isFeatureEnabled(\n featureFlag: AiGameFeatureFlagKey,\n snapshot: AiGameFeatureFlagSnapshot = {},\n): boolean {\n return snapshot[featureFlag] === true;\n}\n\nfunction normalizeTaskText(value: string): string {\n return value.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\nfunction isActorRole(role?: AiGameActorRole): AiGameActorRole {\n return role ?? \"player\";\n}\n\nfunction normalizeTaskKind(taskKind?: AiGameTaskKind): AiGameTaskKind | undefined {\n if (!taskKind) {\n return undefined;\n }\n\n return (AI_GAME_TASK_KINDS as readonly string[]).includes(taskKind)\n ? taskKind\n : \"unknown\";\n}\n\nexport function classifyAiGameTask(taskText: string): AiGameTaskKind {\n const normalized = normalizeTaskText(taskText);\n\n if (!normalized) {\n return \"unknown\";\n }\n\n for (const taskKind of AI_GAME_TASK_KINDS) {\n if (AI_GAME_TASK_KEYWORD_PATTERNS[taskKind].test(normalized)) {\n return taskKind;\n }\n }\n\n return \"unknown\";\n}\n\nfunction resolveTaskAuthority(taskKind: AiGameTaskKind): AiGameTaskProfile {\n return AI_GAME_TASK_PROFILE_BY_KIND[taskKind];\n}\n\nfunction resolveTaskDecision(\n taskKind: AiGameTaskKind,\n profile: AiGameTaskProfile,\n actorRole: AiGameActorRole,\n): Omit<AiGameTaskDecision, \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"> {\n if (profile.authorityBoundary === \"blocked\") {\n return {\n decision: \"blocked\",\n needsOperatorReview: actorRole !== \"system\",\n };\n }\n\n if (profile.authorityBoundary === \"deterministic\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n if (actorRole === \"system\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n return {\n decision: \"operator-review\",\n needsOperatorReview: true,\n };\n}\n\nfunction buildRequestIds(requests: readonly AiGameTaskRequest[]): string[] {\n return uniqueStrings(requests.map((request) => request.taskId.trim()).filter(Boolean));\n}\n\n/**\n * Resolve game AI task contracts for player actions, NPC actions, gossip, and governance.\n */\nexport function resolveAiGameTaskBatch(\n input: ResolveAiGameTaskInput,\n): AiGameTaskResolution {\n const actorRole = isActorRole(input.actorRole);\n const featureEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.workloads,\n input.featureFlags,\n );\n const reasonCodes = [...(input.reasonCodes ?? [])];\n type ResolvedAiGameTaskRequest = AiGameTaskRequest & { taskKind: AiGameTaskKind };\n const requests: ResolvedAiGameTaskRequest[] = input.requests.map((request): ResolvedAiGameTaskRequest => ({\n ...request,\n taskKind: normalizeTaskKind(request.taskKind) ?? classifyAiGameTask(request.taskText),\n }));\n\n if (!featureEnabled) {\n reasonCodes.push(\"game-feature-disabled\");\n const requestIds = buildRequestIds(requests);\n\n return {\n requestedTasks: requestIds,\n taskDecisions: Object.freeze(\n requestIds.map<AiGameTaskDecision>((taskId) => ({\n taskId,\n taskKind: \"unknown\",\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n decision: \"blocked\",\n needsOperatorReview: false,\n reasonCodes: [\"feature-disabled\"],\n })),\n ),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze(requestIds),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"deny\",\n },\n };\n }\n\n if (requests.length === 0) {\n reasonCodes.push(\"game-task-empty-request\");\n\n return {\n requestedTasks: Object.freeze([] as const),\n taskDecisions: Object.freeze([] as const),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze([] as const),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"allow\",\n },\n };\n }\n const taskDecisions: AiGameTaskDecision[] = [];\n for (const request of requests) {\n const taskKind: AiGameTaskKind = request.taskKind;\n const profile = resolveTaskAuthority(taskKind);\n const decision: Omit<\n AiGameTaskDecision,\n \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"\n > = resolveTaskDecision(taskKind, profile, actorRole);\n\n taskDecisions.push({\n taskId: request.taskId,\n taskKind,\n riskClass: profile.riskClass,\n authorityBoundary: profile.authorityBoundary,\n ...decision,\n reasonCodes: [`task-${taskKind}-${decision.decision}`],\n });\n }\n\n const allowedTaskIds: string[] = [];\n const reviewTaskIds: string[] = [];\n const blockedTaskIds: string[] = [];\n\n for (const decision of taskDecisions) {\n if (decision.decision === \"allow\") {\n allowedTaskIds.push(decision.taskId);\n } else if (decision.decision === \"operator-review\") {\n reviewTaskIds.push(decision.taskId);\n } else {\n blockedTaskIds.push(decision.taskId);\n }\n\n reasonCodes.push(...decision.reasonCodes);\n }\n\n const hasBlockedTasks = blockedTaskIds.length > 0;\n const needsOperatorReview = taskDecisions.some((decision) => decision.needsOperatorReview);\n\n return {\n requestedTasks: Object.freeze(buildRequestIds(requests)),\n taskDecisions: Object.freeze(taskDecisions),\n allowedTaskIds: Object.freeze(uniqueStrings(allowedTaskIds)),\n reviewTaskIds: Object.freeze(uniqueStrings(reviewTaskIds)),\n blockedTaskIds: Object.freeze(uniqueStrings(blockedTaskIds)),\n needsOperatorReview,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: hasBlockedTasks ? \"deny\" : needsOperatorReview ? \"defer\" : \"allow\",\n },\n };\n}\n\n/**\n * Resolve cache policy for player-account text before speech rendering.\n */\nexport function resolveAiGamePlayerAddressText(\n input: ResolveAiGamePlayerAddressInput,\n): ResolveAiGamePlayerAddressResult {\n const actorRole = isActorRole(input.actorRole);\n const cacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n input.featureFlags,\n );\n const sourceText = normalizeToken(input.playerAddressText);\n const reasonCodes = [...(input.reasonCodes ?? [])];\n\n if (!sourceText) {\n reasonCodes.push(\"tts-empty-text\");\n\n return {\n sourceText,\n renderText: \"\",\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const aliasEntries = [\n ...uniqueStrings([normalizeToken(input.playerAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: false,\n })),\n ...uniqueStrings([normalizeToken(input.accountAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: true,\n })),\n ];\n\n let renderText = sourceText;\n let replaced = false;\n\n for (const alias of aliasEntries) {\n const pattern = new RegExp(`\\\\b${escapeRegExp(alias.alias)}\\\\b`, \"gi\");\n\n if (pattern.test(renderText)) {\n renderText = renderText.replace(pattern, alias.isAccountAlias ? \"[ACCOUNT]\" : \"[PLAYER]\");\n replaced = true;\n reasonCodes.push(`tts-redacted-${alias.alias.toLowerCase()}`);\n }\n }\n\n const nearCacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled,\n input.featureFlags,\n );\n\n if (!cacheEnabled) {\n reasonCodes.push(\"tts-cache-disabled\");\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const cachePolicy: AiGameTtsCachePolicy =\n !replaced\n ? \"exact-cache\"\n : nearCacheEnabled\n ? \"near-cache\"\n : \"no-cache\";\n\n if (cachePolicy === \"exact-cache\") {\n reasonCodes.push(\"tts-cache-exact\");\n }\n\n if (cachePolicy === \"near-cache\") {\n reasonCodes.push(\"tts-cache-near\");\n }\n\n if (cachePolicy === \"no-cache\") {\n reasonCodes.push(\"tts-cache-not-available\");\n }\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: cachePolicy,\n reasonCodes,\n enabledFeatureFlags: Object.freeze([\n AI_GAME_FEATURE_FLAGS.workloads,\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n ...(nearCacheEnabled ? [AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled] : []),\n ]),\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy,\n },\n };\n}\n\nexport const packageDescriptor: AiPackageDescriptor = Object.freeze({\n packageName: AI_GAME_PACKAGE,\n featureFlagId: AI_GAME_FEATURE_FLAG_ID,\n envPrefix: AI_GAME_ENV_PREFIX,\n summary: \"Game-domain AI contracts for event recorder, canonical world-state, and NPC gossip projections.\",\n});\n\nexport const aiGameFeatureFlags = Object.freeze({\n contract: AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,\n ingestion: AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,\n incident: AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,\n gossipTopics: AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,\n gossipPerspective: AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,\n gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,\n pointsStore: AI_GAME_POINTS_STORE_FEATURE_FLAG_ID,\n});\n\nexport const gameEventFeatureFlags = Object.freeze([\n aiGameFeatureFlags.contract,\n aiGameFeatureFlags.ingestion,\n aiGameFeatureFlags.incident,\n aiGameFeatureFlags.gossipTopics,\n aiGameFeatureFlags.gossipPerspective,\n aiGameFeatureFlags.gossipLifecycle,\n aiGameFeatureFlags.pointsStore,\n]);\n\nexport {\n createAiGamePointsLedgerSnapshot,\n evaluateAiGameProtoSocialDevolutionEligibility,\n getAiGameProtoSocialDevolutionPolicy,\n getDefaultAiGamePointsSpendPolicies,\n isAiGamePlayerEvolutionStage,\n isAiGamePointsLedgerId,\n resolveAiGamePointsAuthorityBoundary,\n} from \"./points-store.js\";\n\nexport {\n isCanonicalWorldEvent,\n isCandidateWorldEvent,\n isIncidentResolved,\n normalizeIncidentImpactVector,\n} from \"./world-events.js\";\n\nexport {\n isGossipTopicActive,\n isGossipTopicCorrected,\n projectTopicForAudience,\n} from \"./gossip.js\";\n\nexport * from \"./points-store.js\";\nexport * from \"./world-events.js\";\nexport * from \"./gossip.js\";\n","export const AI_GAME_POINTS_STORE_FEATURE_FLAG_ID = \"isekai.player-system.points-store.enabled\";\n\nexport const AI_GAME_POINTS_LEDGER_IDS = [\"pp\", \"esp\", \"tis\", \"dis\"] as const;\n\nexport type AiGamePointsLedgerId = (typeof AI_GAME_POINTS_LEDGER_IDS)[number];\n\nexport const AI_GAME_PLAYER_EVOLUTION_STAGES = [\"proto-social\", \"social-lock\"] as const;\n\nexport type AiGamePlayerEvolutionStage =\n (typeof AI_GAME_PLAYER_EVOLUTION_STAGES)[number];\n\nexport const AI_GAME_POINTS_AUTHORITY_BANDS = [\n \"self\",\n \"frontier\",\n \"civic\",\n \"divine\",\n] as const;\n\nexport type AiGamePointsAuthorityBand =\n (typeof AI_GAME_POINTS_AUTHORITY_BANDS)[number];\n\nexport const AI_GAME_POINTS_AUTHORITY_SYSTEMS = [\n \"player-system\",\n \"exploration-system\",\n \"territorial-influence-system\",\n \"divine-influence-system\",\n] as const;\n\nexport type AiGamePointsAuthoritySystem =\n (typeof AI_GAME_POINTS_AUTHORITY_SYSTEMS)[number];\n\nexport interface AiGamePointsAuthorityBoundary {\n readonly ledgerId: AiGamePointsLedgerId;\n readonly authorityBand: AiGamePointsAuthorityBand;\n readonly authoritySystem: AiGamePointsAuthoritySystem;\n readonly requiresWorldAuthority: boolean;\n readonly combatSafeOnly: boolean;\n}\n\nexport interface AiGamePointsLedgerSnapshot {\n readonly ledgerId: AiGamePointsLedgerId;\n readonly balance: number;\n readonly earnedTotal: number;\n readonly spentTotal: number;\n readonly committedTotal: number;\n readonly asOfEpochMs?: number;\n}\n\nexport interface AiGamePointsSpendAction {\n readonly actionId: string;\n readonly title: string;\n readonly cost: number;\n readonly prerequisiteCodes: readonly string[];\n readonly consequenceCodes: readonly string[];\n}\n\nexport interface AiGamePointsSpendPolicy {\n readonly policyId: string;\n readonly ledgerId: AiGamePointsLedgerId;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly actions: readonly AiGamePointsSpendAction[];\n}\n\nexport interface AiGameProtoSocialDevolutionPolicy {\n readonly actionId: \"return-to-slime\";\n readonly ledgerId: \"pp\";\n readonly cost: number;\n readonly requiredEvolutionStage: \"proto-social\";\n readonly closesAtEvolutionStage: \"social-lock\";\n readonly singleUse: true;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly prerequisiteCodes: readonly string[];\n readonly consequenceCodes: readonly string[];\n}\n\nexport interface ResolveAiGameProtoSocialDevolutionEligibilityInput {\n readonly evolutionStage: AiGamePlayerEvolutionStage;\n readonly currentBalance: number;\n readonly alreadyUsed: boolean;\n}\n\nexport interface AiGameProtoSocialDevolutionEligibilityResult {\n readonly available: boolean;\n readonly reasonCodes: readonly string[];\n readonly policy: AiGameProtoSocialDevolutionPolicy;\n}\n\nexport interface AiGameProtoSocialDevolutionExecution {\n readonly actionId: \"return-to-slime\";\n readonly ledgerId: \"pp\";\n readonly cost: number;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly previousEvolutionStage: \"proto-social\";\n readonly resultingEvolutionStage: \"proto-social\";\n readonly consequenceCodes: readonly string[];\n}\n\nconst AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER: Readonly<\n Record<AiGamePointsLedgerId, AiGamePointsAuthorityBoundary>\n> = Object.freeze({\n pp: Object.freeze({\n ledgerId: \"pp\",\n authorityBand: \"self\",\n authoritySystem: \"player-system\",\n requiresWorldAuthority: false,\n combatSafeOnly: false,\n }),\n esp: Object.freeze({\n ledgerId: \"esp\",\n authorityBand: \"frontier\",\n authoritySystem: \"exploration-system\",\n requiresWorldAuthority: false,\n combatSafeOnly: true,\n }),\n tis: Object.freeze({\n ledgerId: \"tis\",\n authorityBand: \"civic\",\n authoritySystem: \"territorial-influence-system\",\n requiresWorldAuthority: true,\n combatSafeOnly: false,\n }),\n dis: Object.freeze({\n ledgerId: \"dis\",\n authorityBand: \"divine\",\n authoritySystem: \"divine-influence-system\",\n requiresWorldAuthority: true,\n combatSafeOnly: false,\n }),\n});\n\nconst AI_GAME_DEFAULT_POINTS_SPEND_POLICIES: readonly AiGamePointsSpendPolicy[] =\n Object.freeze([\n Object.freeze({\n policyId: \"pp-personal-respec\",\n ledgerId: \"pp\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"return-to-slime\",\n title: \"Return to slime\",\n cost: 12,\n prerequisiteCodes: Object.freeze([\"proto-social-window-open\", \"single-use-remaining\"]),\n consequenceCodes: Object.freeze([\"reset-social-form\", \"consume-pp-balance\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"esp-exploration-routing\",\n ledgerId: \"esp\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.esp,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"fast-travel-upgrade\",\n title: \"Unlock frontier fast travel\",\n cost: 8,\n prerequisiteCodes: Object.freeze([\"frontier-route-discovered\", \"out-of-combat-only\"]),\n consequenceCodes: Object.freeze([\"reduce-route-friction\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"tis-civic-investment\",\n ledgerId: \"tis\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.tis,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"district-favor\",\n title: \"Commit district influence favor\",\n cost: 5,\n prerequisiteCodes: Object.freeze([\"civic-authority-approval\"]),\n consequenceCodes: Object.freeze([\"alter-territorial-standing\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"dis-divine-covenant\",\n ledgerId: \"dis\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.dis,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"divine-oath\",\n title: \"Bind a divine covenant\",\n cost: 3,\n prerequisiteCodes: Object.freeze([\"divine-clearance-granted\"]),\n consequenceCodes: Object.freeze([\"alter-divine-standing\"]),\n }),\n ]),\n }),\n ]);\n\nconst AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY: AiGameProtoSocialDevolutionPolicy =\n Object.freeze({\n actionId: \"return-to-slime\",\n ledgerId: \"pp\",\n cost: 12,\n requiredEvolutionStage: \"proto-social\",\n closesAtEvolutionStage: \"social-lock\",\n singleUse: true,\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,\n prerequisiteCodes: Object.freeze([\"proto-social-window-open\", \"single-use-remaining\"]),\n consequenceCodes: Object.freeze([\"reset-social-form\", \"consume-pp-balance\"]),\n });\n\nfunction normalizeNonNegativeInteger(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n return Math.max(0, Math.trunc(value));\n}\n\nexport function isAiGamePointsLedgerId(value: string): value is AiGamePointsLedgerId {\n return (AI_GAME_POINTS_LEDGER_IDS as readonly string[]).includes(value);\n}\n\nexport function isAiGamePlayerEvolutionStage(\n value: string,\n): value is AiGamePlayerEvolutionStage {\n return (AI_GAME_PLAYER_EVOLUTION_STAGES as readonly string[]).includes(value);\n}\n\nexport function resolveAiGamePointsAuthorityBoundary(\n ledgerId: AiGamePointsLedgerId,\n): AiGamePointsAuthorityBoundary {\n return AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER[ledgerId];\n}\n\nexport function createAiGamePointsLedgerSnapshot(\n input: AiGamePointsLedgerSnapshot,\n): AiGamePointsLedgerSnapshot {\n return Object.freeze({\n ledgerId: input.ledgerId,\n balance: normalizeNonNegativeInteger(input.balance),\n earnedTotal: normalizeNonNegativeInteger(input.earnedTotal),\n spentTotal: normalizeNonNegativeInteger(input.spentTotal),\n committedTotal: normalizeNonNegativeInteger(input.committedTotal),\n asOfEpochMs: input.asOfEpochMs,\n });\n}\n\nexport function getDefaultAiGamePointsSpendPolicies(): readonly AiGamePointsSpendPolicy[] {\n return AI_GAME_DEFAULT_POINTS_SPEND_POLICIES;\n}\n\nexport function getAiGameProtoSocialDevolutionPolicy(): AiGameProtoSocialDevolutionPolicy {\n return AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;\n}\n\n/**\n * Evaluate whether the one-time PP devolution action is still allowed.\n */\nexport function evaluateAiGameProtoSocialDevolutionEligibility(\n input: ResolveAiGameProtoSocialDevolutionEligibilityInput,\n): AiGameProtoSocialDevolutionEligibilityResult {\n const reasonCodes: string[] = [];\n const policy = AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;\n const currentBalance = normalizeNonNegativeInteger(input.currentBalance);\n\n if (input.evolutionStage !== policy.requiredEvolutionStage) {\n reasonCodes.push(\"devolution-window-closed\");\n }\n\n if (input.alreadyUsed) {\n reasonCodes.push(\"devolution-already-used\");\n }\n\n if (currentBalance < policy.cost) {\n reasonCodes.push(\"insufficient-pp-balance\");\n }\n\n if (reasonCodes.length === 0) {\n reasonCodes.push(\"devolution-allowed\");\n }\n\n return Object.freeze({\n available: reasonCodes.length === 1 && reasonCodes[0] === \"devolution-allowed\",\n reasonCodes: Object.freeze(reasonCodes),\n policy,\n });\n}\n","export type Version = string;\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type GameWorldEventType =\n | \"monster.spawned\"\n | \"monster.killed\"\n | \"dungeon.created\"\n | \"dungeon.cleared\"\n | \"war.declared\"\n | \"war.resolved\"\n | \"famine.started\"\n | \"surplus.updated\"\n | \"system.checkpoint\";\n\nexport type GameEventVisibilityClass = \"global\" | \"regional\" | \"local\" | \"faction\" | \"secret\";\nexport type GameEventRecordType = \"candidate\" | \"canonical\";\nexport type GameEventSubmissionChannel = \"player\" | \"system\" | \"admin\" | \"simulation\";\nexport type GameEventActorKind = \"player\" | \"npc\" | \"monster\" | \"system\" | \"faction\" | \"environment\";\nexport type GameEventParticipantRole = \"causer\" | \"target\" | \"witness\" | \"owner\" | \"observer\";\nexport type GameEventSeverity = \"info\" | \"warning\" | \"critical\";\n\nexport interface GameEventActor {\n readonly kind: GameEventActorKind;\n readonly subjectRef: string;\n}\n\nexport interface GameEventParticipant {\n readonly role: GameEventParticipantRole;\n readonly actor: GameEventActor;\n}\n\nexport interface GameEventLocation {\n readonly world: string;\n readonly zone: string;\n readonly x?: number;\n readonly y?: number;\n readonly radiusMeters?: number;\n}\n\nexport interface GameEventCausation {\n readonly rootEventId?: string;\n readonly parentEventIds: readonly string[];\n readonly correlationId?: string;\n}\n\nexport interface GameWorldEventPayloadBase {\n readonly eventKind: GameEventSeverity;\n readonly summary: string;\n}\n\nexport interface MonsterSpawnedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.spawned\";\n readonly monsterType: string;\n readonly monsterRef: string;\n}\n\nexport interface MonsterKilledPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.killed\";\n readonly monsterRef: string;\n readonly killerRef?: string;\n readonly encounterResult: \"vanquished\" | \"escaped\" | \"failed\";\n}\n\nexport interface DungeonCreatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.created\";\n readonly dungeonRef: string;\n readonly dungeonType: string;\n readonly difficulty: number;\n}\n\nexport interface DungeonClearedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.cleared\";\n readonly dungeonRef: string;\n readonly clearedByPartyRef: string;\n readonly durationSeconds: number;\n}\n\nexport interface WarDeclaredPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.declared\";\n readonly aggressorFactionRef: string;\n readonly defenderFactionRef: string;\n readonly disputedZone: string;\n}\n\nexport interface WarResolvedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.resolved\";\n readonly warEventRef: string;\n readonly outcome: \"ceasefire\" | \"victory\" | \"loss\" | \"draw\";\n readonly winnerFactionRef?: string;\n}\n\nexport interface FamineStartedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"famine.started\";\n readonly zoneRef: string;\n readonly severity: \"low\" | \"moderate\" | \"high\" | \"critical\";\n}\n\nexport interface SurplusUpdatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"surplus.updated\";\n readonly commodity: string;\n readonly region: string;\n readonly previousBalance: number;\n readonly delta: number;\n}\n\nexport interface SystemCheckpointPayload extends GameWorldEventPayloadBase {\n readonly kind: \"system.checkpoint\";\n readonly sequence: string;\n readonly checkpointState: JsonValue;\n}\n\nexport type GameWorldEventPayload =\n | MonsterSpawnedPayload\n | MonsterKilledPayload\n | DungeonCreatedPayload\n | DungeonClearedPayload\n | WarDeclaredPayload\n | WarResolvedPayload\n | FamineStartedPayload\n | SurplusUpdatedPayload\n | SystemCheckpointPayload;\n\nexport interface GameWorldEventEnvelope {\n readonly eventId: string;\n readonly eventType: GameWorldEventType;\n readonly occurredAtEpochMs: number;\n readonly recordedAtEpochMs: number;\n readonly schemaVersion: string;\n readonly visibility: GameEventVisibilityClass;\n readonly location: GameEventLocation;\n readonly participants: readonly GameEventParticipant[];\n readonly causation: GameEventCausation;\n readonly source: string;\n readonly payload: GameWorldEventPayload;\n readonly tags: readonly string[];\n}\n\nexport interface GameWorldEventCandidate extends GameWorldEventEnvelope {\n readonly recordType: \"candidate\";\n readonly candidateId: string;\n readonly submittedBy?: GameEventActor;\n readonly submittedAtEpochMs: number;\n readonly submissionChannel: GameEventSubmissionChannel;\n}\n\nexport interface GameWorldEventCanonical extends GameWorldEventEnvelope {\n readonly recordType: \"canonical\";\n readonly canonicalEventId: string;\n readonly sourceCandidateId?: string;\n readonly approvedBy: string;\n readonly approvedAtEpochMs: number;\n}\n\nexport type GameWorldEvent = GameWorldEventCandidate | GameWorldEventCanonical;\n\nexport interface GameEventValidationIssue {\n readonly field: string;\n readonly message: string;\n readonly severity: GameEventSeverity;\n}\n\nexport interface GameEventValidationResult {\n readonly valid: boolean;\n readonly issues: readonly GameEventValidationIssue[];\n}\n\nexport interface GameEventSubmissionReceipt {\n readonly accepted: boolean;\n readonly candidateId: string;\n readonly eventId: string;\n readonly notes: readonly string[];\n}\n\nexport interface GameEventCommitReceipt {\n readonly committed: boolean;\n readonly eventId: string;\n readonly sequence: string;\n}\n\nexport interface ProjectionProjectorCheckpoint {\n readonly streamId: string;\n readonly lastAppliedEventOffset: number;\n readonly lastAppliedEventId: string;\n readonly eventVersion: Version;\n readonly updatedAtEpochMs: number;\n}\n\nexport interface ProjectionCheckpointStore {\n getCheckpoint(streamId: string): Promise<ProjectionProjectorCheckpoint | null>;\n setCheckpoint(checkpoint: ProjectionProjectorCheckpoint): Promise<void>;\n}\n\nexport interface WorldEventIngestionPort {\n submitCandidate(candidate: GameWorldEventCandidate): Promise<GameEventSubmissionReceipt>;\n commitCanonical(event: GameWorldEventCanonical): Promise<GameEventCommitReceipt>;\n validateCandidate(candidate: GameWorldEventCandidate): GameEventValidationResult;\n}\n\nexport interface WorldEventProjectorPort {\n readonly streamId: string;\n readonly checkpointStore: ProjectionCheckpointStore;\n project(event: GameWorldEventCanonical): Promise<void>;\n}\n\nexport type WorldIncidentImpactKey = \"security\" | \"economy\" | \"ecology\" | \"politics\" | \"morale\" | \"magic\" | \"population\";\n\nexport type WorldIncidentScope = \"local\" | \"regional\" | \"global\";\n\nexport type WorldIncidentLifecycle = \"active\" | \"resolved\" | \"superseded\" | \"expired\";\n\nexport interface WorldIncidentImpactVector {\n readonly security: number;\n readonly economy: number;\n readonly ecology: number;\n readonly politics: number;\n readonly morale: number;\n readonly magic: number;\n readonly population: number;\n}\n\nexport interface WorldIncidentResolution {\n readonly resolvedAtEpochMs: number;\n readonly closingEventRef: string;\n readonly summary: string;\n}\n\nexport interface WorldIncidentThread {\n readonly incidentId: string;\n readonly scope: WorldIncidentScope;\n readonly lifecycle: WorldIncidentLifecycle;\n readonly causeEventRef: string;\n readonly impact: WorldIncidentImpactVector;\n readonly openedAtEpochMs: number;\n readonly updatedAtEpochMs: number;\n readonly supersededBy?: string;\n readonly resolution?: WorldIncidentResolution;\n readonly affectedEventRefs: readonly string[];\n}\n\nexport interface WorldIncidentRegistry {\n readonly incidents: readonly WorldIncidentThread[];\n readonly activeCount: number;\n}\n\nexport function isCanonicalWorldEvent(event: GameWorldEvent): event is GameWorldEventCanonical {\n return event.recordType === \"canonical\";\n}\n\nexport function isCandidateWorldEvent(event: GameWorldEvent): event is GameWorldEventCandidate {\n return event.recordType === \"candidate\";\n}\n\nconst WORLD_IMPACT_SCALE_LIMIT = 100;\n\nfunction clampImpactValue(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n return Math.max(0, Math.min(WORLD_IMPACT_SCALE_LIMIT, value));\n}\n\nexport function normalizeIncidentImpactVector(\n impact: Partial<WorldIncidentImpactVector> | Record<string, number>,\n): Readonly<WorldIncidentImpactVector> {\n return Object.freeze({\n security: clampImpactValue(Number(impact.security ?? 0)),\n economy: clampImpactValue(Number(impact.economy ?? 0)),\n ecology: clampImpactValue(Number(impact.ecology ?? 0)),\n politics: clampImpactValue(Number(impact.politics ?? 0)),\n morale: clampImpactValue(Number(impact.morale ?? 0)),\n magic: clampImpactValue(Number(impact.magic ?? 0)),\n population: clampImpactValue(Number(impact.population ?? 0)),\n });\n}\n\nexport function isIncidentResolved(incident: WorldIncidentThread): boolean {\n return incident.lifecycle === \"resolved\" || incident.lifecycle === \"expired\";\n}\n","export type GossipSalience = \"low\" | \"medium\" | \"high\" | \"critical\";\nexport type GossipConfidence = \"uncertain\" | \"possible\" | \"strong\" | \"verified\";\nexport type GossipTopicStatus = \"active\" | \"corrected\" | \"resolved\" | \"stale\";\nexport type GossipAudienceSegment = \"player\" | \"npc\" | \"public\";\nexport type GossipProjectionMode = \"segment-level\" | \"npc-level\";\n\nexport interface EventSourceLink {\n readonly sourceType: \"event\" | \"incident\";\n readonly sourceId: string;\n}\n\nexport interface GossipSpeechHint {\n readonly sentenceTone: \"whisper\" | \"formal\" | \"urgent\";\n readonly localizedHintKey: string;\n}\n\nexport interface GossipTopicPayload {\n readonly factSummary: string;\n readonly certainty: number;\n readonly salience: GossipSalience;\n readonly evidenceRefs: readonly EventSourceLink[];\n readonly speechHint: GossipSpeechHint;\n}\n\nexport interface GossipTopic {\n readonly topicId: string;\n readonly status: GossipTopicStatus;\n readonly emittedAtEpochMs: number;\n readonly expiresAtEpochMs: number;\n readonly sourceLink: EventSourceLink;\n readonly sourceEventRef: string;\n readonly lineageOf?: string;\n readonly replacedBy?: string;\n readonly payload: GossipTopicPayload;\n readonly confidenceLevel: GossipConfidence;\n readonly audienceScope: \"faction\" | \"region\" | \"public\";\n}\n\nexport interface WitnessChannel {\n readonly witnessRef: string;\n readonly seenAtEpochMs: number;\n readonly confidenceWeight: number;\n}\n\nexport interface PerspectiveRule {\n readonly locality: readonly string[];\n readonly factions: readonly string[];\n readonly relationshipScore: number;\n}\n\nexport interface KnowledgeSource {\n readonly sourceType: \"segment\" | \"npc\";\n readonly sourceRef: string;\n readonly relationshipToAudience?: number;\n}\n\nexport interface GossipPerspectiveProjection {\n readonly projectionMode: GossipProjectionMode;\n readonly audienceSegment: GossipAudienceSegment;\n readonly requestedByNpcRef?: string;\n readonly locality: string;\n readonly faction: string;\n readonly segmentRules: readonly PerspectiveRule[];\n readonly witnessChannels: readonly WitnessChannel[];\n}\n\nexport interface ProjectedGossipEnvelope {\n readonly topicId: string;\n readonly visible: boolean;\n readonly redactedPayload?: GossipTopicPayload;\n readonly reasons: readonly string[];\n}\n\nexport interface GossipLifecyclePort {\n readonly topicId: string;\n load(): Promise<GossipTopic | null>;\n applyCorrection(next: GossipTopic): Promise<void>;\n markResolved(topicId: string, replacementTopicId?: string): Promise<void>;\n}\n\nexport interface GossipTopicEnvelope {\n readonly topic: GossipTopic;\n readonly topics: readonly EventSourceLink[];\n}\n\nexport function isGossipTopicActive(topic: GossipTopic, nowEpochMs = Date.now()): boolean {\n return topic.status === \"active\" && topic.expiresAtEpochMs > nowEpochMs && topic.payload.certainty >= 0.35;\n}\n\nexport function isGossipTopicCorrected(topic: GossipTopic): boolean {\n return topic.status === \"corrected\";\n}\n\nfunction matchSegmentAudience(\n sourceValue: readonly string[], targetValue: readonly string[], fallback: boolean,\n): boolean {\n if (sourceValue.length === 0 || targetValue.length === 0) {\n return fallback;\n }\n\n return sourceValue.some((value) => targetValue.includes(value));\n}\n\nexport function projectTopicForAudience(\n topic: GossipTopic,\n projection: GossipPerspectiveProjection,\n nowEpochMs = Date.now(),\n): ProjectedGossipEnvelope {\n if (!isGossipTopicActive(topic, nowEpochMs)) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"inactive-or-expired-topic\"],\n };\n }\n\n const hasMatchingRule = projection.segmentRules.some((rule) =>\n matchSegmentAudience(rule.locality, [projection.locality], true) &&\n matchSegmentAudience(rule.factions, [projection.faction], false)\n );\n\n if (!hasMatchingRule) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"audience-not-authorized\"],\n };\n }\n\n if (projection.projectionMode === \"segment-level\" && topic.audienceScope === \"public\") {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"segment-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope === \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope !== \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"scope-constraints\"],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,uCAAuC;AAE7C,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