@plasius/ai-game 0.6.3 → 0.6.4

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.js CHANGED
@@ -2318,6 +2318,306 @@ function createAiGameApprenticeshipHandoff(input) {
2318
2318
  });
2319
2319
  }
2320
2320
 
2321
+ // src/guild-quests.ts
2322
+ var AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID = "isekai.player-system.guild-quests.enabled";
2323
+ var AI_GAME_GUILD_QUESTS_CONTRACT_VERSION = "1.0";
2324
+ var AI_GAME_GUILD_QUEST_STATUSES = [
2325
+ "offered",
2326
+ "accepted",
2327
+ "active",
2328
+ "completed",
2329
+ "failed",
2330
+ "abandoned",
2331
+ "expired"
2332
+ ];
2333
+ var AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES = [
2334
+ "pending",
2335
+ "active",
2336
+ "completed",
2337
+ "failed"
2338
+ ];
2339
+ var AI_GAME_GUILD_QUEST_REWARD_KINDS = [
2340
+ "currency",
2341
+ "item",
2342
+ "recipe",
2343
+ "reputation",
2344
+ "access"
2345
+ ];
2346
+ var AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS = [
2347
+ "recommended",
2348
+ "optional",
2349
+ "not-recommended",
2350
+ "blocked"
2351
+ ];
2352
+ function freezeReadonlyArray9(items) {
2353
+ return Object.freeze([...items]);
2354
+ }
2355
+ function isMember7(value, members) {
2356
+ return members.includes(value);
2357
+ }
2358
+ function assertNonEmptyString9(value, label) {
2359
+ if (value.trim().length === 0) {
2360
+ throw new Error(`${label} must be a non-empty string`);
2361
+ }
2362
+ }
2363
+ function assertIsoTimestamp5(value, label) {
2364
+ assertNonEmptyString9(value, label);
2365
+ if (Number.isNaN(Date.parse(value))) {
2366
+ throw new Error(`${label} must be an ISO-8601 timestamp`);
2367
+ }
2368
+ }
2369
+ function assertPositiveInteger3(value, label) {
2370
+ if (!Number.isInteger(value) || value <= 0) {
2371
+ throw new Error(`${label} must be a positive integer`);
2372
+ }
2373
+ }
2374
+ function assertNonNegativeInteger4(value, label) {
2375
+ if (!Number.isInteger(value) || value < 0) {
2376
+ throw new Error(`${label} must be a non-negative integer`);
2377
+ }
2378
+ }
2379
+ function assertContractVersion8(value) {
2380
+ if (value !== AI_GAME_GUILD_QUESTS_CONTRACT_VERSION) {
2381
+ throw new Error(
2382
+ `contractVersion must be ${AI_GAME_GUILD_QUESTS_CONTRACT_VERSION}`
2383
+ );
2384
+ }
2385
+ }
2386
+ function createStringArray6(values, label, requireAtLeastOne = false) {
2387
+ const result = freezeReadonlyArray9(values ?? []);
2388
+ result.forEach((value) => assertNonEmptyString9(value, `${label} entry`));
2389
+ if (requireAtLeastOne && result.length === 0) {
2390
+ throw new Error(`${label} must contain at least one value`);
2391
+ }
2392
+ return result;
2393
+ }
2394
+ function isAiGameGuildQuestStatus(value) {
2395
+ return isMember7(value, AI_GAME_GUILD_QUEST_STATUSES);
2396
+ }
2397
+ function isAiGameGuildQuestObjectiveStatus(value) {
2398
+ return isMember7(value, AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES);
2399
+ }
2400
+ function isAiGameGuildQuestRewardKind(value) {
2401
+ return isMember7(value, AI_GAME_GUILD_QUEST_REWARD_KINDS);
2402
+ }
2403
+ function isAiGameGuildQuestSystemRecommendation(value) {
2404
+ return isMember7(value, AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS);
2405
+ }
2406
+ function createAiGameGuildQuestObjectiveProgress(input) {
2407
+ assertNonEmptyString9(input.objectiveId, "objectiveId");
2408
+ assertNonEmptyString9(input.objectiveCode, "objectiveCode");
2409
+ assertNonEmptyString9(input.label, "label");
2410
+ assertIsoTimestamp5(input.updatedAtIso, "updatedAtIso");
2411
+ assertPositiveInteger3(input.targetCount, "targetCount");
2412
+ const currentCount = input.currentCount ?? 0;
2413
+ assertNonNegativeInteger4(currentCount, "currentCount");
2414
+ if (currentCount > input.targetCount) {
2415
+ throw new Error("currentCount must be less than or equal to targetCount");
2416
+ }
2417
+ if (!isAiGameGuildQuestObjectiveStatus(input.status)) {
2418
+ throw new Error("status must be a supported guild-quest objective status");
2419
+ }
2420
+ return Object.freeze({
2421
+ objectiveId: input.objectiveId,
2422
+ objectiveCode: input.objectiveCode,
2423
+ label: input.label,
2424
+ status: input.status,
2425
+ targetCount: input.targetCount,
2426
+ currentCount,
2427
+ updatedAtIso: input.updatedAtIso,
2428
+ reasonCodes: createStringArray6(input.reasonCodes, "reasonCodes")
2429
+ });
2430
+ }
2431
+ function createAiGameGuildQuestProgress(input) {
2432
+ assertIsoTimestamp5(input.updatedAtIso, "updatedAtIso");
2433
+ if (!isAiGameGuildQuestStatus(input.status)) {
2434
+ throw new Error("status must be a supported guild-quest status");
2435
+ }
2436
+ if (input.objectives.length === 0) {
2437
+ throw new Error("objectives must contain at least one objective");
2438
+ }
2439
+ const objectives = input.objectives.map(
2440
+ (objective) => createAiGameGuildQuestObjectiveProgress(objective)
2441
+ );
2442
+ const objectiveIds = /* @__PURE__ */ new Set();
2443
+ for (const objective of objectives) {
2444
+ if (objectiveIds.has(objective.objectiveId)) {
2445
+ throw new Error("objectiveIds must be unique within a quest");
2446
+ }
2447
+ objectiveIds.add(objective.objectiveId);
2448
+ }
2449
+ return Object.freeze({
2450
+ status: input.status,
2451
+ objectives: freezeReadonlyArray9(objectives),
2452
+ updatedAtIso: input.updatedAtIso
2453
+ });
2454
+ }
2455
+ function createAiGameGuildQuestFailure(input) {
2456
+ assertNonEmptyString9(input.failureId, "failureId");
2457
+ assertNonEmptyString9(input.code, "code");
2458
+ assertNonEmptyString9(input.summary, "summary");
2459
+ assertIsoTimestamp5(input.failedAtIso, "failedAtIso");
2460
+ return Object.freeze({
2461
+ failureId: input.failureId,
2462
+ code: input.code,
2463
+ summary: input.summary,
2464
+ failedAtIso: input.failedAtIso,
2465
+ retryable: input.retryable,
2466
+ consequenceReasonCodes: createStringArray6(
2467
+ input.consequenceReasonCodes,
2468
+ "consequenceReasonCodes"
2469
+ )
2470
+ });
2471
+ }
2472
+ function createAiGameGuildQuestRewardPreview(input) {
2473
+ assertNonEmptyString9(input.previewId, "previewId");
2474
+ const entries = input.entries.map((entry) => {
2475
+ assertNonEmptyString9(entry.rewardId, "rewardId");
2476
+ assertNonEmptyString9(entry.label, "label");
2477
+ assertPositiveInteger3(entry.quantity, "quantity");
2478
+ if (!isAiGameGuildQuestRewardKind(entry.kind)) {
2479
+ throw new Error("kind must be a supported guild-quest reward kind");
2480
+ }
2481
+ return Object.freeze({
2482
+ rewardId: entry.rewardId,
2483
+ kind: entry.kind,
2484
+ label: entry.label,
2485
+ quantity: entry.quantity
2486
+ });
2487
+ });
2488
+ const rewardIds = /* @__PURE__ */ new Set();
2489
+ for (const entry of entries) {
2490
+ if (rewardIds.has(entry.rewardId)) {
2491
+ throw new Error("rewardIds must be unique within a reward preview");
2492
+ }
2493
+ rewardIds.add(entry.rewardId);
2494
+ }
2495
+ const expiresAtIso = input.expiresAtIso ?? null;
2496
+ if (expiresAtIso !== null) {
2497
+ assertIsoTimestamp5(expiresAtIso, "expiresAtIso");
2498
+ }
2499
+ return Object.freeze({
2500
+ previewId: input.previewId,
2501
+ authority: "guild",
2502
+ previewOnly: true,
2503
+ entries: freezeReadonlyArray9(entries),
2504
+ claimRequirementCodes: createStringArray6(
2505
+ input.claimRequirementCodes,
2506
+ "claimRequirementCodes",
2507
+ true
2508
+ ),
2509
+ expiresAtIso
2510
+ });
2511
+ }
2512
+ function createAiGameGuildQuest(input) {
2513
+ assertNonEmptyString9(input.questId, "questId");
2514
+ assertContractVersion8(
2515
+ input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION
2516
+ );
2517
+ assertNonEmptyString9(input.guildTruth.guildId, "guildId");
2518
+ assertNonEmptyString9(input.guildTruth.guildContractId, "guildContractId");
2519
+ assertNonEmptyString9(input.guildTruth.title, "title");
2520
+ assertNonEmptyString9(input.guildTruth.summary, "summary");
2521
+ assertPositiveInteger3(input.guildTruth.authorityRevision, "authorityRevision");
2522
+ if (!isAiGameGuildQuestStatus(input.guildTruth.status)) {
2523
+ throw new Error("status must be a supported guild-quest status");
2524
+ }
2525
+ const progress = createAiGameGuildQuestProgress(input.guildTruth.progress);
2526
+ if (progress.status !== input.guildTruth.status) {
2527
+ throw new Error("progress.status must match guildTruth.status");
2528
+ }
2529
+ const failure = input.guildTruth.failure ? createAiGameGuildQuestFailure(input.guildTruth.failure) : null;
2530
+ if (input.guildTruth.status === "failed" && failure === null) {
2531
+ throw new Error("failed guild quests must include failure details");
2532
+ }
2533
+ if (input.guildTruth.status !== "failed" && failure !== null) {
2534
+ throw new Error("failure details are only valid for failed guild quests");
2535
+ }
2536
+ const annotations = input.systemAnnotations ?? {};
2537
+ const recommendation = annotations.recommendation ?? "optional";
2538
+ if (!isAiGameGuildQuestSystemRecommendation(recommendation)) {
2539
+ throw new Error("recommendation must be a supported System annotation");
2540
+ }
2541
+ return Object.freeze({
2542
+ contractVersion: input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
2543
+ featureFlagId: AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
2544
+ questId: input.questId,
2545
+ guildTruth: Object.freeze({
2546
+ guildId: input.guildTruth.guildId,
2547
+ guildContractId: input.guildTruth.guildContractId,
2548
+ title: input.guildTruth.title,
2549
+ summary: input.guildTruth.summary,
2550
+ status: input.guildTruth.status,
2551
+ authorityRevision: input.guildTruth.authorityRevision,
2552
+ progress,
2553
+ failure,
2554
+ rewardPreview: createAiGameGuildQuestRewardPreview(
2555
+ input.guildTruth.rewardPreview
2556
+ )
2557
+ }),
2558
+ systemAnnotations: Object.freeze({
2559
+ recommendation,
2560
+ synergyCodes: createStringArray6(
2561
+ annotations.synergyCodes,
2562
+ "synergyCodes"
2563
+ ),
2564
+ linkedMissionIds: createStringArray6(
2565
+ annotations.linkedMissionIds,
2566
+ "linkedMissionIds"
2567
+ ),
2568
+ reasonCodes: createStringArray6(annotations.reasonCodes, "reasonCodes")
2569
+ })
2570
+ });
2571
+ }
2572
+ function createAiGameGuildQuestSyncPayload(input) {
2573
+ assertNonEmptyString9(input.guildId, "guildId");
2574
+ assertPositiveInteger3(input.authorityRevision, "authorityRevision");
2575
+ assertIsoTimestamp5(input.syncedAtIso, "syncedAtIso");
2576
+ assertContractVersion8(
2577
+ input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION
2578
+ );
2579
+ const quests = (input.quests ?? []).map(
2580
+ (quest) => createAiGameGuildQuest(quest)
2581
+ );
2582
+ const questIds = /* @__PURE__ */ new Set();
2583
+ for (const quest of quests) {
2584
+ if (questIds.has(quest.questId)) {
2585
+ throw new Error("questIds must be unique within a sync payload");
2586
+ }
2587
+ if (quest.guildTruth.guildId !== input.guildId) {
2588
+ throw new Error("all quests in a sync payload must belong to guildId");
2589
+ }
2590
+ questIds.add(quest.questId);
2591
+ }
2592
+ const removedQuestIds = createStringArray6(
2593
+ input.removedQuestIds,
2594
+ "removedQuestIds"
2595
+ );
2596
+ if (new Set(removedQuestIds).size !== removedQuestIds.length) {
2597
+ throw new Error("removedQuestIds must be unique within a sync payload");
2598
+ }
2599
+ if (quests.length === 0 && removedQuestIds.length === 0) {
2600
+ throw new Error("sync payload must contain quests or removedQuestIds");
2601
+ }
2602
+ for (const removedQuestId of removedQuestIds) {
2603
+ if (questIds.has(removedQuestId)) {
2604
+ throw new Error("removedQuestIds cannot overlap quests");
2605
+ }
2606
+ }
2607
+ return Object.freeze({
2608
+ contractVersion: input.contractVersion ?? AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
2609
+ featureFlagId: AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
2610
+ guildId: input.guildId,
2611
+ authorityRevision: input.authorityRevision,
2612
+ syncedAtIso: input.syncedAtIso,
2613
+ quests: freezeReadonlyArray9(quests),
2614
+ removedQuestIds
2615
+ });
2616
+ }
2617
+ function assertAiGameGuildQuestsContractVersion(value) {
2618
+ assertContractVersion8(value);
2619
+ }
2620
+
2321
2621
  // src/world-events.ts
2322
2622
  function isCanonicalWorldEvent(event) {
2323
2623
  return event.recordType === "canonical";
@@ -2469,7 +2769,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
2469
2769
  "private-or-low-witness-evidence",
2470
2770
  "costly-pressure-event"
2471
2771
  ];
2472
- function isMember7(value, members) {
2772
+ function isMember8(value, members) {
2473
2773
  return members.includes(value);
2474
2774
  }
2475
2775
  function assertRecord(value, label) {
@@ -2510,7 +2810,7 @@ function normalizeTimestamp(value, label) {
2510
2810
  }
2511
2811
  function normalizeMember(value, members, label) {
2512
2812
  const normalized = normalizeNonEmptyString(value, label);
2513
- if (!isMember7(normalized, members)) {
2813
+ if (!isMember8(normalized, members)) {
2514
2814
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
2515
2815
  }
2516
2816
  return normalized;
@@ -2643,13 +2943,13 @@ function normalizeDominantReads(value) {
2643
2943
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
2644
2944
  }
2645
2945
  function isQuietMeasureAxis(value) {
2646
- return isMember7(value, QUIET_MEASURE_AXES);
2946
+ return isMember8(value, QUIET_MEASURE_AXES);
2647
2947
  }
2648
2948
  function isQuietMeasureMissionProbeMode(value) {
2649
- return isMember7(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2949
+ return isMember8(value, QUIET_MEASURE_MISSION_PROBE_MODES);
2650
2950
  }
2651
2951
  function isQuietMeasureMissionResolutionShape(value) {
2652
- return isMember7(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2952
+ return isMember8(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
2653
2953
  }
2654
2954
  function createQuietMeasureJudgmentEligibility(input = {}) {
2655
2955
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -3165,6 +3465,12 @@ export {
3165
3465
  AI_GAME_GOSSIP_EXPORT_AUDIENCES,
3166
3466
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
3167
3467
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
3468
+ AI_GAME_GUILD_QUESTS_CONTRACT_VERSION,
3469
+ AI_GAME_GUILD_QUESTS_FEATURE_FLAG_ID,
3470
+ AI_GAME_GUILD_QUEST_OBJECTIVE_STATUSES,
3471
+ AI_GAME_GUILD_QUEST_REWARD_KINDS,
3472
+ AI_GAME_GUILD_QUEST_STATUSES,
3473
+ AI_GAME_GUILD_QUEST_SYSTEM_RECOMMENDATIONS,
3168
3474
  AI_GAME_IDENTITY_CONTRACT_VERSION,
3169
3475
  AI_GAME_IDENTITY_DISCLOSURE_POLICY,
3170
3476
  AI_GAME_IDENTITY_FEATURE_FLAG_ID,
@@ -3277,6 +3583,7 @@ export {
3277
3583
  QUIET_MEASURE_PERSPECTIVES,
3278
3584
  QUIET_MEASURE_SIGNAL_BANDS,
3279
3585
  aiGameFeatureFlags,
3586
+ assertAiGameGuildQuestsContractVersion,
3280
3587
  assertAiGameIdentityProjectionContractVersion,
3281
3588
  assertAiGameMissionContractVersion,
3282
3589
  assertAiGameObservedEventLogContractVersion,
@@ -3287,6 +3594,12 @@ export {
3287
3594
  createAiGameApprenticeshipSponsorship,
3288
3595
  createAiGameApprenticeshipSupervision,
3289
3596
  createAiGameGossipExport,
3597
+ createAiGameGuildQuest,
3598
+ createAiGameGuildQuestFailure,
3599
+ createAiGameGuildQuestObjectiveProgress,
3600
+ createAiGameGuildQuestProgress,
3601
+ createAiGameGuildQuestRewardPreview,
3602
+ createAiGameGuildQuestSyncPayload,
3290
3603
  createAiGameIdentityProjectionContract,
3291
3604
  createAiGameIdentitySelfProjection,
3292
3605
  createAiGameIdentityTargetProjection,
@@ -3337,6 +3650,10 @@ export {
3337
3650
  getAiGamePlayerSystemModuleContract,
3338
3651
  isAiGameApprenticeshipReadinessState,
3339
3652
  isAiGameGossipExportAudience,
3653
+ isAiGameGuildQuestObjectiveStatus,
3654
+ isAiGameGuildQuestRewardKind,
3655
+ isAiGameGuildQuestStatus,
3656
+ isAiGameGuildQuestSystemRecommendation,
3340
3657
  isAiGameIdentityKnowledgeState,
3341
3658
  isAiGameIdentityProjectionRead,
3342
3659
  isAiGameIdentityTargetCategory,