@dsh-agentic-roleplay/state 0.3.0 → 0.3.1
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/README.md +1 -1
- package/lib/index.d.ts +190 -12
- package/lib/index.js +684 -49
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ characters created during play have none.
|
|
|
133
133
|
| `locations`, `exits`, `placements` | Places (with features), the ways between them (one direction each, `open` / `locked` / `blocked`, optional travel seconds) and where things stand (a character: place, position, feature; the same table will place items). `session.planMove` / `session.move` move a character over open exits only (`InvalidMoveError` names every reason); the edit wire format can make places, change exits and move characters. |
|
|
134
134
|
| `events` | What objectively happened: turn, round, text, importance (1 to 5), tags. `event_involves` lists the characters an event is about. Events are immutable: a draft until `sealed`, final afterwards (`events.seal()`); updating or removing a sealed one throws `ConflictError`. |
|
|
135
135
|
| `perceptions` | What one character took in of an event, in its own terms: mode (witnessed, heard, told, inferred), content, a gist for when it fades, an accuracy label (never shown to the character), and how often it was recalled. One per character and event. |
|
|
136
|
-
| `memories` | What a character believes or knows beyond single events: kind
|
|
136
|
+
| `memories`, `memory_evidence` | What a character believes or knows beyond single events: kind, text, subjects, importance, confidence, formation turn, and the perceptions that support or contradict it. |
|
|
137
137
|
| `story_threads` | Things not settled yet: promises, mysteries, goals; open or resolved. |
|
|
138
138
|
| `summaries` | The account of the story for the conversation's head: digests of recent turns and chapters of older ones, each with the turns it covers. |
|
|
139
139
|
| `recall_items`, `recall_fts`, `recall_vocab`, `recall_vec` | The search index: one row per perception, memory and event, indexed by words (FTS5) and, once vectors are stored, by meaning (sqlite-vec, cosine, partitioned by character). `store.recallIndex` lists the texts without a vector (`pending`), stores vectors (`store`, which fixes the model and dimensions of the session's vectors) and searches (`lexical`, `vector`). Vector support is optional: without the extension everything but `vector` works. |
|
package/lib/index.d.ts
CHANGED
|
@@ -367,6 +367,11 @@ interface LocationDefinition {
|
|
|
367
367
|
interface RoutineWindow {
|
|
368
368
|
/** The days of the week it applies on, 0 for Sunday; every day when empty. A window past midnight belongs to the day it starts on. */
|
|
369
369
|
days: number[];
|
|
370
|
+
/**
|
|
371
|
+
* Other days it applies on or does not (`dec`, `12-24`, `season:winter`, `nth:mon:1`, `holiday:<id>`, a `!` before one for a day it does not apply
|
|
372
|
+
* on): it applies on a day that is among `days` and that these allow. Every day when empty or left out.
|
|
373
|
+
*/
|
|
374
|
+
on?: string[];
|
|
370
375
|
/** The minute of the day it starts, 0 to 1439. */
|
|
371
376
|
start: number;
|
|
372
377
|
/** The minute it ends (exclusive); before `start` it ends the next day. Equal to `start` is not a window. */
|
|
@@ -380,6 +385,7 @@ interface RoutineWindow {
|
|
|
380
385
|
interruptible: boolean;
|
|
381
386
|
}
|
|
382
387
|
interface StoredRoutineWindow extends RoutineWindow {
|
|
388
|
+
on: string[];
|
|
383
389
|
id: number;
|
|
384
390
|
characterId: CharacterId;
|
|
385
391
|
}
|
|
@@ -387,6 +393,8 @@ interface StoredRoutineWindow extends RoutineWindow {
|
|
|
387
393
|
interface RoutineDefinition {
|
|
388
394
|
/** Three-letter days (`mon` to `sun`); every day when left out. */
|
|
389
395
|
days: string[];
|
|
396
|
+
/** Other days it applies on or does not, as for {@link RoutineWindow.on}. */
|
|
397
|
+
on?: string[];
|
|
390
398
|
/** `HH:MM`. */
|
|
391
399
|
from: string;
|
|
392
400
|
to: string;
|
|
@@ -714,6 +722,13 @@ declare const ACCURACIES: readonly ["accurate", "partial", "mistaken"];
|
|
|
714
722
|
type Accuracy = (typeof ACCURACIES)[number];
|
|
715
723
|
declare const MEMORY_KINDS: readonly ["belief", "relationship", "knowledge"];
|
|
716
724
|
type MemoryKind = (typeof MEMORY_KINDS)[number];
|
|
725
|
+
/** How sure a character is of what it believes, from least to most. */
|
|
726
|
+
declare const MEMORY_CONFIDENCES: readonly ["doubtful", "likely", "sure"];
|
|
727
|
+
type MemoryConfidence = (typeof MEMORY_CONFIDENCES)[number];
|
|
728
|
+
declare const DEFAULT_CONFIDENCE: MemoryConfidence;
|
|
729
|
+
/** Whether a perception speaks for a belief or against it. */
|
|
730
|
+
declare const EVIDENCE_RELATIONS: readonly ["supports", "contradicts"];
|
|
731
|
+
type EvidenceRelation = (typeof EVIDENCE_RELATIONS)[number];
|
|
717
732
|
declare const THREAD_STATUSES: readonly ["open", "resolved"];
|
|
718
733
|
type ThreadStatus = (typeof THREAD_STATUSES)[number];
|
|
719
734
|
/** A digest covers a stretch of recent turns closely; a chapter covers older turns briefly. */
|
|
@@ -808,17 +823,30 @@ interface CharacterMemory {
|
|
|
808
823
|
/** The characters it is about. */
|
|
809
824
|
about: CharacterId[];
|
|
810
825
|
importance: number;
|
|
826
|
+
/** How sure the character is of it. */
|
|
827
|
+
confidence: MemoryConfidence;
|
|
811
828
|
/** The turn it was formed in. */
|
|
812
829
|
turn: number;
|
|
813
830
|
recalls: number;
|
|
814
831
|
lastRecalledTurn?: number;
|
|
815
832
|
createdAt: string;
|
|
816
833
|
}
|
|
817
|
-
type NewCharacterMemory = Omit<CharacterMemory, 'id' | 'createdAt' | 'recalls' | 'lastRecalledTurn'
|
|
834
|
+
type NewCharacterMemory = Omit<CharacterMemory, 'id' | 'createdAt' | 'recalls' | 'lastRecalledTurn' | 'confidence'> & {
|
|
835
|
+
confidence?: MemoryConfidence;
|
|
836
|
+
};
|
|
818
837
|
interface CharacterMemoryPatch {
|
|
819
838
|
text?: string;
|
|
820
839
|
about?: CharacterId[];
|
|
821
840
|
importance?: number;
|
|
841
|
+
confidence?: MemoryConfidence;
|
|
842
|
+
}
|
|
843
|
+
/** What a character took in that a belief rests on, or that speaks against it. */
|
|
844
|
+
interface MemoryEvidence {
|
|
845
|
+
memoryId: MemoryId;
|
|
846
|
+
perceptionId: PerceptionId;
|
|
847
|
+
relation: EvidenceRelation;
|
|
848
|
+
/** The turn the link was made. */
|
|
849
|
+
turn: number;
|
|
822
850
|
}
|
|
823
851
|
/** Something in the story that is not settled yet: a promise, a mystery, a goal. */
|
|
824
852
|
interface StoryThread {
|
|
@@ -1012,7 +1040,7 @@ type Comparison = (typeof COMPARISONS)[number];
|
|
|
1012
1040
|
* the story's zone: `YYYY-MM-DDTHH:MM`, and `HH:MM` for a time of day.
|
|
1013
1041
|
*/
|
|
1014
1042
|
type TriggerCondition =
|
|
1015
|
-
/** True from `from` on, until `to`; or while the time of day is in `window` (past midnight when it ends before it starts), on `days` (`mon` to `sun`) when given. */
|
|
1043
|
+
/** True from `from` on, until `to`; or while the time of day is in `window` (past midnight when it ends before it starts), on `days` (`mon` to `sun`) when given and on the days `on` allows (months, dates, seasons, holidays of the world's calendar). */
|
|
1016
1044
|
{
|
|
1017
1045
|
type: 'time';
|
|
1018
1046
|
from?: string;
|
|
@@ -1022,6 +1050,7 @@ type TriggerCondition =
|
|
|
1022
1050
|
to: string;
|
|
1023
1051
|
};
|
|
1024
1052
|
days?: string[];
|
|
1053
|
+
on?: string[];
|
|
1025
1054
|
} |
|
|
1026
1055
|
/** A character is in a place, at a feature of it when given. */
|
|
1027
1056
|
{
|
|
@@ -1256,6 +1285,24 @@ interface PlotProgress {
|
|
|
1256
1285
|
lastNudgeAt?: number;
|
|
1257
1286
|
}
|
|
1258
1287
|
//#endregion
|
|
1288
|
+
//#region ../dsh-roleplay-model/src/messages.d.ts
|
|
1289
|
+
/** The languages the texts a model reads are written in. English is the source: a text is its own key. */
|
|
1290
|
+
declare const LANGUAGES: readonly ["en", "zh"];
|
|
1291
|
+
type Language = (typeof LANGUAGES)[number];
|
|
1292
|
+
/** The language a setting such as `zh-CN` or `en` stands for; English when it is none that is known. */
|
|
1293
|
+
declare function languageOf(code: string | undefined): Language;
|
|
1294
|
+
type MessageValues = Readonly<Record<string, string | number>>;
|
|
1295
|
+
/** Says a text in the language of the story: `tr('{name} is in {place}.', { name, place })`. */
|
|
1296
|
+
type Translate = (text: string, values?: MessageValues) => string;
|
|
1297
|
+
/**
|
|
1298
|
+
* The texts the engine builds for a model (briefs, reports, refusals) in a language. The text written in the code is the English one and the key of
|
|
1299
|
+
* the others; a text a language lacks is told in English, and a test keeps that from happening.
|
|
1300
|
+
*/
|
|
1301
|
+
declare function translator(language: Language): Translate;
|
|
1302
|
+
/** The texts with a translation, for the test that every text has one. */
|
|
1303
|
+
declare const translated: (language: Exclude<Language, "en">) => readonly string[];
|
|
1304
|
+
declare const translation: (language: Exclude<Language, "en">, text: string) => string | undefined;
|
|
1305
|
+
//#endregion
|
|
1259
1306
|
//#region src/clock.d.ts
|
|
1260
1307
|
type Clock = () => Date;
|
|
1261
1308
|
declare const systemClock: Clock;
|
|
@@ -1482,6 +1529,17 @@ interface MemoryRepository {
|
|
|
1482
1529
|
/** Count a memory as recalled in `turn`. */
|
|
1483
1530
|
touch(ids: readonly MemoryId[], turn: number): void;
|
|
1484
1531
|
remove(id: MemoryId): boolean;
|
|
1532
|
+
/** Record that a perception of the character's speaks for a belief or against it; one link per pair, the later replaces the earlier. @throws {NotFoundError} */
|
|
1533
|
+
addEvidence(memoryId: MemoryId, perceptionId: PerceptionId, relation: EvidenceRelation, turn: number): void;
|
|
1534
|
+
evidenceOf(memoryId: MemoryId): MemoryEvidence[];
|
|
1535
|
+
/**
|
|
1536
|
+
* What a character's beliefs rest on: for each perception that some belief of the character cites, the beliefs that do (it is folded into them),
|
|
1537
|
+
* and the beliefs something it took in speaks against (disputed).
|
|
1538
|
+
*/
|
|
1539
|
+
evidenceIndex(characterId: CharacterId): {
|
|
1540
|
+
folded: Map<PerceptionId, MemoryId[]>;
|
|
1541
|
+
disputed: Set<MemoryId>;
|
|
1542
|
+
};
|
|
1485
1543
|
}
|
|
1486
1544
|
interface ThreadRepository {
|
|
1487
1545
|
open(text: string, turn: number): StoryThread;
|
|
@@ -1999,6 +2057,8 @@ interface RecordsTarget {
|
|
|
1999
2057
|
routines: RoutineRepository;
|
|
2000
2058
|
engagements: EngagementRepository;
|
|
2001
2059
|
triggers: TriggerRepository;
|
|
2060
|
+
/** What the story keeps about itself; the calendar of its world is read from here. */
|
|
2061
|
+
metadata: Pick<MetadataRepository, 'getValue'>;
|
|
2002
2062
|
transaction<T>(fn: () => T): T;
|
|
2003
2063
|
}
|
|
2004
2064
|
interface PerceivedBy {
|
|
@@ -2249,12 +2309,20 @@ interface NewBelief {
|
|
|
2249
2309
|
text: string;
|
|
2250
2310
|
about?: string[];
|
|
2251
2311
|
importance: number;
|
|
2312
|
+
/** How sure the character is; likely when not said. */
|
|
2313
|
+
confidence?: MemoryConfidence;
|
|
2314
|
+
/** The numbers of perceptions of the character's own that it rests on, and that speak against it. */
|
|
2315
|
+
evidenceFor?: number[];
|
|
2316
|
+
evidenceAgainst?: number[];
|
|
2252
2317
|
}
|
|
2253
2318
|
interface BeliefEdit {
|
|
2254
2319
|
id: number;
|
|
2255
2320
|
text?: string;
|
|
2256
2321
|
about?: string[];
|
|
2257
2322
|
importance?: number;
|
|
2323
|
+
confidence?: MemoryConfidence;
|
|
2324
|
+
evidenceFor?: number[];
|
|
2325
|
+
evidenceAgainst?: number[];
|
|
2258
2326
|
}
|
|
2259
2327
|
/**
|
|
2260
2328
|
* A change to the story's records, applied together or not at all: the unit in which the
|
|
@@ -2309,6 +2377,8 @@ interface EngagementEditSpec {
|
|
|
2309
2377
|
interface RoutineWindowSpec {
|
|
2310
2378
|
/** `mon` to `sun`; every day when left out. */
|
|
2311
2379
|
days?: string[];
|
|
2380
|
+
/** Other days it applies on or not: `dec`, `12-24`, `season:winter`, `nth:mon:1`, `holiday:<id>`, `!` before one for a day it does not apply on. */
|
|
2381
|
+
on?: string[];
|
|
2312
2382
|
/** `HH:MM`. */
|
|
2313
2383
|
from: string;
|
|
2314
2384
|
to: string;
|
|
@@ -2397,7 +2467,7 @@ declare function parseTriggerDefinition(value: unknown, path: string, checkEdit:
|
|
|
2397
2467
|
} | {
|
|
2398
2468
|
problems: string[];
|
|
2399
2469
|
};
|
|
2400
|
-
type Reading$1 = Pick<RecordsTarget, 'characters' | 'locations' | 'items' | 'variables' | 'triggers'>;
|
|
2470
|
+
type Reading$1 = Pick<RecordsTarget, 'characters' | 'locations' | 'items' | 'variables' | 'triggers' | 'metadata'>;
|
|
2401
2471
|
/**
|
|
2402
2472
|
* What in a trigger names something the story does not have: a character, place, item or variable in a condition, the characters of a cue,
|
|
2403
2473
|
* a trigger it waits for. (What an edit effect touches is checked when it is applied.)
|
|
@@ -2544,6 +2614,11 @@ interface MemoryPolicy {
|
|
|
2544
2614
|
* included) to 1 (only what adds something new): maximal marginal relevance over the pool. 0 or absent: none.
|
|
2545
2615
|
*/
|
|
2546
2616
|
diversity?: number;
|
|
2617
|
+
/**
|
|
2618
|
+
* How long what a character took in lasts once a belief rests on it, as a share of how long it would last: below 1 it fades sooner, the
|
|
2619
|
+
* belief having taken over, and it is not told again when that belief is told. 1 or absent: no change.
|
|
2620
|
+
*/
|
|
2621
|
+
foldedFade?: number;
|
|
2547
2622
|
}
|
|
2548
2623
|
declare const DEFAULT_MEMORY_POLICY: MemoryPolicy;
|
|
2549
2624
|
/** How much of a memory is left: what the character is told of it. */
|
|
@@ -2563,6 +2638,10 @@ interface Recalled {
|
|
|
2563
2638
|
};
|
|
2564
2639
|
/** It did not match the moment itself: it came to mind with something that did ({@link MemoryPolicy.associate}). */
|
|
2565
2640
|
linked?: true;
|
|
2641
|
+
/** For what the character believes: how sure it is. */
|
|
2642
|
+
confidence?: MemoryConfidence;
|
|
2643
|
+
/** For what the character believes: something it took in since speaks against it. */
|
|
2644
|
+
disputed?: true;
|
|
2566
2645
|
/** Why it came back, when the query asked to be told ({@link RecallQuery.explain}). */
|
|
2567
2646
|
why?: RecallWhy;
|
|
2568
2647
|
}
|
|
@@ -2612,7 +2691,7 @@ interface RecallQuery {
|
|
|
2612
2691
|
/** What recall reads: the events a character took in and what it believes. */
|
|
2613
2692
|
interface RecallSource {
|
|
2614
2693
|
events: Pick<EventRepository, 'perceivedBy'>;
|
|
2615
|
-
memories: Pick<MemoryRepository, 'list'
|
|
2694
|
+
memories: Pick<MemoryRepository, 'list'> & Partial<Pick<MemoryRepository, 'evidenceIndex'>>;
|
|
2616
2695
|
clock: Pick<ClockRepository, 'get' | 'log'>;
|
|
2617
2696
|
/** Optional for lightweight callers; a session supplies it so socially charged people are stronger cues. */
|
|
2618
2697
|
relationships?: Pick<RelationshipRepository, 'from'>;
|
|
@@ -2655,6 +2734,8 @@ interface Candidate {
|
|
|
2655
2734
|
recalls: number;
|
|
2656
2735
|
seed: number;
|
|
2657
2736
|
durability: number;
|
|
2737
|
+
/** For something the character took in that beliefs rest on: those beliefs. */
|
|
2738
|
+
covered?: number[];
|
|
2658
2739
|
}
|
|
2659
2740
|
declare function overlap(cues: ReadonlySet<string>, text: string, tags: readonly string[]): number;
|
|
2660
2741
|
/** One thing a character could be reminded of, with the text to match it against the moment. */
|
|
@@ -2678,7 +2759,9 @@ interface RecallEvidence {
|
|
|
2678
2759
|
rerank?: ReadonlyMap<string, number>;
|
|
2679
2760
|
}
|
|
2680
2761
|
/** Everything the character could be reminded of, for a caller that ranks by meaning (an embedding, a reranker) before asking for the recall. */
|
|
2681
|
-
declare function recallCandidates(source: RecallSource, query: Pick<RecallQuery, 'characterId' | 'characters' | 'situation' | 'turn' | 'locationId' | 'about'>
|
|
2762
|
+
declare function recallCandidates(source: RecallSource, query: Pick<RecallQuery, 'characterId' | 'characters' | 'situation' | 'turn' | 'locationId' | 'about'> & {
|
|
2763
|
+
policy?: MemoryPolicy;
|
|
2764
|
+
}): RecallCandidate[];
|
|
2682
2765
|
/** Fuse scores from 0 to 1 into one, per key: the weighted average over the searches that ran (those with any score above 0). */
|
|
2683
2766
|
declare function fuseScores(searches: readonly {
|
|
2684
2767
|
weight: number;
|
|
@@ -2852,6 +2935,9 @@ interface RecordsView {
|
|
|
2852
2935
|
text: string;
|
|
2853
2936
|
about: string[];
|
|
2854
2937
|
importance: number;
|
|
2938
|
+
confidence: string;
|
|
2939
|
+
evidence_for: number[];
|
|
2940
|
+
evidence_against: number[];
|
|
2855
2941
|
turn: number;
|
|
2856
2942
|
}[];
|
|
2857
2943
|
open_threads: {
|
|
@@ -3250,6 +3336,95 @@ declare function createCharacterTools(link: () => AgentLink, characterId: Charac
|
|
|
3250
3336
|
/** Why a value is not one the variable can have, or nothing when it is. */
|
|
3251
3337
|
declare function valueIssue(def: Pick<VariableDefinition, 'key' | 'kind' | 'min' | 'max' | 'integer' | 'options'>, value: unknown): string | undefined;
|
|
3252
3338
|
//#endregion
|
|
3339
|
+
//#region src/records/calendar.d.ts
|
|
3340
|
+
/**
|
|
3341
|
+
* Which days a thing applies on, beyond the days of the week: whole months, a date every year or once, a stretch of dates, the day of the month,
|
|
3342
|
+
* the first or last Monday of a month, a season, and the holidays a world names. A day is told by tokens (`dec`, `12-24`, `1912-09-21..1912-09-22`,
|
|
3343
|
+
* `dom:1`, `nth:mon:1`, `season:winter`, `holiday:founders-day`, `fri`); a token with `!` before it is a day it does not apply on. A list holds on a
|
|
3344
|
+
* day when it names no day to apply on or one of them is today, and none of the days to leave out is.
|
|
3345
|
+
*/
|
|
3346
|
+
declare const MONTH_NAMES: readonly ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
3347
|
+
declare const SEASONS: readonly ["spring", "summer", "autumn", "winter"];
|
|
3348
|
+
type Season = (typeof SEASONS)[number];
|
|
3349
|
+
type Hemisphere = 'north' | 'south';
|
|
3350
|
+
/** A day by the wall clock of the story: the month is 1 to 12 and the weekday 0 (Sunday) to 6. */
|
|
3351
|
+
interface CalendarDay {
|
|
3352
|
+
year: number;
|
|
3353
|
+
month: number;
|
|
3354
|
+
day: number;
|
|
3355
|
+
weekday: number;
|
|
3356
|
+
}
|
|
3357
|
+
interface Holiday {
|
|
3358
|
+
id: string;
|
|
3359
|
+
name: string;
|
|
3360
|
+
/** The days it falls on, as tokens other than `holiday:`. */
|
|
3361
|
+
on: string[];
|
|
3362
|
+
}
|
|
3363
|
+
interface Calendar {
|
|
3364
|
+
hemisphere: Hemisphere;
|
|
3365
|
+
holidays: Holiday[];
|
|
3366
|
+
}
|
|
3367
|
+
declare const NO_CALENDAR: Calendar;
|
|
3368
|
+
type Parsed = {
|
|
3369
|
+
kind: 'weekday';
|
|
3370
|
+
weekday: number;
|
|
3371
|
+
} | {
|
|
3372
|
+
kind: 'month';
|
|
3373
|
+
month: number;
|
|
3374
|
+
} | {
|
|
3375
|
+
kind: 'date';
|
|
3376
|
+
year?: number;
|
|
3377
|
+
month: number;
|
|
3378
|
+
day: number;
|
|
3379
|
+
} | {
|
|
3380
|
+
kind: 'span';
|
|
3381
|
+
from: {
|
|
3382
|
+
year?: number;
|
|
3383
|
+
month: number;
|
|
3384
|
+
day: number;
|
|
3385
|
+
};
|
|
3386
|
+
to: {
|
|
3387
|
+
year?: number;
|
|
3388
|
+
month: number;
|
|
3389
|
+
day: number;
|
|
3390
|
+
};
|
|
3391
|
+
} | {
|
|
3392
|
+
kind: 'dom';
|
|
3393
|
+
day: number | 'last';
|
|
3394
|
+
} | {
|
|
3395
|
+
kind: 'nth';
|
|
3396
|
+
weekday: number;
|
|
3397
|
+
n: number | 'last';
|
|
3398
|
+
} | {
|
|
3399
|
+
kind: 'season';
|
|
3400
|
+
season: Season;
|
|
3401
|
+
} | {
|
|
3402
|
+
kind: 'holiday';
|
|
3403
|
+
id: string;
|
|
3404
|
+
};
|
|
3405
|
+
/** What a token says, or why it says nothing. */
|
|
3406
|
+
declare function parseDayToken(raw: string): {
|
|
3407
|
+
token: Parsed;
|
|
3408
|
+
negated: boolean;
|
|
3409
|
+
} | {
|
|
3410
|
+
problem: string;
|
|
3411
|
+
};
|
|
3412
|
+
/** What is wrong with a list of day tokens, each with where it is. `holidays` are those the world names, when `holiday:` may be used. */
|
|
3413
|
+
declare function dayTokenProblems(tokens: readonly string[], path: string, holidays?: ReadonlySet<string> | 'any'): string[];
|
|
3414
|
+
/** The season a day is in, by the months of its hemisphere (winter is December to February in the north, June to August in the south). */
|
|
3415
|
+
declare function seasonOf(day: Pick<CalendarDay, 'month'>, hemisphere?: Hemisphere): Season;
|
|
3416
|
+
/** Whether a list of day tokens holds on a day; tokens that say nothing sensible count as not matching. An empty list holds on every day. */
|
|
3417
|
+
declare function dayMatches(tokens: readonly string[], day: CalendarDay, calendar?: Calendar): boolean;
|
|
3418
|
+
/** The holidays that fall on a day. A holiday is told by days that are no holidays themselves, so that none can lead back to itself. */
|
|
3419
|
+
declare function holidaysOn(calendar: Calendar, day: CalendarDay): Holiday[];
|
|
3420
|
+
/** The calendar a story was started with, from its metadata; none when the world has none. */
|
|
3421
|
+
declare function readCalendar(metadata: {
|
|
3422
|
+
getValue(key: string): unknown;
|
|
3423
|
+
}): Calendar;
|
|
3424
|
+
declare const writeCalendar: (metadata: {
|
|
3425
|
+
setValue(key: string, value: never): void;
|
|
3426
|
+
}, calendar: Calendar) => void;
|
|
3427
|
+
//#endregion
|
|
3253
3428
|
//#region src/records/agenda.d.ts
|
|
3254
3429
|
/** One occurrence of a routine window: the stretch of time it holds on a particular day. */
|
|
3255
3430
|
interface Occurrence {
|
|
@@ -3260,9 +3435,9 @@ interface Occurrence {
|
|
|
3260
3435
|
/** An engagement still pending this long after it was due (or over) is overdue. */
|
|
3261
3436
|
declare const ENGAGEMENT_GRACE: number;
|
|
3262
3437
|
/** The window that holds at an instant (the first of the list that does), with the stretch of this occurrence of it. */
|
|
3263
|
-
declare function occurrenceAt(windows: readonly StoredRoutineWindow[], now: number, zone: string): Occurrence | undefined;
|
|
3438
|
+
declare function occurrenceAt(windows: readonly StoredRoutineWindow[], now: number, zone: string, calendar?: Calendar): Occurrence | undefined;
|
|
3264
3439
|
/** The window that starts next after an instant, within `horizon`. */
|
|
3265
|
-
declare function nextOccurrence(windows: readonly StoredRoutineWindow[], now: number, zone: string, horizon: number): Occurrence | undefined;
|
|
3440
|
+
declare function nextOccurrence(windows: readonly StoredRoutineWindow[], now: number, zone: string, horizon: number, calendar?: Calendar): Occurrence | undefined;
|
|
3266
3441
|
interface RankedGoal {
|
|
3267
3442
|
intent: CharacterIntent;
|
|
3268
3443
|
/** The deadline as an instant, when it has one that can be read. */
|
|
@@ -3296,6 +3471,9 @@ declare function agendaAt(source: {
|
|
|
3296
3471
|
routines: Pick<RoutineRepository, 'list'>;
|
|
3297
3472
|
engagements: Pick<EngagementRepository, 'list'>;
|
|
3298
3473
|
intents: Pick<IntentRepository, 'list'>;
|
|
3474
|
+
metadata?: {
|
|
3475
|
+
getValue(key: string): unknown;
|
|
3476
|
+
};
|
|
3299
3477
|
}, characterId: CharacterId, now: number, zone: string, options?: AgendaOptions): Agenda;
|
|
3300
3478
|
//#endregion
|
|
3301
3479
|
//#region src/sqlite/agenda-repositories.d.ts
|
|
@@ -3341,16 +3519,16 @@ declare function zonedInstant(fields: {
|
|
|
3341
3519
|
* @throws {RangeError} when it is not a date and time.
|
|
3342
3520
|
*/
|
|
3343
3521
|
declare function parseInstant(text: string, zone: string): number;
|
|
3344
|
-
/** `Tuesday 4 October 1912, 21:40`. */
|
|
3345
|
-
declare function describeInstant(instant: number, zone: string): string;
|
|
3522
|
+
/** `Tuesday 4 October 1912, 21:40`, or `1912年10月4日 星期二 21:40`. */
|
|
3523
|
+
declare function describeInstant(instant: number, zone: string, language?: 'en' | 'zh'): string;
|
|
3346
3524
|
/** `1912-10-04T21:40:00` as the wall clock of a zone reads, the form a file or a person can write back. */
|
|
3347
3525
|
declare function localIso(instant: number, zone: string): string;
|
|
3348
3526
|
declare const DAY_PARTS: readonly ["night", "morning", "afternoon", "evening"];
|
|
3349
3527
|
type DayPart = (typeof DAY_PARTS)[number];
|
|
3350
3528
|
/** Night is from 22:00 to 05:00, morning to 12:00, afternoon to 17:00, evening after. */
|
|
3351
3529
|
declare function dayPart(minuteOfDay: number): DayPart;
|
|
3352
|
-
/** In words and rounded to what matters: `45 seconds`, `3 hours 12 minutes`, `2 days 3 hours
|
|
3353
|
-
declare function describeDuration(milliseconds: number): string;
|
|
3530
|
+
/** In words and rounded to what matters: `45 seconds`, `3 hours 12 minutes`, `2 days 3 hours`; or `45秒`, `3小时12分钟`, `2天3小时`. */
|
|
3531
|
+
declare function describeDuration(milliseconds: number, language?: 'en' | 'zh'): string;
|
|
3354
3532
|
/** The minute of the day for `HH:MM` (24-hour), or nothing when it is not one. */
|
|
3355
3533
|
declare function parseTimeOfDay(text: string): number | undefined;
|
|
3356
3534
|
/**
|
|
@@ -3461,5 +3639,5 @@ type LintTarget = Pick<RecordsTarget, 'characters' | 'locations' | 'placements'
|
|
|
3461
3639
|
*/
|
|
3462
3640
|
declare function lintWorld(target: LintTarget): LintFinding[];
|
|
3463
3641
|
//#endregion
|
|
3464
|
-
export { ACCURACIES, Accuracy, type Agenda, type AgendaEngagement, type AgendaOptions, type AgentLink, type AgentResolver, type Announcement, type BeliefEdit, CHARACTER_CONTROLS, CHARACTER_KINDS, CHARACTER_ROLES, CHARACTER_TIERS, CLOCK_MODES, COMPARISONS, CONSOLIDATION_KINDS, CONTAINER_STATES, Character, CharacterControl, CharacterDefinition, CharacterFilter, CharacterId, CharacterIntent, CharacterKind, CharacterMemory, CharacterMemoryPatch, type CharacterMove, CharacterPatch, type CharacterRepository, CharacterRole, CharacterSpeech, CharacterStart, CharacterState, CharacterStatePatch, type CharacterStateRepository, CharacterTier, type Clarity, type Clock, ClockMode, ClockState, Comparison, Config, ConflictError, ConsolidationItem, ConsolidationItemId, ConsolidationKind, type ConsolidationRepository, ContainerSpec, ContainerState, CorruptDataError, DAY, DAY_PARTS, DEFAULT_MEMORY_POLICY, DEFAULT_SLOTS, type DayPart, type Delivery, EMOTION_VARIABLES, ENGAGEMENT_GRACE, ENGAGEMENT_STATUSES, EXIT_STATES, type EditChecker, type EditResult, EmbeddingIndexInfo, EmotionStart, EmotionVector, Engagement, EngagementFilter, EngagementId, EngagementPatch, EngagementStatus, EntityKnowledge, type EventEdit, EventId, type EventRepository, Exit, type ExitChange, ExitDefinition, ExitId, ExitOpener, ExitPatch, ExitState, Faction, FactionDefinition, FactionId, FactionIntent, type FactionIntentRepository, FactionMembership, FactionMembershipDefinition, type FactionMembershipRepository, FactionPatch, FactionRelationship, FactionRelationshipDefinition, type FactionRelationshipRepository, type FactionRepository, FactionState, FactionStatePatch, type FactionStateRepository, type FiredTrigger, HOUR, Holder, Holding, IMPORTANCE_MAX, IMPORTANCE_MIN, INTENT_HORIZONS, INTENT_STATUSES, INTENT_TYPES, ITEM_ACTIONS, Intent, IntentFilter, IntentHorizon, IntentId, IntentPatch, type IntentRepository, IntentStatus, IntentType, InvalidEditError, InvalidMoveError, InvalidValueError, Item, type ItemAction, type ItemChange, type ItemChangeSpec, type ItemContext, ItemDefinition, type ItemEditSpec, type ItemEffect, ItemId, ItemPatch, type ItemPlan, type ItemRepository, JsonValue, KNOWLEDGE_KINDS, KnowledgeDefinition, KnowledgeKind, type KnowledgeRepository, type KnownMoveContext, LORE_KINDS, LORE_SUBJECT_KINDS, type LintFinding, type LintSeverity, type LintTarget, type LocalTime, Location, LocationDefinition, LocationFeature, LocationId, LocationPatch, type LocationRepository, Lore, LoreDefinition, LoreId, LoreKind, LorePatch, LoreSubject, LoreSubjectDefinition, LoreSubjectKind, MAX_LOCATION_FEATURES, MAX_ROUTINE_WINDOWS, MAX_SHOWN, MAX_TRIGGERS, MAX_VARIABLES, MEMBERSHIP_STATUSES, MEMORY_KINDS, MIGRATION_BACKUP_FOLDER, MINUTE, MembershipPatch, MembershipStatus, MemoryId, MemoryKind, type MemoryPolicy, type MemoryRepository, type MetadataRepository, Move, type MoveContext, MovePlan, type NewBelief, NewCharacter, NewCharacterMemory, type NewCharacterSpec, NewCharacterState, NewEngagement, type NewEvent, NewExit, type NewExitBetween, type NewExit$1 as NewExitEdit, NewFaction, NewFactionState, NewItem, type NewItemSpec, NewLocation, NewLore, NewPerception, type NewPlace, NewPlacement, NewRelationship, NewSession, NewStoryEvent, NewSummary, NewTriggerNote, NotFoundError, type Occurrence, type OpenOptions, PERCEPTION_MODES, PLACEABLE_KINDS, PLOT_NUDGE_MODES, PLOT_STATUSES, PendingCommit, type PendingCommitRepository, PendingEmbedding, type PerceivedBy, PerceivedEvent, Perception, type PerceptionAddition, type PerceptionEdit, PerceptionId, PerceptionMode, PerceptionPatch, type PlaceEdit, PlaceableKind, type Placeholder, Placement, type PlacementRepository, PlotDefinition, PlotDevelopment, PlotNudgeMode, PlotProgress, PlotStatus, RECALL_ITEM_KINDS, type RankedGoal, type RecallCandidate, type RecallEvidence, RecallHit, type RecallIndexRepository, RecallItemKind, type RecallPool, type RecallQuery, type RecallSearch, type RecallSource, type RecallWhy, type Recalled, type RecordsEdit, type RecordsScope, type RecordsTarget, type RecordsView, Relationship, RelationshipDefinition, RelationshipId, RelationshipPatch, type RelationshipRepository, type RelationshipRetraction, type RelationshipSet, RoleplayState, RoutineDefinition, RoutineWindow, type RunResult, LATEST_VERSION as SCHEMA_VERSION, SECOND, SELF, SESSION_DATABASE_FILE, SLOT_ID, SUMMARY_LEVELS, SchemaError, type SemanticRanker, type Session, type SessionInit, type SessionListing, SessionMetadata, type SessionStore, type ShownVariable, Slot, type SlotRepository, SocialSubjectKind, type SqlDatabase, type SqlDriver, type SqlValue, StateError, type StatePatch, type StoreOptions, StoredRoutineWindow, StoredVariable, StoryEvent, StoryEventFilter, StoryEventPatch, StoryThread, Summary, SummaryId, SummaryLevel, type SummaryRepository, TEMPLATE_KINDS, THREAD_STATUSES, TIME_CHANGE_KINDS, TRIGGER_NOTE_KINDS, TRIGGER_STATUSES, type TemplateKind, ThreadId, type ThreadRepository, ThreadStatus, TimeChange, TimeChangeFilter, TimeChangeKind, Trigger, TriggerAnnouncement, TriggerAudience, type TriggerClock, TriggerCondition, TriggerDefinition, TriggerEffect, TriggerId, TriggerNote, TriggerNoteKind, type TriggerRun, type TriggerRunOptions, TriggerStatus, UnwritableError, VARIABLE_KEY, VARIABLE_KINDS, VARIABLE_SUBJECTS, VARIABLE_VISIBILITIES, VISUAL_SUBJECT_KINDS, type VariableAudience, VariableBand, type VariableChangeSpec, type VariableContext, VariableDefinition, VariableDefinitionInput, type VariableEffect, VariableKind, type VariablePlan, VariableSubject, VariableValue, VariableVisibility, type VectorSearch, type VectorSupport, VisualIdentity, VisualIdentityInput, VisualIdentityPatch, type VisualIdentityRepository, VisualSubjectKind, WEEKDAY_NAMES, WorldReference, addLocalDays, agendaAt, announcements, apply, applyItemPlan, applyRecordsEdit, audienceIds, catchUpPlan, changeItem, changeVariable, characterKey, clarityAt, clockTime, conditionHolds, createCharacterTools, createSession, createSessionStore, createTools, dayPart, deleteSession, deliverNotes, denseScore, describeDuration, describeHolder, describeInstant, describeValue, finishRecall, fuseScores, inAudience, inWindow, isSessionId, isTimeZone, itemKey, jitter, judgedStatements, lapseNotes, lintWorld, listSessions, localIso, localTime, locationKey, mentioned, migrationBackupPath, moveCharacter, name, nextOccurrence, nextTimeOfDay, nodeSqliteDriver, occurrenceAt, openSession, openSessionStore, overlap, parseInstant, parseRecordsEdit, parseTimeOfDay, parseTriggerDefinition, placeholdersOf, planItemChange, planKnownMove, planMove, planVariableChange, poolCandidates, rankGoals, readRecords, readTriggerDefinition, recall, recallCandidates, recallPool, recordsEditSchema, renderWords, retention, runTriggers, seededRoll, sessionDatabase, sessionFolder, shownVariables, subjectOf, systemClock, systemTimeZone, tokens, triggerReferenceProblems, valueIssue, zonedInstant };
|
|
3642
|
+
export { ACCURACIES, Accuracy, type Agenda, type AgendaEngagement, type AgendaOptions, type AgentLink, type AgentResolver, type Announcement, type BeliefEdit, CHARACTER_CONTROLS, CHARACTER_KINDS, CHARACTER_ROLES, CHARACTER_TIERS, CLOCK_MODES, COMPARISONS, CONSOLIDATION_KINDS, CONTAINER_STATES, type Calendar, type CalendarDay, Character, CharacterControl, CharacterDefinition, CharacterFilter, CharacterId, CharacterIntent, CharacterKind, CharacterMemory, CharacterMemoryPatch, type CharacterMove, CharacterPatch, type CharacterRepository, CharacterRole, CharacterSpeech, CharacterStart, CharacterState, CharacterStatePatch, type CharacterStateRepository, CharacterTier, type Clarity, type Clock, ClockMode, ClockState, Comparison, Config, ConflictError, ConsolidationItem, ConsolidationItemId, ConsolidationKind, type ConsolidationRepository, ContainerSpec, ContainerState, CorruptDataError, DAY, DAY_PARTS, DEFAULT_CONFIDENCE, DEFAULT_MEMORY_POLICY, DEFAULT_SLOTS, type DayPart, type Delivery, EMOTION_VARIABLES, ENGAGEMENT_GRACE, ENGAGEMENT_STATUSES, EVIDENCE_RELATIONS, EXIT_STATES, type EditChecker, type EditResult, EmbeddingIndexInfo, EmotionStart, EmotionVector, Engagement, EngagementFilter, EngagementId, EngagementPatch, EngagementStatus, EntityKnowledge, type EventEdit, EventId, type EventRepository, EvidenceRelation, Exit, type ExitChange, ExitDefinition, ExitId, ExitOpener, ExitPatch, ExitState, Faction, FactionDefinition, FactionId, FactionIntent, type FactionIntentRepository, FactionMembership, FactionMembershipDefinition, type FactionMembershipRepository, FactionPatch, FactionRelationship, FactionRelationshipDefinition, type FactionRelationshipRepository, type FactionRepository, FactionState, FactionStatePatch, type FactionStateRepository, type FiredTrigger, HOUR, type Hemisphere, Holder, Holding, type Holiday, IMPORTANCE_MAX, IMPORTANCE_MIN, INTENT_HORIZONS, INTENT_STATUSES, INTENT_TYPES, ITEM_ACTIONS, Intent, IntentFilter, IntentHorizon, IntentId, IntentPatch, type IntentRepository, IntentStatus, IntentType, InvalidEditError, InvalidMoveError, InvalidValueError, Item, type ItemAction, type ItemChange, type ItemChangeSpec, type ItemContext, ItemDefinition, type ItemEditSpec, type ItemEffect, ItemId, ItemPatch, type ItemPlan, type ItemRepository, JsonValue, KNOWLEDGE_KINDS, KnowledgeDefinition, KnowledgeKind, type KnowledgeRepository, type KnownMoveContext, LANGUAGES, LORE_KINDS, LORE_SUBJECT_KINDS, Language, type LintFinding, type LintSeverity, type LintTarget, type LocalTime, Location, LocationDefinition, LocationFeature, LocationId, LocationPatch, type LocationRepository, Lore, LoreDefinition, LoreId, LoreKind, LorePatch, LoreSubject, LoreSubjectDefinition, LoreSubjectKind, MAX_LOCATION_FEATURES, MAX_ROUTINE_WINDOWS, MAX_SHOWN, MAX_TRIGGERS, MAX_VARIABLES, MEMBERSHIP_STATUSES, MEMORY_CONFIDENCES, MEMORY_KINDS, MIGRATION_BACKUP_FOLDER, MINUTE, MONTH_NAMES, MembershipPatch, MembershipStatus, MemoryConfidence, MemoryEvidence, MemoryId, MemoryKind, type MemoryPolicy, type MemoryRepository, MessageValues, type MetadataRepository, Move, type MoveContext, MovePlan, NO_CALENDAR, type NewBelief, NewCharacter, NewCharacterMemory, type NewCharacterSpec, NewCharacterState, NewEngagement, type NewEvent, NewExit, type NewExitBetween, type NewExit$1 as NewExitEdit, NewFaction, NewFactionState, NewItem, type NewItemSpec, NewLocation, NewLore, NewPerception, type NewPlace, NewPlacement, NewRelationship, NewSession, NewStoryEvent, NewSummary, NewTriggerNote, NotFoundError, type Occurrence, type OpenOptions, PERCEPTION_MODES, PLACEABLE_KINDS, PLOT_NUDGE_MODES, PLOT_STATUSES, PendingCommit, type PendingCommitRepository, PendingEmbedding, type PerceivedBy, PerceivedEvent, Perception, type PerceptionAddition, type PerceptionEdit, PerceptionId, PerceptionMode, PerceptionPatch, type PlaceEdit, PlaceableKind, type Placeholder, Placement, type PlacementRepository, PlotDefinition, PlotDevelopment, PlotNudgeMode, PlotProgress, PlotStatus, RECALL_ITEM_KINDS, type RankedGoal, type RecallCandidate, type RecallEvidence, RecallHit, type RecallIndexRepository, RecallItemKind, type RecallPool, type RecallQuery, type RecallSearch, type RecallSource, type RecallWhy, type Recalled, type RecordsEdit, type RecordsScope, type RecordsTarget, type RecordsView, Relationship, RelationshipDefinition, RelationshipId, RelationshipPatch, type RelationshipRepository, type RelationshipRetraction, type RelationshipSet, RoleplayState, RoutineDefinition, RoutineWindow, type RunResult, LATEST_VERSION as SCHEMA_VERSION, SEASONS, SECOND, SELF, SESSION_DATABASE_FILE, SLOT_ID, SUMMARY_LEVELS, SchemaError, type Season, type SemanticRanker, type Session, type SessionInit, type SessionListing, SessionMetadata, type SessionStore, type ShownVariable, Slot, type SlotRepository, SocialSubjectKind, type SqlDatabase, type SqlDriver, type SqlValue, StateError, type StatePatch, type StoreOptions, StoredRoutineWindow, StoredVariable, StoryEvent, StoryEventFilter, StoryEventPatch, StoryThread, Summary, SummaryId, SummaryLevel, type SummaryRepository, TEMPLATE_KINDS, THREAD_STATUSES, TIME_CHANGE_KINDS, TRIGGER_NOTE_KINDS, TRIGGER_STATUSES, type TemplateKind, ThreadId, type ThreadRepository, ThreadStatus, TimeChange, TimeChangeFilter, TimeChangeKind, Translate, Trigger, TriggerAnnouncement, TriggerAudience, type TriggerClock, TriggerCondition, TriggerDefinition, TriggerEffect, TriggerId, TriggerNote, TriggerNoteKind, type TriggerRun, type TriggerRunOptions, TriggerStatus, UnwritableError, VARIABLE_KEY, VARIABLE_KINDS, VARIABLE_SUBJECTS, VARIABLE_VISIBILITIES, VISUAL_SUBJECT_KINDS, type VariableAudience, VariableBand, type VariableChangeSpec, type VariableContext, VariableDefinition, VariableDefinitionInput, type VariableEffect, VariableKind, type VariablePlan, VariableSubject, VariableValue, VariableVisibility, type VectorSearch, type VectorSupport, VisualIdentity, VisualIdentityInput, VisualIdentityPatch, type VisualIdentityRepository, VisualSubjectKind, WEEKDAY_NAMES, WorldReference, addLocalDays, agendaAt, announcements, apply, applyItemPlan, applyRecordsEdit, audienceIds, catchUpPlan, changeItem, changeVariable, characterKey, clarityAt, clockTime, conditionHolds, createCharacterTools, createSession, createSessionStore, createTools, dayMatches, dayPart, dayTokenProblems, deleteSession, deliverNotes, denseScore, describeDuration, describeHolder, describeInstant, describeValue, finishRecall, fuseScores, holidaysOn, inAudience, inWindow, isSessionId, isTimeZone, itemKey, jitter, judgedStatements, languageOf, lapseNotes, lintWorld, listSessions, localIso, localTime, locationKey, mentioned, migrationBackupPath, moveCharacter, name, nextOccurrence, nextTimeOfDay, nodeSqliteDriver, occurrenceAt, openSession, openSessionStore, overlap, parseDayToken, parseInstant, parseRecordsEdit, parseTimeOfDay, parseTriggerDefinition, placeholdersOf, planItemChange, planKnownMove, planMove, planVariableChange, poolCandidates, rankGoals, readCalendar, readRecords, readTriggerDefinition, recall, recallCandidates, recallPool, recordsEditSchema, renderWords, retention, runTriggers, seasonOf, seededRoll, sessionDatabase, sessionFolder, shownVariables, subjectOf, systemClock, systemTimeZone, tokens, translated, translation, translator, triggerReferenceProblems, valueIssue, writeCalendar, zonedInstant };
|
|
3465
3643
|
//# sourceMappingURL=index.d.ts.map
|