@onlyworlds/sdk 4.85.0 → 4.87.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/AGENTS.md +4 -0
- package/CHANGELOG.md +13 -0
- package/README.md +8 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +263 -31
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -89,6 +89,10 @@ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum)
|
|
|
89
89
|
- Lookup without a model (since 4.11.0): `buildWorldIndex(elements)` then
|
|
90
90
|
`lookupWorld(index, question)` ranks the elements a question is about (names, then kind, one
|
|
91
91
|
link step, then text); `renderElement(el, index)` is a compact card with links by name.
|
|
92
|
+
- A Character's context as text: `draughtText(draught)` turns a `draught(characterId)` packet,
|
|
93
|
+
full or compact, into plain text, read from the packet alone (the same bytes as the Python
|
|
94
|
+
package's `draught_text`). Its title says "dated up to" the horizon, never what the Character
|
|
95
|
+
knew; its last line counts only what the budget left out.
|
|
92
96
|
- Photos (browser only, since 4.11.0): `preparePhoto(blob)` shrinks to 2048 px and converts to
|
|
93
97
|
webp (JPEG where webp can't be encoded) before `uploadImage`.
|
|
94
98
|
- World files (no account needed; since 4.10.0): `readWorldFile(bytes)` opens a `.zip` holding one
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.87.0] - 2026-10-26
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **`draughtText` names what the date horizon left out.** When the draught has an `as_of`, a line above the budget line says it: `Not listed: rows dated after Year 300.` when the read was the Character's own view (`mode: voice`, where the horizon fences every section), and `Not listed: Events, Knowledge and proposed Events or Narratives dated after Year 300.` when it was the caller's (`act`, where it fences only those). The packet carries no count of those rows, so the line gives none. Before, only the title said the horizon, and `Left out by the budget: nothing.` could be read as a complete record when the text was pasted alone.
|
|
13
|
+
- **A removed member reads `removed from the world`**, not `removed`, so the word cannot be read as part of the member's name. The shared fixture's expected texts are regenerated (45 of 47 cases change; the two with no `as_of` are unchanged), and the Python package's `draught_text` gives the same bytes from 0.71.0.
|
|
14
|
+
|
|
15
|
+
## [4.86.0] - 2026-10-26
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`draughtText(draught)`**: one Character's context packet (`draught(characterId)`, full or compact) as plain text to paste into a prompt or a note, the same bytes from both packages and held to them by one shared fixture (47 cases, the full and compact reads of each giving the same text). It reads the packet alone and calls nothing: a link the packet does not hold is counted, never looked up. The title claims only the read's horizon ("dated up to Year 300"), never what the Character knew; every row says how it was reached (`via`), its grade or date, and the marks hidden and proposed; the sections that hold nothing are named on one line, and the last line says only what the budget left out (`cut`). Nothing is trimmed or cut by length, so the two languages cannot disagree on where a string ends. One known difference between a full and a compact read: the server's compact form drops an empty `x_review_proposed` (`""`, `[]`, `{}`), which the full read counts as proposed. The Python package's `draught_text` (0.70.0) gives the same text.
|
|
20
|
+
|
|
8
21
|
## [4.85.0] - 2026-10-26
|
|
9
22
|
|
|
10
23
|
### Changed
|
package/README.md
CHANGED
|
@@ -268,6 +268,14 @@ Asking and sorting spend tokens from the account's token rating, its daily budge
|
|
|
268
268
|
const { token_rating, tokens_remaining, resets_at } = await account.allowance(); // resets_at: the next midnight UTC
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
+
### A Character's context as text
|
|
272
|
+
|
|
273
|
+
`draughtText(draught)` gives one Character's context packet (`draught(characterId)`, full or `compact`) as plain text to paste into a prompt or a note. It reads the packet alone and calls nothing, and the Python package's `draught_text` gives the same bytes. The title claims only the read's horizon ("dated up to Year 300"), never what the Character knew, and the last line says only what the budget left out (`cut`).
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
const text = draughtText(await client.draught(characterId));
|
|
277
|
+
```
|
|
278
|
+
|
|
271
279
|
## World files
|
|
272
280
|
|
|
273
281
|
A world file (`.owworld`, a `.zip` by another name) is one archive holding a whole world folder (`world.json` and `elements/<type>/*.json`, as Atlas keeps a world on disk), the way Atlas downloads and opens one. It needs no account and works in the browser and in Node. Both functions follow the Folder Format spec's §4.7 and pass its fixture set.
|
package/dist/index.d.ts
CHANGED
|
@@ -5106,6 +5106,21 @@ interface OwAskContext {
|
|
|
5106
5106
|
*/
|
|
5107
5107
|
declare function buildAskContext<T extends OwLookupElement>(items: Array<OwLookupHit<T> | T>, index: OwWorldIndex<T>, opts?: OwAskContextOptions): OwAskContext;
|
|
5108
5108
|
|
|
5109
|
+
/**
|
|
5110
|
+
* The draught as plain text: a `#` title, `##` sections and `- ` rows, LF line endings and one
|
|
5111
|
+
* newline at the end. The same read gives the same text served full or `compact`.
|
|
5112
|
+
*
|
|
5113
|
+
* The frame says what the packet does: the horizon (`as_of`), the world's now, and whose view it
|
|
5114
|
+
* was read through (`mode`). Her own element prints whole; every other row prints its name, type
|
|
5115
|
+
* and kind, how it reached her (`via`), its grade or date, the marks `hidden` and `proposed`, and
|
|
5116
|
+
* its description. The sections that hold nothing are named on one line; what the date horizon left
|
|
5117
|
+
* out is named (never counted: the packet carries no count), and what the budget left out (`cut`) is
|
|
5118
|
+
* always said.
|
|
5119
|
+
*
|
|
5120
|
+
* A draught that is not an object, or has no `world` object, is a TypeError. Takes no options.
|
|
5121
|
+
*/
|
|
5122
|
+
declare function draughtText(draught: OwDraught | OwDraughtCompact): string;
|
|
5123
|
+
|
|
5109
5124
|
/**
|
|
5110
5125
|
* Photo preparation: make a picture from a phone's camera or files ready for
|
|
5111
5126
|
* `uploadImage` (webp, png, jpeg or avif, at most 15 MB), in the browser,
|
|
@@ -5759,4 +5774,4 @@ declare class TokenResource {
|
|
|
5759
5774
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
5760
5775
|
}
|
|
5761
5776
|
|
|
5762
|
-
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, MESSAGE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtPolicy, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, handsOnAsProposed, intercalaryInYear, isAddressedTo, isAgentDoor, isDemoKey, isKnownOf, isLeapYear, isMessage, isParseError, isRoomElement, isSentBy, isToEveryone, kindCanWrite, lookupWorld, monthStartSteps, nfc, parseDate, parseErrorEnvelope, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
|
5777
|
+
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, MESSAGE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtPolicy, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, draughtText, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, handsOnAsProposed, intercalaryInYear, isAddressedTo, isAgentDoor, isDemoKey, isKnownOf, isLeapYear, isMessage, isParseError, isRoomElement, isSentBy, isToEveryone, kindCanWrite, lookupWorld, monthStartSteps, nfc, parseDate, parseErrorEnvelope, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -406,12 +406,12 @@ function parseRetryAfter(value, now = Date.now()) {
|
|
|
406
406
|
}
|
|
407
407
|
async function errorFromResponse(res) {
|
|
408
408
|
let body = null;
|
|
409
|
-
let
|
|
409
|
+
let text2 = "";
|
|
410
410
|
try {
|
|
411
|
-
|
|
412
|
-
body =
|
|
411
|
+
text2 = await res.text();
|
|
412
|
+
body = text2 ? JSON.parse(text2) : null;
|
|
413
413
|
} catch {
|
|
414
|
-
body =
|
|
414
|
+
body = text2 || null;
|
|
415
415
|
}
|
|
416
416
|
return parseErrorEnvelope(res.status, body, parseRetryAfter(res.headers?.get?.("Retry-After") ?? null));
|
|
417
417
|
}
|
|
@@ -1285,7 +1285,7 @@ var OwV2Client = class {
|
|
|
1285
1285
|
throw new TypeError("signInWithPassword needs a tokenName: the name the new token is listed under");
|
|
1286
1286
|
}
|
|
1287
1287
|
const auth = `${this.baseUrl}/auth/app/v1`;
|
|
1288
|
-
const safe = (
|
|
1288
|
+
const safe = (text2, fallback) => typeof text2 === "string" && text2 !== "" && !text2.includes(password) ? text2 : fallback;
|
|
1289
1289
|
let res;
|
|
1290
1290
|
try {
|
|
1291
1291
|
res = await this.fetchImpl(`${auth}/auth/login`, {
|
|
@@ -1880,8 +1880,8 @@ var OwV2Client = class {
|
|
|
1880
1880
|
if (!res.ok) throw await errorFromResponse(res);
|
|
1881
1881
|
if (opts.proposable && res.status === 202) throw await proposedFromResponse(res, method, path);
|
|
1882
1882
|
if (res.status === 204 || opts.allowEmpty) {
|
|
1883
|
-
const
|
|
1884
|
-
return
|
|
1883
|
+
const text2 = await res.text();
|
|
1884
|
+
return text2 ? JSON.parse(text2) : null;
|
|
1885
1885
|
}
|
|
1886
1886
|
const parsed = await res.json();
|
|
1887
1887
|
if (opts.replayAware && parsed && typeof parsed === "object") {
|
|
@@ -1948,8 +1948,8 @@ async function endAuthSession(fetchImpl, auth, session) {
|
|
|
1948
1948
|
}
|
|
1949
1949
|
async function readJsonBody(res) {
|
|
1950
1950
|
try {
|
|
1951
|
-
const
|
|
1952
|
-
return
|
|
1951
|
+
const text2 = await res.text();
|
|
1952
|
+
return text2 ? JSON.parse(text2) : null;
|
|
1953
1953
|
} catch {
|
|
1954
1954
|
return null;
|
|
1955
1955
|
}
|
|
@@ -2034,13 +2034,13 @@ function xhrUpload(XHR, url, headers, body, total, onProgress) {
|
|
|
2034
2034
|
}
|
|
2035
2035
|
const ok = status >= 200 && status < 300;
|
|
2036
2036
|
if (ok && last !== total) report(total);
|
|
2037
|
-
const
|
|
2037
|
+
const text2 = typeof xhr.responseText === "string" ? xhr.responseText : "";
|
|
2038
2038
|
resolve({
|
|
2039
2039
|
ok,
|
|
2040
2040
|
status,
|
|
2041
2041
|
headers: { get: (n) => xhr.getResponseHeader(n) },
|
|
2042
|
-
text: async () =>
|
|
2043
|
-
json: async () => JSON.parse(
|
|
2042
|
+
text: async () => text2,
|
|
2043
|
+
json: async () => JSON.parse(text2)
|
|
2044
2044
|
});
|
|
2045
2045
|
};
|
|
2046
2046
|
xhr.send(body);
|
|
@@ -3056,17 +3056,17 @@ function load() {
|
|
|
3056
3056
|
for (const c of raw.keys()) full(c);
|
|
3057
3057
|
return { ccc, decomp, compose };
|
|
3058
3058
|
}
|
|
3059
|
-
function nfc(
|
|
3059
|
+
function nfc(text2) {
|
|
3060
3060
|
let plain = true;
|
|
3061
|
-
for (let i = 0; i <
|
|
3061
|
+
for (let i = 0; i < text2.length; i++) if (text2.charCodeAt(i) >= 192) {
|
|
3062
3062
|
plain = false;
|
|
3063
3063
|
break;
|
|
3064
3064
|
}
|
|
3065
|
-
if (plain) return
|
|
3065
|
+
if (plain) return text2;
|
|
3066
3066
|
const t = tables ?? (tables = load());
|
|
3067
3067
|
const cls = (c) => t.ccc.get(c) ?? 0;
|
|
3068
3068
|
const cps = [];
|
|
3069
|
-
for (const ch of
|
|
3069
|
+
for (const ch of text2) {
|
|
3070
3070
|
const c = ch.codePointAt(0);
|
|
3071
3071
|
const s = c - S_BASE;
|
|
3072
3072
|
if (s >= 0 && s < S_COUNT) {
|
|
@@ -3174,7 +3174,7 @@ function isJunk(path) {
|
|
|
3174
3174
|
}
|
|
3175
3175
|
var FOLD_RUNS = "1t.q..w,51...lj,5c.n..w,60.7..w,74.o.2.1,8i.3.2.1,8p.8.2.1,96.n.2.1,ag...-3d,ah.3.2.1,an...-7g,ap...5u,aq.2.2.1,au...5q,av...1,ax.2..5p,az...1,b2...27,b3...5m,b4...5n,b5...1,b7...5p,b8...5r,ba...5v,bb...5t,bc...1,bg...5v,bh...5x,bj...5y,bk.3.2.1,bq...62,br...1,bt...62,bw...1,by...62,bz...1,c1.2..61,c3.2.2.1,c7...63,c8...1,cc...1,ck...2,cl...1,cn...2,co...1,cq...2,cr.9.2.1,da.9.2.1,dt...2,du.2.2.1,dy...-2p,dz...-1k,e0.k.2.1,f4...-3m,f6.9.2.1,fu...8bv,fv...1,fx...-4j,fy...8bs,g1...1,g3...-5f,g4...1x,g5...1z,g6.5.2.1,n9...38,og.2.2.1,om...1,ov...38,p2...12,p4.3..11,p8...1s,pa.2..1r,pd.h..w,pv.9..w,qq...1,r3...8,r4...-u,r5...-p,r9...-f,ra...-m,rc.c.2.1,s0...-1i,s1...-1c,s4...-1o,s5...-1s,s7...1,s9...-7,sa...1,sd.3..-3m,sg.g..28,sw.w..w,v4.h.2.1,wa.r.2.1,xs...f,xt.7.2.1,y8.1c.2.1,10x.12..1c,3a8.12..5ls,3bb...5ls,3bh...5ls,3y0.6..-8,5mo...-4su,5mp...-4st,5mq...-4sk,5mr.2..-4si,5mt...-4sj,5mu...-4sc,5mv...-4ro,5mw...r7n,5n4.17..-2bk,5od.3..-2bk,5xc.23.2.1,61n...-1m,61q...-5vj,61s.1c.2.1,64o.8..-8,654.6..-8,65k.8..-8,660.8..-8,66g.6..-8,66x.4.2.-8,67c.8..-8,688.8..-8,68o.8..-8,694.8..-8,69k.2..-8,69m.2..-22,69o...-9,69q...-5j9,6a0.4..-2e,6a4...-9,6ab...-5kz,6ag.2..-8,6ai.2..-2s,6ar...-5kj,6aw.2..-8,6ay.2..-34,6b0...-7,6bc.2..-3k,6be.2..-3i,6bg...-9,6jq...-5st,6ju...-6gv,6jv...-6di,6k2...s,6lc.g..g,6mb...1,792.q..q,8ow.1c..1c,8rk...1,8rm...-8af,8rn...-2xy,8ro...-89z,8rr.3.2.1,8rx...-8bg,8ry...-8al,8rz...-8bj,8s0...-8bi,8s2...1,8s5...1,8se.2..-8cf,8sg.1e.2.1,8vf.2.2.1,8vm...1,wu8.n.2.1,ww0.e.2.1,x0i.7.2.1,x0y.v.2.1,x2x.2.2.1,x31...-r9g,x32.5.2.1,x3f...1,x3h...-wmg,x3k.2.2.1,x3q.a.2.1,x4a...-wn8,x4b...-wnj,x4c...-wnf,x4d...-wn5,x4e...-wn8,x4g...-wlu,x4h...-wmi,x4i...-wlx,x4j...ps,x4k.8.2.1,x50...-1c,x51...-wn7,x52...-raw,x53.2.2.1,x5c...1,x5i.2.2.1,x6d...1,xv4.28..-tzk,1dl1...1,1ee9.q..w,1fcw.14..14,1fhs.10..14,1fn4.b..13,1fng.f..13,1fnw.7..13,1fo4.2..13,1h1c.1f..1s,1jfk.w..w,20cg.w..w,2olc.y..y";
|
|
3176
3176
|
var foldTable = null;
|
|
3177
|
-
function simpleCaseFold(
|
|
3177
|
+
function simpleCaseFold(text2) {
|
|
3178
3178
|
if (!foldTable) {
|
|
3179
3179
|
foldTable = /* @__PURE__ */ new Map();
|
|
3180
3180
|
for (const run of FOLD_RUNS.split(",")) {
|
|
@@ -3187,7 +3187,7 @@ function simpleCaseFold(text) {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
}
|
|
3189
3189
|
let out = "";
|
|
3190
|
-
for (const c of
|
|
3190
|
+
for (const c of text2) {
|
|
3191
3191
|
const to = foldTable.get(c.codePointAt(0));
|
|
3192
3192
|
out += to === void 0 ? c : String.fromCodePoint(to);
|
|
3193
3193
|
}
|
|
@@ -3656,14 +3656,14 @@ var WHITE_SPACE = /* @__PURE__ */ new Set([
|
|
|
3656
3656
|
8287,
|
|
3657
3657
|
12288
|
|
3658
3658
|
]);
|
|
3659
|
-
function trimWhiteSpace(
|
|
3659
|
+
function trimWhiteSpace(text2) {
|
|
3660
3660
|
let start = 0;
|
|
3661
|
-
let end =
|
|
3662
|
-
while (start < end && WHITE_SPACE.has(
|
|
3663
|
-
while (end > start && WHITE_SPACE.has(
|
|
3664
|
-
return
|
|
3661
|
+
let end = text2.length;
|
|
3662
|
+
while (start < end && WHITE_SPACE.has(text2.charCodeAt(start))) start++;
|
|
3663
|
+
while (end > start && WHITE_SPACE.has(text2.charCodeAt(end - 1))) end--;
|
|
3664
|
+
return text2.slice(start, end);
|
|
3665
3665
|
}
|
|
3666
|
-
var fold = (
|
|
3666
|
+
var fold = (text2) => simpleCaseFold(trimWhiteSpace(text2));
|
|
3667
3667
|
function isRoomElement(el) {
|
|
3668
3668
|
if (el == null || typeof el.type !== "string" || typeof el.supertype !== "string") return false;
|
|
3669
3669
|
const mark = el[ROOM_MARK];
|
|
@@ -4377,25 +4377,256 @@ function buildAskContext(items, index, opts = {}) {
|
|
|
4377
4377
|
out.dropped.push(el.id);
|
|
4378
4378
|
continue;
|
|
4379
4379
|
}
|
|
4380
|
-
let
|
|
4381
|
-
if (isProposed(el))
|
|
4382
|
-
if (chars(
|
|
4383
|
-
|
|
4380
|
+
let text2 = renderElement(el, viewFor(el));
|
|
4381
|
+
if (isProposed(el)) text2 = `[${REVIEW_PROPOSED_LABEL}] ${text2}`;
|
|
4382
|
+
if (chars(text2) > ASK_LIMITS.itemMax) {
|
|
4383
|
+
text2 = cut(text2, ASK_LIMITS.itemMax);
|
|
4384
4384
|
out.truncated.push(el.id);
|
|
4385
4385
|
}
|
|
4386
|
-
if (total + chars(
|
|
4386
|
+
if (total + chars(text2) > ASK_LIMITS.totalMax) {
|
|
4387
4387
|
full = true;
|
|
4388
4388
|
out.truncated = out.truncated.filter((id) => id !== el.id);
|
|
4389
4389
|
out.dropped.push(el.id);
|
|
4390
4390
|
continue;
|
|
4391
4391
|
}
|
|
4392
|
-
total += chars(
|
|
4393
|
-
out.context.push(
|
|
4392
|
+
total += chars(text2);
|
|
4393
|
+
out.context.push(text2);
|
|
4394
4394
|
out.kept.push(el.id);
|
|
4395
4395
|
}
|
|
4396
4396
|
return out;
|
|
4397
4397
|
}
|
|
4398
4398
|
|
|
4399
|
+
// src/draught-text.ts
|
|
4400
|
+
var SECTIONS = [
|
|
4401
|
+
["role", "Role"],
|
|
4402
|
+
["work", "Work"],
|
|
4403
|
+
["style", "Style"],
|
|
4404
|
+
["events", "Events"],
|
|
4405
|
+
["knowledge", "Knowledge"],
|
|
4406
|
+
["names", "Names"],
|
|
4407
|
+
["sheet", "Sheet"],
|
|
4408
|
+
["recent", "Recent"],
|
|
4409
|
+
["messages", "Messages"],
|
|
4410
|
+
["room", "Room"],
|
|
4411
|
+
["proposed", "Proposed"],
|
|
4412
|
+
["roster", "Members"]
|
|
4413
|
+
];
|
|
4414
|
+
var ELEMENT_SECTIONS2 = ["role", "work", "style", "events", "knowledge", "names", "sheet", "messages", "room", "proposed"];
|
|
4415
|
+
var UNPRINTED = /* @__PURE__ */ new Set([
|
|
4416
|
+
"id",
|
|
4417
|
+
"type",
|
|
4418
|
+
"name",
|
|
4419
|
+
"description",
|
|
4420
|
+
"supertype",
|
|
4421
|
+
"subtype",
|
|
4422
|
+
"hidden",
|
|
4423
|
+
"known_of",
|
|
4424
|
+
"x_review_proposed",
|
|
4425
|
+
"image_url",
|
|
4426
|
+
"created_at",
|
|
4427
|
+
"updated_at",
|
|
4428
|
+
"change_seq",
|
|
4429
|
+
"created_by",
|
|
4430
|
+
"changed_by",
|
|
4431
|
+
"changed_via",
|
|
4432
|
+
"changed_client",
|
|
4433
|
+
"world"
|
|
4434
|
+
]);
|
|
4435
|
+
var UNPRINTED_PREFIXES = ["x_", "atlas_", "shadow_"];
|
|
4436
|
+
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4437
|
+
var isInt = (v) => typeof v === "number" && Number.isInteger(v);
|
|
4438
|
+
var own = (o, k) => Object.prototype.hasOwnProperty.call(o, k) ? o[k] : void 0;
|
|
4439
|
+
function isSet(v) {
|
|
4440
|
+
if (v === null || v === void 0 || v === "") return false;
|
|
4441
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
4442
|
+
if (isObj(v)) return Object.keys(v).length > 0;
|
|
4443
|
+
return true;
|
|
4444
|
+
}
|
|
4445
|
+
function text(v) {
|
|
4446
|
+
if (typeof v === "string") return v === "" ? null : v.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
4447
|
+
if (isInt(v)) return BigInt(v).toString();
|
|
4448
|
+
return null;
|
|
4449
|
+
}
|
|
4450
|
+
function typeWordOf(t) {
|
|
4451
|
+
const s = typeof t === "string" ? t : "";
|
|
4452
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
4453
|
+
}
|
|
4454
|
+
function fieldsOf(t) {
|
|
4455
|
+
return typeof t === "string" && Object.prototype.hasOwnProperty.call(FIELD_SCHEMA, t) ? FIELD_SCHEMA[t] : {};
|
|
4456
|
+
}
|
|
4457
|
+
function isLinkField(t, field) {
|
|
4458
|
+
const info = own(fieldsOf(t), field);
|
|
4459
|
+
return isObj(info) && (info.type === "single_link" || info.type === "multi_link");
|
|
4460
|
+
}
|
|
4461
|
+
var isDatedType = (t) => own(fieldsOf(t), "start_date") !== void 0;
|
|
4462
|
+
function kindOf(el) {
|
|
4463
|
+
const sup = text(own(el, "supertype"));
|
|
4464
|
+
const sub = text(own(el, "subtype"));
|
|
4465
|
+
if (sup !== null && sub !== null) return `${sup} / ${sub}`;
|
|
4466
|
+
return sup ?? sub;
|
|
4467
|
+
}
|
|
4468
|
+
function marks(el) {
|
|
4469
|
+
const proposed = own(el, "x_review_proposed");
|
|
4470
|
+
return (own(el, "hidden") === true ? " \xB7 hidden" : "") + (proposed !== void 0 && proposed !== null ? " \xB7 proposed" : "");
|
|
4471
|
+
}
|
|
4472
|
+
function descriptionLines(el) {
|
|
4473
|
+
const d = text(own(el, "description"));
|
|
4474
|
+
return d === null ? [] : d.split("\n").map((l) => ` ${l}`);
|
|
4475
|
+
}
|
|
4476
|
+
function rowsOf(key, v) {
|
|
4477
|
+
if (key === "style") return [v];
|
|
4478
|
+
if (key === "names") {
|
|
4479
|
+
if (!isObj(v)) return [];
|
|
4480
|
+
return Object.keys(v).flatMap((t) => Array.isArray(v[t]) ? v[t] : []);
|
|
4481
|
+
}
|
|
4482
|
+
return Array.isArray(v) ? v : [];
|
|
4483
|
+
}
|
|
4484
|
+
function draughtText(draught) {
|
|
4485
|
+
const d = draught;
|
|
4486
|
+
if (!isObj(d)) throw new TypeError("draughtText: the draught is an object, as draught() returns it.");
|
|
4487
|
+
const world = own(d, "world");
|
|
4488
|
+
if (!isObj(world)) throw new TypeError("draughtText: the draught has no world object.");
|
|
4489
|
+
const names = /* @__PURE__ */ new Map();
|
|
4490
|
+
const hold = (el) => {
|
|
4491
|
+
if (!isObj(el)) return;
|
|
4492
|
+
const id = own(el, "id");
|
|
4493
|
+
if (typeof id === "string" && !names.has(id)) names.set(id, text(own(el, "name")) ?? "(unnamed)");
|
|
4494
|
+
};
|
|
4495
|
+
const asked = Object.prototype.hasOwnProperty.call(d, "character");
|
|
4496
|
+
const character = own(d, "character");
|
|
4497
|
+
const her = isObj(character) && isObj(own(character, "element")) ? own(character, "element") : null;
|
|
4498
|
+
hold(her);
|
|
4499
|
+
for (const key of ELEMENT_SECTIONS2) {
|
|
4500
|
+
for (const row of rowsOf(key, own(d, key))) if (isObj(row)) hold(own(row, "element"));
|
|
4501
|
+
}
|
|
4502
|
+
const calendar = own(d, "calendar");
|
|
4503
|
+
const unit = isObj(calendar) ? text(own(calendar, "time_basic_unit")) : null;
|
|
4504
|
+
const moment = (n) => unit === null ? BigInt(n).toString() : `${unit} ${BigInt(n).toString()}`;
|
|
4505
|
+
const herName = her === null ? "the Character" : text(own(her, "name")) ?? "(unnamed)";
|
|
4506
|
+
const out = [];
|
|
4507
|
+
const put = (line, cont = " ") => {
|
|
4508
|
+
const [first, ...rest] = line.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
4509
|
+
out.push(first, ...rest.map((l) => cont + l));
|
|
4510
|
+
};
|
|
4511
|
+
put(`# ${herName}, in ${text(own(world, "name")) ?? "(unnamed)"}`);
|
|
4512
|
+
const asOf = own(d, "as_of");
|
|
4513
|
+
const now = own(d, "now");
|
|
4514
|
+
const mode = own(d, "mode");
|
|
4515
|
+
put(
|
|
4516
|
+
`What the record holds around ${herName}` + (isInt(asOf) ? `, dated up to ${moment(asOf)}` : "") + (isInt(now) ? ` (the world's now: ${moment(now)})` : "") + "." + (mode === "voice" ? " Read as the Character's own view." : mode === "act" ? " Read as the caller's view." : "")
|
|
4517
|
+
);
|
|
4518
|
+
if (asked) {
|
|
4519
|
+
out.push("");
|
|
4520
|
+
put(`## ${herName}`);
|
|
4521
|
+
}
|
|
4522
|
+
if (asked && her === null) {
|
|
4523
|
+
out.push("Hidden from this reader.");
|
|
4524
|
+
} else if (her !== null) {
|
|
4525
|
+
const type = own(her, "type");
|
|
4526
|
+
const kind = kindOf(her);
|
|
4527
|
+
put(typeWordOf(type) + (kind === null ? "" : ` \xB7 ${kind}`) + marks(her));
|
|
4528
|
+
for (const l of descriptionLines(her)) put(l);
|
|
4529
|
+
for (const key of Object.keys(her)) {
|
|
4530
|
+
if (UNPRINTED.has(key) || UNPRINTED_PREFIXES.some((p) => key.startsWith(p))) continue;
|
|
4531
|
+
const v = her[key];
|
|
4532
|
+
if (!isSet(v)) continue;
|
|
4533
|
+
let value;
|
|
4534
|
+
if (isLinkField(type, key)) {
|
|
4535
|
+
const resolved = [];
|
|
4536
|
+
let missing = 0;
|
|
4537
|
+
for (const id of Array.isArray(v) ? v : [v]) {
|
|
4538
|
+
if (typeof id !== "string" || id === "") continue;
|
|
4539
|
+
const name = names.get(id);
|
|
4540
|
+
if (name === void 0) missing += 1;
|
|
4541
|
+
else resolved.push(name);
|
|
4542
|
+
}
|
|
4543
|
+
const notHeld = `${missing} not in this draught`;
|
|
4544
|
+
value = missing === 0 ? resolved.length ? resolved.join(", ") : null : resolved.length ? `${resolved.join(", ")}, and ${notHeld}` : notHeld;
|
|
4545
|
+
} else if (Array.isArray(v)) {
|
|
4546
|
+
const parts = v.map(text).filter((p) => p !== null);
|
|
4547
|
+
value = parts.length ? parts.join(", ") : null;
|
|
4548
|
+
} else {
|
|
4549
|
+
value = text(v);
|
|
4550
|
+
}
|
|
4551
|
+
if (value !== null) put(` ${key.replace(/_/g, " ")}: ${value}`, " ");
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4554
|
+
const roster = own(d, "roster");
|
|
4555
|
+
const memberName = (id) => {
|
|
4556
|
+
if (!Array.isArray(roster) || typeof id !== "string") return null;
|
|
4557
|
+
for (const r of roster) if (isObj(r) && own(r, "id") === id) return text(own(r, "name"));
|
|
4558
|
+
return null;
|
|
4559
|
+
};
|
|
4560
|
+
const elementRow = (row) => {
|
|
4561
|
+
const el = isObj(own(row, "element")) ? own(row, "element") : {};
|
|
4562
|
+
const type = own(el, "type");
|
|
4563
|
+
const kind = kindOf(el);
|
|
4564
|
+
let line = `- ${text(own(el, "name")) ?? "(unnamed)"} (${typeWordOf(type)}${kind === null ? "" : ` \xB7 ${kind}`})`;
|
|
4565
|
+
const viaRaw = own(row, "via");
|
|
4566
|
+
const via = (Array.isArray(viaRaw) ? viaRaw : []).map(text).filter((f) => f !== null);
|
|
4567
|
+
if (via.length) line += ` \xB7 via ${via.map((f) => f.replace(/_/g, " ")).join(", ")}`;
|
|
4568
|
+
const start = own(el, "start_date");
|
|
4569
|
+
if (own(row, "grade") === "known_of") line += " \xB7 known of";
|
|
4570
|
+
else if (isInt(start)) line += ` \xB7 ${moment(start)}`;
|
|
4571
|
+
else if (isDatedType(type)) line += " \xB7 undated";
|
|
4572
|
+
line += marks(el);
|
|
4573
|
+
return [line, ...descriptionLines(el)];
|
|
4574
|
+
};
|
|
4575
|
+
const recentRow = (row) => {
|
|
4576
|
+
const op = own(row, "op");
|
|
4577
|
+
const verb = op === "upsert" ? "changed" : op === "delete" ? "deleted" : text(op) ?? "";
|
|
4578
|
+
const id = own(row, "id");
|
|
4579
|
+
const target = (typeof id === "string" ? names.get(id) : void 0) ?? text(id) ?? "";
|
|
4580
|
+
const who = own(row, "who");
|
|
4581
|
+
const writer = !isSet(who) ? "an unrecorded writer" : who === "owner" ? "the owner" : memberName(who) ?? "a member";
|
|
4582
|
+
const when = text(own(row, "when"));
|
|
4583
|
+
const door = text(own(row, "door"));
|
|
4584
|
+
return `- ${when === null ? "" : `${when} \xB7 `}${verb} ${typeWordOf(own(row, "type"))} ${target} \xB7 by ${writer}` + (door === null ? "" : ` \xB7 through ${door}`);
|
|
4585
|
+
};
|
|
4586
|
+
const memberRow = (row) => {
|
|
4587
|
+
let line = `- ${text(own(row, "role")) ?? ""}`;
|
|
4588
|
+
const name = text(own(row, "name"));
|
|
4589
|
+
if (name !== null) line += ` \xB7 ${name}`;
|
|
4590
|
+
const plays = own(row, "character");
|
|
4591
|
+
if (isSet(plays)) {
|
|
4592
|
+
const n = typeof plays === "string" ? names.get(plays) : void 0;
|
|
4593
|
+
line += n === void 0 ? " \xB7 plays a Character not in this draught" : ` \xB7 plays ${n}`;
|
|
4594
|
+
}
|
|
4595
|
+
if (own(row, "status") === "removed") line += " \xB7 removed from the world";
|
|
4596
|
+
return line;
|
|
4597
|
+
};
|
|
4598
|
+
const recentMore = own(d, "recent_more") === true;
|
|
4599
|
+
const sectionSet = (key) => isSet(own(d, key)) || key === "recent" && recentMore;
|
|
4600
|
+
for (const [key, heading] of SECTIONS) {
|
|
4601
|
+
const v = own(d, key);
|
|
4602
|
+
if (!sectionSet(key)) continue;
|
|
4603
|
+
out.push("", `## ${heading}`);
|
|
4604
|
+
for (const row of rowsOf(key, v)) {
|
|
4605
|
+
if (!isObj(row)) continue;
|
|
4606
|
+
if (key === "recent") put(recentRow(row));
|
|
4607
|
+
else if (key === "roster") put(memberRow(row));
|
|
4608
|
+
else for (const l of elementRow(row)) put(l);
|
|
4609
|
+
}
|
|
4610
|
+
if (key === "recent" && recentMore) out.push("More changes than these; read on from recent_cursor.");
|
|
4611
|
+
}
|
|
4612
|
+
const policy = own(d, "policy");
|
|
4613
|
+
const components = isObj(policy) ? own(policy, "components") : void 0;
|
|
4614
|
+
if (Array.isArray(components)) {
|
|
4615
|
+
const empty = components.filter((c) => typeof c === "string" && c !== "self" && !sectionSet(c));
|
|
4616
|
+
if (empty.length) {
|
|
4617
|
+
out.push("");
|
|
4618
|
+
put(`Nothing in: ${empty.join(", ")}.`);
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
const cut2 = own(d, "cut");
|
|
4622
|
+
const left = isObj(cut2) ? Object.keys(cut2).filter((k) => isInt(cut2[k])).map((k) => `${BigInt(cut2[k]).toString()} ${k}`) : [];
|
|
4623
|
+
out.push("");
|
|
4624
|
+
if (isInt(asOf) && mode === "voice") put(`Not listed: rows dated after ${moment(asOf)}.`);
|
|
4625
|
+
else if (isInt(asOf) && mode === "act") put(`Not listed: Events, Knowledge and proposed Events or Narratives dated after ${moment(asOf)}.`);
|
|
4626
|
+
put(`Left out by the budget: ${left.length ? left.join(", ") : "nothing"}.`);
|
|
4627
|
+
return out.join("\n") + "\n";
|
|
4628
|
+
}
|
|
4629
|
+
|
|
4399
4630
|
// src/photo.ts
|
|
4400
4631
|
var PHOTO_TYPES = ["image/webp", "image/png", "image/jpeg", "image/avif"];
|
|
4401
4632
|
var PHOTO_MAX_BYTES = 15 * 1024 * 1024;
|
|
@@ -5216,6 +5447,7 @@ export {
|
|
|
5216
5447
|
buildWorldIndex,
|
|
5217
5448
|
detectKeyKind,
|
|
5218
5449
|
displayYear,
|
|
5450
|
+
draughtText,
|
|
5219
5451
|
elementColor,
|
|
5220
5452
|
eraForStep,
|
|
5221
5453
|
errorFromResponse,
|