@agentshouse/mdruntime 0.1.0-cbb8d8acc9d19 → 0.1.0-cc56db96f86ae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +285 -225
- package/README.md +21 -10
- package/dist/adapter.d.ts +114 -26
- package/dist/adapter.d.ts.map +1 -1
- 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 +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +18 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +147 -40
- package/dist/change-set.d.ts +7 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +50 -16
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/chat/acts.d.ts +33 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +11 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +92 -0
- package/dist/chat/kit.d.ts +61 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +28 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +103 -0
- package/dist/chat/markdown.d.ts +21 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +246 -0
- package/dist/chat/message.d.ts +7 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +237 -0
- package/dist/chat/messages.d.ts +29 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +190 -0
- package/dist/chat/name.d.ts +7 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +12 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +19 -0
- package/dist/chat/overlay.d.ts +32 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +103 -0
- package/dist/chat/parts.d.ts +58 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +120 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +68 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +619 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +69 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +37 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +93 -0
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +67 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +306 -0
- package/dist/chat.d.ts +15 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +33 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +81 -16
- package/dist/collection.d.ts +23 -13
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +367 -38
- package/dist/connection.d.ts +54 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2582 -486
- package/dist/conversation.d.ts +39 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +546 -171
- package/dist/digest.d.ts +2 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +100 -0
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +157 -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 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +107 -21
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +19 -1
- package/dist/index.d.ts +20 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +92 -27
- package/dist/model.d.ts +7 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +7 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +29 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +57 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +67 -1
- package/dist/overlay.d.ts +18 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +271 -165
- package/dist/query.d.ts +61 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +40 -7
- package/dist/reach.d.ts +13 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +201 -47
- package/dist/react.d.ts +31 -20
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/read-side.d.ts +18 -9
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +903 -157
- package/dist/readiness.d.ts +53 -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 +98 -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 +13 -3
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +73 -43
- package/dist/replica.d.ts +16 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +198 -91
- package/dist/room-draft.d.ts +40 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +153 -37
- package/dist/rows.d.ts +10 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +19 -14
- package/dist/save.d.ts +72 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +812 -145
- package/dist/search.d.ts +52 -8
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +242 -46
- 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 +19 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +461 -0
- package/dist/status.d.ts +6 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +90 -23
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +675 -295
- package/dist/tables.d.ts +181 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +309 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +67 -0
- package/dist/windows.d.ts +21 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +84 -0
- package/dist/wire.d.ts +165 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +67 -31
- package/package.json +30 -14
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/memory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sameChange } from './overlay.js';
|
|
2
2
|
const FIXTURE_RETENTION = {
|
|
3
3
|
history: { kind: 'duration', seconds: 1 },
|
|
4
|
-
outcome:
|
|
4
|
+
outcome: 604_800,
|
|
5
5
|
refreshHorizon: 1,
|
|
6
6
|
};
|
|
7
7
|
function declaredRetention(value) {
|
|
@@ -55,6 +55,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
55
55
|
const scripted = new Map();
|
|
56
56
|
const unsealed = new Map();
|
|
57
57
|
const sealed = new Set();
|
|
58
|
+
const sentTurns = new Map();
|
|
58
59
|
const historyPageSize = options.historyPageSize;
|
|
59
60
|
let held = [];
|
|
60
61
|
let expiring = [];
|
|
@@ -107,30 +108,35 @@ export function createMemoryAdapter(options = {}) {
|
|
|
107
108
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
function page(room,
|
|
111
|
+
function page(room, after) {
|
|
111
112
|
const paths = Object.keys(room.documents ?? {}).sort();
|
|
113
|
+
const opening = after === undefined;
|
|
114
|
+
const from = opening ? 0 : paths.filter((path) => path <= after).length;
|
|
112
115
|
const size = pageSize ?? paths.length;
|
|
113
116
|
const taken = paths.slice(from, from + size);
|
|
114
117
|
const next = from + taken.length;
|
|
115
|
-
const targets =
|
|
118
|
+
const targets = opening ? Object.keys(room.binaryFiles ?? {}) : [];
|
|
116
119
|
return {
|
|
117
120
|
kind: 'bootstrap',
|
|
118
121
|
roomVersion: room.roomVersion,
|
|
119
|
-
...(
|
|
122
|
+
...(opening ? { models: modelsOf(room) } : {}),
|
|
120
123
|
documents: named(room.documents ?? {}, taken),
|
|
121
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
124
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
125
|
+
...(room.fileIds === undefined
|
|
126
|
+
? {}
|
|
127
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
122
128
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
123
|
-
|
|
124
|
-
...(
|
|
125
|
-
...(next < paths.length ? { pageToken: String(next) } : {}),
|
|
129
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
130
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
126
131
|
};
|
|
127
132
|
}
|
|
128
133
|
function advancement(room, from, at) {
|
|
129
134
|
const current = room.documents ?? {};
|
|
130
135
|
const previous = from.documents ?? {};
|
|
131
|
-
const currentTargets = new Set(room.
|
|
132
|
-
const previousTargets = new Set(from.
|
|
136
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
137
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
133
138
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
139
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
134
140
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
135
141
|
const changed = Object.keys(current)
|
|
136
142
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -145,24 +151,24 @@ export function createMemoryAdapter(options = {}) {
|
|
|
145
151
|
const targets = opening
|
|
146
152
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
147
153
|
: [];
|
|
148
|
-
const attachments = room.attachments ?? [];
|
|
149
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
150
154
|
const models = opening ? changedModels(room, from) : undefined;
|
|
151
155
|
return {
|
|
152
156
|
kind: 'net-advancement',
|
|
153
157
|
roomVersion: room.roomVersion,
|
|
154
158
|
...(models === undefined ? {} : { models }),
|
|
155
159
|
documents: named(current, taken),
|
|
156
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
160
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
161
|
+
...(room.fileIds === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
157
164
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
158
|
-
|
|
165
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
159
166
|
removals: opening
|
|
160
167
|
? [
|
|
161
168
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
162
169
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
163
170
|
].sort()
|
|
164
171
|
: [],
|
|
165
|
-
...(declared ? { attachments } : {}),
|
|
166
172
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
167
173
|
};
|
|
168
174
|
}
|
|
@@ -183,7 +189,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
189
|
function historiesOf(input) {
|
|
184
190
|
const asked = input?.conversations;
|
|
185
191
|
if (!Array.isArray(asked))
|
|
186
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
192
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
187
193
|
const histories = [];
|
|
188
194
|
for (const entry of asked) {
|
|
189
195
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -211,21 +217,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
211
217
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
212
218
|
const conversation = scripted.get(named);
|
|
213
219
|
if (conversation === undefined) {
|
|
214
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
kind: 'rejected',
|
|
222
|
+
code: 'unknown-conversation',
|
|
223
|
+
fields: { conversation: named },
|
|
224
|
+
retryable: false,
|
|
225
|
+
};
|
|
215
226
|
}
|
|
216
227
|
const outcome = conversation.outcomes?.[name];
|
|
217
228
|
if (outcome !== undefined)
|
|
218
229
|
return outcome;
|
|
219
230
|
if (name === 'conversation.send') {
|
|
231
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
232
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
233
|
+
if (answered !== undefined)
|
|
234
|
+
return { kind: 'action', result: { turn: answered } };
|
|
220
235
|
issued += 1;
|
|
221
236
|
const turn = `turn-${issued}`;
|
|
222
237
|
unsealed.set(turn, named);
|
|
238
|
+
if (operation !== null)
|
|
239
|
+
sentTurns.set(operation, turn);
|
|
223
240
|
return { kind: 'action', result: { turn } };
|
|
224
241
|
}
|
|
225
242
|
if (name === 'conversation.cancel') {
|
|
226
243
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
227
244
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
228
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
245
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
229
246
|
}
|
|
230
247
|
unsealed.delete(turn);
|
|
231
248
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -246,9 +263,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
246
263
|
capabilities,
|
|
247
264
|
providerLimits,
|
|
248
265
|
retention,
|
|
266
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
249
267
|
};
|
|
250
268
|
}
|
|
251
269
|
return {
|
|
270
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
252
271
|
setRooms(next) {
|
|
253
272
|
rooms = [...next];
|
|
254
273
|
retain(rooms);
|
|
@@ -261,9 +280,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
261
280
|
for (const observer of observers)
|
|
262
281
|
observer({ kind: 'opened' });
|
|
263
282
|
},
|
|
264
|
-
close(revoked = false) {
|
|
283
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
265
284
|
for (const observer of observers)
|
|
266
|
-
observer({ kind: 'closed', revoked });
|
|
285
|
+
observer({ kind: 'closed', revoked, lost });
|
|
267
286
|
},
|
|
268
287
|
expire(locators) {
|
|
269
288
|
expiring = [...locators];
|
|
@@ -272,6 +291,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
272
291
|
for (const observer of observers)
|
|
273
292
|
observer({ kind: 'room-version', locator, roomVersion });
|
|
274
293
|
},
|
|
294
|
+
notifyAuthorityChanged(scope) {
|
|
295
|
+
for (const observer of observers) {
|
|
296
|
+
observer(scope === undefined
|
|
297
|
+
? { kind: 'authority-changed' }
|
|
298
|
+
: { kind: 'authority-changed', scope });
|
|
299
|
+
}
|
|
300
|
+
},
|
|
275
301
|
notifyConversation(event) {
|
|
276
302
|
if (event.kind === 'accepted-message') {
|
|
277
303
|
sealed.add(event.message.turn);
|
|
@@ -332,17 +358,19 @@ export function createMemoryAdapter(options = {}) {
|
|
|
332
358
|
},
|
|
333
359
|
reopen() {
|
|
334
360
|
queueMicrotask(() => {
|
|
335
|
-
for (const observer of observers)
|
|
336
|
-
observer({ kind: 'closed', revoked: false });
|
|
361
|
+
for (const observer of observers) {
|
|
362
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
363
|
+
}
|
|
337
364
|
});
|
|
338
365
|
},
|
|
366
|
+
published() { },
|
|
339
367
|
observe(notify) {
|
|
340
368
|
observers.add(notify);
|
|
341
369
|
queueMicrotask(() => {
|
|
342
370
|
if (!observers.has(notify))
|
|
343
371
|
return;
|
|
344
372
|
if (options.unopened === true) {
|
|
345
|
-
notify({ kind: 'closed', revoked: false });
|
|
373
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
346
374
|
return;
|
|
347
375
|
}
|
|
348
376
|
announceList();
|
|
@@ -385,7 +413,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
385
413
|
if (room === undefined) {
|
|
386
414
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
387
415
|
}
|
|
388
|
-
return page(room, request.pageToken
|
|
416
|
+
return page(room, request.pageToken);
|
|
389
417
|
}, request).then((answer) => note(request.locator, answer));
|
|
390
418
|
},
|
|
391
419
|
async refresh(_authorization, request) {
|
|
@@ -418,8 +446,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
418
446
|
if (room === undefined) {
|
|
419
447
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
420
448
|
}
|
|
421
|
-
return {
|
|
422
|
-
|
|
449
|
+
return {
|
|
450
|
+
kind: 'rejected',
|
|
451
|
+
code: 'unscripted-mutation',
|
|
452
|
+
fields: {},
|
|
453
|
+
retryable: false,
|
|
454
|
+
affected: {},
|
|
455
|
+
};
|
|
456
|
+
}, request).then((answer) => {
|
|
457
|
+
const destination = request.changeBatch.between?.destination.room;
|
|
458
|
+
if (answer.kind === 'accepted' && answer.destination !== undefined && destination) {
|
|
459
|
+
note(destination, answer.destination);
|
|
460
|
+
}
|
|
461
|
+
return note(request.locator, answer);
|
|
462
|
+
});
|
|
423
463
|
},
|
|
424
464
|
async history(_authorization, request) {
|
|
425
465
|
return resolveScript(scripts.history, () => {
|
|
@@ -433,11 +473,36 @@ export function createMemoryAdapter(options = {}) {
|
|
|
433
473
|
};
|
|
434
474
|
}, request);
|
|
435
475
|
},
|
|
476
|
+
async binary(_authorization, request) {
|
|
477
|
+
return resolveScript(scripts.binary, () => {
|
|
478
|
+
if (request.kind === 'reference') {
|
|
479
|
+
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
480
|
+
}
|
|
481
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
482
|
+
if (room === undefined)
|
|
483
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
484
|
+
const blob = room.blobs?.[request.path];
|
|
485
|
+
return blob === undefined
|
|
486
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
487
|
+
: { kind: 'binary', blob };
|
|
488
|
+
}, request);
|
|
489
|
+
},
|
|
490
|
+
async link(_authorization, request) {
|
|
491
|
+
return resolveScript(scripts.link, () => ({ kind: 'rejected', code: 'unscripted-link', fields: {}, retryable: false }), request);
|
|
492
|
+
},
|
|
493
|
+
referrerScope(referrer) {
|
|
494
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
495
|
+
return null;
|
|
496
|
+
const { room, path } = referrer;
|
|
497
|
+
if (typeof room !== 'string')
|
|
498
|
+
return null;
|
|
499
|
+
return { locator: room, ...(typeof path === 'string' ? { path } : {}) };
|
|
500
|
+
},
|
|
436
501
|
async action(_authorization, request) {
|
|
437
502
|
return resolveScript(scripts.action, () => {
|
|
438
503
|
if (request.name.startsWith('conversation.'))
|
|
439
504
|
return conversationAction(request);
|
|
440
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
505
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
441
506
|
}, request).then((answer) => {
|
|
442
507
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
443
508
|
note(answer.at.locator, answer.at);
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Definition, ValueFacts, VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Open } from './open.js';
|
|
2
3
|
export type ModelIdentity = {
|
|
3
4
|
identity: string;
|
|
4
5
|
version: string;
|
|
@@ -7,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
7
8
|
schema: string | null;
|
|
8
9
|
revision: string | null;
|
|
9
10
|
};
|
|
10
|
-
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | 'invalid'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
11
12
|
export type ModelResult = {
|
|
12
13
|
kind: 'model';
|
|
13
14
|
snapshot: ModelSnapshot;
|
|
@@ -28,12 +29,13 @@ export type ModelState = {
|
|
|
28
29
|
types: VerifiedModel['types'];
|
|
29
30
|
};
|
|
30
31
|
export type TypesResult = {
|
|
31
|
-
status: 'unavailable'
|
|
32
|
+
status: Open<'unavailable'>;
|
|
32
33
|
reason: ModelUnavailableReason;
|
|
34
|
+
types: null;
|
|
33
35
|
schema?: string | null;
|
|
34
36
|
revision?: string | null;
|
|
35
37
|
} | {
|
|
36
|
-
status: 'current' | 'cached'
|
|
38
|
+
status: Open<'current' | 'cached'>;
|
|
37
39
|
identity: string;
|
|
38
40
|
version: string;
|
|
39
41
|
verifiedWith: ModelIdentity;
|
|
@@ -44,12 +46,13 @@ export type TypesResult = {
|
|
|
44
46
|
export type ValidationReceipt = {
|
|
45
47
|
identity: string;
|
|
46
48
|
version: string;
|
|
47
|
-
source: 'current' | 'cached'
|
|
49
|
+
source: Open<'current' | 'cached'>;
|
|
48
50
|
};
|
|
49
51
|
export declare const NO_MODEL: ModelState;
|
|
50
52
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
51
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
52
54
|
export declare function cached(state: ModelState): ModelState;
|
|
53
55
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
54
57
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
55
58
|
//# 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;
|
|
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,EAAE,aAAa,CAAC;IACxB,YAAY,EAAE,aAAa,CAAC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wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAErE"}
|
package/dist/model.js
CHANGED
|
@@ -6,7 +6,7 @@ export function definitionOf(state, type) {
|
|
|
6
6
|
}
|
|
7
7
|
export function modelTypes(state) {
|
|
8
8
|
return state.status === 'unavailable'
|
|
9
|
-
? { ...state }
|
|
9
|
+
? { ...state, types: null }
|
|
10
10
|
: {
|
|
11
11
|
status: state.status,
|
|
12
12
|
identity: state.snapshot.identity,
|
|
@@ -23,6 +23,15 @@ export function cached(state) {
|
|
|
23
23
|
export function sameModel(left, right) {
|
|
24
24
|
return left.identity === right.identity && left.version === right.version;
|
|
25
25
|
}
|
|
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
|
+
}
|
|
26
35
|
export function referenceField(facts) {
|
|
27
36
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
28
37
|
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
2
|
export type Observation<T> = {
|
|
3
3
|
current(): T;
|
|
4
4
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -13,14 +13,19 @@ export type QueryChange = {
|
|
|
13
13
|
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
16
19
|
};
|
|
20
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
21
|
export type Observed = {
|
|
18
22
|
observation: Observation<unknown>;
|
|
19
23
|
receive(message: unknown): void;
|
|
20
24
|
end(): void;
|
|
21
25
|
};
|
|
22
26
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
27
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
30
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
31
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
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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AAC,KAAK,SAAS,MAAM,EAC5C,KAAK,EAAE,CACL,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAChC,MAAM,IAAI,WAEA,KAAK,YAAY,OAAO,EAAE,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAQ1E"}
|
package/dist/observation.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
export function rowsOf(result) {
|
|
2
|
-
|
|
2
|
+
if ('groups' in result)
|
|
3
|
+
return result.groups;
|
|
4
|
+
return 'documents' in result ? result.documents : [];
|
|
3
5
|
}
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
+
export function whole(message) {
|
|
7
|
+
return 'result' in message;
|
|
8
|
+
}
|
|
9
|
+
export function applied(keyed, message) {
|
|
10
|
+
if (whole(message))
|
|
11
|
+
return message;
|
|
12
|
+
const result = keyed.result;
|
|
13
|
+
if ('pending' in result)
|
|
14
|
+
return keyed;
|
|
15
|
+
const rows = rowsOf(result);
|
|
6
16
|
const byKey = new Map(keyed.keys.map((key, index) => [key, rows[index]]));
|
|
7
|
-
for (const key of
|
|
17
|
+
for (const key of message.removed)
|
|
8
18
|
byKey.delete(key);
|
|
9
|
-
for (const [key, row] of
|
|
19
|
+
for (const [key, row] of message.changed)
|
|
10
20
|
byKey.set(key, row);
|
|
11
|
-
const keys =
|
|
12
|
-
const
|
|
21
|
+
const keys = message.order ?? keyed.keys.filter((key) => byKey.has(key));
|
|
22
|
+
const kept = keys.map((key) => byKey.get(key));
|
|
23
|
+
const coverage = message.coverage ?? result.coverage;
|
|
24
|
+
const next = message.next === undefined ? result.next : (message.next ?? undefined);
|
|
25
|
+
const total = message.total ?? result.total;
|
|
26
|
+
const window = {
|
|
27
|
+
...(next === undefined ? {} : { next }),
|
|
28
|
+
...(total === undefined ? {} : { total }),
|
|
29
|
+
};
|
|
13
30
|
return {
|
|
14
|
-
result: 'groups' in
|
|
15
|
-
? { groups:
|
|
16
|
-
: { documents:
|
|
31
|
+
result: 'groups' in result
|
|
32
|
+
? { groups: kept, coverage, ...window }
|
|
33
|
+
: { documents: kept, coverage, ...window },
|
|
17
34
|
keys,
|
|
18
35
|
};
|
|
19
36
|
}
|
|
@@ -27,11 +44,11 @@ function keyedResult(first) {
|
|
|
27
44
|
},
|
|
28
45
|
};
|
|
29
46
|
}
|
|
30
|
-
function
|
|
47
|
+
function replaced(first) {
|
|
31
48
|
return { value: first, next: (message) => message };
|
|
32
49
|
}
|
|
33
50
|
export function observed(first, stop, keyed) {
|
|
34
|
-
const reducer = keyed ? keyedResult(first) :
|
|
51
|
+
const reducer = keyed ? keyedResult(first) : replaced(first);
|
|
35
52
|
let value = reducer.value;
|
|
36
53
|
let open = true;
|
|
37
54
|
const listeners = new Set();
|
package/dist/open.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC"}
|
package/dist/open.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,8 +1,59 @@
|
|
|
1
|
-
import type { ActionResult } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryLinkResult, BinaryResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
-
|
|
4
|
-
kind:
|
|
3
|
+
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
|
+
kind: Kind;
|
|
5
5
|
};
|
|
6
|
+
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
|
+
locator: string;
|
|
8
|
+
}) | (Refused<'room-locked'> & {
|
|
9
|
+
locator: string;
|
|
10
|
+
}) | ScopedRefusal;
|
|
11
|
+
export type CallResult = {
|
|
12
|
+
kind: 'action';
|
|
13
|
+
result: unknown;
|
|
14
|
+
at?: RoomVersionAt;
|
|
15
|
+
} | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
16
|
+
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
17
|
+
kind: Failure['kind'];
|
|
18
|
+
}> | Failure;
|
|
19
|
+
export type BinaryAnswer = {
|
|
20
|
+
kind: 'binary';
|
|
21
|
+
blob: Blob;
|
|
22
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
23
|
+
export type BinaryLinkAnswer = {
|
|
24
|
+
kind: 'link';
|
|
25
|
+
url: string;
|
|
26
|
+
name: string;
|
|
27
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
28
|
+
export type Resolution = {
|
|
29
|
+
readonly kind: 'document';
|
|
30
|
+
readonly room: string;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'deleted';
|
|
34
|
+
readonly room: string;
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly revision: HistoryRevision;
|
|
37
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
38
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
39
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
40
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
41
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
42
|
+
export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
|
|
43
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
44
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
45
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
46
|
+
locator: string;
|
|
47
|
+
};
|
|
48
|
+
export type Offline = {
|
|
49
|
+
readonly kind: 'offline';
|
|
50
|
+
};
|
|
51
|
+
export declare const OFFLINE: Offline;
|
|
52
|
+
export declare const UNCERTAIN: Failure;
|
|
53
|
+
export declare function undeclared(name: string): CallResult;
|
|
54
|
+
export declare function failure(result: AdapterFailure): Failure;
|
|
55
|
+
export declare function calledResult(result: ActionResult): CallResult;
|
|
56
|
+
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
6
57
|
export type Submission = {
|
|
7
58
|
readonly state: 'waiting' | 'submitted';
|
|
8
59
|
} | {
|
|
@@ -12,7 +63,10 @@ export type Submission = {
|
|
|
12
63
|
export type QueueEntry = {
|
|
13
64
|
readonly batch: ChangeBatch;
|
|
14
65
|
} & (Submission | {
|
|
66
|
+
readonly state: 'local';
|
|
67
|
+
} | {
|
|
15
68
|
readonly state: 'accepted';
|
|
16
69
|
readonly roomVersion: string;
|
|
17
70
|
});
|
|
71
|
+
export {};
|
|
18
72
|
//# 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,
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,GACf,OAAO,CAAC,uBAAuB,CA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AA;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,GAC3B;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAC/D,CAAC"}
|
package/dist/outcome.js
CHANGED
|
@@ -1 +1,67 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export const UNREADABLE = {
|
|
2
|
+
kind: 'unreadable',
|
|
3
|
+
code: 'room-not-readable',
|
|
4
|
+
fields: {},
|
|
5
|
+
retryable: false,
|
|
6
|
+
};
|
|
7
|
+
export const LOCKED_UNREADABLE = {
|
|
8
|
+
kind: 'unreadable',
|
|
9
|
+
code: 'room-locked',
|
|
10
|
+
fields: {},
|
|
11
|
+
retryable: true,
|
|
12
|
+
};
|
|
13
|
+
export const ABSENT_TARGET = {
|
|
14
|
+
kind: 'absent',
|
|
15
|
+
code: 'reference-absent',
|
|
16
|
+
fields: {},
|
|
17
|
+
retryable: false,
|
|
18
|
+
};
|
|
19
|
+
export function absentBinary(path) {
|
|
20
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
|
+
}
|
|
22
|
+
export function binaryAnswer(result) {
|
|
23
|
+
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
|
+
}
|
|
25
|
+
export function binaryLinkAnswer(result) {
|
|
26
|
+
return result.kind === 'link' || result.kind === 'rejected' ? result : failure(result);
|
|
27
|
+
}
|
|
28
|
+
export const ROOM_LOCKED = 'room-locked';
|
|
29
|
+
export function lockedRoom(locator) {
|
|
30
|
+
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
31
|
+
}
|
|
32
|
+
export const OFFLINE = { kind: 'offline' };
|
|
33
|
+
export const UNCERTAIN = {
|
|
34
|
+
kind: 'transport-uncertainty',
|
|
35
|
+
code: 'transport-uncertainty',
|
|
36
|
+
fields: {},
|
|
37
|
+
retryable: true,
|
|
38
|
+
};
|
|
39
|
+
export function undeclared(name) {
|
|
40
|
+
return { kind: 'undeclared', code: 'action-undeclared', fields: { name }, retryable: false };
|
|
41
|
+
}
|
|
42
|
+
export function failure(result) {
|
|
43
|
+
switch (result.kind) {
|
|
44
|
+
case 'transport-uncertainty':
|
|
45
|
+
return UNCERTAIN;
|
|
46
|
+
case 'revoked-authorization':
|
|
47
|
+
return { kind: result.kind, code: result.kind, fields: {}, retryable: false };
|
|
48
|
+
case 'room-not-readable':
|
|
49
|
+
return {
|
|
50
|
+
kind: result.kind,
|
|
51
|
+
locator: result.locator,
|
|
52
|
+
code: result.kind,
|
|
53
|
+
fields: {},
|
|
54
|
+
retryable: false,
|
|
55
|
+
};
|
|
56
|
+
case 'scoped-refusal':
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function calledResult(result) {
|
|
61
|
+
return result.kind === 'action' || result.kind === 'rejected' ? result : failure(result);
|
|
62
|
+
}
|
|
63
|
+
export function historyAnswer(result) {
|
|
64
|
+
return result.kind === 'history' || result.kind === 'revision' || result.kind === 'no-history'
|
|
65
|
+
? result
|
|
66
|
+
: failure(result);
|
|
67
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import type { HeadChange } from './adapter.js';
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
5
6
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
7
|
};
|
|
8
|
+
export type HeldBinary = ({
|
|
9
|
+
readonly state: 'accepted';
|
|
10
|
+
} & BinaryFile) | {
|
|
11
|
+
readonly state: 'pending';
|
|
12
|
+
readonly localId: string;
|
|
13
|
+
readonly byteLength: number;
|
|
14
|
+
readonly mediaType: string;
|
|
15
|
+
readonly sha256: string;
|
|
16
|
+
};
|
|
7
17
|
export type Layer = Heads & {
|
|
8
18
|
documents: Readonly<Record<string, string>>;
|
|
9
|
-
|
|
19
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
10
20
|
};
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
22
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
11
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
24
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
25
|
+
export declare function sameText(left: Layer, right: Layer): Generator<number, boolean, void>;
|
|
26
|
+
export declare function changedPaths(left: Layer, right: Layer): Generator<number, ReadonlySet<string>, void>;
|
|
27
|
+
export declare function overlayChanged(base: Layer, batch: ChangeBatch, previousBase: Layer, previousBatch: ChangeBatch, previousVisible: Layer): Generator<number, Layer, void>;
|
|
15
28
|
//# sourceMappingURL=overlay.d.ts.map
|