@agentshouse/mdruntime 0.1.0-cacb4c3f6734e → 0.1.0-cb0eb0d87ff49
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 +164 -99
- package/README.md +13 -3
- package/dist/adapter.d.ts +72 -16
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +15 -2
- 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 +17 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +109 -37
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +48 -16
- package/dist/change.d.ts +15 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- 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/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +60 -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 +26 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +62 -0
- package/dist/chat/markdown.d.ts +20 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +188 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/messages.d.ts +21 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +151 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +31 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +97 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -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 +63 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +620 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +80 -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 +33 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +20 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +66 -16
- package/dist/collection.d.ts +21 -12
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +271 -23
- package/dist/connection.d.ts +29 -14
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1262 -377
- package/dist/conversation.d.ts +23 -10
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +304 -136
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +156 -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/host.d.ts +4 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +17 -12
- 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 +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/memory.d.ts +5 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +70 -21
- package/dist/model.d.ts +11 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -0
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- 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 +32 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +42 -1
- package/dist/overlay.d.ts +15 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +94 -77
- package/dist/query.d.ts +32 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +5 -31
- package/dist/reach.d.ts +2 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +45 -21
- package/dist/react.d.ts +26 -17
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +8 -6
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +291 -85
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +10 -0
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +43 -38
- package/dist/replica.d.ts +9 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +116 -68
- package/dist/room-draft.d.ts +26 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +132 -23
- package/dist/rows.d.ts +8 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +12 -14
- package/dist/save.d.ts +31 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +376 -45
- package/dist/search.d.ts +31 -8
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +109 -44
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +2 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +66 -17
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +506 -196
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +7 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +15 -2
- package/package.json +26 -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,29 +108,30 @@ 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]),
|
|
122
125
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
123
|
-
|
|
124
|
-
...(
|
|
125
|
-
...(next < paths.length ? { pageToken: String(next) } : {}),
|
|
126
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
127
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
function advancement(room, from, at) {
|
|
129
131
|
const current = room.documents ?? {};
|
|
130
132
|
const previous = from.documents ?? {};
|
|
131
|
-
const currentTargets = new Set(room.
|
|
132
|
-
const previousTargets = new Set(from.
|
|
133
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
134
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
133
135
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
134
136
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
135
137
|
const changed = Object.keys(current)
|
|
@@ -145,24 +147,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
145
147
|
const targets = opening
|
|
146
148
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
147
149
|
: [];
|
|
148
|
-
const attachments = room.attachments ?? [];
|
|
149
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
150
150
|
const models = opening ? changedModels(room, from) : undefined;
|
|
151
151
|
return {
|
|
152
152
|
kind: 'net-advancement',
|
|
153
153
|
roomVersion: room.roomVersion,
|
|
154
154
|
...(models === undefined ? {} : { models }),
|
|
155
155
|
documents: named(current, taken),
|
|
156
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
156
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
157
157
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
158
|
-
|
|
158
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
159
159
|
removals: opening
|
|
160
160
|
? [
|
|
161
161
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
162
162
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
163
163
|
].sort()
|
|
164
164
|
: [],
|
|
165
|
-
...(declared ? { attachments } : {}),
|
|
166
165
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
167
166
|
};
|
|
168
167
|
}
|
|
@@ -183,7 +182,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
182
|
function historiesOf(input) {
|
|
184
183
|
const asked = input?.conversations;
|
|
185
184
|
if (!Array.isArray(asked))
|
|
186
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
185
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
187
186
|
const histories = [];
|
|
188
187
|
for (const entry of asked) {
|
|
189
188
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -211,21 +210,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
211
210
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
212
211
|
const conversation = scripted.get(named);
|
|
213
212
|
if (conversation === undefined) {
|
|
214
|
-
return {
|
|
213
|
+
return {
|
|
214
|
+
kind: 'rejected',
|
|
215
|
+
code: 'unknown-conversation',
|
|
216
|
+
fields: { conversation: named },
|
|
217
|
+
retryable: false,
|
|
218
|
+
};
|
|
215
219
|
}
|
|
216
220
|
const outcome = conversation.outcomes?.[name];
|
|
217
221
|
if (outcome !== undefined)
|
|
218
222
|
return outcome;
|
|
219
223
|
if (name === 'conversation.send') {
|
|
224
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
225
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
226
|
+
if (answered !== undefined)
|
|
227
|
+
return { kind: 'action', result: { turn: answered } };
|
|
220
228
|
issued += 1;
|
|
221
229
|
const turn = `turn-${issued}`;
|
|
222
230
|
unsealed.set(turn, named);
|
|
231
|
+
if (operation !== null)
|
|
232
|
+
sentTurns.set(operation, turn);
|
|
223
233
|
return { kind: 'action', result: { turn } };
|
|
224
234
|
}
|
|
225
235
|
if (name === 'conversation.cancel') {
|
|
226
236
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
227
237
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
228
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
238
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
229
239
|
}
|
|
230
240
|
unsealed.delete(turn);
|
|
231
241
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -246,9 +256,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
246
256
|
capabilities,
|
|
247
257
|
providerLimits,
|
|
248
258
|
retention,
|
|
259
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
249
260
|
};
|
|
250
261
|
}
|
|
251
262
|
return {
|
|
263
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
252
264
|
setRooms(next) {
|
|
253
265
|
rooms = [...next];
|
|
254
266
|
retain(rooms);
|
|
@@ -330,6 +342,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
330
342
|
}
|
|
331
343
|
});
|
|
332
344
|
},
|
|
345
|
+
reopen() {
|
|
346
|
+
queueMicrotask(() => {
|
|
347
|
+
for (const observer of observers)
|
|
348
|
+
observer({ kind: 'closed', revoked: false });
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
published() { },
|
|
333
352
|
observe(notify) {
|
|
334
353
|
observers.add(notify);
|
|
335
354
|
queueMicrotask(() => {
|
|
@@ -379,7 +398,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
379
398
|
if (room === undefined) {
|
|
380
399
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
381
400
|
}
|
|
382
|
-
return page(room, request.pageToken
|
|
401
|
+
return page(room, request.pageToken);
|
|
383
402
|
}, request).then((answer) => note(request.locator, answer));
|
|
384
403
|
},
|
|
385
404
|
async refresh(_authorization, request) {
|
|
@@ -412,7 +431,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
412
431
|
if (room === undefined) {
|
|
413
432
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
414
433
|
}
|
|
415
|
-
return {
|
|
434
|
+
return {
|
|
435
|
+
kind: 'rejected',
|
|
436
|
+
code: 'unscripted-mutation',
|
|
437
|
+
fields: {},
|
|
438
|
+
retryable: false,
|
|
439
|
+
affected: {},
|
|
440
|
+
};
|
|
416
441
|
}, request).then((answer) => note(request.locator, answer));
|
|
417
442
|
},
|
|
418
443
|
async history(_authorization, request) {
|
|
@@ -427,11 +452,35 @@ export function createMemoryAdapter(options = {}) {
|
|
|
427
452
|
};
|
|
428
453
|
}, request);
|
|
429
454
|
},
|
|
455
|
+
async binary(_authorization, request) {
|
|
456
|
+
return resolveScript(scripts.binary, () => {
|
|
457
|
+
if (request.kind === 'reference') {
|
|
458
|
+
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
459
|
+
}
|
|
460
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
461
|
+
if (room === undefined)
|
|
462
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
463
|
+
const blob = room.blobs?.[request.path];
|
|
464
|
+
return blob === undefined
|
|
465
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
466
|
+
: { kind: 'binary', blob };
|
|
467
|
+
}, request);
|
|
468
|
+
},
|
|
469
|
+
referrerScope(referrer) {
|
|
470
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
471
|
+
return null;
|
|
472
|
+
const { room, path, message } = referrer;
|
|
473
|
+
if (typeof message === 'string')
|
|
474
|
+
return { kind: 'conversations' };
|
|
475
|
+
if (typeof room !== 'string')
|
|
476
|
+
return null;
|
|
477
|
+
return { kind: 'room', locator: room, ...(typeof path === 'string' ? { path } : {}) };
|
|
478
|
+
},
|
|
430
479
|
async action(_authorization, request) {
|
|
431
480
|
return resolveScript(scripts.action, () => {
|
|
432
481
|
if (request.name.startsWith('conversation.'))
|
|
433
482
|
return conversationAction(request);
|
|
434
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
483
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
435
484
|
}, request).then((answer) => {
|
|
436
485
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
437
486
|
note(answer.at.locator, answer.at);
|
package/dist/model.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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;
|
|
5
6
|
};
|
|
6
7
|
export type ModelSnapshot = ModelIdentity & {
|
|
7
8
|
schema: string | null;
|
|
9
|
+
revision: string | null;
|
|
8
10
|
};
|
|
9
|
-
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | 'invalid'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
10
12
|
export type ModelResult = {
|
|
11
13
|
kind: 'model';
|
|
12
14
|
snapshot: ModelSnapshot;
|
|
@@ -18,6 +20,8 @@ export type MdType = Definition;
|
|
|
18
20
|
export type ModelState = {
|
|
19
21
|
status: 'unavailable';
|
|
20
22
|
reason: ModelUnavailableReason;
|
|
23
|
+
schema?: string | null;
|
|
24
|
+
revision?: string | null;
|
|
21
25
|
} | {
|
|
22
26
|
status: 'current' | 'cached';
|
|
23
27
|
snapshot: ModelSnapshot;
|
|
@@ -27,22 +31,27 @@ export type ModelState = {
|
|
|
27
31
|
export type TypesResult = {
|
|
28
32
|
status: 'unavailable';
|
|
29
33
|
reason: ModelUnavailableReason;
|
|
34
|
+
schema?: string | null;
|
|
35
|
+
revision?: string | null;
|
|
30
36
|
} | {
|
|
31
37
|
status: 'current' | 'cached';
|
|
32
38
|
identity: string;
|
|
33
39
|
version: string;
|
|
34
40
|
verifiedWith: ModelIdentity;
|
|
35
41
|
types: readonly MdType[];
|
|
42
|
+
schema: string | null;
|
|
43
|
+
revision: string | null;
|
|
36
44
|
};
|
|
37
45
|
export type ValidationReceipt = {
|
|
38
46
|
identity: string;
|
|
39
47
|
version: string;
|
|
40
|
-
source: 'current' | 'cached'
|
|
48
|
+
source: Open<'current' | 'cached'>;
|
|
41
49
|
};
|
|
42
50
|
export declare const NO_MODEL: ModelState;
|
|
43
51
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
44
52
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
45
53
|
export declare function cached(state: ModelState): ModelState;
|
|
46
54
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
55
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
47
56
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
48
57
|
//# 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,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G,UAAU,CAEpD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAE5E;AACD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CASvE;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAErE"}
|
package/dist/model.js
CHANGED
|
@@ -12,6 +12,8 @@ export function modelTypes(state) {
|
|
|
12
12
|
identity: state.snapshot.identity,
|
|
13
13
|
version: state.snapshot.version,
|
|
14
14
|
verifiedWith: { ...state.verifiedWith },
|
|
15
|
+
schema: state.snapshot.schema,
|
|
16
|
+
revision: state.snapshot.revision,
|
|
15
17
|
types: structuredClone(Object.values(state.types).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)),
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -21,6 +23,15 @@ export function cached(state) {
|
|
|
21
23
|
export function sameModel(left, right) {
|
|
22
24
|
return left.identity === right.identity && left.version === right.version;
|
|
23
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
|
+
}
|
|
24
35
|
export function referenceField(facts) {
|
|
25
36
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
26
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,17 @@ 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;
|
|
16
17
|
};
|
|
18
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
19
|
export type Observed = {
|
|
18
20
|
observation: Observation<unknown>;
|
|
19
21
|
receive(message: unknown): void;
|
|
20
22
|
end(): void;
|
|
21
23
|
};
|
|
22
24
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
26
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
27
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
28
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
29
|
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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,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,EAC1D,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAiB/B;AAED,wBAAgB,SAAS,CAAC,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,30 @@
|
|
|
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 =
|
|
21
|
+
const keys = message.order ?? keyed.keys.filter((key) => byKey.has(key));
|
|
12
22
|
const next = keys.map((key) => byKey.get(key));
|
|
23
|
+
const coverage = message.coverage ?? result.coverage;
|
|
13
24
|
return {
|
|
14
|
-
result: 'groups' in
|
|
15
|
-
? { groups: next }
|
|
16
|
-
: { documents: next },
|
|
25
|
+
result: 'groups' in result
|
|
26
|
+
? { groups: next, coverage }
|
|
27
|
+
: { documents: next, coverage },
|
|
17
28
|
keys,
|
|
18
29
|
};
|
|
19
30
|
}
|
|
@@ -27,11 +38,11 @@ function keyedResult(first) {
|
|
|
27
38
|
},
|
|
28
39
|
};
|
|
29
40
|
}
|
|
30
|
-
function
|
|
41
|
+
function replaced(first) {
|
|
31
42
|
return { value: first, next: (message) => message };
|
|
32
43
|
}
|
|
33
44
|
export function observed(first, stop, keyed) {
|
|
34
|
-
const reducer = keyed ? keyedResult(first) :
|
|
45
|
+
const reducer = keyed ? keyedResult(first) : replaced(first);
|
|
35
46
|
let value = reducer.value;
|
|
36
47
|
let open = true;
|
|
37
48
|
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,34 @@
|
|
|
1
|
-
import type { ActionResult } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryResult, HistoryResult, 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
|
+
}) | ScopedRefusal;
|
|
9
|
+
export type CallResult = {
|
|
10
|
+
kind: 'action';
|
|
11
|
+
result: unknown;
|
|
12
|
+
at?: RoomVersionAt;
|
|
13
|
+
} | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
14
|
+
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
|
+
kind: Failure['kind'];
|
|
16
|
+
}> | Failure;
|
|
17
|
+
export type BinaryAnswer = {
|
|
18
|
+
kind: 'binary';
|
|
19
|
+
blob: Blob;
|
|
20
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
+
export declare function absentBinary(path: string): BinaryAnswer;
|
|
22
|
+
export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
|
|
23
|
+
export type Offline = {
|
|
24
|
+
readonly kind: 'offline';
|
|
25
|
+
};
|
|
26
|
+
export declare const OFFLINE: Offline;
|
|
27
|
+
export declare const UNCERTAIN: Failure;
|
|
28
|
+
export declare function undeclared(name: string): CallResult;
|
|
29
|
+
export declare function failure(result: AdapterFailure): Failure;
|
|
30
|
+
export declare function calledResult(result: ActionResult): CallResult;
|
|
31
|
+
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
6
32
|
export type Submission = {
|
|
7
33
|
readonly state: 'waiting' | 'submitted';
|
|
8
34
|
} | {
|
|
@@ -12,7 +38,10 @@ export type Submission = {
|
|
|
12
38
|
export type QueueEntry = {
|
|
13
39
|
readonly batch: ChangeBatch;
|
|
14
40
|
} & (Submission | {
|
|
41
|
+
readonly state: 'local';
|
|
42
|
+
} | {
|
|
15
43
|
readonly state: 'accepted';
|
|
16
44
|
readonly roomVersion: string;
|
|
17
45
|
});
|
|
46
|
+
export {};
|
|
18
47
|
//# 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.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CAAA;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,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,42 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export function absentBinary(path) {
|
|
2
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
3
|
+
}
|
|
4
|
+
export function binaryAnswer(result) {
|
|
5
|
+
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
6
|
+
}
|
|
7
|
+
export const OFFLINE = { kind: 'offline' };
|
|
8
|
+
export const UNCERTAIN = {
|
|
9
|
+
kind: 'transport-uncertainty',
|
|
10
|
+
code: 'transport-uncertainty',
|
|
11
|
+
fields: {},
|
|
12
|
+
retryable: true,
|
|
13
|
+
};
|
|
14
|
+
export function undeclared(name) {
|
|
15
|
+
return { kind: 'undeclared', code: 'action-undeclared', fields: { name }, retryable: false };
|
|
16
|
+
}
|
|
17
|
+
export function failure(result) {
|
|
18
|
+
switch (result.kind) {
|
|
19
|
+
case 'transport-uncertainty':
|
|
20
|
+
return UNCERTAIN;
|
|
21
|
+
case 'revoked-authorization':
|
|
22
|
+
return { kind: result.kind, code: result.kind, fields: {}, retryable: false };
|
|
23
|
+
case 'room-not-readable':
|
|
24
|
+
return {
|
|
25
|
+
kind: result.kind,
|
|
26
|
+
locator: result.locator,
|
|
27
|
+
code: result.kind,
|
|
28
|
+
fields: {},
|
|
29
|
+
retryable: false,
|
|
30
|
+
};
|
|
31
|
+
case 'scoped-refusal':
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function calledResult(result) {
|
|
36
|
+
return result.kind === 'action' || result.kind === 'rejected' ? result : failure(result);
|
|
37
|
+
}
|
|
38
|
+
export function historyAnswer(result) {
|
|
39
|
+
return result.kind === 'history' || result.kind === 'revision' || result.kind === 'no-history'
|
|
40
|
+
? result
|
|
41
|
+
: failure(result);
|
|
42
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
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
5
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
6
|
};
|
|
7
|
+
export type HeldBinary = ({
|
|
8
|
+
readonly state: 'accepted';
|
|
9
|
+
} & BinaryFile) | {
|
|
10
|
+
readonly state: 'pending';
|
|
11
|
+
readonly localId: string;
|
|
12
|
+
readonly byteLength: number;
|
|
13
|
+
readonly mediaType: string;
|
|
14
|
+
readonly sha256: string;
|
|
15
|
+
};
|
|
7
16
|
export type Layer = Heads & {
|
|
8
17
|
documents: Readonly<Record<string, string>>;
|
|
9
|
-
|
|
18
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
10
19
|
};
|
|
20
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
|
|
21
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
11
22
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
12
|
-
export declare function overlay(base: Layer, queue: readonly ChangeBatch[]): Layer;
|
|
23
|
+
export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
|
|
13
24
|
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
+
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
14
26
|
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
15
27
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAU,WAAW,EAAgB,MAAM,aAAa,CAAC;AAGrE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,C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