@serene-pub/sdk 0.6.0-pr-7 → 0.6.0-pr-9

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.
Files changed (106) hide show
  1. package/dist/annexFields.d.ts +14 -0
  2. package/dist/annexFields.js +7 -0
  3. package/dist/announce.d.ts +62 -16
  4. package/dist/announce.js +90 -4
  5. package/dist/appletCard.d.ts +17 -0
  6. package/dist/appletCard.js +60 -0
  7. package/dist/attributes.d.ts +3 -3
  8. package/dist/attributes.js +1 -1
  9. package/dist/builder.d.ts +28 -13
  10. package/dist/builder.js +57 -5
  11. package/dist/cadences.d.ts +8 -1
  12. package/dist/cadences.js +27 -2
  13. package/dist/characterProfile.d.ts +137 -0
  14. package/dist/characterProfile.js +24 -0
  15. package/dist/component.d.ts +1 -1
  16. package/dist/componentImports.d.ts +1 -1
  17. package/dist/componentImports.js +2 -0
  18. package/dist/componentWire.js +28 -0
  19. package/dist/conditions.d.ts +5 -1
  20. package/dist/conditions.js +7 -0
  21. package/dist/declarations.d.ts +63 -1
  22. package/dist/declarations.js +176 -7
  23. package/dist/descriptors.d.ts +145 -6
  24. package/dist/descriptors.js +106 -5
  25. package/dist/document.d.ts +9 -1
  26. package/dist/document.js +44 -1
  27. package/dist/events.d.ts +82 -8
  28. package/dist/events.js +42 -5
  29. package/dist/executor.d.ts +27 -0
  30. package/dist/executor.js +32 -8
  31. package/dist/exposure.d.ts +35 -1
  32. package/dist/exposure.js +64 -2
  33. package/dist/extension.d.ts +30 -2
  34. package/dist/extension.js +3 -1
  35. package/dist/fit.d.ts +4 -1
  36. package/dist/fit.js +43 -1
  37. package/dist/functions.d.ts +7 -1
  38. package/dist/functions.js +3 -1
  39. package/dist/genres.d.ts +67 -2
  40. package/dist/genres.js +160 -8
  41. package/dist/hookGrants.js +10 -0
  42. package/dist/hostElements.d.ts +3 -3
  43. package/dist/hostElements.js +12 -4
  44. package/dist/index.d.ts +5 -0
  45. package/dist/index.js +10 -0
  46. package/dist/layout.d.ts +18 -0
  47. package/dist/libraryDraft.d.ts +2 -0
  48. package/dist/libraryDraft.js +5 -1
  49. package/dist/lorebookFile.d.ts +8 -0
  50. package/dist/lorebookFile.js +21 -0
  51. package/dist/participants.d.ts +83 -8
  52. package/dist/participants.js +9 -5
  53. package/dist/pluginPermissions.js +1 -1
  54. package/dist/promptBlocks.d.ts +5 -1
  55. package/dist/promptBlocks.js +23 -8
  56. package/dist/provisos.d.ts +92 -0
  57. package/dist/provisos.js +273 -0
  58. package/dist/receiverRules.js +1 -1
  59. package/dist/registrations.d.ts +154 -14
  60. package/dist/registrations.js +293 -23
  61. package/dist/registry.js +6 -3
  62. package/dist/repertoires.d.ts +13 -1
  63. package/dist/repertoires.js +5 -1
  64. package/dist/rulesetDocument.d.ts +11 -0
  65. package/dist/rulesetDocument.js +17 -0
  66. package/dist/rulesetSections.d.ts +12 -0
  67. package/dist/rulesetSections.js +8 -0
  68. package/dist/rulesets.js +6 -0
  69. package/dist/sceneSettings.d.ts +7 -1
  70. package/dist/sceneSettings.js +10 -5
  71. package/dist/sessionDossier.d.ts +159 -2
  72. package/dist/sessionLayout.d.ts +296 -85
  73. package/dist/sessionLayout.js +397 -133
  74. package/dist/sessionSettings.d.ts +18 -0
  75. package/dist/settings.d.ts +28 -1
  76. package/dist/settings.js +50 -2
  77. package/dist/shapes.d.ts +15 -1
  78. package/dist/shapes.js +15 -1
  79. package/dist/sheetLatitude.d.ts +148 -0
  80. package/dist/sheetLatitude.js +161 -0
  81. package/dist/speech.d.ts +14 -3
  82. package/dist/storyTime.d.ts +77 -1
  83. package/dist/storyTime.js +117 -8
  84. package/dist/surfaces.d.ts +49 -2
  85. package/dist/surfaces.js +3 -0
  86. package/dist/template.d.ts +38 -1
  87. package/dist/templateCheck.d.ts +24 -0
  88. package/dist/templateCheck.js +465 -10
  89. package/dist/templateFit.js +8 -1
  90. package/dist/templateIds.d.ts +6 -0
  91. package/dist/templateIds.js +9 -0
  92. package/dist/turnLock.d.ts +10 -1
  93. package/dist/turnLock.js +6 -1
  94. package/dist/turnOrder.d.ts +37 -4
  95. package/dist/turnOrder.js +49 -11
  96. package/dist/validate.d.ts +4 -2
  97. package/dist/validate.js +84 -11
  98. package/dist/variableLayouts.d.ts +160 -0
  99. package/dist/variableLayouts.js +202 -0
  100. package/dist/variables.d.ts +237 -20
  101. package/dist/variables.js +292 -33
  102. package/dist/widgetDecls.js +12 -0
  103. package/dist/widgets.d.ts +449 -47
  104. package/dist/widgets.js +31 -0
  105. package/host-elements.d.ts +4 -2
  106. package/package.json +1 -1
package/dist/variables.js CHANGED
@@ -384,6 +384,98 @@ export const varWorldLore = defineVariable({
384
384
  'The Long Winter': 'Nine years without a thaw.',
385
385
  },
386
386
  });
387
+ const D = (en) => ({ en });
388
+ /**
389
+ * 🚧 The date value every dated row and the current date carry (`StoryDateValue`).
390
+ * An object field constant, not a `VarType`. Names come only from the lorebook's
391
+ * calendar and are absent for a free-form book.
392
+ * @experimental
393
+ */
394
+ export const STORY_DATE_FIELD = {
395
+ type: 'object',
396
+ description: D('A story date: year, and month, day and time of day where the date has them.'),
397
+ fields: {
398
+ year: {
399
+ type: 'object',
400
+ description: D('The story year.'),
401
+ fields: {
402
+ number: { type: 'number', description: D('The year number.') },
403
+ name: {
404
+ type: 'string',
405
+ optional: true,
406
+ description: D('The year spelled in the calendar’s era (`Year 412 AR`); absent for a free-form book.'),
407
+ },
408
+ },
409
+ },
410
+ month: {
411
+ type: 'object',
412
+ optional: true,
413
+ description: D('The month; absent when the date is only to a year.'),
414
+ fields: {
415
+ number: { type: 'number', description: D('The month number, from 1.') },
416
+ name: {
417
+ type: 'string',
418
+ optional: true,
419
+ description: D('The calendar’s name for the month; absent for a free-form book.'),
420
+ },
421
+ },
422
+ },
423
+ day: {
424
+ type: 'object',
425
+ optional: true,
426
+ description: D('The day of the month; absent when the date is only to a month or a year.'),
427
+ fields: {
428
+ number: { type: 'number', description: D('The day number, from 1.') },
429
+ name: {
430
+ type: 'string',
431
+ optional: true,
432
+ description: D('The weekday name; absent when the calendar has no week or the book is free-form.'),
433
+ },
434
+ },
435
+ },
436
+ time: {
437
+ type: 'object',
438
+ optional: true,
439
+ description: D('The time of day; absent when the date has none.'),
440
+ fields: {
441
+ hour: { type: 'number', description: D('The hour, 0–23.') },
442
+ minute: { type: 'number', description: D('The minute, 0–59.') },
443
+ },
444
+ },
445
+ },
446
+ };
447
+ /**
448
+ * 🚧 The date delta every dated row may carry (`StoryDateDelta`): the row's date
449
+ * minus the session's current date. An object field constant, not a `VarType`.
450
+ * @experimental
451
+ */
452
+ export const STORY_DATE_DELTA_FIELD = {
453
+ type: 'object',
454
+ description: D('How far the row’s date is from the story’s current date: row minus now.'),
455
+ fields: {
456
+ sign: { type: 'number', description: D('-1 when the row is before the current date, 1 after, 0 when equal.') },
457
+ year: { type: 'number', description: D('Whole years apart, never negative.') },
458
+ month: {
459
+ type: 'number',
460
+ optional: true,
461
+ description: D('Months apart; absent where months were not compared or cannot be known.'),
462
+ },
463
+ day: {
464
+ type: 'number',
465
+ optional: true,
466
+ description: D('Days apart; absent where days were not compared or cannot be known.'),
467
+ },
468
+ time: {
469
+ type: 'object',
470
+ optional: true,
471
+ description: D('Hours and minutes apart; absent when a time of day was not compared.'),
472
+ fields: {
473
+ hour: { type: 'number', description: D('Hours apart.') },
474
+ minute: { type: 'number', description: D('Minutes apart.') },
475
+ },
476
+ },
477
+ },
478
+ };
387
479
  /** @experimental */
388
480
  export const varHistory = defineVariable({
389
481
  id: 'core:var/history@1',
@@ -392,13 +484,88 @@ export const varHistory = defineVariable({
392
484
  // the chat so far, which is a different feature that does not exist here.
393
485
  i18n: { name: { en: 'History entries' } },
394
486
  description: {
395
- en: 'Earlier events from the chat that fit the budget, newest first, keyed by date.',
487
+ en: "Earlier events from the story that fit the budget, newest first, each with its date and its distance from the story's current date.",
396
488
  },
397
- scope: { history: { type: 'record', of: { type: 'string' } } },
398
- sample: {
399
- 'Year 412, Month 3': 'The caravan reached the wastes.',
400
- 'Year 412, Month 1': 'Ash left the Ashguard.',
489
+ scope: {
490
+ history: {
491
+ type: 'list',
492
+ of: {
493
+ type: 'object',
494
+ fields: {
495
+ date: {
496
+ ...STORY_DATE_FIELD,
497
+ optional: true,
498
+ description: D('When the entry happened. History rows carry no time of day.'),
499
+ },
500
+ dateDelta: {
501
+ ...STORY_DATE_DELTA_FIELD,
502
+ optional: true,
503
+ description: D('The entry’s distance from the story’s current date. Absent with no current date set, with the Timeline off, or when the present is only the newest history entry.'),
504
+ },
505
+ content: { type: 'string', description: D('What happened.') },
506
+ },
507
+ },
508
+ },
509
+ },
510
+ sample: [
511
+ {
512
+ date: { year: { number: 412 }, month: { number: 3 }, day: null, time: null },
513
+ dateDelta: { sign: -1, year: 0, month: 2, day: null, time: null },
514
+ content: 'The caravan reached the wastes.',
515
+ },
516
+ {
517
+ date: { year: { number: 412 }, month: { number: 1 }, day: null, time: null },
518
+ dateDelta: null,
519
+ content: 'Ash left the Ashguard.',
520
+ },
521
+ ],
522
+ });
523
+ // 🚧 Provisional. Not `history` (compiled, dated entries): these are the
524
+ // session's own scene summaries, oldest first, for scenes whose lines have left
525
+ // the prompt.
526
+ /** @experimental */
527
+ export const varEarlierScenes = defineVariable({
528
+ id: 'core:var/earlier-scenes@1',
529
+ i18n: { name: { en: 'Earlier in the story' } },
530
+ description: {
531
+ en: "The summaries of this session's finished scenes whose lines are no longer in the prompt, oldest first, each with its scene's name.",
532
+ },
533
+ scope: {
534
+ earlierScenes: {
535
+ type: 'list',
536
+ of: {
537
+ type: 'object',
538
+ fields: {
539
+ name: { type: 'string', description: { en: "The scene's name, as shown." } },
540
+ summary: { type: 'string', description: { en: "The scene's summary." } },
541
+ date: {
542
+ ...STORY_DATE_FIELD,
543
+ optional: true,
544
+ description: D('The story clock, day and time when the scene opened; absent when it opened with no clock.'),
545
+ },
546
+ dateDelta: {
547
+ ...STORY_DATE_DELTA_FIELD,
548
+ optional: true,
549
+ description: D('The scene’s distance from the story’s current date. Absent with no current date set, with the Timeline off, when the present is only the newest history entry, or when the scene has no date.'),
550
+ },
551
+ },
552
+ },
553
+ },
401
554
  },
555
+ sample: [
556
+ {
557
+ name: 'Scene 1 · The ferry',
558
+ summary: 'Ash and Rell crossed the river at dusk and lost the mule to the current.',
559
+ date: { year: { number: 412 }, month: { number: 3 }, day: { number: 2 }, time: { hour: 18, minute: 30 } },
560
+ dateDelta: { sign: -1, year: 0, month: 0, day: 3, time: { hour: 1, minute: 0 } },
561
+ },
562
+ {
563
+ name: 'Scene 2 · Greyford',
564
+ summary: 'In Greyford the reeve refused them lodging until Rell paid in salt.',
565
+ date: { year: { number: 412 }, month: { number: 3 }, day: { number: 4 }, time: { hour: 9, minute: 0 } },
566
+ dateDelta: { sign: -1, year: 0, month: 0, day: 1, time: { hour: 10, minute: 30 } },
567
+ },
568
+ ],
402
569
  });
403
570
  /**
404
571
  * Documentation excerpts retrieved for the latest question — the band
@@ -653,57 +820,149 @@ export const varCurrentDate = defineVariable({
653
820
  id: 'core:var/current-date@1',
654
821
  i18n: { name: { en: 'Current date' } },
655
822
  description: {
656
- en: "The story's present date: the lorebook's clock when it is set, else the most recent history entry.",
823
+ en: "The story's present date: the session's clock when it is set, else the present of the session's line, else the most recent history entry.",
657
824
  },
658
825
  /**
659
- * ⚠ Was `{ currentDate: { type: 'string' } }` with the sample
660
- * `'Year 412, Month 3'`, and the sample was **wrong** — the value arrived
661
- * pre-formatted by `formatDate` as `412-03`, so the preview showed a
662
- * rendering the prompt never contained. That is the failure mode a sample
663
- * exists to prevent, and it happened because the shape was a finished
664
- * string: nothing could disagree with the formatting, so nothing did.
826
+ * ⚠ The value is the same date value every dated row carries
827
+ * (`StoryDateValue`), so a layout prints all of them one way. The calendar's
828
+ * spelling is reached through the `name` of each part; there are no
829
+ * pre-formatted fields. An earlier shape handed down a finished string and
830
+ * its sample disagreed with the prompt, which is the failure a sample exists
831
+ * to prevent.
665
832
  *
666
- * The parts travel separately now and the layout joins them, which is what
667
- * makes "state the date differently" a setting rather than a code change.
668
- * `month` and `day` are absent rather than null when the entry has no such
669
- * precision — `{{#if (isSet …)}}` is what a layout tests.
833
+ * 🚧 It may be absent, so a template guards it (`{{#if currentDate}}`). The
834
+ * settings document's `timeline` (`SessionSettingsV1.timeline`) says whether
835
+ * the session's lorebook keeps a timeline, and promises no date either way:
836
+ * `true` with no story clock and no dated history entry on the line has
837
+ * none; with `false` it is always absent: on a lorebook that keeps no
838
+ * timeline, every story-time value a run can read is `null`, whatever is
839
+ * stored.
670
840
  */
671
841
  scope: {
672
842
  currentDate: {
843
+ ...STORY_DATE_FIELD,
844
+ description: D('The story’s present date.'),
845
+ },
846
+ },
847
+ sample: { year: { number: 412 }, month: { number: 3 }, day: { number: 5 }, time: null },
848
+ });
849
+ /**
850
+ * 🚧 The session's lorebook calendar, for a template that wants to tell the
851
+ * model how the calendar runs. Absent for a free-form book. The day's periods
852
+ * and the seasons are not declared here: their labels are `I18n`, which a
853
+ * `VarField` cannot type.
854
+ * @experimental
855
+ */
856
+ export const varStoryCalendar = defineVariable({
857
+ id: 'core:var/story-calendar@1',
858
+ i18n: { name: { en: 'Story calendar' } },
859
+ description: {
860
+ en: "The session's lorebook calendar, for a template that wants to tell the model how the calendar runs; absent for a free-form book.",
861
+ },
862
+ scope: {
863
+ storyCalendar: {
673
864
  type: 'object',
674
865
  fields: {
675
- year: { type: 'number', description: { en: 'The story year.' } },
676
- month: {
677
- type: 'number',
866
+ months: {
867
+ type: 'list',
868
+ description: D('The months in order.'),
869
+ of: {
870
+ type: 'object',
871
+ fields: {
872
+ name: { type: 'string', description: D('The month’s name.') },
873
+ days: { type: 'number', description: D('How many days it has.') },
874
+ },
875
+ },
876
+ },
877
+ weekdays: {
878
+ type: 'list',
678
879
  optional: true,
679
- description: { en: 'Absent when the entry is only dated to a year.' },
880
+ description: D('Weekday names in order; absent when the calendar has no week.'),
881
+ of: { type: 'string' },
680
882
  },
681
- day: {
883
+ firstWeekday: {
682
884
  type: 'number',
683
885
  optional: true,
684
- description: { en: 'Absent when the entry is only dated to a month.' },
886
+ description: D('Which weekday (0-based) the first day of year 1 falls on.'),
685
887
  },
686
- hour: {
687
- type: 'number',
888
+ yearLabel: {
889
+ type: 'string',
688
890
  optional: true,
689
- description: { en: "The clock's hour (0–23), when the present has a time of day." },
891
+ description: D('The word before a year number.'),
690
892
  },
691
- minute: {
692
- type: 'number',
893
+ leap: {
894
+ type: 'object',
693
895
  optional: true,
694
- description: { en: "The clock's minute, when the present has a time of day." },
896
+ description: D('The leap rule: one extra day in one month.'),
897
+ fields: {
898
+ every: { type: 'number', description: D('Every this many years.') },
899
+ month: { type: 'number', description: D('The month that gains the day, from 1.') },
900
+ skipEvery: {
901
+ type: 'number',
902
+ optional: true,
903
+ description: D('Years divisible by this are not leap years, unless a later level says otherwise.'),
904
+ },
905
+ keepEvery: {
906
+ type: 'number',
907
+ optional: true,
908
+ description: D('Years divisible by this are leap years again.'),
909
+ },
910
+ more: {
911
+ type: 'list',
912
+ optional: true,
913
+ description: D('The further levels, in order, each a multiple of the one before.'),
914
+ of: { type: 'number' },
915
+ },
916
+ // 🚧 provisional field name and shape.
917
+ furtherLevels: {
918
+ type: 'list',
919
+ optional: true,
920
+ description: D('Every level after the first, in order: its years, and whether it adds the leap day back (true) or takes it away (false). Laid out by the host.'),
921
+ of: {
922
+ type: 'object',
923
+ fields: {
924
+ every: { type: 'number', description: D('Every this many years.') },
925
+ addsLeapDay: { type: 'boolean', description: D('True when it adds the leap day, false when it takes it away.') },
926
+ },
927
+ },
928
+ },
929
+ },
695
930
  },
696
- label: {
697
- type: 'string',
931
+ eras: {
932
+ type: 'list',
698
933
  optional: true,
699
- description: {
700
- en: "The date spelled through the lorebook's calendar; absent when the book is free-form.",
934
+ description: D('The eras that spell the year count, in order.'),
935
+ of: {
936
+ type: 'object',
937
+ fields: {
938
+ name: { type: 'string', description: D('The era’s name.') },
939
+ start: {
940
+ type: 'number',
941
+ optional: true,
942
+ description: D('The first year it spells; absent for the first era.'),
943
+ },
944
+ backwards: {
945
+ type: 'boolean',
946
+ optional: true,
947
+ description: D('True when its year numbers count down.'),
948
+ },
949
+ },
701
950
  },
702
951
  },
703
952
  },
704
953
  },
705
954
  },
706
- sample: { year: 412, month: 3, day: 5 },
955
+ sample: {
956
+ months: [
957
+ { name: 'Frostmoot', days: 30 },
958
+ { name: 'Seedfall', days: 30 },
959
+ { name: 'Highsun', days: 31 },
960
+ ],
961
+ weekdays: ['Moonday', 'Toilday', 'Restday'],
962
+ firstWeekday: 0,
963
+ yearLabel: 'Year',
964
+ eras: [{ name: 'AR', start: null }],
965
+ },
707
966
  });
708
967
  // ── Samples ─────────────────────────────────────────────────────────────────
709
968
  /**
@@ -95,6 +95,18 @@ export function widget(d) {
95
95
  problems.push(...widgetReadsFindings(d.reads, `widget '${d.id}' reads`));
96
96
  if (d.maxInstances !== undefined && !(Number.isInteger(d.maxInstances) && d.maxInstances > 0))
97
97
  problems.push(`widget '${d.id}' maxInstances: a positive whole number, or leave it out for no cap`);
98
+ if (d.panel !== undefined) {
99
+ const p = d.panel;
100
+ if (typeof p !== 'object' || p === null || Array.isArray(p))
101
+ problems.push(`widget '${d.id}' panel: { height?, priority? } — an object`);
102
+ else {
103
+ const { height, priority } = p;
104
+ if (height !== undefined && height !== 'fit' && height !== 'fill')
105
+ problems.push(`widget '${d.id}' panel.height: 'fit' or 'fill'`);
106
+ if (priority !== undefined && priority !== 'high' && priority !== 'normal' && priority !== 'low')
107
+ problems.push(`widget '${d.id}' panel.priority: 'high', 'normal' or 'low'`);
108
+ }
109
+ }
98
110
  const genres = d.genres?.map((g) => g?.id);
99
111
  if (genres?.some((g) => typeof g !== 'string' || !g))
100
112
  problems.push(`widget '${d.id}' genres: each is a genre value (or use('<id>')), never a bare string`);