@agentshouse/mdruntime 0.1.0-ccd098ff75bbf → 0.1.0-cce1d81ef3d6d
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/dist/adapter.d.ts +65 -48
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +18 -1
- package/dist/bootstrap.d.ts +9 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +97 -85
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -6
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +65 -19
- package/dist/connection.d.ts +5 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +925 -900
- package/dist/conversation.d.ts +11 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +204 -129
- package/dist/durability.d.ts +0 -1
- package/dist/durability.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/fulltext.js +8 -6
- package/dist/host.d.ts +0 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +10 -11
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.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 +8 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +174 -82
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -9
- 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 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- 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 +6 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +8 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +49 -22
- package/dist/readiness.d.ts +3 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- 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 +5 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +2 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -5
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +40 -6
- package/dist/rows.d.ts +4 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +29 -20
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +11 -5
- 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 +18 -32
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +25 -60
- package/dist/stored.d.ts +9 -24
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +207 -204
- package/dist/tables.d.ts +16 -45
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +7 -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 +8 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +8 -2
- package/package.json +2 -2
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
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,
|
|
@@ -48,13 +52,16 @@ export function createMemoryAdapter(options = {}) {
|
|
|
48
52
|
const listeners = new Set();
|
|
49
53
|
const modeObservers = new Set();
|
|
50
54
|
const scripted = new Map();
|
|
51
|
-
const unsealed = new Map();
|
|
52
|
-
const sealed = new Set();
|
|
53
55
|
const sentTurns = new Map();
|
|
54
56
|
const historyPageSize = options.historyPageSize;
|
|
55
|
-
|
|
57
|
+
const attached = new Map();
|
|
58
|
+
const linked = new WeakMap();
|
|
59
|
+
const carried = new Map();
|
|
56
60
|
let expiring = [];
|
|
61
|
+
let openings = 0;
|
|
62
|
+
const declaredRooms = new Set();
|
|
57
63
|
let replicated = [];
|
|
64
|
+
let heldCursor = null;
|
|
58
65
|
let issued = 0;
|
|
59
66
|
function scriptConversations(entries) {
|
|
60
67
|
scripted.clear();
|
|
@@ -82,6 +89,19 @@ export function createMemoryAdapter(options = {}) {
|
|
|
82
89
|
const wanted = ordinals.get(`${locator}\u0000${target}`);
|
|
83
90
|
return held !== undefined && wanted !== undefined && held >= wanted;
|
|
84
91
|
}
|
|
92
|
+
function heldBlob(room, path) {
|
|
93
|
+
return attached.get(`${room.locator}\u0000${path}`) ?? room.blobs?.[path];
|
|
94
|
+
}
|
|
95
|
+
function freePath(room, name) {
|
|
96
|
+
const dot = name.lastIndexOf('.');
|
|
97
|
+
const stem = dot > 0 ? name.slice(0, dot) : name;
|
|
98
|
+
const extension = dot > 0 ? name.slice(dot) : '';
|
|
99
|
+
for (let count = 1;; count += 1) {
|
|
100
|
+
const path = `${ATTACHMENTS}/${count === 1 ? stem : `${stem}-${count}`}${extension}`;
|
|
101
|
+
if (heldBlob(room, path) === undefined && room.documents?.[path] === undefined)
|
|
102
|
+
return path;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
85
105
|
function retain(entries) {
|
|
86
106
|
for (const room of entries) {
|
|
87
107
|
note(room.locator, room);
|
|
@@ -136,7 +156,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
136
156
|
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
137
157
|
};
|
|
138
158
|
}
|
|
139
|
-
function advancement(room, from, at) {
|
|
159
|
+
function advancement(room, from, at, whole = false) {
|
|
140
160
|
const current = room.documents ?? {};
|
|
141
161
|
const previous = from.documents ?? {};
|
|
142
162
|
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
@@ -147,7 +167,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
147
167
|
const changed = Object.keys(current)
|
|
148
168
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
149
169
|
.sort();
|
|
150
|
-
const size = pageSize ?? changed.length;
|
|
170
|
+
const size = whole ? changed.length : (pageSize ?? changed.length);
|
|
151
171
|
const taken = changed.slice(at, at + size);
|
|
152
172
|
const next = at + taken.length;
|
|
153
173
|
const opening = at === 0;
|
|
@@ -179,6 +199,26 @@ export function createMemoryAdapter(options = {}) {
|
|
|
179
199
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
180
200
|
};
|
|
181
201
|
}
|
|
202
|
+
function carry(locator) {
|
|
203
|
+
const at = carried.get(locator);
|
|
204
|
+
const current = rooms.find((entry) => entry.locator === locator);
|
|
205
|
+
if (at === undefined || current === undefined || current.roomVersion === at)
|
|
206
|
+
return;
|
|
207
|
+
const from = served.get(locator)?.get(at);
|
|
208
|
+
carried.set(locator, current.roomVersion);
|
|
209
|
+
if (from === undefined)
|
|
210
|
+
return;
|
|
211
|
+
const page = advancement(current, from, 0, true);
|
|
212
|
+
for (const observer of observers) {
|
|
213
|
+
observer({
|
|
214
|
+
kind: 'room-change',
|
|
215
|
+
locator,
|
|
216
|
+
from: at,
|
|
217
|
+
roomVersion: current.roomVersion,
|
|
218
|
+
read: async () => page,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
182
222
|
function pageOf(conversation, after) {
|
|
183
223
|
const messages = conversation.messages ?? [];
|
|
184
224
|
const first = typeof after === 'string' ? messages.findIndex((message) => message.position > after) : 0;
|
|
@@ -193,16 +233,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
193
233
|
: {}),
|
|
194
234
|
};
|
|
195
235
|
}
|
|
196
|
-
function historiesOf(
|
|
197
|
-
const asked = input?.conversations;
|
|
198
|
-
if (!Array.isArray(asked))
|
|
199
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
236
|
+
function historiesOf(request) {
|
|
200
237
|
const histories = [];
|
|
201
|
-
for (const entry of
|
|
202
|
-
const conversation =
|
|
238
|
+
for (const entry of request.conversations) {
|
|
239
|
+
const conversation = scripted.get(entry.conversation);
|
|
203
240
|
if (conversation === undefined)
|
|
204
241
|
continue;
|
|
205
|
-
const outcome = conversation.outcomes?.
|
|
242
|
+
const outcome = conversation.outcomes?.history;
|
|
206
243
|
if (outcome !== undefined)
|
|
207
244
|
return outcome;
|
|
208
245
|
histories.push(pageOf(conversation, entry.after));
|
|
@@ -213,15 +250,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
213
250
|
function conversationAction(request) {
|
|
214
251
|
const name = request.name;
|
|
215
252
|
const input = (request.input ?? {});
|
|
216
|
-
if (name === '
|
|
217
|
-
return historiesOf(request.input);
|
|
218
|
-
if (name === 'conversation.create') {
|
|
253
|
+
if (name === 'conversations/create') {
|
|
219
254
|
issued += 1;
|
|
220
255
|
const conversation = `conversation-${issued}`;
|
|
221
256
|
scripted.set(conversation, { conversation });
|
|
222
|
-
return { kind: 'action', result: { conversation } };
|
|
257
|
+
return { kind: 'action', result: { conversation_id: conversation } };
|
|
223
258
|
}
|
|
224
|
-
const named = typeof input.
|
|
259
|
+
const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
|
|
225
260
|
const conversation = scripted.get(named);
|
|
226
261
|
if (conversation === undefined) {
|
|
227
262
|
return {
|
|
@@ -234,34 +269,28 @@ export function createMemoryAdapter(options = {}) {
|
|
|
234
269
|
const outcome = conversation.outcomes?.[name];
|
|
235
270
|
if (outcome !== undefined)
|
|
236
271
|
return outcome;
|
|
237
|
-
if (name === '
|
|
272
|
+
if (name === 'conversations/send') {
|
|
238
273
|
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
239
274
|
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
240
275
|
if (answered !== undefined)
|
|
241
|
-
return { kind: 'action', result: {
|
|
276
|
+
return { kind: 'action', result: { message_id: answered } };
|
|
242
277
|
issued += 1;
|
|
243
278
|
const turn = `turn-${issued}`;
|
|
244
|
-
unsealed.set(turn, named);
|
|
245
279
|
if (operation !== null)
|
|
246
280
|
sentTurns.set(operation, turn);
|
|
247
|
-
return { kind: 'action', result: { turn } };
|
|
248
|
-
}
|
|
249
|
-
if (name === 'conversation.cancel') {
|
|
250
|
-
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
251
|
-
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
252
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
253
|
-
}
|
|
254
|
-
unsealed.delete(turn);
|
|
255
|
-
return { kind: 'action', result: { turn, cancelled: true } };
|
|
281
|
+
return { kind: 'action', result: { message_id: turn } };
|
|
256
282
|
}
|
|
257
|
-
if (name === '
|
|
283
|
+
if (name === 'conversations/delete')
|
|
258
284
|
scripted.delete(named);
|
|
259
|
-
return { kind: 'action', result: {
|
|
285
|
+
return { kind: 'action', result: { conversation_id: named } };
|
|
260
286
|
}
|
|
261
287
|
function announceList() {
|
|
262
|
-
const entries = [...scripted.values()].flatMap(({ conversation, listed }) => listed === undefined
|
|
263
|
-
|
|
264
|
-
|
|
288
|
+
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
289
|
+
? []
|
|
290
|
+
: [{ conversation, ...listed, newest: messages.at(-1)?.position ?? null }]);
|
|
291
|
+
for (const listener of listeners) {
|
|
292
|
+
listener({ kind: 'list', entries, whole: true, more: false, cursor: null });
|
|
293
|
+
}
|
|
265
294
|
}
|
|
266
295
|
function discovery() {
|
|
267
296
|
return {
|
|
@@ -273,8 +302,40 @@ export function createMemoryAdapter(options = {}) {
|
|
|
273
302
|
...(options.member === undefined ? {} : { member: options.member }),
|
|
274
303
|
};
|
|
275
304
|
}
|
|
305
|
+
function discovered() {
|
|
306
|
+
return resolveScript(scripts.discover, discovery, undefined).then((answer) => {
|
|
307
|
+
if (answer.kind === 'discovery')
|
|
308
|
+
for (const room of answer.rooms)
|
|
309
|
+
note(room.locator, room);
|
|
310
|
+
return answer;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function opened(notify) {
|
|
314
|
+
const opening = ++openings;
|
|
315
|
+
notify({ kind: 'opened' });
|
|
316
|
+
void discovered()
|
|
317
|
+
.catch(() => ({ kind: 'transport-uncertainty' }))
|
|
318
|
+
.then((answer) => {
|
|
319
|
+
if (opening !== openings)
|
|
320
|
+
return;
|
|
321
|
+
if (answer.kind !== 'discovery') {
|
|
322
|
+
openings += 1;
|
|
323
|
+
carried.clear();
|
|
324
|
+
const revoked = answer.kind === 'revoked-authorization';
|
|
325
|
+
notify({ kind: 'closed', revoked, lost: !revoked });
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
declaredRooms.clear();
|
|
329
|
+
for (const room of answer.rooms)
|
|
330
|
+
declaredRooms.add(room.locator);
|
|
331
|
+
notify({ kind: 'discovered', discovery: answer });
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function emitAll(event) {
|
|
335
|
+
for (const observer of observers)
|
|
336
|
+
observer(event);
|
|
337
|
+
}
|
|
276
338
|
return {
|
|
277
|
-
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
278
339
|
...(options.roomTypes === undefined ? {} : { roomTypes: options.roomTypes }),
|
|
279
340
|
setRooms(next) {
|
|
280
341
|
rooms = [...next];
|
|
@@ -284,33 +345,37 @@ export function createMemoryAdapter(options = {}) {
|
|
|
284
345
|
scriptConversations(next);
|
|
285
346
|
},
|
|
286
347
|
open() {
|
|
348
|
+
carried.clear();
|
|
287
349
|
announceList();
|
|
288
|
-
|
|
289
|
-
observer({ kind: 'opened' });
|
|
350
|
+
opened(emitAll);
|
|
290
351
|
},
|
|
291
352
|
close({ revoked = false, lost = !revoked } = {}) {
|
|
292
|
-
|
|
293
|
-
|
|
353
|
+
openings += 1;
|
|
354
|
+
carried.clear();
|
|
355
|
+
emitAll({ kind: 'closed', revoked, lost });
|
|
294
356
|
},
|
|
295
357
|
expire(locators) {
|
|
296
358
|
expiring = [...locators];
|
|
297
359
|
},
|
|
298
|
-
notifyRoomVersion({ locator
|
|
299
|
-
|
|
300
|
-
observer({ kind: 'room-version', locator, roomVersion });
|
|
360
|
+
notifyRoomVersion({ locator }) {
|
|
361
|
+
carry(locator);
|
|
301
362
|
},
|
|
302
|
-
notifyAuthorityChanged(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
363
|
+
notifyAuthorityChanged(locators) {
|
|
364
|
+
const named = new Set(locators ?? [...declaredRooms, ...rooms.map((room) => room.locator)]);
|
|
365
|
+
const listed = rooms.filter((room) => named.has(room.locator));
|
|
366
|
+
const left = [...named].filter((locator) => !listed.some((room) => room.locator === locator));
|
|
367
|
+
for (const room of listed)
|
|
368
|
+
declaredRooms.add(room.locator);
|
|
369
|
+
for (const locator of left)
|
|
370
|
+
declaredRooms.delete(locator);
|
|
371
|
+
emitAll({
|
|
372
|
+
kind: 'authority-changed',
|
|
373
|
+
rooms: listed.map(declared),
|
|
374
|
+
left,
|
|
375
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
376
|
+
});
|
|
308
377
|
},
|
|
309
378
|
notifyConversation(event) {
|
|
310
|
-
if (event.kind === 'accepted-message') {
|
|
311
|
-
sealed.add(event.message.turn);
|
|
312
|
-
unsealed.delete(event.message.turn);
|
|
313
|
-
}
|
|
314
379
|
for (const listener of listeners)
|
|
315
380
|
listener(event);
|
|
316
381
|
},
|
|
@@ -319,21 +384,31 @@ export function createMemoryAdapter(options = {}) {
|
|
|
319
384
|
observer(mode);
|
|
320
385
|
},
|
|
321
386
|
heldRooms() {
|
|
322
|
-
return
|
|
387
|
+
return [...carried.keys()].sort();
|
|
323
388
|
},
|
|
324
389
|
replicatedConversations() {
|
|
325
390
|
return replicated;
|
|
326
391
|
},
|
|
392
|
+
heldConversationCursor() {
|
|
393
|
+
return heldCursor;
|
|
394
|
+
},
|
|
327
395
|
conversations: {
|
|
328
396
|
replicate(next) {
|
|
329
397
|
replicated = [...next];
|
|
330
398
|
},
|
|
399
|
+
hold(cursor) {
|
|
400
|
+
heldCursor = cursor;
|
|
401
|
+
},
|
|
331
402
|
observe(notify) {
|
|
332
403
|
listeners.add(notify);
|
|
333
404
|
return () => {
|
|
334
405
|
listeners.delete(notify);
|
|
335
406
|
};
|
|
336
407
|
},
|
|
408
|
+
history: (request) => Promise.resolve(historiesOf(request)),
|
|
409
|
+
...(options.agents === undefined
|
|
410
|
+
? {}
|
|
411
|
+
: { agents: () => Promise.resolve(structuredClone(options.agents)) }),
|
|
337
412
|
},
|
|
338
413
|
serviceMode: {
|
|
339
414
|
observe(notify) {
|
|
@@ -345,33 +420,31 @@ export function createMemoryAdapter(options = {}) {
|
|
|
345
420
|
},
|
|
346
421
|
roomStream: {
|
|
347
422
|
hold(asked) {
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
expiring = [];
|
|
351
|
-
const moved = asked.flatMap((room) => {
|
|
423
|
+
const named = asked.map((room) => room.locator);
|
|
424
|
+
const unknown = asked.flatMap((room) => {
|
|
352
425
|
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
353
426
|
return current === undefined ||
|
|
354
|
-
|
|
355
|
-
|
|
427
|
+
current.roomVersion === room.roomVersion ||
|
|
428
|
+
served.get(room.locator)?.has(room.roomVersion) === true
|
|
356
429
|
? []
|
|
357
|
-
: [
|
|
430
|
+
: [room.locator];
|
|
358
431
|
});
|
|
432
|
+
const expired = [
|
|
433
|
+
...new Set([...expiring.filter((locator) => named.includes(locator)), ...unknown]),
|
|
434
|
+
];
|
|
435
|
+
expiring = expiring.filter((locator) => !named.includes(locator));
|
|
359
436
|
queueMicrotask(() => {
|
|
360
|
-
for (const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
437
|
+
for (const room of asked) {
|
|
438
|
+
if (expired.includes(room.locator))
|
|
439
|
+
carried.delete(room.locator);
|
|
440
|
+
else {
|
|
441
|
+
carried.set(room.locator, room.roomVersion);
|
|
442
|
+
carry(room.locator);
|
|
443
|
+
}
|
|
364
444
|
}
|
|
445
|
+
emitAll({ kind: 'caught-up', expired });
|
|
365
446
|
});
|
|
366
447
|
},
|
|
367
|
-
reopen() {
|
|
368
|
-
queueMicrotask(() => {
|
|
369
|
-
for (const observer of observers) {
|
|
370
|
-
observer({ kind: 'closed', revoked: false, lost: false });
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
},
|
|
374
|
-
published() { },
|
|
375
448
|
observe(notify) {
|
|
376
449
|
observers.add(notify);
|
|
377
450
|
queueMicrotask(() => {
|
|
@@ -382,7 +455,10 @@ export function createMemoryAdapter(options = {}) {
|
|
|
382
455
|
return;
|
|
383
456
|
}
|
|
384
457
|
announceList();
|
|
385
|
-
|
|
458
|
+
opened((event) => {
|
|
459
|
+
if (observers.has(notify))
|
|
460
|
+
notify(event);
|
|
461
|
+
});
|
|
386
462
|
});
|
|
387
463
|
return () => {
|
|
388
464
|
observers.delete(notify);
|
|
@@ -399,12 +475,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
399
475
|
return resolveScript(scripts.authorize, () => ({}), undefined);
|
|
400
476
|
},
|
|
401
477
|
async discover(_authorization) {
|
|
402
|
-
return
|
|
403
|
-
if (answer.kind === 'discovery')
|
|
404
|
-
for (const room of answer.rooms)
|
|
405
|
-
note(room.locator, room);
|
|
406
|
-
return answer;
|
|
407
|
-
});
|
|
478
|
+
return discovered();
|
|
408
479
|
},
|
|
409
480
|
reached,
|
|
410
481
|
follows(locator, roomVersion, next) {
|
|
@@ -486,18 +557,39 @@ export function createMemoryAdapter(options = {}) {
|
|
|
486
557
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
487
558
|
if (room === undefined)
|
|
488
559
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
489
|
-
const blob = room
|
|
560
|
+
const blob = heldBlob(room, request.path);
|
|
490
561
|
return blob === undefined
|
|
491
562
|
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
492
563
|
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
493
564
|
}, request);
|
|
494
565
|
},
|
|
495
566
|
async link(_authorization, request) {
|
|
496
|
-
return resolveScript(scripts.link, () =>
|
|
567
|
+
return resolveScript(scripts.link, () => {
|
|
568
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
569
|
+
if (room === undefined)
|
|
570
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
571
|
+
const blob = heldBlob(room, request.path);
|
|
572
|
+
if (blob === undefined) {
|
|
573
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
574
|
+
}
|
|
575
|
+
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
576
|
+
linked.set(blob, url);
|
|
577
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: blob.type };
|
|
578
|
+
}, request);
|
|
579
|
+
},
|
|
580
|
+
async attach(_authorization, request) {
|
|
581
|
+
return resolveScript(scripts.attach, () => {
|
|
582
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
583
|
+
if (room === undefined)
|
|
584
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
585
|
+
const path = freePath(room, request.name);
|
|
586
|
+
attached.set(`${room.locator}\u0000${path}`, request.blob);
|
|
587
|
+
return { kind: 'attached', path, revision: `attached-${attached.size}` };
|
|
588
|
+
}, request);
|
|
497
589
|
},
|
|
498
590
|
async action(_authorization, request) {
|
|
499
591
|
return resolveScript(scripts.action, () => {
|
|
500
|
-
if (request.name.startsWith('
|
|
592
|
+
if (request.name.startsWith('conversations/'))
|
|
501
593
|
return conversationAction(request);
|
|
502
594
|
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
503
595
|
}, request).then((answer) => {
|
package/dist/model.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export type ModelState = {
|
|
|
28
28
|
verifiedWith: ModelIdentity;
|
|
29
29
|
types: VerifiedModel['types'];
|
|
30
30
|
};
|
|
31
|
+
export type StoredModel = Extract<ModelState, {
|
|
32
|
+
status: 'unavailable';
|
|
33
|
+
}> | Omit<Extract<ModelState, {
|
|
34
|
+
status: 'current' | 'cached';
|
|
35
|
+
}>, 'types'>;
|
|
31
36
|
export type TypesResult = {
|
|
32
37
|
status: Open<'unavailable'>;
|
|
33
38
|
reason: ModelUnavailableReason;
|
|
@@ -51,8 +56,8 @@ export type ValidationReceipt = {
|
|
|
51
56
|
export declare const NO_MODEL: ModelState;
|
|
52
57
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
53
58
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
54
60
|
export declare function cached(state: ModelState): ModelState;
|
|
55
61
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
-
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
57
62
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
58
63
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAC/F,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC,CAAC;AACnG,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC;AAChC,MAAM,MAAM,UAAU,GAClB;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GACD;IACE,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,QAAQ,EAA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types: Object.values(state.types).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
export function storedModel(state) {
|
|
21
|
+
if (state.status === 'unavailable')
|
|
22
|
+
return state;
|
|
23
|
+
const { types: _types, ...stored } = state;
|
|
24
|
+
return stored;
|
|
25
|
+
}
|
|
20
26
|
export function cached(state) {
|
|
21
27
|
return state.status === 'unavailable' ? state : { ...state, status: 'cached' };
|
|
22
28
|
}
|
|
23
29
|
export function sameModel(left, right) {
|
|
24
30
|
return left.identity === right.identity && left.version === right.version;
|
|
25
31
|
}
|
|
26
|
-
export function sameTyping(left, right) {
|
|
27
|
-
if (left === right)
|
|
28
|
-
return true;
|
|
29
|
-
if (left.status === 'unavailable' || right.status === 'unavailable') {
|
|
30
|
-
return left.status === right.status;
|
|
31
|
-
}
|
|
32
|
-
return (left.snapshot.schema === right.snapshot.schema &&
|
|
33
|
-
sameModel(left.verifiedWith, right.verifiedWith));
|
|
34
|
-
}
|
|
35
32
|
export function referenceField(facts) {
|
|
36
33
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
37
34
|
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export type Digest = {
|
|
|
38
38
|
readonly next: string | undefined;
|
|
39
39
|
readonly total: number | undefined;
|
|
40
40
|
};
|
|
41
|
+
export declare function hashed(text: string): number;
|
|
41
42
|
export declare function digestOf({ result, keys }: KeyedResult): Digest;
|
|
42
43
|
export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
|
|
43
44
|
export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,MAAM,WA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function observing(watch) {
|
|
|
110
110
|
deliver(structuredClone(message));
|
|
111
111
|
}), topic === 'query');
|
|
112
112
|
}
|
|
113
|
-
function hashed(text) {
|
|
113
|
+
export function hashed(text) {
|
|
114
114
|
let first = 0xdeadbeef;
|
|
115
115
|
let second = 0x41c6ce57;
|
|
116
116
|
for (let index = 0; index < text.length; index += 1) {
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
@@ -29,7 +29,17 @@ export type BinaryLinkAnswer = {
|
|
|
29
29
|
kind: 'link';
|
|
30
30
|
url: string;
|
|
31
31
|
name: string;
|
|
32
|
+
mediaType: string;
|
|
32
33
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
34
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
35
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
36
|
+
export type AttachAnswer = {
|
|
37
|
+
kind: 'attached';
|
|
38
|
+
path: string;
|
|
39
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
40
|
+
export type DownloadAnswer = {
|
|
41
|
+
kind: 'started';
|
|
42
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
33
43
|
export type Resolution = {
|
|
34
44
|
readonly kind: 'document';
|
|
35
45
|
readonly room: string;
|
|
@@ -45,7 +55,8 @@ export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
|
45
55
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
46
56
|
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
47
57
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
48
|
-
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
58
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
59
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
49
60
|
export declare const ROOM_LOCKED = "room-locked";
|
|
50
61
|
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
51
62
|
locator: string;
|
|
@@ -69,9 +80,6 @@ export type QueueEntry = {
|
|
|
69
80
|
readonly batch: ChangeBatch;
|
|
70
81
|
} & (Submission | {
|
|
71
82
|
readonly state: 'local';
|
|
72
|
-
} | {
|
|
73
|
-
readonly state: 'accepted';
|
|
74
|
-
readonly roomVersion: string;
|
|
75
83
|
});
|
|
76
84
|
export {};
|
|
77
85
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,GAChC,OAAO,CAAC,uBAAuB,CA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AU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC"}
|
package/dist/outcome.js
CHANGED
|
@@ -22,8 +22,22 @@ export function absentBinary(path) {
|
|
|
22
22
|
export function binaryAnswer(result) {
|
|
23
23
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const OCTET_STREAM = 'application/octet-stream';
|
|
26
|
+
export function binaryLinkAnswer(result, held) {
|
|
27
|
+
if (result.kind === 'link') {
|
|
28
|
+
return {
|
|
29
|
+
kind: 'link',
|
|
30
|
+
url: result.url,
|
|
31
|
+
name: result.name,
|
|
32
|
+
mediaType: result.mediaType ?? held ?? OCTET_STREAM,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
36
|
+
}
|
|
37
|
+
export function attachAnswer(result) {
|
|
38
|
+
if (result.kind === 'attached')
|
|
39
|
+
return { kind: 'attached', path: result.path };
|
|
40
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
27
41
|
}
|
|
28
42
|
export const ROOM_LOCKED = 'room-locked';
|
|
29
43
|
export function lockedRoom(locator) {
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
+
export declare function ancestors(path: string): readonly string[];
|
|
4
5
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1E"}
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAGzD"}
|
package/dist/paths.js
CHANGED
|
@@ -22,3 +22,7 @@ export function covered(prefixes, path) {
|
|
|
22
22
|
return normalized !== null && (normalized === '' || beneath(normalized, path));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
export function ancestors(path) {
|
|
26
|
+
const parts = path.split('/');
|
|
27
|
+
return parts.slice(1).map((_, at) => parts.slice(0, at + 1).join('/'));
|
|
28
|
+
}
|
package/dist/query.d.ts
CHANGED
|
@@ -232,9 +232,15 @@ export type GroupShape = {
|
|
|
232
232
|
direction: Direction;
|
|
233
233
|
}[];
|
|
234
234
|
};
|
|
235
|
+
export type PlanArea = {
|
|
236
|
+
room: string;
|
|
237
|
+
path: string;
|
|
238
|
+
open: readonly string[];
|
|
239
|
+
};
|
|
235
240
|
export type PlanReach = {
|
|
236
241
|
rooms: readonly string[];
|
|
237
242
|
documents: readonly string[];
|
|
243
|
+
areas: readonly PlanArea[];
|
|
238
244
|
};
|
|
239
245
|
export type Continuation = {
|
|
240
246
|
text: string;
|