@agentshouse/mdruntime 0.1.0-cf6041a06849c → 0.1.0-cf6e25bcd52f6
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 +23 -10
- package/dist/adapter.d.ts +144 -29
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +53 -6
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +41 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +224 -45
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -56
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +35 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +156 -19
- package/dist/collection.d.ts +14 -13
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +66 -54
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +765 -0
- package/dist/connection.d.ts +63 -20
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3889 -743
- package/dist/conversation.d.ts +42 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +642 -188
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +134 -21
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +124 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +208 -0
- package/dist/memory.d.ts +13 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +140 -31
- 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 +20 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +19 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +20 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +73 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +81 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/paths.d.ts +1 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -16
- package/dist/query.d.ts +71 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +100 -26
- package/dist/reach.d.ts +18 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +247 -84
- package/dist/react.d.ts +31 -19
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/readiness.d.ts +64 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +100 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +198 -0
- package/dist/refresh.d.ts +19 -8
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +125 -57
- package/dist/replica.d.ts +59 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +322 -155
- package/dist/room-draft.d.ts +41 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +186 -37
- package/dist/rows.d.ts +39 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +197 -80
- package/dist/save.d.ts +74 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +900 -178
- package/dist/search.d.ts +41 -29
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +11 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -9
- package/dist/store.d.ts +132 -58
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +379 -344
- package/dist/stored.d.ts +154 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +578 -0
- package/dist/tables.d.ts +362 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +627 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +173 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +69 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +26 -15
- package/AGENTS.md +0 -231
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -377
package/dist/media.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export const ROOM_MEDIA = 'room-media';
|
|
2
|
+
const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
|
|
3
|
+
const LOADING = new Set(['room', 'path', 'revision']);
|
|
4
|
+
const NEARING = '600px 0px';
|
|
5
|
+
const RELINKS = 2;
|
|
6
|
+
// 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.
|
|
7
|
+
const UNSHOWN_MS = 3_000;
|
|
8
|
+
const SHAPE = '16 / 9';
|
|
9
|
+
const STYLE = `:host{display:block}
|
|
10
|
+
[part=box]{position:relative;overflow:hidden}
|
|
11
|
+
[part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
|
|
12
|
+
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
|
|
13
|
+
const shows = new WeakMap();
|
|
14
|
+
export function shownBy(show, client) {
|
|
15
|
+
shows.set(client, show);
|
|
16
|
+
return client;
|
|
17
|
+
}
|
|
18
|
+
function ratioOf(width, height) {
|
|
19
|
+
const across = Number(width);
|
|
20
|
+
const down = Number(height);
|
|
21
|
+
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
22
|
+
? `${across} / ${down}`
|
|
23
|
+
: SHAPE;
|
|
24
|
+
}
|
|
25
|
+
function refusedForGood(shown) {
|
|
26
|
+
if (shown.kind === 'revoked-authorization')
|
|
27
|
+
return true;
|
|
28
|
+
return (shown.kind === 'rejected' || shown.kind === 'scoped-refusal') && !shown.retryable;
|
|
29
|
+
}
|
|
30
|
+
function drawnFor(mediaType) {
|
|
31
|
+
if (mediaType.startsWith('image/'))
|
|
32
|
+
return 'img';
|
|
33
|
+
if (mediaType.startsWith('video/'))
|
|
34
|
+
return 'video';
|
|
35
|
+
if (mediaType.startsWith('audio/'))
|
|
36
|
+
return 'audio';
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
export function defineRoomMedia(client, registry = customElements) {
|
|
40
|
+
if (registry.get(ROOM_MEDIA) !== undefined)
|
|
41
|
+
return;
|
|
42
|
+
const connected = Promise.resolve(client);
|
|
43
|
+
class RoomMedia extends HTMLElement {
|
|
44
|
+
static observedAttributes = ATTRIBUTES;
|
|
45
|
+
#root = this.attachShadow({ mode: 'open' });
|
|
46
|
+
#box = document.createElement('div');
|
|
47
|
+
#fallback = document.createElement('slot');
|
|
48
|
+
#watching = null;
|
|
49
|
+
#near = false;
|
|
50
|
+
#asked = 0;
|
|
51
|
+
#shown = null;
|
|
52
|
+
#drawn = null;
|
|
53
|
+
#loaded = false;
|
|
54
|
+
#relinked = 0;
|
|
55
|
+
constructor() {
|
|
56
|
+
super();
|
|
57
|
+
this.#box.setAttribute('part', 'box');
|
|
58
|
+
this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
|
|
59
|
+
this.#shape();
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
this.#label();
|
|
63
|
+
this.#watching ??= new IntersectionObserver((seen) => {
|
|
64
|
+
if (!seen.some((entry) => entry.isIntersecting) || this.#near)
|
|
65
|
+
return;
|
|
66
|
+
this.#near = true;
|
|
67
|
+
void this.#load();
|
|
68
|
+
}, { rootMargin: NEARING });
|
|
69
|
+
this.#watching.observe(this);
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this.#watching?.disconnect();
|
|
73
|
+
this.#watching = null;
|
|
74
|
+
this.#near = false;
|
|
75
|
+
this.#asked += 1;
|
|
76
|
+
this.#show(null);
|
|
77
|
+
}
|
|
78
|
+
attributeChangedCallback(name, before, after) {
|
|
79
|
+
if (before === after)
|
|
80
|
+
return;
|
|
81
|
+
this.#shape();
|
|
82
|
+
if (this.isConnected)
|
|
83
|
+
this.#label();
|
|
84
|
+
if (!LOADING.has(name) || !this.#near)
|
|
85
|
+
return;
|
|
86
|
+
this.#relinked = 0;
|
|
87
|
+
void this.#load();
|
|
88
|
+
}
|
|
89
|
+
#shape() {
|
|
90
|
+
this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
|
|
91
|
+
}
|
|
92
|
+
#label() {
|
|
93
|
+
const alt = this.getAttribute('alt') ?? '';
|
|
94
|
+
const drawn = this.#drawn;
|
|
95
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
96
|
+
this.removeAttribute('role');
|
|
97
|
+
this.removeAttribute('aria-label');
|
|
98
|
+
drawn.setAttribute('aria-label', alt);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.setAttribute('role', 'img');
|
|
102
|
+
this.setAttribute('aria-label', alt);
|
|
103
|
+
if (drawn !== null)
|
|
104
|
+
drawn.alt = '';
|
|
105
|
+
}
|
|
106
|
+
async #load() {
|
|
107
|
+
const asked = (this.#asked += 1);
|
|
108
|
+
this.#loaded = false;
|
|
109
|
+
const room = this.getAttribute('room');
|
|
110
|
+
const path = this.getAttribute('path');
|
|
111
|
+
const revision = this.getAttribute('revision') ?? undefined;
|
|
112
|
+
if (room === null || path === null) {
|
|
113
|
+
this.#unreadable();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const show = shows.get(await connected);
|
|
117
|
+
const shown = show === undefined ? null : await show(room, path, revision);
|
|
118
|
+
if (asked !== this.#asked)
|
|
119
|
+
return;
|
|
120
|
+
if (shown?.kind === 'link') {
|
|
121
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (shown?.kind !== 'binary') {
|
|
125
|
+
this.#unreadable();
|
|
126
|
+
if (shown === null || refusedForGood(shown))
|
|
127
|
+
return;
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
if (asked === this.#asked && this.#near)
|
|
130
|
+
void this.#load();
|
|
131
|
+
}, UNSHOWN_MS);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const copy = await new Response(shown.stream, {
|
|
135
|
+
headers: { 'content-type': shown.mediaType },
|
|
136
|
+
}).blob();
|
|
137
|
+
if (asked !== this.#asked)
|
|
138
|
+
return;
|
|
139
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
140
|
+
}
|
|
141
|
+
#show(shown, content = null) {
|
|
142
|
+
if (this.#shown?.copy === true)
|
|
143
|
+
URL.revokeObjectURL(this.#shown.url);
|
|
144
|
+
this.#shown = shown;
|
|
145
|
+
if (content !== this.#drawn)
|
|
146
|
+
this.#drawn = null;
|
|
147
|
+
if (content === null)
|
|
148
|
+
this.#box.replaceChildren();
|
|
149
|
+
else if (content.parentNode !== this.#box)
|
|
150
|
+
this.#box.replaceChildren(content);
|
|
151
|
+
this.#label();
|
|
152
|
+
}
|
|
153
|
+
#unreadable() {
|
|
154
|
+
this.#show(null, this.#fallback);
|
|
155
|
+
}
|
|
156
|
+
#draw(shown, mediaType) {
|
|
157
|
+
const tag = drawnFor(mediaType);
|
|
158
|
+
if (tag === null) {
|
|
159
|
+
if (shown.copy)
|
|
160
|
+
URL.revokeObjectURL(shown.url);
|
|
161
|
+
this.#unreadable();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const kept = this.#drawn?.localName === tag ? this.#drawn : null;
|
|
165
|
+
const drawn = kept ?? document.createElement(tag);
|
|
166
|
+
if (kept === null) {
|
|
167
|
+
if (drawn instanceof HTMLImageElement)
|
|
168
|
+
drawn.decoding = 'async';
|
|
169
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
170
|
+
drawn.controls = true;
|
|
171
|
+
drawn.preload = 'metadata';
|
|
172
|
+
if (drawn instanceof HTMLVideoElement)
|
|
173
|
+
drawn.playsInline = true;
|
|
174
|
+
}
|
|
175
|
+
drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
|
|
176
|
+
if (drawn !== this.#drawn)
|
|
177
|
+
return;
|
|
178
|
+
this.#loaded = true;
|
|
179
|
+
this.#relinked = 0;
|
|
180
|
+
});
|
|
181
|
+
drawn.addEventListener('error', () => this.#failed(drawn));
|
|
182
|
+
}
|
|
183
|
+
this.#drawn = drawn;
|
|
184
|
+
this.#show(shown, drawn);
|
|
185
|
+
drawn.src = shown.url;
|
|
186
|
+
}
|
|
187
|
+
#failed(drawn) {
|
|
188
|
+
if (drawn !== this.#drawn)
|
|
189
|
+
return;
|
|
190
|
+
if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
|
|
191
|
+
this.#unreadable();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.#relinked += 1;
|
|
195
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
196
|
+
const at = drawn.currentTime;
|
|
197
|
+
const playing = !drawn.paused;
|
|
198
|
+
drawn.addEventListener('loadedmetadata', () => {
|
|
199
|
+
drawn.currentTime = at;
|
|
200
|
+
if (playing)
|
|
201
|
+
void drawn.play().catch(() => undefined);
|
|
202
|
+
}, { once: true });
|
|
203
|
+
}
|
|
204
|
+
void this.#load();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
registry.define(ROOM_MEDIA, RoomMedia);
|
|
208
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type
|
|
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>>;
|
|
7
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
8
8
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
|
+
folders?: readonly string[];
|
|
11
|
+
blobs?: Readonly<Record<string, Blob>>;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryConversation = {
|
|
13
14
|
conversation: string;
|
|
@@ -23,19 +24,26 @@ export type MemoryAdapterOptions = {
|
|
|
23
24
|
capabilities?: readonly Capability[];
|
|
24
25
|
providerLimits?: readonly ProviderLimit[];
|
|
25
26
|
retention?: Retention;
|
|
27
|
+
member?: Member;
|
|
26
28
|
unopened?: boolean;
|
|
29
|
+
exhaustiveDiscovery?: true;
|
|
30
|
+
roomTypes?: string;
|
|
27
31
|
};
|
|
28
32
|
export type MemoryAdapter = Adapter & {
|
|
29
33
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
30
34
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
31
35
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
32
36
|
open(): void;
|
|
33
|
-
close(
|
|
37
|
+
close(closing?: {
|
|
38
|
+
revoked?: boolean;
|
|
39
|
+
lost?: boolean;
|
|
40
|
+
}): void;
|
|
34
41
|
expire(locators: readonly string[]): void;
|
|
35
42
|
notifyRoomVersion(notification: {
|
|
36
43
|
locator: string;
|
|
37
44
|
roomVersion: string;
|
|
38
45
|
}): void;
|
|
46
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
39
47
|
notifyConversation(event: ConversationEvent): void;
|
|
40
48
|
notifyServiceMode(mode: ServiceMode): void;
|
|
41
49
|
heldRooms(): readonly string[];
|
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,EAIZ,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,
|
|
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,EAGlB,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}
|
package/dist/memory.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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
|
-
outcome:
|
|
8
|
+
outcome: 604_800,
|
|
5
9
|
refreshHorizon: 1,
|
|
6
10
|
};
|
|
7
11
|
function declaredRetention(value) {
|
|
@@ -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);
|
|
@@ -55,7 +54,10 @@ export function createMemoryAdapter(options = {}) {
|
|
|
55
54
|
const scripted = new Map();
|
|
56
55
|
const unsealed = new Map();
|
|
57
56
|
const sealed = new Set();
|
|
57
|
+
const sentTurns = new Map();
|
|
58
58
|
const historyPageSize = options.historyPageSize;
|
|
59
|
+
const attached = new Map();
|
|
60
|
+
const linked = new WeakMap();
|
|
59
61
|
let held = [];
|
|
60
62
|
let expiring = [];
|
|
61
63
|
let replicated = [];
|
|
@@ -86,6 +88,19 @@ export function createMemoryAdapter(options = {}) {
|
|
|
86
88
|
const wanted = ordinals.get(`${locator}\u0000${target}`);
|
|
87
89
|
return held !== undefined && wanted !== undefined && held >= wanted;
|
|
88
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
|
+
}
|
|
89
104
|
function retain(entries) {
|
|
90
105
|
for (const room of entries) {
|
|
91
106
|
note(room.locator, room);
|
|
@@ -99,6 +114,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
99
114
|
return {
|
|
100
115
|
name: room.name,
|
|
101
116
|
locator: room.locator,
|
|
117
|
+
handle: room.handle,
|
|
102
118
|
roomVersion: room.roomVersion,
|
|
103
119
|
operations: room.operations,
|
|
104
120
|
replica: room.replica,
|
|
@@ -106,30 +122,46 @@ export function createMemoryAdapter(options = {}) {
|
|
|
106
122
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
107
123
|
};
|
|
108
124
|
}
|
|
109
|
-
function page(room,
|
|
125
|
+
function page(room, after) {
|
|
110
126
|
const paths = Object.keys(room.documents ?? {}).sort();
|
|
127
|
+
const opening = after === undefined;
|
|
128
|
+
const from = opening ? 0 : paths.filter((path) => path <= after).length;
|
|
111
129
|
const size = pageSize ?? paths.length;
|
|
112
130
|
const taken = paths.slice(from, from + size);
|
|
113
131
|
const next = from + taken.length;
|
|
114
|
-
const targets =
|
|
132
|
+
const targets = opening ? Object.keys(room.binaryFiles ?? {}) : [];
|
|
115
133
|
return {
|
|
116
134
|
kind: 'bootstrap',
|
|
117
135
|
roomVersion: room.roomVersion,
|
|
118
|
-
...(
|
|
136
|
+
...(opening ? { models: modelsOf(room) } : {}),
|
|
119
137
|
documents: named(room.documents ?? {}, taken),
|
|
120
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
138
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
139
|
+
...(room.fileIds === undefined
|
|
140
|
+
? {}
|
|
141
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
121
142
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
122
|
-
|
|
123
|
-
...(
|
|
124
|
-
...(next < paths.length ? { pageToken:
|
|
143
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
144
|
+
...(opening && room.folders !== undefined ? { folders: room.folders } : {}),
|
|
145
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function foldersMoved(room, from) {
|
|
149
|
+
const now = new Set(room.folders ?? []);
|
|
150
|
+
const before = new Set(from.folders ?? []);
|
|
151
|
+
const folders = [...now].filter((folder) => !before.has(folder)).sort();
|
|
152
|
+
const folderRemovals = [...before].filter((folder) => !now.has(folder)).sort();
|
|
153
|
+
return {
|
|
154
|
+
...(folders.length === 0 ? {} : { folders }),
|
|
155
|
+
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
125
156
|
};
|
|
126
157
|
}
|
|
127
158
|
function advancement(room, from, at) {
|
|
128
159
|
const current = room.documents ?? {};
|
|
129
160
|
const previous = from.documents ?? {};
|
|
130
|
-
const currentTargets = new Set(room.
|
|
131
|
-
const previousTargets = new Set(from.
|
|
161
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
162
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
132
163
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
164
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
133
165
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
134
166
|
const changed = Object.keys(current)
|
|
135
167
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -144,24 +176,25 @@ export function createMemoryAdapter(options = {}) {
|
|
|
144
176
|
const targets = opening
|
|
145
177
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
146
178
|
: [];
|
|
147
|
-
const attachments = room.attachments ?? [];
|
|
148
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
149
179
|
const models = opening ? changedModels(room, from) : undefined;
|
|
150
180
|
return {
|
|
151
181
|
kind: 'net-advancement',
|
|
152
182
|
roomVersion: room.roomVersion,
|
|
153
183
|
...(models === undefined ? {} : { models }),
|
|
154
184
|
documents: named(current, taken),
|
|
155
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
185
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
186
|
+
...(room.fileIds === undefined
|
|
187
|
+
? {}
|
|
188
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
156
189
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
157
|
-
|
|
190
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
191
|
+
...(opening ? foldersMoved(room, from) : {}),
|
|
158
192
|
removals: opening
|
|
159
193
|
? [
|
|
160
194
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
161
195
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
162
196
|
].sort()
|
|
163
197
|
: [],
|
|
164
|
-
...(declared ? { attachments } : {}),
|
|
165
198
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
166
199
|
};
|
|
167
200
|
}
|
|
@@ -182,7 +215,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
182
215
|
function historiesOf(input) {
|
|
183
216
|
const asked = input?.conversations;
|
|
184
217
|
if (!Array.isArray(asked))
|
|
185
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
218
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
186
219
|
const histories = [];
|
|
187
220
|
for (const entry of asked) {
|
|
188
221
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -210,21 +243,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
210
243
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
211
244
|
const conversation = scripted.get(named);
|
|
212
245
|
if (conversation === undefined) {
|
|
213
|
-
return {
|
|
246
|
+
return {
|
|
247
|
+
kind: 'rejected',
|
|
248
|
+
code: 'unknown-conversation',
|
|
249
|
+
fields: { conversation: named },
|
|
250
|
+
retryable: false,
|
|
251
|
+
};
|
|
214
252
|
}
|
|
215
253
|
const outcome = conversation.outcomes?.[name];
|
|
216
254
|
if (outcome !== undefined)
|
|
217
255
|
return outcome;
|
|
218
256
|
if (name === 'conversation.send') {
|
|
257
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
258
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
259
|
+
if (answered !== undefined)
|
|
260
|
+
return { kind: 'action', result: { turn: answered } };
|
|
219
261
|
issued += 1;
|
|
220
262
|
const turn = `turn-${issued}`;
|
|
221
263
|
unsealed.set(turn, named);
|
|
264
|
+
if (operation !== null)
|
|
265
|
+
sentTurns.set(operation, turn);
|
|
222
266
|
return { kind: 'action', result: { turn } };
|
|
223
267
|
}
|
|
224
268
|
if (name === 'conversation.cancel') {
|
|
225
269
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
226
270
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
227
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
271
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
228
272
|
}
|
|
229
273
|
unsealed.delete(turn);
|
|
230
274
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -245,9 +289,12 @@ export function createMemoryAdapter(options = {}) {
|
|
|
245
289
|
capabilities,
|
|
246
290
|
providerLimits,
|
|
247
291
|
retention,
|
|
292
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
248
293
|
};
|
|
249
294
|
}
|
|
250
295
|
return {
|
|
296
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
297
|
+
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
251
298
|
setRooms(next) {
|
|
252
299
|
rooms = [...next];
|
|
253
300
|
retain(rooms);
|
|
@@ -260,9 +307,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
260
307
|
for (const observer of observers)
|
|
261
308
|
observer({ kind: 'opened' });
|
|
262
309
|
},
|
|
263
|
-
close(revoked = false) {
|
|
310
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
264
311
|
for (const observer of observers)
|
|
265
|
-
observer({ kind: 'closed', revoked });
|
|
312
|
+
observer({ kind: 'closed', revoked, lost });
|
|
266
313
|
},
|
|
267
314
|
expire(locators) {
|
|
268
315
|
expiring = [...locators];
|
|
@@ -271,6 +318,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
271
318
|
for (const observer of observers)
|
|
272
319
|
observer({ kind: 'room-version', locator, roomVersion });
|
|
273
320
|
},
|
|
321
|
+
notifyAuthorityChanged(scope) {
|
|
322
|
+
for (const observer of observers) {
|
|
323
|
+
observer(scope === undefined
|
|
324
|
+
? { kind: 'authority-changed' }
|
|
325
|
+
: { kind: 'authority-changed', scope });
|
|
326
|
+
}
|
|
327
|
+
},
|
|
274
328
|
notifyConversation(event) {
|
|
275
329
|
if (event.kind === 'accepted-message') {
|
|
276
330
|
sealed.add(event.message.turn);
|
|
@@ -329,13 +383,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
329
383
|
}
|
|
330
384
|
});
|
|
331
385
|
},
|
|
386
|
+
reopen() {
|
|
387
|
+
queueMicrotask(() => {
|
|
388
|
+
for (const observer of observers) {
|
|
389
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
published() { },
|
|
332
394
|
observe(notify) {
|
|
333
395
|
observers.add(notify);
|
|
334
396
|
queueMicrotask(() => {
|
|
335
397
|
if (!observers.has(notify))
|
|
336
398
|
return;
|
|
337
399
|
if (options.unopened === true) {
|
|
338
|
-
notify({ kind: 'closed', revoked: false });
|
|
400
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
339
401
|
return;
|
|
340
402
|
}
|
|
341
403
|
announceList();
|
|
@@ -378,7 +440,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
378
440
|
if (room === undefined) {
|
|
379
441
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
380
442
|
}
|
|
381
|
-
return page(room, request.pageToken
|
|
443
|
+
return page(room, request.pageToken);
|
|
382
444
|
}, request).then((answer) => note(request.locator, answer));
|
|
383
445
|
},
|
|
384
446
|
async refresh(_authorization, request) {
|
|
@@ -411,8 +473,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
411
473
|
if (room === undefined) {
|
|
412
474
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
413
475
|
}
|
|
414
|
-
return {
|
|
415
|
-
|
|
476
|
+
return {
|
|
477
|
+
kind: 'rejected',
|
|
478
|
+
code: 'unscripted-mutation',
|
|
479
|
+
fields: {},
|
|
480
|
+
retryable: false,
|
|
481
|
+
affected: {},
|
|
482
|
+
};
|
|
483
|
+
}, request).then((answer) => {
|
|
484
|
+
const destination = request.changeBatch.between?.destination.room;
|
|
485
|
+
if (answer.kind === 'accepted' && answer.destination !== undefined && destination) {
|
|
486
|
+
note(destination, answer.destination);
|
|
487
|
+
}
|
|
488
|
+
return note(request.locator, answer);
|
|
489
|
+
});
|
|
416
490
|
},
|
|
417
491
|
async history(_authorization, request) {
|
|
418
492
|
return resolveScript(scripts.history, () => {
|
|
@@ -426,11 +500,46 @@ export function createMemoryAdapter(options = {}) {
|
|
|
426
500
|
};
|
|
427
501
|
}, request);
|
|
428
502
|
},
|
|
503
|
+
async binary(_authorization, request) {
|
|
504
|
+
return resolveScript(scripts.binary, () => {
|
|
505
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
506
|
+
if (room === undefined)
|
|
507
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
508
|
+
const blob = heldBlob(room, request.path);
|
|
509
|
+
return blob === undefined
|
|
510
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
511
|
+
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
512
|
+
}, request);
|
|
513
|
+
},
|
|
514
|
+
async link(_authorization, request) {
|
|
515
|
+
return resolveScript(scripts.link, () => {
|
|
516
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
517
|
+
if (room === undefined)
|
|
518
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
519
|
+
const blob = heldBlob(room, request.path);
|
|
520
|
+
if (blob === undefined) {
|
|
521
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
522
|
+
}
|
|
523
|
+
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
524
|
+
linked.set(blob, url);
|
|
525
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: blob.type };
|
|
526
|
+
}, request);
|
|
527
|
+
},
|
|
528
|
+
async attach(_authorization, request) {
|
|
529
|
+
return resolveScript(scripts.attach, () => {
|
|
530
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
531
|
+
if (room === undefined)
|
|
532
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
533
|
+
const path = freePath(room, request.name);
|
|
534
|
+
attached.set(`${room.locator}\u0000${path}`, request.blob);
|
|
535
|
+
return { kind: 'attached', path, revision: `attached-${attached.size}` };
|
|
536
|
+
}, request);
|
|
537
|
+
},
|
|
429
538
|
async action(_authorization, request) {
|
|
430
539
|
return resolveScript(scripts.action, () => {
|
|
431
540
|
if (request.name.startsWith('conversation.'))
|
|
432
541
|
return conversationAction(request);
|
|
433
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
542
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
434
543
|
}, request).then((answer) => {
|
|
435
544
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
436
545
|
note(answer.at.locator, answer.at);
|
|
@@ -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.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