@agentshouse/mdruntime 0.1.0-c0bed82db8d73 → 0.1.0-c0c1e81da9166
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 +3 -2
- package/dist/adapter.d.ts +101 -71
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +35 -46
- package/dist/bootstrap.d.ts +16 -15
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +273 -131
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +2 -0
- package/dist/client.d.ts +15 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -6
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +278 -282
- package/dist/connection.d.ts +16 -11
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2312 -1988
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +47 -0
- package/dist/conversation.d.ts +27 -18
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +489 -260
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/figures.d.ts +48 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +26 -29
- 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 +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +62 -20
- 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 +13 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +218 -91
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +97 -19
- package/dist/model.d.ts +8 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -18
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +8 -3
- package/dist/outcome.d.ts +13 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +59 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +118 -0
- 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 +18 -207
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +32 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +118 -0
- package/dist/reach.d.ts +18 -11
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +201 -126
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +3 -17
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +34 -10
- package/dist/replica.d.ts +10 -9
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +53 -21
- package/dist/room-draft.d.ts +21 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +98 -51
- package/dist/rows.d.ts +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +22 -13
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +81 -0
- package/dist/status.d.ts +4 -5
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- package/dist/store.d.ts +104 -62
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +159 -161
- package/dist/stored.d.ts +66 -55
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +343 -273
- package/dist/tables.d.ts +110 -65
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +188 -99
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- 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 +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +18 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -2
- package/package.json +2 -3
- package/AGENTS.md +0 -312
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/store.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { composedOf } from './collection.js';
|
|
1
2
|
import { binaryLocalId } from './identity.js';
|
|
2
3
|
const FILE = '\u0000file';
|
|
4
|
+
function batchFacts(batch) {
|
|
5
|
+
return { paths: batch.changes.map(({ path }) => path), moving: batch.between !== undefined };
|
|
6
|
+
}
|
|
3
7
|
function batchFiles(batch) {
|
|
4
8
|
return batch.changes.flatMap((change) => (change.kind === 'binary' ? [change.localId] : []));
|
|
5
9
|
}
|
|
@@ -9,7 +13,8 @@ function draftFiles(drafts) {
|
|
|
9
13
|
function roomDraftRow(record) {
|
|
10
14
|
return { path: record.path, record: JSON.stringify(record), files: draftFiles([record]) };
|
|
11
15
|
}
|
|
12
|
-
function authoredRows({ locator, queue, founded, saved, roomDrafts, consumedRoomDrafts,
|
|
16
|
+
function authoredRows({ locator, queue, stored, founded, saved, roomDrafts, consumedRoomDrafts, }) {
|
|
17
|
+
const held = new Set((stored ?? []).map(({ id }) => id));
|
|
13
18
|
return {
|
|
14
19
|
locator,
|
|
15
20
|
...(queue === undefined
|
|
@@ -17,7 +22,7 @@ function authoredRows({ locator, queue, founded, saved, roomDrafts, consumedRoom
|
|
|
17
22
|
: {
|
|
18
23
|
order: queue.map(({ id }) => id),
|
|
19
24
|
added: queue
|
|
20
|
-
.filter(({ id }) => held
|
|
25
|
+
.filter(({ id }) => !held.has(id))
|
|
21
26
|
.map((batch) => {
|
|
22
27
|
const drafts = saved?.get(batch.id) ?? [];
|
|
23
28
|
return {
|
|
@@ -29,6 +34,7 @@ function authoredRows({ locator, queue, founded, saved, roomDrafts, consumedRoom
|
|
|
29
34
|
lost: false,
|
|
30
35
|
}),
|
|
31
36
|
files: [...batchFiles(batch), ...draftFiles(drafts)],
|
|
37
|
+
...batchFacts(batch),
|
|
32
38
|
};
|
|
33
39
|
}),
|
|
34
40
|
}),
|
|
@@ -39,18 +45,11 @@ function authoredRows({ locator, queue, founded, saved, roomDrafts, consumedRoom
|
|
|
39
45
|
id: batch.id,
|
|
40
46
|
batch: JSON.stringify(batch),
|
|
41
47
|
files: batchFiles(batch),
|
|
48
|
+
...batchFacts(batch),
|
|
42
49
|
})),
|
|
43
50
|
}),
|
|
44
51
|
...(roomDrafts === undefined ? {} : { roomDrafts: roomDrafts.map(roomDraftRow) }),
|
|
45
52
|
...(consumedRoomDrafts === undefined ? {} : { consumedRoomDrafts }),
|
|
46
|
-
...(accepted === undefined
|
|
47
|
-
? {}
|
|
48
|
-
: {
|
|
49
|
-
amendments: accepted.map(({ id, roomVersion }) => ({
|
|
50
|
-
id,
|
|
51
|
-
amendment: JSON.stringify({ accepted: roomVersion }),
|
|
52
|
-
})),
|
|
53
|
-
}),
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
function marked(value) {
|
|
@@ -85,10 +84,17 @@ async function filed(value, read) {
|
|
|
85
84
|
restored[name] = await filed(item, read);
|
|
86
85
|
return restored;
|
|
87
86
|
}
|
|
87
|
+
function roomOf(row) {
|
|
88
|
+
return {
|
|
89
|
+
record: { ...JSON.parse(row.record), key: row.key },
|
|
90
|
+
indexed: row.indexed,
|
|
91
|
+
documents: row.documents,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
88
94
|
function json(value, fallback) {
|
|
89
95
|
return value === undefined ? fallback : JSON.parse(value);
|
|
90
96
|
}
|
|
91
|
-
export function openRuntimeStore(
|
|
97
|
+
export function openRuntimeStore(authored) {
|
|
92
98
|
const keys = new WeakMap();
|
|
93
99
|
const read = async (key, type) => {
|
|
94
100
|
const blob = await authored.ask({ kind: 'authored.file', key, type });
|
|
@@ -97,8 +103,6 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
97
103
|
};
|
|
98
104
|
const restored = async (records) => Promise.all(records.map(async (record) => (await filed(JSON.parse(record), read))));
|
|
99
105
|
const amend = async (locator, id, amendment) => {
|
|
100
|
-
if (fenced(locator))
|
|
101
|
-
return;
|
|
102
106
|
await authored.ask({
|
|
103
107
|
kind: 'authored.amend',
|
|
104
108
|
locator,
|
|
@@ -107,56 +111,95 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
107
111
|
});
|
|
108
112
|
};
|
|
109
113
|
const fact = (name) => authored.ask({ kind: 'authored.fact', name });
|
|
110
|
-
const queued = new Map();
|
|
111
114
|
const changed = new Map();
|
|
112
115
|
const change = (key) => changed.set(key, (changed.get(key) ?? 0) + 1);
|
|
113
|
-
const rows = (writes) => writes.map((write) => authoredRows(write, queued.get(write.locator)));
|
|
114
|
-
const noted = (writes) => {
|
|
115
|
-
for (const { locator, queue } of writes) {
|
|
116
|
-
if (queue !== undefined)
|
|
117
|
-
queued.set(locator, new Set(queue.map(({ id }) => id)));
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
116
|
return {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
117
|
+
opened() {
|
|
118
|
+
return authored.ask({ kind: 'replica.open' });
|
|
119
|
+
},
|
|
120
|
+
async rooms(locators) {
|
|
121
|
+
const held = await authored.ask({ kind: 'replica.rooms', locators: locators ?? null });
|
|
122
|
+
return held.map(roomOf);
|
|
123
|
+
},
|
|
124
|
+
async room(locator) {
|
|
125
|
+
const { room, queue } = await authored.ask({ kind: 'replica.room', locator });
|
|
130
126
|
return {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
room: room === null ? null : { ...roomOf(room), overlaid: new Set(room.overlaid) },
|
|
128
|
+
queue: queue.map(({ batch, state }) => ({
|
|
129
|
+
batch: JSON.parse(batch),
|
|
130
|
+
state: JSON.parse(state),
|
|
131
|
+
})),
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
async covering() {
|
|
135
|
+
const { rooms, queues } = await authored.ask({ kind: 'replica.covering' });
|
|
136
|
+
return {
|
|
137
|
+
rooms: new Map(rooms.map(({ locator, ...room }) => [locator, room])),
|
|
138
|
+
queues: new Map(queues.map(({ locator, ids }) => [locator, ids])),
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
offline(locator) {
|
|
142
|
+
return authored.ask({ kind: 'replica.offline', locator });
|
|
143
|
+
},
|
|
144
|
+
async held() {
|
|
145
|
+
const { held, staged } = await authored.ask({ kind: 'replica.held' });
|
|
146
|
+
return { held: new Set(held), staged: new Set(staged) };
|
|
147
|
+
},
|
|
148
|
+
async status() {
|
|
149
|
+
const { queued, lastCompleted, changes, resets, returned } = await authored.ask({
|
|
150
|
+
kind: 'authored.status',
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
queued,
|
|
154
|
+
lastCompleted: json(lastCompleted ?? undefined, null),
|
|
155
|
+
unsent: changes.map(({ locator, path }) => ({ room: locator, path })),
|
|
156
|
+
resets,
|
|
157
|
+
returned: returned.map((record) => JSON.parse(record)),
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
async batch(locator, id) {
|
|
161
|
+
const held = await authored.ask({ kind: 'authored.batch', locator, id });
|
|
162
|
+
return held === null ? null : JSON.parse(held);
|
|
163
|
+
},
|
|
164
|
+
order(locator) {
|
|
165
|
+
return authored.ask({ kind: 'authored.order', locator });
|
|
166
|
+
},
|
|
167
|
+
queued() {
|
|
168
|
+
return authored.ask({ kind: 'authored.queued' });
|
|
169
|
+
},
|
|
170
|
+
async moving() {
|
|
171
|
+
const { queues, pending } = await authored.ask({ kind: 'authored.moving' });
|
|
172
|
+
return {
|
|
173
|
+
queued: new Map(queues.map(({ locator, ids }) => [locator, ids])),
|
|
174
|
+
moving: pending.map(({ locator, batch, state }) => ({
|
|
140
175
|
locator,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
unindexed,
|
|
144
|
-
overlaid,
|
|
145
|
-
erasing: held.erasing.length > 0,
|
|
146
|
-
orphans: held.orphans,
|
|
147
|
-
lastCompleted: json(held.facts.lastCompleted, null),
|
|
148
|
-
providerLimits: json(held.facts.providerLimits, []),
|
|
149
|
-
capabilities: json(held.facts.capabilities, []),
|
|
150
|
-
member: json(held.facts.member, null),
|
|
151
|
-
targets: json(held.facts.targets, {}),
|
|
152
|
-
presentation: held.presentation.map(({ app, value }) => ({
|
|
153
|
-
app,
|
|
154
|
-
value: JSON.parse(value),
|
|
176
|
+
batch: JSON.parse(batch),
|
|
177
|
+
state: JSON.parse(state),
|
|
155
178
|
})),
|
|
156
179
|
};
|
|
157
180
|
},
|
|
158
|
-
|
|
159
|
-
|
|
181
|
+
async pending(locator, id) {
|
|
182
|
+
const { state, room } = await authored.ask({ kind: 'authored.pending', locator, id });
|
|
183
|
+
return { state: state === null ? undefined : JSON.parse(state), room };
|
|
184
|
+
},
|
|
185
|
+
async facts() {
|
|
186
|
+
const held = await authored.ask({ kind: 'replica.facts' });
|
|
187
|
+
return {
|
|
188
|
+
lastCompleted: json(held.lastCompleted, null),
|
|
189
|
+
providerLimits: json(held.providerLimits, []),
|
|
190
|
+
capabilities: json(held.capabilities, []),
|
|
191
|
+
member: json(held.member, null),
|
|
192
|
+
targets: json(held.targets, {}),
|
|
193
|
+
conversationList: json(held.conversationList, null),
|
|
194
|
+
conversationCursor: json(held.conversationCursor, null),
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
async presentation(app) {
|
|
198
|
+
const held = await authored.ask({ kind: 'replica.presentation', app });
|
|
199
|
+
return held === null ? undefined : JSON.parse(held);
|
|
200
|
+
},
|
|
201
|
+
async demote() {
|
|
202
|
+
await authored.ask({ kind: 'replica.demote' });
|
|
160
203
|
},
|
|
161
204
|
query(plan, rooms, budget) {
|
|
162
205
|
return authored.ask({ kind: 'replica.query', plan, rooms, budget });
|
|
@@ -170,51 +213,42 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
170
213
|
typed(key, view, paths) {
|
|
171
214
|
return authored.ask({ kind: 'replica.typed', key, view, paths });
|
|
172
215
|
},
|
|
173
|
-
referrers(key, view, targets
|
|
174
|
-
return authored.ask({ kind: 'replica.referrers', key, view, targets
|
|
216
|
+
referrers(key, view, targets) {
|
|
217
|
+
return authored.ask({ kind: 'replica.referrers', key, view, targets });
|
|
175
218
|
},
|
|
176
|
-
|
|
177
|
-
return authored.ask({ kind: 'replica.
|
|
178
|
-
},
|
|
179
|
-
files(key, view, after, limit) {
|
|
180
|
-
return authored.ask({ kind: 'replica.files', key, view, after, limit });
|
|
219
|
+
folders(key, view, paths) {
|
|
220
|
+
return authored.ask({ kind: 'replica.folders', key, view, paths });
|
|
181
221
|
},
|
|
182
222
|
typedWithin(key, view, roots, within) {
|
|
183
223
|
return authored.ask({ kind: 'replica.typedWithin', key, view, roots, within });
|
|
184
224
|
},
|
|
185
|
-
|
|
186
|
-
return authored.ask({ kind: 'replica.search', ...ask });
|
|
187
|
-
},
|
|
188
|
-
async stage(record, composition, page, written) {
|
|
189
|
-
if (fenced(record.locator))
|
|
190
|
-
return null;
|
|
191
|
-
const { key, ...kept } = record;
|
|
225
|
+
stage(record, composition, page) {
|
|
192
226
|
return authored.ask({
|
|
193
227
|
kind: 'replica.stage',
|
|
194
228
|
locator: record.locator,
|
|
195
229
|
transfer: record.transfer,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
composition,
|
|
230
|
+
key: record.key,
|
|
231
|
+
fingerprint: composedOf(composition).fingerprint,
|
|
199
232
|
entries: page.entries,
|
|
200
233
|
folders: page.folders,
|
|
201
|
-
|
|
234
|
+
part: page.part ?? null,
|
|
202
235
|
});
|
|
203
236
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
237
|
+
resume(record, composition, parts, published) {
|
|
238
|
+
return authored.ask({
|
|
239
|
+
kind: 'replica.resume',
|
|
240
|
+
locator: record.locator,
|
|
241
|
+
transfer: record.transfer,
|
|
242
|
+
fingerprint: composedOf(composition).fingerprint,
|
|
243
|
+
parts,
|
|
244
|
+
published,
|
|
245
|
+
});
|
|
213
246
|
},
|
|
214
|
-
async refresh(key, page) {
|
|
247
|
+
async refresh(key, composition, page) {
|
|
215
248
|
await authored.ask({
|
|
216
249
|
kind: 'replica.refresh',
|
|
217
250
|
key,
|
|
251
|
+
composed: composedOf(composition),
|
|
218
252
|
entries: page.entries,
|
|
219
253
|
removals: page.removals,
|
|
220
254
|
folders: page.folders,
|
|
@@ -224,82 +258,59 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
224
258
|
async unrefresh(key) {
|
|
225
259
|
await authored.ask({ kind: 'replica.unrefresh', key });
|
|
226
260
|
},
|
|
227
|
-
|
|
228
|
-
const kept = whole ? writes : writes.filter(({ locator }) => !fenced(locator));
|
|
229
|
-
const refused = whole ? kept.find(({ locator }) => fenced(locator)) : undefined;
|
|
230
|
-
if (refused !== undefined) {
|
|
231
|
-
return { fenced: refused.locator, counts: {}, changed: {}, indexed: {} };
|
|
232
|
-
}
|
|
261
|
+
commit({ rooms, writes = [], files = [], whole = false }) {
|
|
233
262
|
for (const room of rooms)
|
|
234
263
|
change(room.key);
|
|
235
|
-
|
|
264
|
+
return authored.ask({
|
|
236
265
|
kind: 'replica.commit',
|
|
237
|
-
...(
|
|
266
|
+
...(writes.length === 0 && files.length === 0
|
|
238
267
|
? {}
|
|
239
|
-
: { authored: { writes:
|
|
240
|
-
rooms
|
|
268
|
+
: { authored: { writes: writes.map(authoredRows), files, whole } }),
|
|
269
|
+
rooms,
|
|
241
270
|
});
|
|
242
|
-
if (committed.fenced === null || !whole)
|
|
243
|
-
noted(kept);
|
|
244
|
-
for (const locator of discards)
|
|
245
|
-
queued.delete(locator);
|
|
246
|
-
return committed;
|
|
247
271
|
},
|
|
248
272
|
async fence(locators) {
|
|
249
273
|
await authored.ask({ kind: 'replica.fence', locators });
|
|
250
|
-
for (const locator of locators)
|
|
251
|
-
queued.delete(locator);
|
|
252
274
|
},
|
|
253
275
|
async erase(locator, limit) {
|
|
254
276
|
return (await authored.ask({ kind: 'replica.erase', locator, limit })).remaining;
|
|
255
277
|
},
|
|
256
|
-
async abandon(locator
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
278
|
+
async abandon(locator) {
|
|
279
|
+
await authored.ask({ kind: 'replica.abandon', locator });
|
|
280
|
+
},
|
|
281
|
+
async unfence(locators) {
|
|
282
|
+
return new Set(await authored.ask({ kind: 'replica.unfence', locators }));
|
|
260
283
|
},
|
|
261
284
|
async release(key) {
|
|
262
285
|
await authored.ask({ kind: 'replica.release', key });
|
|
263
286
|
},
|
|
264
|
-
async rederive(key,
|
|
287
|
+
async rederive(key, composition, bytes, ms, floor) {
|
|
265
288
|
change(key);
|
|
266
|
-
return
|
|
289
|
+
return authored.ask({
|
|
290
|
+
kind: 'replica.rederive',
|
|
291
|
+
key,
|
|
292
|
+
composed: composedOf(composition),
|
|
293
|
+
bytes,
|
|
294
|
+
ms,
|
|
295
|
+
floor,
|
|
296
|
+
});
|
|
267
297
|
},
|
|
268
298
|
async fact(name, value) {
|
|
269
299
|
await authored.ask({ kind: 'replica.fact', name, value: JSON.stringify(value) });
|
|
270
300
|
},
|
|
271
|
-
async queues() {
|
|
272
|
-
const { queues, pending } = await authored.ask({ kind: 'authored.queues' });
|
|
273
|
-
queued.clear();
|
|
274
|
-
for (const queue of queues)
|
|
275
|
-
queued.set(queue.locator, new Set(queue.ids));
|
|
276
|
-
const byId = new Map(pending.map((record) => [`${record.locator}\0${record.id}`, record]));
|
|
277
|
-
return queues
|
|
278
|
-
.filter((queue) => !fenced(queue.locator))
|
|
279
|
-
.map((queue) => ({
|
|
280
|
-
locator: queue.locator,
|
|
281
|
-
pending: queue.ids.map((id) => {
|
|
282
|
-
const record = byId.get(`${queue.locator}\0${id}`);
|
|
283
|
-
if (record === undefined)
|
|
284
|
-
throw new Error(`Missing Pending Change ${queue.locator}/${id}`);
|
|
285
|
-
return {
|
|
286
|
-
batch: JSON.parse(record.batch),
|
|
287
|
-
state: JSON.parse(record.state),
|
|
288
|
-
};
|
|
289
|
-
}),
|
|
290
|
-
}));
|
|
291
|
-
},
|
|
292
301
|
submit(locator, id, submission, lost) {
|
|
293
302
|
return amend(locator, id, { submission, lost });
|
|
294
303
|
},
|
|
295
304
|
keepUpload(locator, id, upload) {
|
|
296
305
|
return amend(locator, id, { upload });
|
|
297
306
|
},
|
|
298
|
-
async roomDrafts() {
|
|
299
|
-
const held = await authored.ask({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
307
|
+
async roomDrafts(locator, paths) {
|
|
308
|
+
const held = await authored.ask({
|
|
309
|
+
kind: 'authored.roomDrafts',
|
|
310
|
+
locator: locator ?? null,
|
|
311
|
+
paths: paths ?? null,
|
|
312
|
+
});
|
|
313
|
+
return held.map((record) => JSON.parse(record));
|
|
303
314
|
},
|
|
304
315
|
async present(record) {
|
|
305
316
|
await authored.ask({
|
|
@@ -308,21 +319,27 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
308
319
|
value: JSON.stringify(record.value ?? null),
|
|
309
320
|
});
|
|
310
321
|
},
|
|
311
|
-
conversations() {
|
|
312
|
-
return authored.ask({ kind: 'conversation.held' });
|
|
322
|
+
conversations(conversations) {
|
|
323
|
+
return authored.ask({ kind: 'conversation.held', conversations: conversations ?? null });
|
|
313
324
|
},
|
|
314
325
|
async keepMessages(write) {
|
|
315
326
|
await authored.ask({ kind: 'conversation.keep', ...write });
|
|
316
327
|
},
|
|
317
|
-
messageWindow(conversation, limit, before) {
|
|
318
|
-
return authored.ask({ kind: 'conversation.window', conversation, limit, before });
|
|
328
|
+
messageWindow(conversation, limit, before, phrase = null) {
|
|
329
|
+
return authored.ask({ kind: 'conversation.window', conversation, limit, before, phrase });
|
|
319
330
|
},
|
|
320
|
-
messageCount(conversation) {
|
|
321
|
-
return authored.ask({ kind: 'conversation.count', conversation });
|
|
331
|
+
messageCount(conversation, phrase = null) {
|
|
332
|
+
return authored.ask({ kind: 'conversation.count', conversation, phrase });
|
|
322
333
|
},
|
|
323
334
|
turnArrived(conversation, turn) {
|
|
324
335
|
return authored.ask({ kind: 'conversation.turn', conversation, turn });
|
|
325
336
|
},
|
|
337
|
+
conversationRows(conversations) {
|
|
338
|
+
return authored.ask({ kind: 'conversation.rows', conversations });
|
|
339
|
+
},
|
|
340
|
+
jobMarkers(conversation) {
|
|
341
|
+
return authored.ask({ kind: 'conversation.jobs', conversation });
|
|
342
|
+
},
|
|
326
343
|
async dropConversations(conversations) {
|
|
327
344
|
await authored.ask({ kind: 'conversation.drop', conversations });
|
|
328
345
|
},
|
|
@@ -330,6 +347,10 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
330
347
|
const records = await authored.ask({ kind: 'authored.chatDrafts' });
|
|
331
348
|
return records.map((record) => JSON.parse(record));
|
|
332
349
|
},
|
|
350
|
+
async chatDraft(conversation) {
|
|
351
|
+
const record = await authored.ask({ kind: 'authored.chatDraft.read', conversation });
|
|
352
|
+
return record === null ? null : JSON.parse(record);
|
|
353
|
+
},
|
|
333
354
|
async keepChatDrafts(records) {
|
|
334
355
|
await authored.ask({
|
|
335
356
|
kind: 'authored.chatDraft',
|
|
@@ -359,8 +380,6 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
359
380
|
await authored.ask({ kind: 'authored.call', operation, kept: null, files: [] });
|
|
360
381
|
},
|
|
361
382
|
async keepRoomDraft(record, files) {
|
|
362
|
-
if (fenced(record.locator))
|
|
363
|
-
return;
|
|
364
383
|
const { path, ...kept } = roomDraftRow(record);
|
|
365
384
|
await authored.ask({
|
|
366
385
|
kind: 'authored.roomDraft',
|
|
@@ -371,32 +390,11 @@ export function openRuntimeStore(fenced, authored) {
|
|
|
371
390
|
});
|
|
372
391
|
},
|
|
373
392
|
async discardRoomDraft(locator, path) {
|
|
374
|
-
if (fenced(locator))
|
|
375
|
-
return;
|
|
376
393
|
await authored.ask({ kind: 'authored.roomDraft', locator, path, kept: null, files: [] });
|
|
377
394
|
},
|
|
378
395
|
fences() {
|
|
379
396
|
return authored.ask({ kind: 'authored.fences' });
|
|
380
397
|
},
|
|
381
|
-
receivedHeads() {
|
|
382
|
-
return authored.ask({ kind: 'replica.received' });
|
|
383
|
-
},
|
|
384
|
-
receivedParts(key, count) {
|
|
385
|
-
return authored.ask({ kind: 'replica.receivedParts', key, count });
|
|
386
|
-
},
|
|
387
|
-
async keepReceived(key, head, part) {
|
|
388
|
-
await authored.ask({
|
|
389
|
-
kind: 'replica.receive',
|
|
390
|
-
key,
|
|
391
|
-
head: JSON.stringify(head),
|
|
392
|
-
...(part === undefined
|
|
393
|
-
? {}
|
|
394
|
-
: { part: { index: part.index, value: JSON.stringify(part.value) } }),
|
|
395
|
-
});
|
|
396
|
-
},
|
|
397
|
-
async dropReceived(keys) {
|
|
398
|
-
await authored.ask({ kind: 'replica.unreceive', keys });
|
|
399
|
-
},
|
|
400
398
|
generation() {
|
|
401
399
|
return fact('generation');
|
|
402
400
|
},
|