@agentshouse/mdruntime 0.1.0-c03e7b79830dd → 0.1.0-c069136dcb4e8
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 +47 -48
- 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 -1174
- package/dist/conversation.d.ts +6 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +191 -121
- 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 +5 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +96 -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 -244
- package/dist/chat/messages.d.ts +0 -30
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -198
- 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 -306
- 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/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;
|
|
@@ -338,6 +376,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
338
376
|
listeners.delete(notify);
|
|
339
377
|
};
|
|
340
378
|
},
|
|
379
|
+
...(options.agents === undefined
|
|
380
|
+
? {}
|
|
381
|
+
: { agents: () => Promise.resolve(structuredClone(options.agents)) }),
|
|
341
382
|
},
|
|
342
383
|
serviceMode: {
|
|
343
384
|
observe(notify) {
|
|
@@ -349,33 +390,40 @@ export function createMemoryAdapter(options = {}) {
|
|
|
349
390
|
},
|
|
350
391
|
roomStream: {
|
|
351
392
|
hold(asked) {
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
expiring = [];
|
|
355
|
-
const moved = asked.flatMap((room) => {
|
|
393
|
+
const named = asked.map((room) => room.locator);
|
|
394
|
+
const unknown = asked.flatMap((room) => {
|
|
356
395
|
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
357
396
|
return current === undefined ||
|
|
358
|
-
|
|
359
|
-
|
|
397
|
+
current.roomVersion === room.roomVersion ||
|
|
398
|
+
served.get(room.locator)?.has(room.roomVersion) === true
|
|
360
399
|
? []
|
|
361
|
-
: [
|
|
400
|
+
: [room.locator];
|
|
362
401
|
});
|
|
402
|
+
const expired = [
|
|
403
|
+
...new Set([...expiring.filter((locator) => named.includes(locator)), ...unknown]),
|
|
404
|
+
];
|
|
405
|
+
expiring = expiring.filter((locator) => !named.includes(locator));
|
|
363
406
|
queueMicrotask(() => {
|
|
364
|
-
for (const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
407
|
+
for (const room of asked) {
|
|
408
|
+
if (expired.includes(room.locator))
|
|
409
|
+
carried.delete(room.locator);
|
|
410
|
+
else {
|
|
411
|
+
carried.set(room.locator, room.roomVersion);
|
|
412
|
+
carry(room.locator);
|
|
413
|
+
}
|
|
368
414
|
}
|
|
415
|
+
for (const observer of observers)
|
|
416
|
+
observer({ kind: 'opening', expired });
|
|
369
417
|
});
|
|
370
418
|
},
|
|
371
419
|
reopen() {
|
|
372
420
|
queueMicrotask(() => {
|
|
421
|
+
carried.clear();
|
|
373
422
|
for (const observer of observers) {
|
|
374
423
|
observer({ kind: 'closed', revoked: false, lost: false });
|
|
375
424
|
}
|
|
376
425
|
});
|
|
377
426
|
},
|
|
378
|
-
published() { },
|
|
379
427
|
observe(notify) {
|
|
380
428
|
observers.add(notify);
|
|
381
429
|
queueMicrotask(() => {
|
|
@@ -487,28 +535,38 @@ export function createMemoryAdapter(options = {}) {
|
|
|
487
535
|
},
|
|
488
536
|
async binary(_authorization, request) {
|
|
489
537
|
return resolveScript(scripts.binary, () => {
|
|
490
|
-
if (request.kind === 'reference') {
|
|
491
|
-
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
492
|
-
}
|
|
493
538
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
494
539
|
if (room === undefined)
|
|
495
540
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
496
|
-
const blob = room
|
|
541
|
+
const blob = heldBlob(room, request.path);
|
|
497
542
|
return blob === undefined
|
|
498
543
|
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
499
544
|
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
500
545
|
}, request);
|
|
501
546
|
},
|
|
502
547
|
async link(_authorization, request) {
|
|
503
|
-
return resolveScript(scripts.link, () =>
|
|
548
|
+
return resolveScript(scripts.link, () => {
|
|
549
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
550
|
+
if (room === undefined)
|
|
551
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
552
|
+
const blob = heldBlob(room, request.path);
|
|
553
|
+
if (blob === undefined) {
|
|
554
|
+
return { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false };
|
|
555
|
+
}
|
|
556
|
+
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
557
|
+
linked.set(blob, url);
|
|
558
|
+
return { kind: 'link', url, name: lastName(request.path), mediaType: blob.type };
|
|
559
|
+
}, request);
|
|
504
560
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
561
|
+
async attach(_authorization, request) {
|
|
562
|
+
return resolveScript(scripts.attach, () => {
|
|
563
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
564
|
+
if (room === undefined)
|
|
565
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
566
|
+
const path = freePath(room, request.name);
|
|
567
|
+
attached.set(`${room.locator}\u0000${path}`, request.blob);
|
|
568
|
+
return { kind: 'attached', path, revision: `attached-${attached.size}` };
|
|
569
|
+
}, request);
|
|
512
570
|
},
|
|
513
571
|
async action(_authorization, request) {
|
|
514
572
|
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":"AA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AY,EAAE,MAAM,GAAG,MAAM,CAMjF;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAW9F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAG9D"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { indexMessage, unindexMessages } from './fulltext.js';
|
|
2
|
+
export const MESSAGE_TABLES = [
|
|
3
|
+
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
4
|
+
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
5
|
+
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
6
|
+
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
7
|
+
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
8
|
+
];
|
|
9
|
+
function text(value) {
|
|
10
|
+
return typeof value === 'string' ? value : String(value);
|
|
11
|
+
}
|
|
12
|
+
export function heldConversations(connection) {
|
|
13
|
+
const held = new Map();
|
|
14
|
+
for (const row of connection.rows('SELECT conversation, read, partial FROM conversation_reads')) {
|
|
15
|
+
held.set(text(row.conversation), {
|
|
16
|
+
conversation: text(row.conversation),
|
|
17
|
+
read: row.read === null ? null : text(row.read),
|
|
18
|
+
partial: Number(row.partial) === 1,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
for (const row of connection.rows('SELECT DISTINCT conversation FROM conversation_messages WHERE conversation NOT IN (SELECT conversation FROM conversation_reads)')) {
|
|
22
|
+
held.set(text(row.conversation), {
|
|
23
|
+
conversation: text(row.conversation),
|
|
24
|
+
read: undefined,
|
|
25
|
+
partial: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return [...held.values()];
|
|
29
|
+
}
|
|
30
|
+
export function keptMessages(connection, { conversation, messages, read }) {
|
|
31
|
+
for (const message of messages) {
|
|
32
|
+
const [held] = connection.rows('SELECT id FROM conversation_messages WHERE conversation = ? AND identity = ?', [conversation, message.identity]);
|
|
33
|
+
const record = [
|
|
34
|
+
message.turn,
|
|
35
|
+
message.position,
|
|
36
|
+
JSON.stringify(message.message ?? null),
|
|
37
|
+
message.text,
|
|
38
|
+
];
|
|
39
|
+
let id;
|
|
40
|
+
if (held === undefined) {
|
|
41
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
42
|
+
id = Number(connection.rows('SELECT last_insert_rowid() AS id')[0].id);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
id = Number(held.id);
|
|
46
|
+
unindexMessages(connection, [id]);
|
|
47
|
+
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, id]);
|
|
48
|
+
}
|
|
49
|
+
indexMessage(connection, id, message.text);
|
|
50
|
+
}
|
|
51
|
+
if (read !== undefined) {
|
|
52
|
+
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function accepted(row) {
|
|
57
|
+
return {
|
|
58
|
+
identity: text(row.identity),
|
|
59
|
+
turn: text(row.turn),
|
|
60
|
+
position: text(row.position),
|
|
61
|
+
text: text(row.text),
|
|
62
|
+
message: JSON.parse(text(row.message)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function messageWindow(connection, conversation, limit, before) {
|
|
66
|
+
const rows = connection.rows(`SELECT identity, turn, position, message, text FROM conversation_messages WHERE conversation = ?${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
67
|
+
? [conversation, limit + 1]
|
|
68
|
+
: [conversation, before[0], before[0], before[1], limit + 1]);
|
|
69
|
+
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
70
|
+
}
|
|
71
|
+
export function messageCount(connection, conversation) {
|
|
72
|
+
const [counted] = connection.rows('SELECT count(*) AS held FROM conversation_messages WHERE conversation = ?', [conversation]);
|
|
73
|
+
return Number(counted?.held ?? 0);
|
|
74
|
+
}
|
|
75
|
+
export function turnArrived(connection, conversation, turn) {
|
|
76
|
+
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
77
|
+
}
|
|
78
|
+
export function droppedMessages(connection, conversations) {
|
|
79
|
+
for (const conversation of conversations) {
|
|
80
|
+
unindexMessages(connection, connection
|
|
81
|
+
.rows('SELECT id FROM conversation_messages WHERE conversation = ?', [conversation])
|
|
82
|
+
.map((row) => Number(row.id)));
|
|
83
|
+
connection.run('DELETE FROM conversation_messages WHERE conversation = ?', [conversation]);
|
|
84
|
+
connection.run('DELETE FROM conversation_reads WHERE conversation = ?', [conversation]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function forgottenMessages(connection) {
|
|
88
|
+
connection.run('DELETE FROM conversation_messages');
|
|
89
|
+
connection.run('DELETE FROM conversation_reads');
|
|
90
|
+
}
|
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,W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G,UAAU,GAAG,SAAS,CAGhG;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAczD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEpD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAE5E;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAErE"}
|
package/dist/model.js
CHANGED
|
@@ -14,24 +14,21 @@ export function modelTypes(state) {
|
|
|
14
14
|
verifiedWith: { ...state.verifiedWith },
|
|
15
15
|
schema: state.snapshot.schema,
|
|
16
16
|
revision: state.snapshot.revision,
|
|
17
|
-
types:
|
|
17
|
+
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,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,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AC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAEN,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa3C;AAMD,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,MAAM,CAU9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAY3E;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CA+BjF"}
|
package/dist/observation.js
CHANGED
|
@@ -110,7 +110,7 @@ export 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;
|
|
@@ -44,9 +54,9 @@ export declare const UNREADABLE: Refused<'unreadable'>;
|
|
|
44
54
|
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
|
-
export declare function absentReference(fileRef: string): Refused<'absent'>;
|
|
48
57
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
49
|
-
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;
|
|
50
60
|
export declare const ROOM_LOCKED = "room-locked";
|
|
51
61
|
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
52
62
|
locator: string;
|
|
@@ -70,9 +80,6 @@ export type QueueEntry = {
|
|
|
70
80
|
readonly batch: ChangeBatch;
|
|
71
81
|
} & (Submission | {
|
|
72
82
|
readonly state: 'local';
|
|
73
|
-
} | {
|
|
74
|
-
readonly state: 'accepted';
|
|
75
|
-
readonly roomVersion: string;
|
|
76
83
|
});
|
|
77
84
|
export {};
|
|
78
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,CAAC,GAChC,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,aAAa,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,aAAa,CAAA;CAAE,GACvD,OAAO,CAAC,UAAU,CAAC,GACnB,OAAO,CAAC,YAAY,CAAC,GACrB,OAAO,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC;AAExF,KAAK,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,G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CAAE,CAAC;AAEnD,eAAO,MAAM,OAAO,EAAE,OAA6B,CAAC;AAEpD,eAAO,MAAM,SAAS,EAAE,OAKvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEnD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAiBvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAE7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAIlE;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG,CACvD,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC"}
|
package/dist/outcome.js
CHANGED
|
@@ -19,14 +19,25 @@ export const ABSENT_TARGET = {
|
|
|
19
19
|
export function absentBinary(path) {
|
|
20
20
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
21
|
}
|
|
22
|
-
export function absentReference(fileRef) {
|
|
23
|
-
return { kind: 'absent', code: 'binary-file-absent', fields: { fileRef }, retryable: false };
|
|
24
|
-
}
|
|
25
22
|
export function binaryAnswer(result) {
|
|
26
23
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
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);
|
|
30
41
|
}
|
|
31
42
|
export const ROOM_LOCKED = 'room-locked';
|
|
32
43
|
export function lockedRoom(locator) {
|
package/dist/overlay.js
CHANGED
|
@@ -13,7 +13,7 @@ export function sameBinary(left, right) {
|
|
|
13
13
|
left.mediaType === right.mediaType &&
|
|
14
14
|
left.sha256 === right.sha256 &&
|
|
15
15
|
(left.state === 'accepted'
|
|
16
|
-
? right.state === 'accepted'
|
|
16
|
+
? right.state === 'accepted'
|
|
17
17
|
: right.state === 'pending' && left.localId === right.localId));
|
|
18
18
|
}
|
|
19
19
|
export function sameChange(left, right) {
|
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
|
+
}
|