@plasius/ai-game 0.1.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +39 -0
- package/dist/index.cjs +621 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +205 -1
- package/dist/index.d.ts +205 -1
- package/dist/index.js +575 -6
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0011-player-system-core-contract-boundary.md +56 -0
- package/docs/adrs/adr-0012-identity-projection-contract-boundary.md +55 -0
- package/docs/adrs/index.md +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -167,6 +167,530 @@ function createAiGameMartialTrainingSnapshot(input) {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
// src/player-system.ts
|
|
171
|
+
var AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID = "isekai.player-system.core.enabled";
|
|
172
|
+
var AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = "1.0";
|
|
173
|
+
var AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [
|
|
174
|
+
"ambient",
|
|
175
|
+
"focused",
|
|
176
|
+
"combat-safe"
|
|
177
|
+
];
|
|
178
|
+
var AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES = ["voice", "touch"];
|
|
179
|
+
var AI_GAME_PLAYER_SYSTEM_MODULES = [
|
|
180
|
+
"identity",
|
|
181
|
+
"missions",
|
|
182
|
+
"guild-quests",
|
|
183
|
+
"event-log",
|
|
184
|
+
"mcc",
|
|
185
|
+
"tutorial",
|
|
186
|
+
"points-store"
|
|
187
|
+
];
|
|
188
|
+
var AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [
|
|
189
|
+
"critical",
|
|
190
|
+
"high",
|
|
191
|
+
"normal",
|
|
192
|
+
"low"
|
|
193
|
+
];
|
|
194
|
+
var AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [
|
|
195
|
+
"combat",
|
|
196
|
+
"exploration",
|
|
197
|
+
"crafting",
|
|
198
|
+
"social",
|
|
199
|
+
"governance"
|
|
200
|
+
];
|
|
201
|
+
var AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES = [
|
|
202
|
+
"explicit",
|
|
203
|
+
"observed"
|
|
204
|
+
];
|
|
205
|
+
var AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS = [
|
|
206
|
+
"low",
|
|
207
|
+
"medium",
|
|
208
|
+
"high"
|
|
209
|
+
];
|
|
210
|
+
var DEFAULT_FOCUS_MODE_CONTRACTS = Object.freeze({
|
|
211
|
+
ambient: Object.freeze({
|
|
212
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
213
|
+
mode: "ambient",
|
|
214
|
+
acceptsInputModalities: Object.freeze([]),
|
|
215
|
+
allowsFullNavigation: false,
|
|
216
|
+
maximumVisibleModules: 1,
|
|
217
|
+
deliverableAlertPriorities: Object.freeze([
|
|
218
|
+
"critical",
|
|
219
|
+
"high",
|
|
220
|
+
"normal",
|
|
221
|
+
"low"
|
|
222
|
+
])
|
|
223
|
+
}),
|
|
224
|
+
focused: Object.freeze({
|
|
225
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
226
|
+
mode: "focused",
|
|
227
|
+
acceptsInputModalities: Object.freeze([
|
|
228
|
+
"voice",
|
|
229
|
+
"touch"
|
|
230
|
+
]),
|
|
231
|
+
allowsFullNavigation: true,
|
|
232
|
+
maximumVisibleModules: 3,
|
|
233
|
+
deliverableAlertPriorities: Object.freeze([
|
|
234
|
+
"critical",
|
|
235
|
+
"high",
|
|
236
|
+
"normal",
|
|
237
|
+
"low"
|
|
238
|
+
])
|
|
239
|
+
}),
|
|
240
|
+
"combat-safe": Object.freeze({
|
|
241
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
242
|
+
mode: "combat-safe",
|
|
243
|
+
acceptsInputModalities: Object.freeze([
|
|
244
|
+
"voice",
|
|
245
|
+
"touch"
|
|
246
|
+
]),
|
|
247
|
+
allowsFullNavigation: false,
|
|
248
|
+
maximumVisibleModules: 1,
|
|
249
|
+
deliverableAlertPriorities: Object.freeze([
|
|
250
|
+
"critical",
|
|
251
|
+
"high"
|
|
252
|
+
])
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
var DEFAULT_MODULE_CONTRACTS = Object.freeze({
|
|
256
|
+
identity: Object.freeze({
|
|
257
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
258
|
+
module: "identity",
|
|
259
|
+
requiresFocusedMode: false,
|
|
260
|
+
availableInCombatSafeMode: true,
|
|
261
|
+
supportedInputModalities: Object.freeze([
|
|
262
|
+
"voice",
|
|
263
|
+
"touch"
|
|
264
|
+
])
|
|
265
|
+
}),
|
|
266
|
+
missions: Object.freeze({
|
|
267
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
268
|
+
module: "missions",
|
|
269
|
+
requiresFocusedMode: true,
|
|
270
|
+
availableInCombatSafeMode: false,
|
|
271
|
+
supportedInputModalities: Object.freeze([
|
|
272
|
+
"voice",
|
|
273
|
+
"touch"
|
|
274
|
+
])
|
|
275
|
+
}),
|
|
276
|
+
"guild-quests": Object.freeze({
|
|
277
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
278
|
+
module: "guild-quests",
|
|
279
|
+
requiresFocusedMode: true,
|
|
280
|
+
availableInCombatSafeMode: false,
|
|
281
|
+
supportedInputModalities: Object.freeze([
|
|
282
|
+
"voice",
|
|
283
|
+
"touch"
|
|
284
|
+
])
|
|
285
|
+
}),
|
|
286
|
+
"event-log": Object.freeze({
|
|
287
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
288
|
+
module: "event-log",
|
|
289
|
+
requiresFocusedMode: true,
|
|
290
|
+
availableInCombatSafeMode: false,
|
|
291
|
+
supportedInputModalities: Object.freeze([
|
|
292
|
+
"voice",
|
|
293
|
+
"touch"
|
|
294
|
+
])
|
|
295
|
+
}),
|
|
296
|
+
mcc: Object.freeze({
|
|
297
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
298
|
+
module: "mcc",
|
|
299
|
+
requiresFocusedMode: true,
|
|
300
|
+
availableInCombatSafeMode: false,
|
|
301
|
+
supportedInputModalities: Object.freeze([
|
|
302
|
+
"voice",
|
|
303
|
+
"touch"
|
|
304
|
+
])
|
|
305
|
+
}),
|
|
306
|
+
tutorial: Object.freeze({
|
|
307
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
308
|
+
module: "tutorial",
|
|
309
|
+
requiresFocusedMode: true,
|
|
310
|
+
availableInCombatSafeMode: false,
|
|
311
|
+
supportedInputModalities: Object.freeze([
|
|
312
|
+
"voice",
|
|
313
|
+
"touch"
|
|
314
|
+
])
|
|
315
|
+
}),
|
|
316
|
+
"points-store": Object.freeze({
|
|
317
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
318
|
+
module: "points-store",
|
|
319
|
+
requiresFocusedMode: true,
|
|
320
|
+
availableInCombatSafeMode: false,
|
|
321
|
+
supportedInputModalities: Object.freeze([
|
|
322
|
+
"voice",
|
|
323
|
+
"touch"
|
|
324
|
+
])
|
|
325
|
+
})
|
|
326
|
+
});
|
|
327
|
+
var DEFAULT_SESSION_MODULES = Object.freeze([DEFAULT_MODULE_CONTRACTS.identity]);
|
|
328
|
+
var AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS = Object.freeze(
|
|
329
|
+
AI_GAME_PLAYER_SYSTEM_FOCUS_MODES.map(
|
|
330
|
+
(mode) => DEFAULT_FOCUS_MODE_CONTRACTS[mode]
|
|
331
|
+
)
|
|
332
|
+
);
|
|
333
|
+
var AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS = Object.freeze(
|
|
334
|
+
AI_GAME_PLAYER_SYSTEM_MODULES.map((module) => DEFAULT_MODULE_CONTRACTS[module])
|
|
335
|
+
);
|
|
336
|
+
function freezeReadonlyArray2(items) {
|
|
337
|
+
return Object.freeze([...items]);
|
|
338
|
+
}
|
|
339
|
+
function assertNonEmptyString2(value, label) {
|
|
340
|
+
if (value.trim().length === 0) {
|
|
341
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function assertContractVersion(value, label = "contractVersion") {
|
|
345
|
+
if (value !== AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION) {
|
|
346
|
+
throw new Error(`${label} must be ${AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function assertIsoTimestamp(value, label) {
|
|
350
|
+
assertNonEmptyString2(value, label);
|
|
351
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
352
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function assertConfidenceScore(value, label = "confidenceScore") {
|
|
356
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
357
|
+
throw new Error(`${label} must be between 0 and 1`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function assertNonNegativeInteger(value, label) {
|
|
361
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
362
|
+
throw new Error(`${label} must be a non-negative integer`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function isMember(value, members) {
|
|
366
|
+
return members.includes(value);
|
|
367
|
+
}
|
|
368
|
+
function isAiGamePlayerSystemFocusMode(value) {
|
|
369
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_FOCUS_MODES);
|
|
370
|
+
}
|
|
371
|
+
function isAiGamePlayerSystemInputModality(value) {
|
|
372
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES);
|
|
373
|
+
}
|
|
374
|
+
function isAiGamePlayerSystemModule(value) {
|
|
375
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_MODULES);
|
|
376
|
+
}
|
|
377
|
+
function isAiGamePlayerSystemAlertPriority(value) {
|
|
378
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);
|
|
379
|
+
}
|
|
380
|
+
function isAiGamePlayerSystemPreferenceKind(value) {
|
|
381
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);
|
|
382
|
+
}
|
|
383
|
+
function isAiGamePlayerSystemPreferenceSource(value) {
|
|
384
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES);
|
|
385
|
+
}
|
|
386
|
+
function isAiGamePlayerSystemConfidenceBand(value) {
|
|
387
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS);
|
|
388
|
+
}
|
|
389
|
+
function getAiGamePlayerSystemFocusModeContract(mode) {
|
|
390
|
+
return DEFAULT_FOCUS_MODE_CONTRACTS[mode];
|
|
391
|
+
}
|
|
392
|
+
function getAiGamePlayerSystemModuleContract(module) {
|
|
393
|
+
return DEFAULT_MODULE_CONTRACTS[module];
|
|
394
|
+
}
|
|
395
|
+
function isAiGamePlayerSystemAlertDeliverable(alert, mode) {
|
|
396
|
+
return getAiGamePlayerSystemFocusModeContract(mode).deliverableAlertPriorities.includes(
|
|
397
|
+
alert.priority
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
function selectAiGamePlayerSystemAlertsForFocusMode(alerts, mode) {
|
|
401
|
+
return freezeReadonlyArray2(
|
|
402
|
+
alerts.filter((alert) => isAiGamePlayerSystemAlertDeliverable(alert, mode))
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function createAiGamePlayerSystemAlert(input) {
|
|
406
|
+
assertNonEmptyString2(input.alertId, "alertId");
|
|
407
|
+
assertNonEmptyString2(input.title, "title");
|
|
408
|
+
assertNonEmptyString2(input.message, "message");
|
|
409
|
+
assertIsoTimestamp(input.createdAtIso, "createdAtIso");
|
|
410
|
+
assertContractVersion(input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION);
|
|
411
|
+
if (!isAiGamePlayerSystemAlertPriority(input.priority)) {
|
|
412
|
+
throw new Error("priority must be a supported Player System alert priority");
|
|
413
|
+
}
|
|
414
|
+
if (!isAiGamePlayerSystemModule(input.sourceModule)) {
|
|
415
|
+
throw new Error("sourceModule must be a supported Player System module");
|
|
416
|
+
}
|
|
417
|
+
return Object.freeze({
|
|
418
|
+
...input,
|
|
419
|
+
contractVersion: input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function resolveAiGamePlayerSystemConfidenceBand(confidenceScore) {
|
|
423
|
+
assertConfidenceScore(confidenceScore);
|
|
424
|
+
if (confidenceScore >= 0.67) {
|
|
425
|
+
return "high";
|
|
426
|
+
}
|
|
427
|
+
if (confidenceScore >= 0.34) {
|
|
428
|
+
return "medium";
|
|
429
|
+
}
|
|
430
|
+
return "low";
|
|
431
|
+
}
|
|
432
|
+
function createAiGamePlayerSystemPreferenceInput(input) {
|
|
433
|
+
assertNonEmptyString2(input.inputId, "inputId");
|
|
434
|
+
assertIsoTimestamp(input.capturedAtIso, "capturedAtIso");
|
|
435
|
+
assertConfidenceScore(input.confidenceScore);
|
|
436
|
+
if (!isAiGamePlayerSystemPreferenceKind(input.kind)) {
|
|
437
|
+
throw new Error("kind must be a supported Player System preference kind");
|
|
438
|
+
}
|
|
439
|
+
if (!isAiGamePlayerSystemPreferenceSource(input.source)) {
|
|
440
|
+
throw new Error("source must be a supported Player System preference source");
|
|
441
|
+
}
|
|
442
|
+
return Object.freeze({
|
|
443
|
+
...input,
|
|
444
|
+
reasonCodes: freezeReadonlyArray2(input.reasonCodes ?? [])
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function createAiGamePlayerSystemPreferenceConfidenceState(input) {
|
|
448
|
+
assertConfidenceScore(input.confidenceScore);
|
|
449
|
+
assertNonNegativeInteger(input.sampleCount, "sampleCount");
|
|
450
|
+
assertIsoTimestamp(input.lastUpdatedAtIso, "lastUpdatedAtIso");
|
|
451
|
+
const confidenceBand = resolveAiGamePlayerSystemConfidenceBand(
|
|
452
|
+
input.confidenceScore
|
|
453
|
+
);
|
|
454
|
+
if (input.confidenceBand !== void 0 && input.confidenceBand !== confidenceBand) {
|
|
455
|
+
throw new Error("confidenceBand must match confidenceScore");
|
|
456
|
+
}
|
|
457
|
+
return Object.freeze({
|
|
458
|
+
confidenceScore: input.confidenceScore,
|
|
459
|
+
confidenceBand,
|
|
460
|
+
sampleCount: input.sampleCount,
|
|
461
|
+
lastUpdatedAtIso: input.lastUpdatedAtIso
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
function createAiGamePlayerSystemPreferenceProfile(input) {
|
|
465
|
+
assertNonEmptyString2(input.profileId, "profileId");
|
|
466
|
+
const inputs = (input.inputs ?? []).map(
|
|
467
|
+
(preferenceInput) => createAiGamePlayerSystemPreferenceInput(preferenceInput)
|
|
468
|
+
);
|
|
469
|
+
const lastUpdatedAtIso = input.confidence?.lastUpdatedAtIso ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
470
|
+
const confidenceScore = input.confidence?.confidenceScore ?? (inputs.length === 0 ? 0 : inputs.reduce((total, preferenceInput) => total + preferenceInput.confidenceScore, 0) / inputs.length);
|
|
471
|
+
const confidence = createAiGamePlayerSystemPreferenceConfidenceState({
|
|
472
|
+
confidenceScore,
|
|
473
|
+
sampleCount: input.confidence?.sampleCount ?? inputs.length,
|
|
474
|
+
lastUpdatedAtIso,
|
|
475
|
+
confidenceBand: input.confidence?.confidenceBand
|
|
476
|
+
});
|
|
477
|
+
return Object.freeze({
|
|
478
|
+
profileId: input.profileId,
|
|
479
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
480
|
+
inputs: freezeReadonlyArray2(inputs),
|
|
481
|
+
confidence
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function createAiGamePlayerSystemSession(input) {
|
|
485
|
+
assertNonEmptyString2(input.sessionId, "sessionId");
|
|
486
|
+
if (!isAiGamePlayerSystemFocusMode(input.focusMode)) {
|
|
487
|
+
throw new Error("focusMode must be a supported Player System focus mode");
|
|
488
|
+
}
|
|
489
|
+
if (input.activeModule !== null && input.activeModule !== void 0 && !isAiGamePlayerSystemModule(input.activeModule)) {
|
|
490
|
+
throw new Error("activeModule must be a supported Player System module");
|
|
491
|
+
}
|
|
492
|
+
const modeContract = getAiGamePlayerSystemFocusModeContract(input.focusMode);
|
|
493
|
+
const modules = freezeReadonlyArray2(
|
|
494
|
+
(input.modules ?? DEFAULT_SESSION_MODULES).map(
|
|
495
|
+
(moduleContract) => Object.freeze({
|
|
496
|
+
...moduleContract,
|
|
497
|
+
supportedInputModalities: freezeReadonlyArray2(
|
|
498
|
+
moduleContract.supportedInputModalities
|
|
499
|
+
)
|
|
500
|
+
})
|
|
501
|
+
)
|
|
502
|
+
);
|
|
503
|
+
const acceptedInputModalities = freezeReadonlyArray2(
|
|
504
|
+
input.acceptedInputModalities ?? modeContract.acceptsInputModalities
|
|
505
|
+
);
|
|
506
|
+
const pendingAlerts = freezeReadonlyArray2(
|
|
507
|
+
(input.pendingAlerts ?? []).map((alert) => createAiGamePlayerSystemAlert(alert))
|
|
508
|
+
);
|
|
509
|
+
if (modules.length > modeContract.maximumVisibleModules) {
|
|
510
|
+
throw new Error("modules exceed the focus mode visibility limit");
|
|
511
|
+
}
|
|
512
|
+
for (const modality of acceptedInputModalities) {
|
|
513
|
+
if (!isAiGamePlayerSystemInputModality(modality)) {
|
|
514
|
+
throw new Error("acceptedInputModalities contains an unsupported modality");
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (input.focusMode === "focused" && (!acceptedInputModalities.includes("voice") || !acceptedInputModalities.includes("touch"))) {
|
|
518
|
+
throw new Error("focused sessions must accept both voice and touch input");
|
|
519
|
+
}
|
|
520
|
+
for (const moduleContract of modules) {
|
|
521
|
+
assertContractVersion(moduleContract.contractVersion, "module contractVersion");
|
|
522
|
+
if (!isAiGamePlayerSystemModule(moduleContract.module)) {
|
|
523
|
+
throw new Error("modules contains an unsupported Player System module");
|
|
524
|
+
}
|
|
525
|
+
for (const modality of moduleContract.supportedInputModalities) {
|
|
526
|
+
if (!isAiGamePlayerSystemInputModality(modality)) {
|
|
527
|
+
throw new Error("modules contains an unsupported input modality");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (input.focusMode === "combat-safe" && !moduleContract.availableInCombatSafeMode) {
|
|
531
|
+
throw new Error("combat-safe sessions cannot expose unsafe modules");
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (input.activeModule !== null && input.activeModule !== void 0 && !modules.some((moduleContract) => moduleContract.module === input.activeModule)) {
|
|
535
|
+
throw new Error("activeModule must be included in modules");
|
|
536
|
+
}
|
|
537
|
+
return Object.freeze({
|
|
538
|
+
sessionId: input.sessionId,
|
|
539
|
+
contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
540
|
+
featureFlagId: AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
|
|
541
|
+
focusMode: input.focusMode,
|
|
542
|
+
activeModule: input.activeModule ?? null,
|
|
543
|
+
modules,
|
|
544
|
+
acceptedInputModalities,
|
|
545
|
+
pendingAlerts,
|
|
546
|
+
preferenceProfile: createAiGamePlayerSystemPreferenceProfile({
|
|
547
|
+
profileId: input.preferenceProfile.profileId,
|
|
548
|
+
inputs: input.preferenceProfile.inputs,
|
|
549
|
+
confidence: input.preferenceProfile.confidence
|
|
550
|
+
})
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/identity.ts
|
|
555
|
+
var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
|
|
556
|
+
var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
|
|
557
|
+
var AI_GAME_IDENTITY_PROJECTION_READS = [
|
|
558
|
+
"self",
|
|
559
|
+
"partial",
|
|
560
|
+
"full"
|
|
561
|
+
];
|
|
562
|
+
var AI_GAME_IDENTITY_TARGET_CATEGORIES = [
|
|
563
|
+
"allied",
|
|
564
|
+
"neutral",
|
|
565
|
+
"unknown",
|
|
566
|
+
"unfriendly"
|
|
567
|
+
];
|
|
568
|
+
var AI_GAME_IDENTITY_KNOWLEDGE_STATES = [
|
|
569
|
+
"unknown",
|
|
570
|
+
"partial",
|
|
571
|
+
"full"
|
|
572
|
+
];
|
|
573
|
+
var AI_GAME_IDENTITY_VISIBILITY_STATES = ["visible", "occluded"];
|
|
574
|
+
var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
|
|
575
|
+
self: "full",
|
|
576
|
+
visibleTargets: "partial-or-full-by-knowledge",
|
|
577
|
+
occludedTargets: "partial-redacted"
|
|
578
|
+
});
|
|
579
|
+
function freezeReadonlyArray3(items) {
|
|
580
|
+
return Object.freeze([...items]);
|
|
581
|
+
}
|
|
582
|
+
function assertNonEmptyString3(value, label) {
|
|
583
|
+
if (value.trim().length === 0) {
|
|
584
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function assertContractVersion2(value, label = "contractVersion") {
|
|
588
|
+
if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
|
|
589
|
+
throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function isMember2(value, members) {
|
|
593
|
+
return members.includes(value);
|
|
594
|
+
}
|
|
595
|
+
function createField(field) {
|
|
596
|
+
assertNonEmptyString3(field.label, "field.label");
|
|
597
|
+
assertNonEmptyString3(field.value, "field.value");
|
|
598
|
+
return Object.freeze({
|
|
599
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
600
|
+
label: field.label,
|
|
601
|
+
value: field.value,
|
|
602
|
+
redacted: field.redacted ?? false
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
function redactField(field, value) {
|
|
606
|
+
return createField({
|
|
607
|
+
label: field.label,
|
|
608
|
+
value,
|
|
609
|
+
redacted: true
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function isAiGameIdentityProjectionRead(value) {
|
|
613
|
+
return isMember2(value, AI_GAME_IDENTITY_PROJECTION_READS);
|
|
614
|
+
}
|
|
615
|
+
function isAiGameIdentityTargetCategory(value) {
|
|
616
|
+
return isMember2(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
|
|
617
|
+
}
|
|
618
|
+
function isAiGameIdentityKnowledgeState(value) {
|
|
619
|
+
return isMember2(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
|
|
620
|
+
}
|
|
621
|
+
function isAiGameIdentityVisibilityState(value) {
|
|
622
|
+
return isMember2(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
|
|
623
|
+
}
|
|
624
|
+
function resolveAiGameIdentityProjectionRead(input) {
|
|
625
|
+
return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
|
|
626
|
+
}
|
|
627
|
+
function createAiGameIdentitySelfProjection(input) {
|
|
628
|
+
assertNonEmptyString3(input.entityId, "entityId");
|
|
629
|
+
assertNonEmptyString3(input.label, "label");
|
|
630
|
+
assertNonEmptyString3(input.summary, "summary");
|
|
631
|
+
return Object.freeze({
|
|
632
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
633
|
+
entityId: input.entityId,
|
|
634
|
+
label: input.label,
|
|
635
|
+
projectionRead: "self",
|
|
636
|
+
summary: input.summary,
|
|
637
|
+
fields: freezeReadonlyArray3(input.fields.map((field) => createField(field)))
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
function createAiGameIdentityTargetProjection(input) {
|
|
641
|
+
assertNonEmptyString3(input.targetId, "targetId");
|
|
642
|
+
assertNonEmptyString3(input.label, "label");
|
|
643
|
+
assertNonEmptyString3(input.summary, "summary");
|
|
644
|
+
assertNonEmptyString3(input.combatSummary, "combatSummary");
|
|
645
|
+
if (!isAiGameIdentityTargetCategory(input.category)) {
|
|
646
|
+
throw new Error("category must be a supported identity target category");
|
|
647
|
+
}
|
|
648
|
+
if (!isAiGameIdentityKnowledgeState(input.knowledgeState)) {
|
|
649
|
+
throw new Error("knowledgeState must be a supported identity knowledge state");
|
|
650
|
+
}
|
|
651
|
+
const projectionRead = resolveAiGameIdentityProjectionRead(input);
|
|
652
|
+
const visibility = input.lineOfSight ? "visible" : "occluded";
|
|
653
|
+
const fields = input.fields.map(
|
|
654
|
+
(field) => projectionRead === "full" ? createField(field) : redactField(field, input.lineOfSight ? "Unknown" : "Withheld")
|
|
655
|
+
);
|
|
656
|
+
return Object.freeze({
|
|
657
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
658
|
+
targetId: input.targetId,
|
|
659
|
+
label: input.label,
|
|
660
|
+
category: input.category,
|
|
661
|
+
knowledgeState: input.knowledgeState,
|
|
662
|
+
visibility,
|
|
663
|
+
lineOfSight: input.lineOfSight,
|
|
664
|
+
projectionRead,
|
|
665
|
+
summary: input.summary,
|
|
666
|
+
combatSummary: input.combatSummary,
|
|
667
|
+
fields: freezeReadonlyArray3(fields)
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function selectAiGameVisibleIdentityTargets(targets) {
|
|
671
|
+
return freezeReadonlyArray3(
|
|
672
|
+
targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
function createAiGameIdentityProjectionContract(input) {
|
|
676
|
+
const self = createAiGameIdentitySelfProjection(input.self);
|
|
677
|
+
const targets = freezeReadonlyArray3(
|
|
678
|
+
(input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
|
|
679
|
+
);
|
|
680
|
+
return Object.freeze({
|
|
681
|
+
contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
682
|
+
featureFlagId: AI_GAME_IDENTITY_FEATURE_FLAG_ID,
|
|
683
|
+
authorityOwner: "identity-card",
|
|
684
|
+
authorityMode: "projection-only",
|
|
685
|
+
disclosurePolicy: AI_GAME_IDENTITY_DISCLOSURE_POLICY,
|
|
686
|
+
self,
|
|
687
|
+
targets
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
function assertAiGameIdentityProjectionContractVersion(value) {
|
|
691
|
+
assertContractVersion2(value);
|
|
692
|
+
}
|
|
693
|
+
|
|
170
694
|
// src/world-events.ts
|
|
171
695
|
function isCanonicalWorldEvent(event) {
|
|
172
696
|
return event.recordType === "canonical";
|
|
@@ -318,7 +842,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
318
842
|
"private-or-low-witness-evidence",
|
|
319
843
|
"costly-pressure-event"
|
|
320
844
|
];
|
|
321
|
-
function
|
|
845
|
+
function isMember3(value, members) {
|
|
322
846
|
return members.includes(value);
|
|
323
847
|
}
|
|
324
848
|
function assertRecord(value, label) {
|
|
@@ -359,7 +883,7 @@ function normalizeTimestamp(value, label) {
|
|
|
359
883
|
}
|
|
360
884
|
function normalizeMember(value, members, label) {
|
|
361
885
|
const normalized = normalizeNonEmptyString(value, label);
|
|
362
|
-
if (!
|
|
886
|
+
if (!isMember3(normalized, members)) {
|
|
363
887
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
364
888
|
}
|
|
365
889
|
return normalized;
|
|
@@ -492,13 +1016,13 @@ function normalizeDominantReads(value) {
|
|
|
492
1016
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
493
1017
|
}
|
|
494
1018
|
function isQuietMeasureAxis(value) {
|
|
495
|
-
return
|
|
1019
|
+
return isMember3(value, QUIET_MEASURE_AXES);
|
|
496
1020
|
}
|
|
497
1021
|
function isQuietMeasureMissionProbeMode(value) {
|
|
498
|
-
return
|
|
1022
|
+
return isMember3(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
499
1023
|
}
|
|
500
1024
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
501
|
-
return
|
|
1025
|
+
return isMember3(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
502
1026
|
}
|
|
503
1027
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
504
1028
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -1003,9 +1527,27 @@ export {
|
|
|
1003
1527
|
AI_GAME_FEATURE_FLAG_ID,
|
|
1004
1528
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
1005
1529
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
1530
|
+
AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
1531
|
+
AI_GAME_IDENTITY_DISCLOSURE_POLICY,
|
|
1532
|
+
AI_GAME_IDENTITY_FEATURE_FLAG_ID,
|
|
1533
|
+
AI_GAME_IDENTITY_KNOWLEDGE_STATES,
|
|
1534
|
+
AI_GAME_IDENTITY_PROJECTION_READS,
|
|
1535
|
+
AI_GAME_IDENTITY_TARGET_CATEGORIES,
|
|
1536
|
+
AI_GAME_IDENTITY_VISIBILITY_STATES,
|
|
1006
1537
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
1007
1538
|
AI_GAME_PACKAGE,
|
|
1008
1539
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
1540
|
+
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
1541
|
+
AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS,
|
|
1542
|
+
AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
1543
|
+
AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
|
|
1544
|
+
AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
|
|
1545
|
+
AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
|
|
1546
|
+
AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
|
|
1547
|
+
AI_GAME_PLAYER_SYSTEM_MODULES,
|
|
1548
|
+
AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
|
|
1549
|
+
AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS,
|
|
1550
|
+
AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES,
|
|
1009
1551
|
AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
|
|
1010
1552
|
AI_GAME_TASK_AUTHORITY_BOUNDARIES,
|
|
1011
1553
|
AI_GAME_TASK_DECISIONS,
|
|
@@ -1041,10 +1583,19 @@ export {
|
|
|
1041
1583
|
QUIET_MEASURE_PERSPECTIVES,
|
|
1042
1584
|
QUIET_MEASURE_SIGNAL_BANDS,
|
|
1043
1585
|
aiGameFeatureFlags,
|
|
1586
|
+
assertAiGameIdentityProjectionContractVersion,
|
|
1044
1587
|
classifyAiGameTask,
|
|
1045
1588
|
createAiGameAcademicTrainingSnapshot,
|
|
1589
|
+
createAiGameIdentityProjectionContract,
|
|
1590
|
+
createAiGameIdentitySelfProjection,
|
|
1591
|
+
createAiGameIdentityTargetProjection,
|
|
1046
1592
|
createAiGameInstitutionEligibility,
|
|
1047
1593
|
createAiGameMartialTrainingSnapshot,
|
|
1594
|
+
createAiGamePlayerSystemAlert,
|
|
1595
|
+
createAiGamePlayerSystemPreferenceConfidenceState,
|
|
1596
|
+
createAiGamePlayerSystemPreferenceInput,
|
|
1597
|
+
createAiGamePlayerSystemPreferenceProfile,
|
|
1598
|
+
createAiGamePlayerSystemSession,
|
|
1048
1599
|
createAiGameSpecializationRecommendation,
|
|
1049
1600
|
createTrainingAcademicMissionPrerequisite as createAiGameTrainingAcademicMissionPrerequisite,
|
|
1050
1601
|
createTrainingAcademyAdmission as createAiGameTrainingAcademyAdmission,
|
|
@@ -1055,6 +1606,20 @@ export {
|
|
|
1055
1606
|
createQuietMeasureJudgmentEligibility,
|
|
1056
1607
|
createQuietMeasureJudgmentResponse,
|
|
1057
1608
|
gameEventFeatureFlags,
|
|
1609
|
+
getAiGamePlayerSystemFocusModeContract,
|
|
1610
|
+
getAiGamePlayerSystemModuleContract,
|
|
1611
|
+
isAiGameIdentityKnowledgeState,
|
|
1612
|
+
isAiGameIdentityProjectionRead,
|
|
1613
|
+
isAiGameIdentityTargetCategory,
|
|
1614
|
+
isAiGameIdentityVisibilityState,
|
|
1615
|
+
isAiGamePlayerSystemAlertDeliverable,
|
|
1616
|
+
isAiGamePlayerSystemAlertPriority,
|
|
1617
|
+
isAiGamePlayerSystemConfidenceBand,
|
|
1618
|
+
isAiGamePlayerSystemFocusMode,
|
|
1619
|
+
isAiGamePlayerSystemInputModality,
|
|
1620
|
+
isAiGamePlayerSystemModule,
|
|
1621
|
+
isAiGamePlayerSystemPreferenceKind,
|
|
1622
|
+
isAiGamePlayerSystemPreferenceSource,
|
|
1058
1623
|
isTrainingAcademicProgressStage as isAiGameTrainingAcademicProgressStage,
|
|
1059
1624
|
isTrainingAcademyAdmissionDecision as isAiGameTrainingAcademyAdmissionDecision,
|
|
1060
1625
|
isTrainingAntiSpellCounterWindow as isAiGameTrainingAntiSpellCounterWindow,
|
|
@@ -1082,7 +1647,11 @@ export {
|
|
|
1082
1647
|
normalizeIncidentImpactVector,
|
|
1083
1648
|
packageDescriptor,
|
|
1084
1649
|
projectTopicForAudience,
|
|
1650
|
+
resolveAiGameIdentityProjectionRead,
|
|
1085
1651
|
resolveAiGamePlayerAddressText,
|
|
1086
|
-
|
|
1652
|
+
resolveAiGamePlayerSystemConfidenceBand,
|
|
1653
|
+
resolveAiGameTaskBatch,
|
|
1654
|
+
selectAiGamePlayerSystemAlertsForFocusMode,
|
|
1655
|
+
selectAiGameVisibleIdentityTargets
|
|
1087
1656
|
};
|
|
1088
1657
|
//# sourceMappingURL=index.js.map
|