@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/CHANGELOG.md +34 -0
- package/README.md +37 -1
- package/dist/index.cjs +450 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -1
- package/dist/index.d.ts +135 -1
- package/dist/index.js +417 -5
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0014-player-system-guidance-cue-contract-boundary.md +43 -0
- package/docs/adrs/adr-0016-observed-event-log-and-gossip-export-contract-boundary.md +52 -0
- package/docs/adrs/index.md +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -170,6 +170,9 @@ function createAiGameMartialTrainingSnapshot(input) {
|
|
|
170
170
|
// src/player-system.ts
|
|
171
171
|
var AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID = "isekai.player-system.core.enabled";
|
|
172
172
|
var AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = "1.0";
|
|
173
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID = "isekai.player-system.guidance-nfr.enabled";
|
|
174
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES = 4096;
|
|
175
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE = 30;
|
|
173
176
|
var AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [
|
|
174
177
|
"ambient",
|
|
175
178
|
"focused",
|
|
@@ -191,6 +194,38 @@ var AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [
|
|
|
191
194
|
"normal",
|
|
192
195
|
"low"
|
|
193
196
|
];
|
|
197
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES = [
|
|
198
|
+
"voice",
|
|
199
|
+
"narration",
|
|
200
|
+
"speech-capture"
|
|
201
|
+
];
|
|
202
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS = [
|
|
203
|
+
"voice-unavailable",
|
|
204
|
+
"narration-unavailable",
|
|
205
|
+
"speech-capture-unavailable"
|
|
206
|
+
];
|
|
207
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS = [
|
|
208
|
+
"touch-controls-and-text-summary",
|
|
209
|
+
"status-copy-and-live-region",
|
|
210
|
+
"manual-actions-stay-visible"
|
|
211
|
+
];
|
|
212
|
+
var AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS = Object.freeze([
|
|
213
|
+
Object.freeze({
|
|
214
|
+
id: "voice-unavailable",
|
|
215
|
+
source: "voice",
|
|
216
|
+
behavior: "touch-controls-and-text-summary"
|
|
217
|
+
}),
|
|
218
|
+
Object.freeze({
|
|
219
|
+
id: "narration-unavailable",
|
|
220
|
+
source: "narration",
|
|
221
|
+
behavior: "status-copy-and-live-region"
|
|
222
|
+
}),
|
|
223
|
+
Object.freeze({
|
|
224
|
+
id: "speech-capture-unavailable",
|
|
225
|
+
source: "speech-capture",
|
|
226
|
+
behavior: "manual-actions-stay-visible"
|
|
227
|
+
})
|
|
228
|
+
]);
|
|
194
229
|
var AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [
|
|
195
230
|
"combat",
|
|
196
231
|
"exploration",
|
|
@@ -377,6 +412,63 @@ function isAiGamePlayerSystemModule(value) {
|
|
|
377
412
|
function isAiGamePlayerSystemAlertPriority(value) {
|
|
378
413
|
return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);
|
|
379
414
|
}
|
|
415
|
+
function isAiGamePlayerSystemGuidanceCueSource(value) {
|
|
416
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES);
|
|
417
|
+
}
|
|
418
|
+
function isAiGamePlayerSystemGuidanceFallbackId(value) {
|
|
419
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS);
|
|
420
|
+
}
|
|
421
|
+
function isAiGamePlayerSystemGuidanceFallbackBehavior(value) {
|
|
422
|
+
return isMember(value, AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS);
|
|
423
|
+
}
|
|
424
|
+
function getAiGamePlayerSystemGuidanceFallbackContract(fallbackId) {
|
|
425
|
+
const contract = AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS.find(
|
|
426
|
+
(candidate) => candidate.id === fallbackId
|
|
427
|
+
);
|
|
428
|
+
if (!contract) {
|
|
429
|
+
throw new Error("fallbackId must identify a supported guidance fallback");
|
|
430
|
+
}
|
|
431
|
+
return contract;
|
|
432
|
+
}
|
|
433
|
+
function createAiGamePlayerSystemGuidanceCue(input) {
|
|
434
|
+
assertNonEmptyString2(input.cueId, "cueId");
|
|
435
|
+
assertContractVersion(
|
|
436
|
+
input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION
|
|
437
|
+
);
|
|
438
|
+
if (!isAiGamePlayerSystemAlertPriority(input.priority)) {
|
|
439
|
+
throw new Error("priority must be a supported Player System alert priority");
|
|
440
|
+
}
|
|
441
|
+
if (!isAiGamePlayerSystemGuidanceCueSource(input.source)) {
|
|
442
|
+
throw new Error("source must be a supported guidance cue source");
|
|
443
|
+
}
|
|
444
|
+
if (!isAiGamePlayerSystemGuidanceFallbackId(input.fallbackId)) {
|
|
445
|
+
throw new Error("fallbackId must identify a supported guidance fallback");
|
|
446
|
+
}
|
|
447
|
+
const fallback = getAiGamePlayerSystemGuidanceFallbackContract(input.fallbackId);
|
|
448
|
+
if (fallback.source !== input.source) {
|
|
449
|
+
throw new Error("fallbackId must match the guidance cue source");
|
|
450
|
+
}
|
|
451
|
+
if (!Number.isInteger(input.maxPayloadBytes) || input.maxPayloadBytes < 1 || input.maxPayloadBytes > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES) {
|
|
452
|
+
throw new Error(
|
|
453
|
+
`maxPayloadBytes must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
if (!Number.isInteger(input.maxOccurrencesPerMinute) || input.maxOccurrencesPerMinute < 1 || input.maxOccurrencesPerMinute > AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE) {
|
|
457
|
+
throw new Error(
|
|
458
|
+
`maxOccurrencesPerMinute must be between 1 and ${AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE}`
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
return Object.freeze({
|
|
462
|
+
cueId: input.cueId,
|
|
463
|
+
contractVersion: input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,
|
|
464
|
+
featureFlagId: AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
|
|
465
|
+
priority: input.priority,
|
|
466
|
+
source: input.source,
|
|
467
|
+
fallbackId: input.fallbackId,
|
|
468
|
+
maxPayloadBytes: input.maxPayloadBytes,
|
|
469
|
+
maxOccurrencesPerMinute: input.maxOccurrencesPerMinute
|
|
470
|
+
});
|
|
471
|
+
}
|
|
380
472
|
function isAiGamePlayerSystemPreferenceKind(value) {
|
|
381
473
|
return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);
|
|
382
474
|
}
|
|
@@ -1120,6 +1212,293 @@ function assertAiGameIdentityProjectionContractVersion(value) {
|
|
|
1120
1212
|
assertContractVersion3(value);
|
|
1121
1213
|
}
|
|
1122
1214
|
|
|
1215
|
+
// src/observed-events.ts
|
|
1216
|
+
var AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID = "isekai.player-system.logs.enabled";
|
|
1217
|
+
var AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION = "1.0";
|
|
1218
|
+
var AI_GAME_OBSERVED_EVENT_KINDS = [
|
|
1219
|
+
"combat",
|
|
1220
|
+
"crafting",
|
|
1221
|
+
"discovery",
|
|
1222
|
+
"mission",
|
|
1223
|
+
"social",
|
|
1224
|
+
"travel",
|
|
1225
|
+
"world"
|
|
1226
|
+
];
|
|
1227
|
+
var AI_GAME_OBSERVED_EVENT_SOURCES = [
|
|
1228
|
+
"player-action",
|
|
1229
|
+
"system-observation",
|
|
1230
|
+
"world-state"
|
|
1231
|
+
];
|
|
1232
|
+
var AI_GAME_OBSERVED_EVENT_VISIBILITIES = [
|
|
1233
|
+
"private",
|
|
1234
|
+
"party",
|
|
1235
|
+
"local",
|
|
1236
|
+
"public"
|
|
1237
|
+
];
|
|
1238
|
+
var AI_GAME_OBSERVED_EVENT_SIGNIFICANCE = [
|
|
1239
|
+
"routine",
|
|
1240
|
+
"notable",
|
|
1241
|
+
"critical"
|
|
1242
|
+
];
|
|
1243
|
+
var AI_GAME_GOSSIP_EXPORT_AUDIENCES = [
|
|
1244
|
+
"player",
|
|
1245
|
+
"npc",
|
|
1246
|
+
"public"
|
|
1247
|
+
];
|
|
1248
|
+
var AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH = 500;
|
|
1249
|
+
var AI_GAME_OBSERVED_EVENT_MAX_TAGS = 20;
|
|
1250
|
+
var AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH = 64;
|
|
1251
|
+
var AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS = 100;
|
|
1252
|
+
function freezeReadonlyArray5(items) {
|
|
1253
|
+
return Object.freeze([...items]);
|
|
1254
|
+
}
|
|
1255
|
+
function isMember4(value, members) {
|
|
1256
|
+
return members.includes(value);
|
|
1257
|
+
}
|
|
1258
|
+
function assertNonEmptyString5(value, label) {
|
|
1259
|
+
if (value.trim().length === 0) {
|
|
1260
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function assertSafeText(value, label, maxLength) {
|
|
1264
|
+
assertNonEmptyString5(value, label);
|
|
1265
|
+
if (value.length > maxLength) {
|
|
1266
|
+
throw new Error(`${label} must be ${maxLength} characters or fewer`);
|
|
1267
|
+
}
|
|
1268
|
+
if ([...value].some((character) => {
|
|
1269
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
1270
|
+
return codePoint <= 31 || codePoint === 127;
|
|
1271
|
+
})) {
|
|
1272
|
+
throw new Error(`${label} must not contain control characters`);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
function assertIsoTimestamp3(value, label) {
|
|
1276
|
+
assertNonEmptyString5(value, label);
|
|
1277
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
1278
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function assertContractVersion4(value) {
|
|
1282
|
+
if (value !== AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION) {
|
|
1283
|
+
throw new Error(
|
|
1284
|
+
`contractVersion must be ${AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION}`
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
function assertArrayLimit(value, label, maximum) {
|
|
1289
|
+
if (value.length > maximum) {
|
|
1290
|
+
throw new Error(`${label} must contain ${maximum} items or fewer`);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
function createStringArray2(values, label, maximum, itemMaximum) {
|
|
1294
|
+
assertArrayLimit(values, label, maximum);
|
|
1295
|
+
const result = values.map((value, index) => {
|
|
1296
|
+
assertSafeText(value, `${label}[${index}]`, itemMaximum);
|
|
1297
|
+
return value.trim();
|
|
1298
|
+
});
|
|
1299
|
+
if (new Set(result).size !== result.length) {
|
|
1300
|
+
throw new Error(`${label} must not contain duplicate values`);
|
|
1301
|
+
}
|
|
1302
|
+
return freezeReadonlyArray5(result);
|
|
1303
|
+
}
|
|
1304
|
+
function assertUniqueIds(values, label) {
|
|
1305
|
+
if (new Set(values).size !== values.length) {
|
|
1306
|
+
throw new Error(`${label} must not contain duplicate values`);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
function cloneObservedEvent(event) {
|
|
1310
|
+
return createAiGameObservedEvent(event);
|
|
1311
|
+
}
|
|
1312
|
+
function cloneRecencyWindow(window) {
|
|
1313
|
+
return createAiGameObservedEventRecencyWindow({
|
|
1314
|
+
contractVersion: window.contractVersion,
|
|
1315
|
+
windowId: window.windowId,
|
|
1316
|
+
startsAtIso: window.startsAtIso,
|
|
1317
|
+
endsAtIso: window.endsAtIso,
|
|
1318
|
+
events: window.events
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
function cloneHighlightSummary(summary) {
|
|
1322
|
+
return createAiGameObservedEventHighlightSummary({
|
|
1323
|
+
contractVersion: summary.contractVersion,
|
|
1324
|
+
summaryId: summary.summaryId,
|
|
1325
|
+
windowId: summary.windowId,
|
|
1326
|
+
title: summary.title,
|
|
1327
|
+
summary: summary.summary,
|
|
1328
|
+
significance: summary.significance,
|
|
1329
|
+
eventIds: summary.eventIds,
|
|
1330
|
+
reasonCodes: summary.reasonCodes
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function isAiGameObservedEventKind(value) {
|
|
1334
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_KINDS);
|
|
1335
|
+
}
|
|
1336
|
+
function isAiGameObservedEventSource(value) {
|
|
1337
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_SOURCES);
|
|
1338
|
+
}
|
|
1339
|
+
function isAiGameObservedEventVisibility(value) {
|
|
1340
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_VISIBILITIES);
|
|
1341
|
+
}
|
|
1342
|
+
function isAiGameObservedEventSignificance(value) {
|
|
1343
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_SIGNIFICANCE);
|
|
1344
|
+
}
|
|
1345
|
+
function isAiGameGossipExportAudience(value) {
|
|
1346
|
+
return isMember4(value, AI_GAME_GOSSIP_EXPORT_AUDIENCES);
|
|
1347
|
+
}
|
|
1348
|
+
function createAiGameObservedEvent(input) {
|
|
1349
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1350
|
+
assertContractVersion4(contractVersion);
|
|
1351
|
+
assertSafeText(input.eventId, "eventId", 200);
|
|
1352
|
+
assertIsoTimestamp3(input.occurredAtIso, "occurredAtIso");
|
|
1353
|
+
assertSafeText(input.subjectRef, "subjectRef", 200);
|
|
1354
|
+
assertSafeText(
|
|
1355
|
+
input.summary,
|
|
1356
|
+
"summary",
|
|
1357
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
|
|
1358
|
+
);
|
|
1359
|
+
if (!isAiGameObservedEventKind(input.kind)) {
|
|
1360
|
+
throw new Error(`kind must be one of: ${AI_GAME_OBSERVED_EVENT_KINDS.join(", ")}`);
|
|
1361
|
+
}
|
|
1362
|
+
if (!isAiGameObservedEventSource(input.source)) {
|
|
1363
|
+
throw new Error(
|
|
1364
|
+
`source must be one of: ${AI_GAME_OBSERVED_EVENT_SOURCES.join(", ")}`
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
if (!isAiGameObservedEventSignificance(input.significance)) {
|
|
1368
|
+
throw new Error(
|
|
1369
|
+
`significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
if (!isAiGameObservedEventVisibility(input.visibility)) {
|
|
1373
|
+
throw new Error(
|
|
1374
|
+
`visibility must be one of: ${AI_GAME_OBSERVED_EVENT_VISIBILITIES.join(", ")}`
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
const tags = createStringArray2(
|
|
1378
|
+
input.tags ?? [],
|
|
1379
|
+
"tags",
|
|
1380
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAGS,
|
|
1381
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH
|
|
1382
|
+
);
|
|
1383
|
+
return Object.freeze({
|
|
1384
|
+
contractVersion,
|
|
1385
|
+
eventId: input.eventId.trim(),
|
|
1386
|
+
occurredAtIso: input.occurredAtIso,
|
|
1387
|
+
kind: input.kind,
|
|
1388
|
+
source: input.source,
|
|
1389
|
+
subjectRef: input.subjectRef.trim(),
|
|
1390
|
+
summary: input.summary.trim(),
|
|
1391
|
+
significance: input.significance,
|
|
1392
|
+
visibility: input.visibility,
|
|
1393
|
+
tags
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
function createAiGameObservedEventRecencyWindow(input) {
|
|
1397
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1398
|
+
assertContractVersion4(contractVersion);
|
|
1399
|
+
assertSafeText(input.windowId, "windowId", 200);
|
|
1400
|
+
assertIsoTimestamp3(input.startsAtIso, "startsAtIso");
|
|
1401
|
+
assertIsoTimestamp3(input.endsAtIso, "endsAtIso");
|
|
1402
|
+
const startsAt = Date.parse(input.startsAtIso);
|
|
1403
|
+
const endsAt = Date.parse(input.endsAtIso);
|
|
1404
|
+
if (startsAt > endsAt) {
|
|
1405
|
+
throw new Error("startsAtIso must be before or equal to endsAtIso");
|
|
1406
|
+
}
|
|
1407
|
+
assertArrayLimit(
|
|
1408
|
+
input.events,
|
|
1409
|
+
"events",
|
|
1410
|
+
AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS
|
|
1411
|
+
);
|
|
1412
|
+
const events = input.events.map(cloneObservedEvent);
|
|
1413
|
+
const eventIds = events.map((event) => event.eventId);
|
|
1414
|
+
assertUniqueIds(eventIds, "events");
|
|
1415
|
+
for (const event of events) {
|
|
1416
|
+
const occurredAt = Date.parse(event.occurredAtIso);
|
|
1417
|
+
if (occurredAt < startsAt || occurredAt > endsAt) {
|
|
1418
|
+
throw new Error(`event ${event.eventId} must occur inside the recency window`);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
return Object.freeze({
|
|
1422
|
+
contractVersion,
|
|
1423
|
+
windowId: input.windowId.trim(),
|
|
1424
|
+
startsAtIso: input.startsAtIso,
|
|
1425
|
+
endsAtIso: input.endsAtIso,
|
|
1426
|
+
events: freezeReadonlyArray5(events)
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
function createAiGameObservedEventHighlightSummary(input) {
|
|
1430
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1431
|
+
assertContractVersion4(contractVersion);
|
|
1432
|
+
assertSafeText(input.summaryId, "summaryId", 200);
|
|
1433
|
+
assertSafeText(input.windowId, "windowId", 200);
|
|
1434
|
+
assertSafeText(input.title, "title", 200);
|
|
1435
|
+
assertSafeText(
|
|
1436
|
+
input.summary,
|
|
1437
|
+
"summary",
|
|
1438
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
|
|
1439
|
+
);
|
|
1440
|
+
if (!isAiGameObservedEventSignificance(input.significance)) {
|
|
1441
|
+
throw new Error(
|
|
1442
|
+
`significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
const eventIds = createStringArray2(input.eventIds, "eventIds", 100, 200);
|
|
1446
|
+
if (eventIds.length === 0) {
|
|
1447
|
+
throw new Error("eventIds must contain at least one event id");
|
|
1448
|
+
}
|
|
1449
|
+
const reasonCodes = createStringArray2(
|
|
1450
|
+
input.reasonCodes ?? [],
|
|
1451
|
+
"reasonCodes",
|
|
1452
|
+
20,
|
|
1453
|
+
100
|
|
1454
|
+
);
|
|
1455
|
+
return Object.freeze({
|
|
1456
|
+
contractVersion,
|
|
1457
|
+
summaryId: input.summaryId.trim(),
|
|
1458
|
+
windowId: input.windowId.trim(),
|
|
1459
|
+
title: input.title.trim(),
|
|
1460
|
+
summary: input.summary.trim(),
|
|
1461
|
+
significance: input.significance,
|
|
1462
|
+
eventIds,
|
|
1463
|
+
reasonCodes
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
function createAiGameGossipExport(input) {
|
|
1467
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1468
|
+
assertContractVersion4(contractVersion);
|
|
1469
|
+
assertSafeText(input.exportId, "exportId", 200);
|
|
1470
|
+
assertIsoTimestamp3(input.exportedAtIso, "exportedAtIso");
|
|
1471
|
+
if (!isAiGameGossipExportAudience(input.audience)) {
|
|
1472
|
+
throw new Error(
|
|
1473
|
+
`audience must be one of: ${AI_GAME_GOSSIP_EXPORT_AUDIENCES.join(", ")}`
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
const sourceWindow = cloneRecencyWindow(input.sourceWindow);
|
|
1477
|
+
const eventIds = new Set(sourceWindow.events.map((event) => event.eventId));
|
|
1478
|
+
const highlights = input.highlights.map(cloneHighlightSummary);
|
|
1479
|
+
const summaryIds = highlights.map((summary) => summary.summaryId);
|
|
1480
|
+
assertUniqueIds(summaryIds, "highlights");
|
|
1481
|
+
for (const highlight of highlights) {
|
|
1482
|
+
if (highlight.windowId !== sourceWindow.windowId) {
|
|
1483
|
+
throw new Error("highlight windowId must match sourceWindow windowId");
|
|
1484
|
+
}
|
|
1485
|
+
if (highlight.eventIds.some((eventId) => !eventIds.has(eventId))) {
|
|
1486
|
+
throw new Error("highlight eventIds must reference sourceWindow events");
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
return Object.freeze({
|
|
1490
|
+
contractVersion,
|
|
1491
|
+
exportId: input.exportId.trim(),
|
|
1492
|
+
exportedAtIso: input.exportedAtIso,
|
|
1493
|
+
audience: input.audience,
|
|
1494
|
+
sourceWindow,
|
|
1495
|
+
highlights: freezeReadonlyArray5(highlights)
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
function assertAiGameObservedEventLogContractVersion(value) {
|
|
1499
|
+
assertContractVersion4(value);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1123
1502
|
// src/world-events.ts
|
|
1124
1503
|
function isCanonicalWorldEvent(event) {
|
|
1125
1504
|
return event.recordType === "canonical";
|
|
@@ -1271,7 +1650,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
1271
1650
|
"private-or-low-witness-evidence",
|
|
1272
1651
|
"costly-pressure-event"
|
|
1273
1652
|
];
|
|
1274
|
-
function
|
|
1653
|
+
function isMember5(value, members) {
|
|
1275
1654
|
return members.includes(value);
|
|
1276
1655
|
}
|
|
1277
1656
|
function assertRecord(value, label) {
|
|
@@ -1312,7 +1691,7 @@ function normalizeTimestamp(value, label) {
|
|
|
1312
1691
|
}
|
|
1313
1692
|
function normalizeMember(value, members, label) {
|
|
1314
1693
|
const normalized = normalizeNonEmptyString(value, label);
|
|
1315
|
-
if (!
|
|
1694
|
+
if (!isMember5(normalized, members)) {
|
|
1316
1695
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
1317
1696
|
}
|
|
1318
1697
|
return normalized;
|
|
@@ -1445,13 +1824,13 @@ function normalizeDominantReads(value) {
|
|
|
1445
1824
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
1446
1825
|
}
|
|
1447
1826
|
function isQuietMeasureAxis(value) {
|
|
1448
|
-
return
|
|
1827
|
+
return isMember5(value, QUIET_MEASURE_AXES);
|
|
1449
1828
|
}
|
|
1450
1829
|
function isQuietMeasureMissionProbeMode(value) {
|
|
1451
|
-
return
|
|
1830
|
+
return isMember5(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
1452
1831
|
}
|
|
1453
1832
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
1454
|
-
return
|
|
1833
|
+
return isMember5(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
1455
1834
|
}
|
|
1456
1835
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
1457
1836
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -1954,6 +2333,7 @@ export {
|
|
|
1954
2333
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
1955
2334
|
AI_GAME_FEATURE_FLAGS,
|
|
1956
2335
|
AI_GAME_FEATURE_FLAG_ID,
|
|
2336
|
+
AI_GAME_GOSSIP_EXPORT_AUDIENCES,
|
|
1957
2337
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
1958
2338
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
1959
2339
|
AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
@@ -1977,6 +2357,16 @@ export {
|
|
|
1977
2357
|
AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
|
|
1978
2358
|
AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
|
|
1979
2359
|
AI_GAME_MISSION_REWARD_KINDS,
|
|
2360
|
+
AI_GAME_OBSERVED_EVENT_KINDS,
|
|
2361
|
+
AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION,
|
|
2362
|
+
AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID,
|
|
2363
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH,
|
|
2364
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAGS,
|
|
2365
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH,
|
|
2366
|
+
AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS,
|
|
2367
|
+
AI_GAME_OBSERVED_EVENT_SIGNIFICANCE,
|
|
2368
|
+
AI_GAME_OBSERVED_EVENT_SOURCES,
|
|
2369
|
+
AI_GAME_OBSERVED_EVENT_VISIBILITIES,
|
|
1980
2370
|
AI_GAME_PACKAGE,
|
|
1981
2371
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
1982
2372
|
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
@@ -1985,6 +2375,13 @@ export {
|
|
|
1985
2375
|
AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,
|
|
1986
2376
|
AI_GAME_PLAYER_SYSTEM_FOCUS_MODES,
|
|
1987
2377
|
AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS,
|
|
2378
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_OCCURRENCES_PER_MINUTE,
|
|
2379
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_MAX_PAYLOAD_BYTES,
|
|
2380
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_CUE_SOURCES,
|
|
2381
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_BEHAVIORS,
|
|
2382
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_CONTRACTS,
|
|
2383
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_FALLBACK_IDS,
|
|
2384
|
+
AI_GAME_PLAYER_SYSTEM_GUIDANCE_NFR_FEATURE_FLAG_ID,
|
|
1988
2385
|
AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES,
|
|
1989
2386
|
AI_GAME_PLAYER_SYSTEM_MODULES,
|
|
1990
2387
|
AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS,
|
|
@@ -2027,8 +2424,10 @@ export {
|
|
|
2027
2424
|
aiGameFeatureFlags,
|
|
2028
2425
|
assertAiGameIdentityProjectionContractVersion,
|
|
2029
2426
|
assertAiGameMissionContractVersion,
|
|
2427
|
+
assertAiGameObservedEventLogContractVersion,
|
|
2030
2428
|
classifyAiGameTask,
|
|
2031
2429
|
createAiGameAcademicTrainingSnapshot,
|
|
2430
|
+
createAiGameGossipExport,
|
|
2032
2431
|
createAiGameIdentityProjectionContract,
|
|
2033
2432
|
createAiGameIdentitySelfProjection,
|
|
2034
2433
|
createAiGameIdentityTargetProjection,
|
|
@@ -2044,7 +2443,11 @@ export {
|
|
|
2044
2443
|
createAiGameMissionRewardBound,
|
|
2045
2444
|
createAiGameMissionRewardEnvelope,
|
|
2046
2445
|
createAiGameMissionRewardGrant,
|
|
2446
|
+
createAiGameObservedEvent,
|
|
2447
|
+
createAiGameObservedEventHighlightSummary,
|
|
2448
|
+
createAiGameObservedEventRecencyWindow,
|
|
2047
2449
|
createAiGamePlayerSystemAlert,
|
|
2450
|
+
createAiGamePlayerSystemGuidanceCue,
|
|
2048
2451
|
createAiGamePlayerSystemPreferenceConfidenceState,
|
|
2049
2452
|
createAiGamePlayerSystemPreferenceInput,
|
|
2050
2453
|
createAiGamePlayerSystemPreferenceProfile,
|
|
@@ -2060,7 +2463,9 @@ export {
|
|
|
2060
2463
|
createQuietMeasureJudgmentResponse,
|
|
2061
2464
|
gameEventFeatureFlags,
|
|
2062
2465
|
getAiGamePlayerSystemFocusModeContract,
|
|
2466
|
+
getAiGamePlayerSystemGuidanceFallbackContract,
|
|
2063
2467
|
getAiGamePlayerSystemModuleContract,
|
|
2468
|
+
isAiGameGossipExportAudience,
|
|
2064
2469
|
isAiGameIdentityKnowledgeState,
|
|
2065
2470
|
isAiGameIdentityProjectionRead,
|
|
2066
2471
|
isAiGameIdentityTargetCategory,
|
|
@@ -2076,10 +2481,17 @@ export {
|
|
|
2076
2481
|
isAiGameMissionRepeatedSignalHandling,
|
|
2077
2482
|
isAiGameMissionRewardCapSemantic,
|
|
2078
2483
|
isAiGameMissionRewardKind,
|
|
2484
|
+
isAiGameObservedEventKind,
|
|
2485
|
+
isAiGameObservedEventSignificance,
|
|
2486
|
+
isAiGameObservedEventSource,
|
|
2487
|
+
isAiGameObservedEventVisibility,
|
|
2079
2488
|
isAiGamePlayerSystemAlertDeliverable,
|
|
2080
2489
|
isAiGamePlayerSystemAlertPriority,
|
|
2081
2490
|
isAiGamePlayerSystemConfidenceBand,
|
|
2082
2491
|
isAiGamePlayerSystemFocusMode,
|
|
2492
|
+
isAiGamePlayerSystemGuidanceCueSource,
|
|
2493
|
+
isAiGamePlayerSystemGuidanceFallbackBehavior,
|
|
2494
|
+
isAiGamePlayerSystemGuidanceFallbackId,
|
|
2083
2495
|
isAiGamePlayerSystemInputModality,
|
|
2084
2496
|
isAiGamePlayerSystemModule,
|
|
2085
2497
|
isAiGamePlayerSystemPreferenceKind,
|