@agentshouse/mdruntime 0.1.0-c5f333dfa0583 → 0.1.0-c5fe3b2cddda7
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 +10 -8
- package/dist/adapter.d.ts +39 -40
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +2 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +28 -4
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +16 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +142 -94
- package/dist/change-set.d.ts +1 -7
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +1 -4
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -7
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +6 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +94 -33
- package/dist/connection.d.ts +8 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1160 -1151
- package/dist/conversation.d.ts +7 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +171 -55
- package/dist/durability.d.ts +1 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +370 -0
- package/dist/host.d.ts +3 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +42 -18
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +2 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +3 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +93 -38
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -10
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -6
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -5
- package/dist/overlay.js +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +12 -1
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +69 -46
- package/dist/readiness.d.ts +14 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -8
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +9 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +64 -30
- package/dist/replica.d.ts +5 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +4 -7
- package/dist/room-draft.d.ts +18 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +73 -6
- package/dist/rows.d.ts +15 -6
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +102 -74
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +13 -7
- package/dist/search.d.ts +11 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +0 -296
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +23 -58
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +37 -272
- package/dist/stored.d.ts +10 -23
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +217 -218
- package/dist/tables.d.ts +51 -46
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +94 -53
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +35 -96
- package/dist/wire.d.ts +5 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +11 -19
- package/AGENTS.md +0 -312
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -21
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -246
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -70
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -98
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,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ACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { departure } from './change.js';
|
|
2
|
-
export { partsAfter } from './room-draft.js';
|
|
2
|
+
export { partsAfter, partsChanges } from './room-draft.js';
|
|
3
3
|
export { cutName, nameFrom, transliterated } from './name.js';
|
|
4
|
-
export { SESSION_STARTED } from './conversation.js';
|
|
4
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
5
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
|
-
export { ROW_WEIGHT, stepped } from './turn.js';
|
|
6
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
7
|
+
export { untilAnswered } from './recovery.js';
|
|
7
8
|
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
8
9
|
export { attempts, identities, intentOf, } from './attempt.js';
|
|
9
10
|
export { expectedList, expecting } from './expectation.js';
|
package/dist/live.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,KAAK,WAAW,EACh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;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAoCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
|
package/dist/live.js
CHANGED
|
@@ -14,7 +14,8 @@ function reads(plan, locator) {
|
|
|
14
14
|
if (plan.reach === null)
|
|
15
15
|
return true;
|
|
16
16
|
return (plan.reach.rooms.includes(locator) ||
|
|
17
|
-
plan.reach.documents.some((document) => roomOfKey(document) === locator)
|
|
17
|
+
plan.reach.documents.some((document) => roomOfKey(document) === locator) ||
|
|
18
|
+
plan.reach.areas.some((area) => area.room === locator && area.types.length > 0));
|
|
18
19
|
}
|
|
19
20
|
function affected(plan, set) {
|
|
20
21
|
if (set.rooms.some((locator) => reads(plan, locator)))
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import { type ShownAnswer } from './outcome.js';
|
|
3
|
+
export declare const ROOM_MEDIA = "room-media";
|
|
4
|
+
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
|
+
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAsBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,EAClD,QAAQ,GAAE,qBAAsC,GAC/C,IAAI,CA0LN"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { UNCERTAIN } from './outcome.js';
|
|
2
|
+
export const ROOM_MEDIA = 'room-media';
|
|
3
|
+
const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
|
|
4
|
+
const LOADING = new Set(['room', 'path', 'revision']);
|
|
5
|
+
const NEARING = '600px 0px';
|
|
6
|
+
const RELINKS = 2;
|
|
7
|
+
// The Room's stream brings a file seconds after the text that links it, minutes after on a first open, and a page's reach of its Rooms settles seconds after it opens, so a file not shown yet is asked for again every three seconds.
|
|
8
|
+
const UNSHOWN_MS = 3_000;
|
|
9
|
+
const SHAPE = '16 / 9';
|
|
10
|
+
const STYLE = `:host{display:block}
|
|
11
|
+
[part=box]{position:relative;overflow:hidden}
|
|
12
|
+
[part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
|
|
13
|
+
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
|
|
14
|
+
const shows = new WeakMap();
|
|
15
|
+
export function shownBy(show, client) {
|
|
16
|
+
shows.set(client, show);
|
|
17
|
+
return client;
|
|
18
|
+
}
|
|
19
|
+
function ratioOf(width, height) {
|
|
20
|
+
const across = Number(width);
|
|
21
|
+
const down = Number(height);
|
|
22
|
+
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
23
|
+
? `${across} / ${down}`
|
|
24
|
+
: SHAPE;
|
|
25
|
+
}
|
|
26
|
+
function refusedForGood(shown) {
|
|
27
|
+
if (shown.kind === 'revoked-authorization')
|
|
28
|
+
return true;
|
|
29
|
+
return (shown.kind === 'rejected' || shown.kind === 'scoped-refusal') && !shown.retryable;
|
|
30
|
+
}
|
|
31
|
+
function drawnFor(mediaType) {
|
|
32
|
+
if (mediaType.startsWith('image/'))
|
|
33
|
+
return 'img';
|
|
34
|
+
if (mediaType.startsWith('video/'))
|
|
35
|
+
return 'video';
|
|
36
|
+
if (mediaType.startsWith('audio/'))
|
|
37
|
+
return 'audio';
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export function defineRoomMedia(client, registry = customElements) {
|
|
41
|
+
if (registry.get(ROOM_MEDIA) !== undefined)
|
|
42
|
+
return;
|
|
43
|
+
const connected = Promise.resolve(client);
|
|
44
|
+
class RoomMedia extends HTMLElement {
|
|
45
|
+
static observedAttributes = ATTRIBUTES;
|
|
46
|
+
#root = this.attachShadow({ mode: 'open' });
|
|
47
|
+
#box = document.createElement('div');
|
|
48
|
+
#fallback = document.createElement('slot');
|
|
49
|
+
#watching = null;
|
|
50
|
+
#near = false;
|
|
51
|
+
#asked = 0;
|
|
52
|
+
#shown = null;
|
|
53
|
+
#drawn = null;
|
|
54
|
+
#loaded = false;
|
|
55
|
+
#relinked = 0;
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
this.#box.setAttribute('part', 'box');
|
|
59
|
+
this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
|
|
60
|
+
this.#shape();
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
this.#label();
|
|
64
|
+
this.#watching ??= new IntersectionObserver((seen) => {
|
|
65
|
+
if (!seen.some((entry) => entry.isIntersecting) || this.#near)
|
|
66
|
+
return;
|
|
67
|
+
this.#near = true;
|
|
68
|
+
void this.#load();
|
|
69
|
+
}, { rootMargin: NEARING });
|
|
70
|
+
this.#watching.observe(this);
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
this.#watching?.disconnect();
|
|
74
|
+
this.#watching = null;
|
|
75
|
+
this.#near = false;
|
|
76
|
+
this.#asked += 1;
|
|
77
|
+
this.#show(null);
|
|
78
|
+
}
|
|
79
|
+
attributeChangedCallback(name, before, after) {
|
|
80
|
+
if (before === after)
|
|
81
|
+
return;
|
|
82
|
+
this.#shape();
|
|
83
|
+
if (this.isConnected)
|
|
84
|
+
this.#label();
|
|
85
|
+
if (!LOADING.has(name) || !this.#near)
|
|
86
|
+
return;
|
|
87
|
+
this.#relinked = 0;
|
|
88
|
+
void this.#load();
|
|
89
|
+
}
|
|
90
|
+
#shape() {
|
|
91
|
+
this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
|
|
92
|
+
}
|
|
93
|
+
#label() {
|
|
94
|
+
const alt = this.getAttribute('alt') ?? '';
|
|
95
|
+
const drawn = this.#drawn;
|
|
96
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
97
|
+
this.removeAttribute('role');
|
|
98
|
+
this.removeAttribute('aria-label');
|
|
99
|
+
drawn.setAttribute('aria-label', alt);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.setAttribute('role', 'img');
|
|
103
|
+
this.setAttribute('aria-label', alt);
|
|
104
|
+
if (drawn !== null)
|
|
105
|
+
drawn.alt = '';
|
|
106
|
+
}
|
|
107
|
+
async #load() {
|
|
108
|
+
const asked = (this.#asked += 1);
|
|
109
|
+
this.#loaded = false;
|
|
110
|
+
const room = this.getAttribute('room');
|
|
111
|
+
const path = this.getAttribute('path');
|
|
112
|
+
const revision = this.getAttribute('revision') ?? undefined;
|
|
113
|
+
if (room === null || path === null) {
|
|
114
|
+
this.#unreadable();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const show = shows.get(await connected);
|
|
118
|
+
const shown = show === undefined ? null : await show(room, path, revision).catch(() => UNCERTAIN);
|
|
119
|
+
if (asked !== this.#asked)
|
|
120
|
+
return;
|
|
121
|
+
if (shown?.kind === 'link') {
|
|
122
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (shown?.kind !== 'binary') {
|
|
126
|
+
if (shown === null || refusedForGood(shown))
|
|
127
|
+
this.#unreadable();
|
|
128
|
+
else
|
|
129
|
+
this.#unshown(asked);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const copy = await new Response(shown.stream, {
|
|
133
|
+
headers: { 'content-type': shown.mediaType },
|
|
134
|
+
})
|
|
135
|
+
.blob()
|
|
136
|
+
.catch(() => null);
|
|
137
|
+
if (asked !== this.#asked)
|
|
138
|
+
return;
|
|
139
|
+
if (copy === null)
|
|
140
|
+
this.#unshown(asked);
|
|
141
|
+
else
|
|
142
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
143
|
+
}
|
|
144
|
+
#unshown(asked) {
|
|
145
|
+
this.#unreadable();
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
if (asked === this.#asked && this.#near)
|
|
148
|
+
void this.#load();
|
|
149
|
+
}, UNSHOWN_MS);
|
|
150
|
+
}
|
|
151
|
+
#show(shown, content = null) {
|
|
152
|
+
if (this.#shown?.copy === true)
|
|
153
|
+
URL.revokeObjectURL(this.#shown.url);
|
|
154
|
+
this.#shown = shown;
|
|
155
|
+
if (content !== this.#drawn)
|
|
156
|
+
this.#drawn = null;
|
|
157
|
+
if (content === null)
|
|
158
|
+
this.#box.replaceChildren();
|
|
159
|
+
else if (content.parentNode !== this.#box)
|
|
160
|
+
this.#box.replaceChildren(content);
|
|
161
|
+
this.#label();
|
|
162
|
+
}
|
|
163
|
+
#unreadable() {
|
|
164
|
+
this.#show(null, this.#fallback);
|
|
165
|
+
}
|
|
166
|
+
#draw(shown, mediaType) {
|
|
167
|
+
const tag = drawnFor(mediaType);
|
|
168
|
+
if (tag === null) {
|
|
169
|
+
if (shown.copy)
|
|
170
|
+
URL.revokeObjectURL(shown.url);
|
|
171
|
+
this.#unreadable();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const kept = this.#drawn?.localName === tag ? this.#drawn : null;
|
|
175
|
+
const drawn = kept ?? document.createElement(tag);
|
|
176
|
+
if (kept === null) {
|
|
177
|
+
if (drawn instanceof HTMLImageElement)
|
|
178
|
+
drawn.decoding = 'async';
|
|
179
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
180
|
+
drawn.controls = true;
|
|
181
|
+
drawn.preload = 'metadata';
|
|
182
|
+
if (drawn instanceof HTMLVideoElement)
|
|
183
|
+
drawn.playsInline = true;
|
|
184
|
+
}
|
|
185
|
+
drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
|
|
186
|
+
if (drawn !== this.#drawn)
|
|
187
|
+
return;
|
|
188
|
+
this.#loaded = true;
|
|
189
|
+
this.#relinked = 0;
|
|
190
|
+
});
|
|
191
|
+
drawn.addEventListener('error', () => this.#failed(drawn));
|
|
192
|
+
}
|
|
193
|
+
this.#drawn = drawn;
|
|
194
|
+
this.#show(shown, drawn);
|
|
195
|
+
drawn.src = shown.url;
|
|
196
|
+
}
|
|
197
|
+
#failed(drawn) {
|
|
198
|
+
if (drawn !== this.#drawn)
|
|
199
|
+
return;
|
|
200
|
+
if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
|
|
201
|
+
this.#unreadable();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.#relinked += 1;
|
|
205
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
206
|
+
const at = drawn.currentTime;
|
|
207
|
+
const playing = !drawn.paused;
|
|
208
|
+
drawn.addEventListener('loadedmetadata', () => {
|
|
209
|
+
drawn.currentTime = at;
|
|
210
|
+
if (playing)
|
|
211
|
+
void drawn.play().catch(() => undefined);
|
|
212
|
+
}, { once: true });
|
|
213
|
+
}
|
|
214
|
+
void this.#load();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
registry.define(ROOM_MEDIA, RoomMedia);
|
|
218
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { ModelResult } from './model.js';
|
|
|
2
2
|
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
|
-
selectionModel?: ModelResult;
|
|
6
5
|
documents?: Readonly<Record<string, string>>;
|
|
7
6
|
revisions?: Readonly<Record<string, string>>;
|
|
8
7
|
fileIds?: Readonly<Record<string, string>>;
|
|
@@ -13,7 +12,7 @@ export type MemoryRoom = DiscoveredRoom & {
|
|
|
13
12
|
};
|
|
14
13
|
export type MemoryConversation = {
|
|
15
14
|
conversation: string;
|
|
16
|
-
listed?: Omit<ListedConversation, 'conversation'>;
|
|
15
|
+
listed?: Omit<ListedConversation, 'conversation' | 'newest'>;
|
|
17
16
|
messages?: readonly AcceptedMessage[];
|
|
18
17
|
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
19
18
|
};
|
|
@@ -28,8 +27,10 @@ export type MemoryAdapterOptions = {
|
|
|
28
27
|
member?: Member;
|
|
29
28
|
unopened?: boolean;
|
|
30
29
|
exhaustiveDiscovery?: true;
|
|
30
|
+
roomTypes?: string;
|
|
31
31
|
};
|
|
32
32
|
export type MemoryAdapter = Adapter & {
|
|
33
|
+
refresh: NonNullable<Adapter['refresh']>;
|
|
33
34
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
34
35
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
35
36
|
script(operation: keyof Adapter, answer: unknown): void;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAIlB,KAAK,SAAS,EAGd,KAAK,WAAW,EACjB,MAAM,c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,GAAE,oBAAyB,GAAG,aAAa,CA4kBrF"}
|
package/dist/memory.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { sameChange } from './overlay.js';
|
|
2
|
+
const ATTACHMENTS = 'attachments';
|
|
3
|
+
function lastName(path) {
|
|
4
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
5
|
+
}
|
|
2
6
|
const FIXTURE_RETENTION = {
|
|
3
7
|
history: { kind: 'duration', seconds: 1 },
|
|
4
8
|
outcome: 604_800,
|
|
@@ -15,12 +19,7 @@ function declaredRetention(value) {
|
|
|
15
19
|
}
|
|
16
20
|
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
17
21
|
function modelsOf(room) {
|
|
18
|
-
return {
|
|
19
|
-
collection: room.model ?? MODEL_ABSENT,
|
|
20
|
-
...(room.typedSelection === undefined
|
|
21
|
-
? {}
|
|
22
|
-
: { selection: room.selectionModel ?? MODEL_ABSENT }),
|
|
23
|
-
};
|
|
22
|
+
return { collection: room.model ?? MODEL_ABSENT };
|
|
24
23
|
}
|
|
25
24
|
function changedModels(room, from) {
|
|
26
25
|
const now = modelsOf(room);
|
|
@@ -57,7 +56,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
57
56
|
const sealed = new Set();
|
|
58
57
|
const sentTurns = new Map();
|
|
59
58
|
const historyPageSize = options.historyPageSize;
|
|
60
|
-
|
|
59
|
+
const attached = new Map();
|
|
60
|
+
const linked = new WeakMap();
|
|
61
|
+
const carried = new Map();
|
|
61
62
|
let expiring = [];
|
|
62
63
|
let replicated = [];
|
|
63
64
|
let issued = 0;
|
|
@@ -87,6 +88,19 @@ export function createMemoryAdapter(options = {}) {
|
|
|
87
88
|
const wanted = ordinals.get(`${locator}\u0000${target}`);
|
|
88
89
|
return held !== undefined && wanted !== undefined && held >= wanted;
|
|
89
90
|
}
|
|
91
|
+
function heldBlob(room, path) {
|
|
92
|
+
return attached.get(`${room.locator}\u0000${path}`) ?? room.blobs?.[path];
|
|
93
|
+
}
|
|
94
|
+
function freePath(room, name) {
|
|
95
|
+
const dot = name.lastIndexOf('.');
|
|
96
|
+
const stem = dot > 0 ? name.slice(0, dot) : name;
|
|
97
|
+
const extension = dot > 0 ? name.slice(dot) : '';
|
|
98
|
+
for (let count = 1;; count += 1) {
|
|
99
|
+
const path = `${ATTACHMENTS}/${count === 1 ? stem : `${stem}-${count}`}${extension}`;
|
|
100
|
+
if (heldBlob(room, path) === undefined && room.documents?.[path] === undefined)
|
|
101
|
+
return path;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
90
104
|
function retain(entries) {
|
|
91
105
|
for (const room of entries) {
|
|
92
106
|
note(room.locator, room);
|
|
@@ -141,7 +155,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
141
155
|
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
142
156
|
};
|
|
143
157
|
}
|
|
144
|
-
function advancement(room, from, at) {
|
|
158
|
+
function advancement(room, from, at, whole = false) {
|
|
145
159
|
const current = room.documents ?? {};
|
|
146
160
|
const previous = from.documents ?? {};
|
|
147
161
|
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
@@ -152,7 +166,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
152
166
|
const changed = Object.keys(current)
|
|
153
167
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
154
168
|
.sort();
|
|
155
|
-
const size = pageSize ?? changed.length;
|
|
169
|
+
const size = whole ? changed.length : (pageSize ?? changed.length);
|
|
156
170
|
const taken = changed.slice(at, at + size);
|
|
157
171
|
const next = at + taken.length;
|
|
158
172
|
const opening = at === 0;
|
|
@@ -184,6 +198,26 @@ export function createMemoryAdapter(options = {}) {
|
|
|
184
198
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
185
199
|
};
|
|
186
200
|
}
|
|
201
|
+
function carry(locator) {
|
|
202
|
+
const at = carried.get(locator);
|
|
203
|
+
const current = rooms.find((entry) => entry.locator === locator);
|
|
204
|
+
if (at === undefined || current === undefined || current.roomVersion === at)
|
|
205
|
+
return;
|
|
206
|
+
const from = served.get(locator)?.get(at);
|
|
207
|
+
carried.set(locator, current.roomVersion);
|
|
208
|
+
if (from === undefined)
|
|
209
|
+
return;
|
|
210
|
+
const page = advancement(current, from, 0, true);
|
|
211
|
+
for (const observer of observers) {
|
|
212
|
+
observer({
|
|
213
|
+
kind: 'room-change',
|
|
214
|
+
locator,
|
|
215
|
+
from: at,
|
|
216
|
+
roomVersion: current.roomVersion,
|
|
217
|
+
read: async () => page,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
187
221
|
function pageOf(conversation, after) {
|
|
188
222
|
const messages = conversation.messages ?? [];
|
|
189
223
|
const first = typeof after === 'string' ? messages.findIndex((message) => message.position > after) : 0;
|
|
@@ -264,7 +298,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
264
298
|
return { kind: 'action', result: { conversation: named } };
|
|
265
299
|
}
|
|
266
300
|
function announceList() {
|
|
267
|
-
const entries = [...scripted.values()].flatMap(({ conversation, listed }) => listed === undefined
|
|
301
|
+
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
302
|
+
? []
|
|
303
|
+
: [{ conversation, ...listed, newest: messages.at(-1)?.position ?? null }]);
|
|
268
304
|
for (const listener of listeners)
|
|
269
305
|
listener({ kind: 'list', entries });
|
|
270
306
|
}
|
|
@@ -280,6 +316,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
280
316
|
}
|
|
281
317
|
return {
|
|
282
318
|
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
319
|
+
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
283
320
|
setRooms(next) {
|
|
284
321
|
rooms = [...next];
|
|
285
322
|
retain(rooms);
|
|
@@ -288,20 +325,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
288
325
|
scriptConversations(next);
|
|
289
326
|
},
|
|
290
327
|
open() {
|
|
328
|
+
carried.clear();
|
|
291
329
|
announceList();
|
|
292
330
|
for (const observer of observers)
|
|
293
331
|
observer({ kind: 'opened' });
|
|
294
332
|
},
|
|
295
333
|
close({ revoked = false, lost = !revoked } = {}) {
|
|
334
|
+
carried.clear();
|
|
296
335
|
for (const observer of observers)
|
|
297
336
|
observer({ kind: 'closed', revoked, lost });
|
|
298
337
|
},
|
|
299
338
|
expire(locators) {
|
|
300
339
|
expiring = [...locators];
|
|
301
340
|
},
|
|
302
|
-
notifyRoomVersion({ locator
|
|
303
|
-
|
|
304
|
-
observer({ kind: 'room-version', locator, roomVersion });
|
|
341
|
+
notifyRoomVersion({ locator }) {
|
|
342
|
+
carry(locator);
|
|
305
343
|
},
|
|
306
344
|
notifyAuthorityChanged(scope) {
|
|
307
345
|
for (const observer of observers) {
|
|
@@ -323,7 +361,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
323
361
|
observer(mode);
|
|
324
362
|
},
|
|
325
363
|
heldRooms() {
|
|
326
|
-
return
|
|
364
|
+
return [...carried.keys()].sort();
|
|
327
365
|
},
|
|
328
366
|
replicatedConversations() {
|
|
329
367
|
return replicated;
|
|
@@ -349,33 +387,40 @@ export function createMemoryAdapter(options = {}) {
|
|
|
349
387
|
},
|
|
350
388
|
roomStream: {
|
|
351
389
|
hold(asked) {
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
expiring = [];
|
|
355
|
-
const moved = asked.flatMap((room) => {
|
|
390
|
+
const named = asked.map((room) => room.locator);
|
|
391
|
+
const unknown = asked.flatMap((room) => {
|
|
356
392
|
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
357
393
|
return current === undefined ||
|
|
358
|
-
|
|
359
|
-
|
|
394
|
+
current.roomVersion === room.roomVersion ||
|
|
395
|
+
served.get(room.locator)?.has(room.roomVersion) === true
|
|
360
396
|
? []
|
|
361
|
-
: [
|
|
397
|
+
: [room.locator];
|
|
362
398
|
});
|
|
399
|
+
const expired = [
|
|
400
|
+
...new Set([...expiring.filter((locator) => named.includes(locator)), ...unknown]),
|
|
401
|
+
];
|
|
402
|
+
expiring = expiring.filter((locator) => !named.includes(locator));
|
|
363
403
|
queueMicrotask(() => {
|
|
364
|
-
for (const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
404
|
+
for (const room of asked) {
|
|
405
|
+
if (expired.includes(room.locator))
|
|
406
|
+
carried.delete(room.locator);
|
|
407
|
+
else {
|
|
408
|
+
carried.set(room.locator, room.roomVersion);
|
|
409
|
+
carry(room.locator);
|
|
410
|
+
}
|
|
368
411
|
}
|
|
412
|
+
for (const observer of observers)
|
|
413
|
+
observer({ kind: 'opening', expired });
|
|
369
414
|
});
|
|
370
415
|
},
|
|
371
416
|
reopen() {
|
|
372
417
|
queueMicrotask(() => {
|
|
418
|
+
carried.clear();
|
|
373
419
|
for (const observer of observers) {
|
|
374
420
|
observer({ kind: 'closed', revoked: false, lost: false });
|
|
375
421
|
}
|
|
376
422
|
});
|
|
377
423
|
},
|
|
378
|
-
published() { },
|
|
379
424
|
observe(notify) {
|
|
380
425
|
observers.add(notify);
|
|
381
426
|
queueMicrotask(() => {
|
|
@@ -487,28 +532,38 @@ export function createMemoryAdapter(options = {}) {
|
|
|
487
532
|
},
|
|
488
533
|
async binary(_authorization, request) {
|
|
489
534
|
return resolveScript(scripts.binary, () => {
|
|
490
|
-
if (request.kind === 'reference') {
|
|
491
|
-
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
492
|
-
}
|
|
493
535
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
494
536
|
if (room === undefined)
|
|
495
537
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
496
|
-
const blob = room
|
|
538
|
+
const blob = heldBlob(room, request.path);
|
|
497
539
|
return blob === undefined
|
|
498
540
|
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
499
541
|
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
500
542
|
}, request);
|
|
501
543
|
},
|
|
502
544
|
async link(_authorization, request) {
|
|
503
|
-
return resolveScript(scripts.link, () =>
|
|
545
|
+
return resolveScript(scripts.link, () => {
|
|
546
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
547
|
+
if (room === undefined)
|
|
548
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
549
|
+
const blob = heldBlob(room, request.path);
|
|
550
|
+
if (blob === undefined) {
|
|
551
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
552
|
+
}
|
|
553
|
+
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
554
|
+
linked.set(blob, url);
|
|
555
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: blob.type };
|
|
556
|
+
}, request);
|
|
504
557
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
558
|
+
async attach(_authorization, request) {
|
|
559
|
+
return resolveScript(scripts.attach, () => {
|
|
560
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
561
|
+
if (room === undefined)
|
|
562
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
563
|
+
const path = freePath(room, request.name);
|
|
564
|
+
attached.set(`${room.locator}\u0000${path}`, request.blob);
|
|
565
|
+
return { kind: 'attached', path, revision: `attached-${attached.size}` };
|
|
566
|
+
}, request);
|
|
512
567
|
},
|
|
513
568
|
async action(_authorization, request) {
|
|
514
569
|
return resolveScript(scripts.action, () => {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export type HeldConversation = {
|
|
5
|
+
readonly conversation: string;
|
|
6
|
+
readonly read: string | null | undefined;
|
|
7
|
+
readonly partial: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MessageWindow = {
|
|
10
|
+
readonly messages: AcceptedMessage[];
|
|
11
|
+
readonly more: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ConversationWrite = {
|
|
14
|
+
readonly conversation: string;
|
|
15
|
+
readonly messages: readonly AcceptedMessage[];
|
|
16
|
+
readonly read?: {
|
|
17
|
+
readonly at: string | null;
|
|
18
|
+
readonly partial: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
22
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
+
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
25
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
|
+
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
|
+
export declare function forgottenMessages(connection: Connection): void;
|
|
28
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAM3C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,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