@plasius/ai-game 0.4.0 → 0.6.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/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID: () => AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
27
27
  AI_GAME_FEATURE_FLAGS: () => AI_GAME_FEATURE_FLAGS,
28
28
  AI_GAME_FEATURE_FLAG_ID: () => AI_GAME_FEATURE_FLAG_ID,
29
+ AI_GAME_GOSSIP_EXPORT_AUDIENCES: () => AI_GAME_GOSSIP_EXPORT_AUDIENCES,
29
30
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
30
31
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
31
32
  AI_GAME_IDENTITY_CONTRACT_VERSION: () => AI_GAME_IDENTITY_CONTRACT_VERSION,
@@ -49,6 +50,16 @@ __export(index_exports, {
49
50
  AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING: () => AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
50
51
  AI_GAME_MISSION_REWARD_CAP_SEMANTICS: () => AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
51
52
  AI_GAME_MISSION_REWARD_KINDS: () => AI_GAME_MISSION_REWARD_KINDS,
53
+ AI_GAME_OBSERVED_EVENT_KINDS: () => AI_GAME_OBSERVED_EVENT_KINDS,
54
+ AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION: () => AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION,
55
+ AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID: () => AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID,
56
+ AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH: () => AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH,
57
+ AI_GAME_OBSERVED_EVENT_MAX_TAGS: () => AI_GAME_OBSERVED_EVENT_MAX_TAGS,
58
+ AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH: () => AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH,
59
+ AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS: () => AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS,
60
+ AI_GAME_OBSERVED_EVENT_SIGNIFICANCE: () => AI_GAME_OBSERVED_EVENT_SIGNIFICANCE,
61
+ AI_GAME_OBSERVED_EVENT_SOURCES: () => AI_GAME_OBSERVED_EVENT_SOURCES,
62
+ AI_GAME_OBSERVED_EVENT_VISIBILITIES: () => AI_GAME_OBSERVED_EVENT_VISIBILITIES,
52
63
  AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
53
64
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
54
65
  AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES: () => AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
@@ -57,6 +68,13 @@ __export(index_exports, {
57
68
  AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID: () => AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
58
69
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODES: () => AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
59
70
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS: () => AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
71
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE,
72
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES,
73
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES,
74
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS,
75
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS,
76
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS,
77
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID: () => AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
60
78
  AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES: () => AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
61
79
  AI_GAME_PLAYER_SYSTEM_MODULES: () => AI_GAME_PLAYER_SYSTEM_MODULES,
62
80
  AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS: () => AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
@@ -99,8 +117,10 @@ __export(index_exports, {
99
117
  aiGameFeatureFlags: () => aiGameFeatureFlags,
100
118
  assertAiGameIdentityProjectionContractVersion: () => assertAiGameIdentityProjectionContractVersion,
101
119
  assertAiGameMissionContractVersion: () => assertAiGameMissionContractVersion,
120
+ assertAiGameObservedEventLogContractVersion: () => assertAiGameObservedEventLogContractVersion,
102
121
  classifyAiGameTask: () => classifyAiGameTask,
103
122
  createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
123
+ createAiGameGossipExport: () => createAiGameGossipExport,
104
124
  createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
105
125
  createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
106
126
  createAiGameIdentityTargetProjection: () => createAiGameIdentityTargetProjection,
@@ -116,7 +136,11 @@ __export(index_exports, {
116
136
  createAiGameMissionRewardBound: () => createAiGameMissionRewardBound,
117
137
  createAiGameMissionRewardEnvelope: () => createAiGameMissionRewardEnvelope,
118
138
  createAiGameMissionRewardGrant: () => createAiGameMissionRewardGrant,
139
+ createAiGameObservedEvent: () => createAiGameObservedEvent,
140
+ createAiGameObservedEventHighlightSummary: () => createAiGameObservedEventHighlightSummary,
141
+ createAiGameObservedEventRecencyWindow: () => createAiGameObservedEventRecencyWindow,
119
142
  createAiGamePlayerSystemAlert: () => createAiGamePlayerSystemAlert,
143
+ createAiGamePlayerSystemGuidanceCue: () => createAiGamePlayerSystemGuidanceCue,
120
144
  createAiGamePlayerSystemPreferenceConfidenceState: () => createAiGamePlayerSystemPreferenceConfidenceState,
121
145
  createAiGamePlayerSystemPreferenceInput: () => createAiGamePlayerSystemPreferenceInput,
122
146
  createAiGamePlayerSystemPreferenceProfile: () => createAiGamePlayerSystemPreferenceProfile,
@@ -132,7 +156,9 @@ __export(index_exports, {
132
156
  createQuietMeasureJudgmentResponse: () => createQuietMeasureJudgmentResponse,
133
157
  gameEventFeatureFlags: () => gameEventFeatureFlags,
134
158
  getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
159
+ getAiGamePlayerSystemGuidanceFallbackContract: () => getAiGamePlayerSystemGuidanceFallbackContract,
135
160
  getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
161
+ isAiGameGossipExportAudience: () => isAiGameGossipExportAudience,
136
162
  isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
137
163
  isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
138
164
  isAiGameIdentityTargetCategory: () => isAiGameIdentityTargetCategory,
@@ -148,10 +174,17 @@ __export(index_exports, {
148
174
  isAiGameMissionRepeatedSignalHandling: () => isAiGameMissionRepeatedSignalHandling,
149
175
  isAiGameMissionRewardCapSemantic: () => isAiGameMissionRewardCapSemantic,
150
176
  isAiGameMissionRewardKind: () => isAiGameMissionRewardKind,
177
+ isAiGameObservedEventKind: () => isAiGameObservedEventKind,
178
+ isAiGameObservedEventSignificance: () => isAiGameObservedEventSignificance,
179
+ isAiGameObservedEventSource: () => isAiGameObservedEventSource,
180
+ isAiGameObservedEventVisibility: () => isAiGameObservedEventVisibility,
151
181
  isAiGamePlayerSystemAlertDeliverable: () => isAiGamePlayerSystemAlertDeliverable,
152
182
  isAiGamePlayerSystemAlertPriority: () => isAiGamePlayerSystemAlertPriority,
153
183
  isAiGamePlayerSystemConfidenceBand: () => isAiGamePlayerSystemConfidenceBand,
154
184
  isAiGamePlayerSystemFocusMode: () => isAiGamePlayerSystemFocusMode,
185
+ isAiGamePlayerSystemGuidanceCueSource: () => isAiGamePlayerSystemGuidanceCueSource,
186
+ isAiGamePlayerSystemGuidanceFallbackBehavior: () => isAiGamePlayerSystemGuidanceFallbackBehavior,
187
+ isAiGamePlayerSystemGuidanceFallbackId: () => isAiGamePlayerSystemGuidanceFallbackId,
155
188
  isAiGamePlayerSystemInputModality: () => isAiGamePlayerSystemInputModality,
156
189
  isAiGamePlayerSystemModule: () => isAiGamePlayerSystemModule,
157
190
  isAiGamePlayerSystemPreferenceKind: () => isAiGamePlayerSystemPreferenceKind,
@@ -328,6 +361,9 @@ function createAiGameMartialTrainingSnapshot(input) {
328
361
  // src/player-system.ts
329
362
  var AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID = "isekai.player-system.core.enabled";
330
363
  var AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = "1.0";
364
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID = "isekai.player-system.guidance-nfr.enabled";
365
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES = 4096;
366
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE = 30;
331
367
  var AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [
332
368
  "ambient",
333
369
  "focused",
@@ -349,6 +385,38 @@ var AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [
349
385
  "normal",
350
386
  "low"
351
387
  ];
388
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES = [
389
+ "voice",
390
+ "narration",
391
+ "speech-capture"
392
+ ];
393
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS = [
394
+ "voice-unavailable",
395
+ "narration-unavailable",
396
+ "speech-capture-unavailable"
397
+ ];
398
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS = [
399
+ "touch-controls-and-text-summary",
400
+ "status-copy-and-live-region",
401
+ "manual-actions-stay-visible"
402
+ ];
403
+ var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS = Object.freeze([
404
+ Object.freeze({
405
+ id: "voice-unavailable",
406
+ source: "voice",
407
+ behavior: "touch-controls-and-text-summary"
408
+ }),
409
+ Object.freeze({
410
+ id: "narration-unavailable",
411
+ source: "narration",
412
+ behavior: "status-copy-and-live-region"
413
+ }),
414
+ Object.freeze({
415
+ id: "speech-capture-unavailable",
416
+ source: "speech-capture",
417
+ behavior: "manual-actions-stay-visible"
418
+ })
419
+ ]);
352
420
  var AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [
353
421
  "combat",
354
422
  "exploration",
@@ -535,6 +603,63 @@ function isAiGamePlayerSystemModule(value) {
535
603
  function isAiGamePlayerSystemAlertPriority(value) {
536
604
  return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);
537
605
  }
606
+ function isAiGamePlayerSystemGuidanceCueSource(value) {
607
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES);
608
+ }
609
+ function isAiGamePlayerSystemGuidanceFallbackId(value) {
610
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS);
611
+ }
612
+ function isAiGamePlayerSystemGuidanceFallbackBehavior(value) {
613
+ return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS);
614
+ }
615
+ function getAiGamePlayerSystemGuidanceFallbackContract(fallbackId) {
616
+ const contract = AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS.find(
617
+ (candidate) => candidate.id === fallbackId
618
+ );
619
+ if (!contract) {
620
+ throw new Error("fallbackId must identify a supported guidance fallback");
621
+ }
622
+ return contract;
623
+ }
624
+ function createAiGamePlayerSystemGuidanceCue(input) {
625
+ assertNonEmptyString2(input.cueId, "cueId");
626
+ assertContractVersion(
627
+ input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION
628
+ );
629
+ if (!isAiGamePlayerSystemAlertPriority(input.priority)) {
630
+ throw new Error("priority must be a supported Player System alert priority");
631
+ }
632
+ if (!isAiGamePlayerSystemGuidanceCueSource(input.source)) {
633
+ throw new Error("source must be a supported guidance cue source");
634
+ }
635
+ if (!isAiGamePlayerSystemGuidanceFallbackId(input.fallbackId)) {
636
+ throw new Error("fallbackId must identify a supported guidance fallback");
637
+ }
638
+ const fallback = getAiGamePlayerSystemGuidanceFallbackContract(input.fallbackId);
639
+ if (fallback.source !== input.source) {
640
+ throw new Error("fallbackId must match the guidance cue source");
641
+ }
642
+ if (!Number.isInteger(input.maxPayloadBytes) || input.maxPayloadBytes < 1 || input.maxPayloadBytes > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES) {
643
+ throw new Error(
644
+ `maxPayloadBytes must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES}`
645
+ );
646
+ }
647
+ if (!Number.isInteger(input.maxOccurrencesPerMinute) || input.maxOccurrencesPerMinute < 1 || input.maxOccurrencesPerMinute > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE) {
648
+ throw new Error(
649
+ `maxOccurrencesPerMinute must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE}`
650
+ );
651
+ }
652
+ return Object.freeze({
653
+ cueId: input.cueId,
654
+ contractVersion: input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
655
+ featureFlagId: AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
656
+ priority: input.priority,
657
+ source: input.source,
658
+ fallbackId: input.fallbackId,
659
+ maxPayloadBytes: input.maxPayloadBytes,
660
+ maxOccurrencesPerMinute: input.maxOccurrencesPerMinute
661
+ });
662
+ }
538
663
  function isAiGamePlayerSystemPreferenceKind(value) {
539
664
  return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);
540
665
  }
@@ -1278,6 +1403,293 @@ function assertAiGameIdentityProjectionContractVersion(value) {
1278
1403
  assertContractVersion3(value);
1279
1404
  }
1280
1405
 
1406
+ // src/observed-events.ts
1407
+ var AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID = "isekai.player-system.logs.enabled";
1408
+ var AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION = "1.0";
1409
+ var AI_GAME_OBSERVED_EVENT_KINDS = [
1410
+ "combat",
1411
+ "crafting",
1412
+ "discovery",
1413
+ "mission",
1414
+ "social",
1415
+ "travel",
1416
+ "world"
1417
+ ];
1418
+ var AI_GAME_OBSERVED_EVENT_SOURCES = [
1419
+ "player-action",
1420
+ "system-observation",
1421
+ "world-state"
1422
+ ];
1423
+ var AI_GAME_OBSERVED_EVENT_VISIBILITIES = [
1424
+ "private",
1425
+ "party",
1426
+ "local",
1427
+ "public"
1428
+ ];
1429
+ var AI_GAME_OBSERVED_EVENT_SIGNIFICANCE = [
1430
+ "routine",
1431
+ "notable",
1432
+ "critical"
1433
+ ];
1434
+ var AI_GAME_GOSSIP_EXPORT_AUDIENCES = [
1435
+ "player",
1436
+ "npc",
1437
+ "public"
1438
+ ];
1439
+ var AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH = 500;
1440
+ var AI_GAME_OBSERVED_EVENT_MAX_TAGS = 20;
1441
+ var AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH = 64;
1442
+ var AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS = 100;
1443
+ function freezeReadonlyArray5(items) {
1444
+ return Object.freeze([...items]);
1445
+ }
1446
+ function isMember4(value, members) {
1447
+ return members.includes(value);
1448
+ }
1449
+ function assertNonEmptyString5(value, label) {
1450
+ if (value.trim().length === 0) {
1451
+ throw new Error(`${label} must be a non-empty string`);
1452
+ }
1453
+ }
1454
+ function assertSafeText(value, label, maxLength) {
1455
+ assertNonEmptyString5(value, label);
1456
+ if (value.length > maxLength) {
1457
+ throw new Error(`${label} must be ${maxLength} characters or fewer`);
1458
+ }
1459
+ if ([...value].some((character) => {
1460
+ const codePoint = character.codePointAt(0) ?? 0;
1461
+ return codePoint <= 31 || codePoint === 127;
1462
+ })) {
1463
+ throw new Error(`${label} must not contain control characters`);
1464
+ }
1465
+ }
1466
+ function assertIsoTimestamp3(value, label) {
1467
+ assertNonEmptyString5(value, label);
1468
+ if (Number.isNaN(Date.parse(value))) {
1469
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
1470
+ }
1471
+ }
1472
+ function assertContractVersion4(value) {
1473
+ if (value !== AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION) {
1474
+ throw new Error(
1475
+ `contractVersion must be ${AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION}`
1476
+ );
1477
+ }
1478
+ }
1479
+ function assertArrayLimit(value, label, maximum) {
1480
+ if (value.length > maximum) {
1481
+ throw new Error(`${label} must contain ${maximum} items or fewer`);
1482
+ }
1483
+ }
1484
+ function createStringArray2(values, label, maximum, itemMaximum) {
1485
+ assertArrayLimit(values, label, maximum);
1486
+ const result = values.map((value, index) => {
1487
+ assertSafeText(value, `${label}[${index}]`, itemMaximum);
1488
+ return value.trim();
1489
+ });
1490
+ if (new Set(result).size !== result.length) {
1491
+ throw new Error(`${label} must not contain duplicate values`);
1492
+ }
1493
+ return freezeReadonlyArray5(result);
1494
+ }
1495
+ function assertUniqueIds(values, label) {
1496
+ if (new Set(values).size !== values.length) {
1497
+ throw new Error(`${label} must not contain duplicate values`);
1498
+ }
1499
+ }
1500
+ function cloneObservedEvent(event) {
1501
+ return createAiGameObservedEvent(event);
1502
+ }
1503
+ function cloneRecencyWindow(window) {
1504
+ return createAiGameObservedEventRecencyWindow({
1505
+ contractVersion: window.contractVersion,
1506
+ windowId: window.windowId,
1507
+ startsAtIso: window.startsAtIso,
1508
+ endsAtIso: window.endsAtIso,
1509
+ events: window.events
1510
+ });
1511
+ }
1512
+ function cloneHighlightSummary(summary) {
1513
+ return createAiGameObservedEventHighlightSummary({
1514
+ contractVersion: summary.contractVersion,
1515
+ summaryId: summary.summaryId,
1516
+ windowId: summary.windowId,
1517
+ title: summary.title,
1518
+ summary: summary.summary,
1519
+ significance: summary.significance,
1520
+ eventIds: summary.eventIds,
1521
+ reasonCodes: summary.reasonCodes
1522
+ });
1523
+ }
1524
+ function isAiGameObservedEventKind(value) {
1525
+ return isMember4(value, AI_GAME_OBSERVED_EVENT_KINDS);
1526
+ }
1527
+ function isAiGameObservedEventSource(value) {
1528
+ return isMember4(value, AI_GAME_OBSERVED_EVENT_SOURCES);
1529
+ }
1530
+ function isAiGameObservedEventVisibility(value) {
1531
+ return isMember4(value, AI_GAME_OBSERVED_EVENT_VISIBILITIES);
1532
+ }
1533
+ function isAiGameObservedEventSignificance(value) {
1534
+ return isMember4(value, AI_GAME_OBSERVED_EVENT_SIGNIFICANCE);
1535
+ }
1536
+ function isAiGameGossipExportAudience(value) {
1537
+ return isMember4(value, AI_GAME_GOSSIP_EXPORT_AUDIENCES);
1538
+ }
1539
+ function createAiGameObservedEvent(input) {
1540
+ const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
1541
+ assertContractVersion4(contractVersion);
1542
+ assertSafeText(input.eventId, "eventId", 200);
1543
+ assertIsoTimestamp3(input.occurredAtIso, "occurredAtIso");
1544
+ assertSafeText(input.subjectRef, "subjectRef", 200);
1545
+ assertSafeText(
1546
+ input.summary,
1547
+ "summary",
1548
+ AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
1549
+ );
1550
+ if (!isAiGameObservedEventKind(input.kind)) {
1551
+ throw new Error(`kind must be one of: ${AI_GAME_OBSERVED_EVENT_KINDS.join(", ")}`);
1552
+ }
1553
+ if (!isAiGameObservedEventSource(input.source)) {
1554
+ throw new Error(
1555
+ `source must be one of: ${AI_GAME_OBSERVED_EVENT_SOURCES.join(", ")}`
1556
+ );
1557
+ }
1558
+ if (!isAiGameObservedEventSignificance(input.significance)) {
1559
+ throw new Error(
1560
+ `significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
1561
+ );
1562
+ }
1563
+ if (!isAiGameObservedEventVisibility(input.visibility)) {
1564
+ throw new Error(
1565
+ `visibility must be one of: ${AI_GAME_OBSERVED_EVENT_VISIBILITIES.join(", ")}`
1566
+ );
1567
+ }
1568
+ const tags = createStringArray2(
1569
+ input.tags ?? [],
1570
+ "tags",
1571
+ AI_GAME_OBSERVED_EVENT_MAX_TAGS,
1572
+ AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH
1573
+ );
1574
+ return Object.freeze({
1575
+ contractVersion,
1576
+ eventId: input.eventId.trim(),
1577
+ occurredAtIso: input.occurredAtIso,
1578
+ kind: input.kind,
1579
+ source: input.source,
1580
+ subjectRef: input.subjectRef.trim(),
1581
+ summary: input.summary.trim(),
1582
+ significance: input.significance,
1583
+ visibility: input.visibility,
1584
+ tags
1585
+ });
1586
+ }
1587
+ function createAiGameObservedEventRecencyWindow(input) {
1588
+ const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
1589
+ assertContractVersion4(contractVersion);
1590
+ assertSafeText(input.windowId, "windowId", 200);
1591
+ assertIsoTimestamp3(input.startsAtIso, "startsAtIso");
1592
+ assertIsoTimestamp3(input.endsAtIso, "endsAtIso");
1593
+ const startsAt = Date.parse(input.startsAtIso);
1594
+ const endsAt = Date.parse(input.endsAtIso);
1595
+ if (startsAt > endsAt) {
1596
+ throw new Error("startsAtIso must be before or equal to endsAtIso");
1597
+ }
1598
+ assertArrayLimit(
1599
+ input.events,
1600
+ "events",
1601
+ AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS
1602
+ );
1603
+ const events = input.events.map(cloneObservedEvent);
1604
+ const eventIds = events.map((event) => event.eventId);
1605
+ assertUniqueIds(eventIds, "events");
1606
+ for (const event of events) {
1607
+ const occurredAt = Date.parse(event.occurredAtIso);
1608
+ if (occurredAt < startsAt || occurredAt > endsAt) {
1609
+ throw new Error(`event ${event.eventId} must occur inside the recency window`);
1610
+ }
1611
+ }
1612
+ return Object.freeze({
1613
+ contractVersion,
1614
+ windowId: input.windowId.trim(),
1615
+ startsAtIso: input.startsAtIso,
1616
+ endsAtIso: input.endsAtIso,
1617
+ events: freezeReadonlyArray5(events)
1618
+ });
1619
+ }
1620
+ function createAiGameObservedEventHighlightSummary(input) {
1621
+ const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
1622
+ assertContractVersion4(contractVersion);
1623
+ assertSafeText(input.summaryId, "summaryId", 200);
1624
+ assertSafeText(input.windowId, "windowId", 200);
1625
+ assertSafeText(input.title, "title", 200);
1626
+ assertSafeText(
1627
+ input.summary,
1628
+ "summary",
1629
+ AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
1630
+ );
1631
+ if (!isAiGameObservedEventSignificance(input.significance)) {
1632
+ throw new Error(
1633
+ `significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
1634
+ );
1635
+ }
1636
+ const eventIds = createStringArray2(input.eventIds, "eventIds", 100, 200);
1637
+ if (eventIds.length === 0) {
1638
+ throw new Error("eventIds must contain at least one event id");
1639
+ }
1640
+ const reasonCodes = createStringArray2(
1641
+ input.reasonCodes ?? [],
1642
+ "reasonCodes",
1643
+ 20,
1644
+ 100
1645
+ );
1646
+ return Object.freeze({
1647
+ contractVersion,
1648
+ summaryId: input.summaryId.trim(),
1649
+ windowId: input.windowId.trim(),
1650
+ title: input.title.trim(),
1651
+ summary: input.summary.trim(),
1652
+ significance: input.significance,
1653
+ eventIds,
1654
+ reasonCodes
1655
+ });
1656
+ }
1657
+ function createAiGameGossipExport(input) {
1658
+ const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
1659
+ assertContractVersion4(contractVersion);
1660
+ assertSafeText(input.exportId, "exportId", 200);
1661
+ assertIsoTimestamp3(input.exportedAtIso, "exportedAtIso");
1662
+ if (!isAiGameGossipExportAudience(input.audience)) {
1663
+ throw new Error(
1664
+ `audience must be one of: ${AI_GAME_GOSSIP_EXPORT_AUDIENCES.join(", ")}`
1665
+ );
1666
+ }
1667
+ const sourceWindow = cloneRecencyWindow(input.sourceWindow);
1668
+ const eventIds = new Set(sourceWindow.events.map((event) => event.eventId));
1669
+ const highlights = input.highlights.map(cloneHighlightSummary);
1670
+ const summaryIds = highlights.map((summary) => summary.summaryId);
1671
+ assertUniqueIds(summaryIds, "highlights");
1672
+ for (const highlight of highlights) {
1673
+ if (highlight.windowId !== sourceWindow.windowId) {
1674
+ throw new Error("highlight windowId must match sourceWindow windowId");
1675
+ }
1676
+ if (highlight.eventIds.some((eventId) => !eventIds.has(eventId))) {
1677
+ throw new Error("highlight eventIds must reference sourceWindow events");
1678
+ }
1679
+ }
1680
+ return Object.freeze({
1681
+ contractVersion,
1682
+ exportId: input.exportId.trim(),
1683
+ exportedAtIso: input.exportedAtIso,
1684
+ audience: input.audience,
1685
+ sourceWindow,
1686
+ highlights: freezeReadonlyArray5(highlights)
1687
+ });
1688
+ }
1689
+ function assertAiGameObservedEventLogContractVersion(value) {
1690
+ assertContractVersion4(value);
1691
+ }
1692
+
1281
1693
  // src/world-events.ts
1282
1694
  function isCanonicalWorldEvent(event) {
1283
1695
  return event.recordType === "canonical";
@@ -1429,7 +1841,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
1429
1841
  "private-or-low-witness-evidence",
1430
1842
  "costly-pressure-event"
1431
1843
  ];
1432
- function isMember4(value, members) {
1844
+ function isMember5(value, members) {
1433
1845
  return members.includes(value);
1434
1846
  }
1435
1847
  function assertRecord(value, label) {
@@ -1470,7 +1882,7 @@ function normalizeTimestamp(value, label) {
1470
1882
  }
1471
1883
  function normalizeMember(value, members, label) {
1472
1884
  const normalized = normalizeNonEmptyString(value, label);
1473
- if (!isMember4(normalized, members)) {
1885
+ if (!isMember5(normalized, members)) {
1474
1886
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
1475
1887
  }
1476
1888
  return normalized;
@@ -1603,13 +2015,13 @@ function normalizeDominantReads(value) {
1603
2015
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
1604
2016
  }
1605
2017
  function isQuietMeasureAxis(value) {
1606
- return isMember4(value, QUIET_MEASURE_AXES);
2018
+ return isMember5(value, QUIET_MEASURE_AXES);
1607
2019
  }
1608
2020
  function isQuietMeasureMissionProbeMode(value) {
1609
- return isMember4(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2021
+ return isMember5(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1610
2022
  }
1611
2023
  function isQuietMeasureMissionResolutionShape(value) {
1612
- return isMember4(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2024
+ return isMember5(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1613
2025
  }
1614
2026
  function createQuietMeasureJudgmentEligibility(input = {}) {
1615
2027
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -2113,6 +2525,7 @@ var gameEventFeatureFlags = Object.freeze([
2113
2525
  AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
2114
2526
  AI_GAME_FEATURE_FLAGS,
2115
2527
  AI_GAME_FEATURE_FLAG_ID,
2528
+ AI_GAME_GOSSIP_EXPORT_AUDIENCES,
2116
2529
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
2117
2530
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
2118
2531
  AI_GAME_IDENTITY_CONTRACT_VERSION,
@@ -2136,6 +2549,16 @@ var gameEventFeatureFlags = Object.freeze([
2136
2549
  AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
2137
2550
  AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
2138
2551
  AI_GAME_MISSION_REWARD_KINDS,
2552
+ AI_GAME_OBSERVED_EVENT_KINDS,
2553
+ AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION,
2554
+ AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID,
2555
+ AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH,
2556
+ AI_GAME_OBSERVED_EVENT_MAX_TAGS,
2557
+ AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH,
2558
+ AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS,
2559
+ AI_GAME_OBSERVED_EVENT_SIGNIFICANCE,
2560
+ AI_GAME_OBSERVED_EVENT_SOURCES,
2561
+ AI_GAME_OBSERVED_EVENT_VISIBILITIES,
2139
2562
  AI_GAME_PACKAGE,
2140
2563
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
2141
2564
  AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
@@ -2144,6 +2567,13 @@ var gameEventFeatureFlags = Object.freeze([
2144
2567
  AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
2145
2568
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
2146
2569
  AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
2570
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE,
2571
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES,
2572
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES,
2573
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS,
2574
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS,
2575
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS,
2576
+ AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
2147
2577
  AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
2148
2578
  AI_GAME_PLAYER_SYSTEM_MODULES,
2149
2579
  AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
@@ -2186,8 +2616,10 @@ var gameEventFeatureFlags = Object.freeze([
2186
2616
  aiGameFeatureFlags,
2187
2617
  assertAiGameIdentityProjectionContractVersion,
2188
2618
  assertAiGameMissionContractVersion,
2619
+ assertAiGameObservedEventLogContractVersion,
2189
2620
  classifyAiGameTask,
2190
2621
  createAiGameAcademicTrainingSnapshot,
2622
+ createAiGameGossipExport,
2191
2623
  createAiGameIdentityProjectionContract,
2192
2624
  createAiGameIdentitySelfProjection,
2193
2625
  createAiGameIdentityTargetProjection,
@@ -2203,7 +2635,11 @@ var gameEventFeatureFlags = Object.freeze([
2203
2635
  createAiGameMissionRewardBound,
2204
2636
  createAiGameMissionRewardEnvelope,
2205
2637
  createAiGameMissionRewardGrant,
2638
+ createAiGameObservedEvent,
2639
+ createAiGameObservedEventHighlightSummary,
2640
+ createAiGameObservedEventRecencyWindow,
2206
2641
  createAiGamePlayerSystemAlert,
2642
+ createAiGamePlayerSystemGuidanceCue,
2207
2643
  createAiGamePlayerSystemPreferenceConfidenceState,
2208
2644
  createAiGamePlayerSystemPreferenceInput,
2209
2645
  createAiGamePlayerSystemPreferenceProfile,
@@ -2219,7 +2655,9 @@ var gameEventFeatureFlags = Object.freeze([
2219
2655
  createQuietMeasureJudgmentResponse,
2220
2656
  gameEventFeatureFlags,
2221
2657
  getAiGamePlayerSystemFocusModeContract,
2658
+ getAiGamePlayerSystemGuidanceFallbackContract,
2222
2659
  getAiGamePlayerSystemModuleContract,
2660
+ isAiGameGossipExportAudience,
2223
2661
  isAiGameIdentityKnowledgeState,
2224
2662
  isAiGameIdentityProjectionRead,
2225
2663
  isAiGameIdentityTargetCategory,
@@ -2235,10 +2673,17 @@ var gameEventFeatureFlags = Object.freeze([
2235
2673
  isAiGameMissionRepeatedSignalHandling,
2236
2674
  isAiGameMissionRewardCapSemantic,
2237
2675
  isAiGameMissionRewardKind,
2676
+ isAiGameObservedEventKind,
2677
+ isAiGameObservedEventSignificance,
2678
+ isAiGameObservedEventSource,
2679
+ isAiGameObservedEventVisibility,
2238
2680
  isAiGamePlayerSystemAlertDeliverable,
2239
2681
  isAiGamePlayerSystemAlertPriority,
2240
2682
  isAiGamePlayerSystemConfidenceBand,
2241
2683
  isAiGamePlayerSystemFocusMode,
2684
+ isAiGamePlayerSystemGuidanceCueSource,
2685
+ isAiGamePlayerSystemGuidanceFallbackBehavior,
2686
+ isAiGamePlayerSystemGuidanceFallbackId,
2242
2687
  isAiGamePlayerSystemInputModality,
2243
2688
  isAiGamePlayerSystemModule,
2244
2689
  isAiGamePlayerSystemPreferenceKind,