@agentshouse/mdruntime 0.1.0-cc7bd7a53214e → 0.1.0-ccd098ff75bbf
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 +24 -11
- package/dist/adapter.d.ts +172 -49
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +15 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +64 -0
- 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 +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +39 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +187 -45
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -56
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +37 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +110 -27
- package/dist/collection.d.ts +9 -13
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +46 -56
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +740 -0
- package/dist/connection.d.ts +62 -25
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3831 -958
- package/dist/conversation.d.ts +56 -16
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +739 -242
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -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/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +134 -31
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +20 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +22 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +167 -47
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +17 -14
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +16 -4
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +19 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +62 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +67 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -16
- package/dist/query.d.ts +65 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +122 -40
- package/dist/reach.d.ts +11 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +211 -75
- package/dist/react.d.ts +43 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +54 -0
- package/dist/readiness.d.ts +64 -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 +100 -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 +19 -7
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +125 -53
- package/dist/replica.d.ts +59 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +321 -156
- package/dist/room-draft.d.ts +41 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +186 -37
- package/dist/rows.d.ts +37 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +187 -82
- package/dist/save.d.ts +72 -6
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +889 -178
- package/dist/search.d.ts +41 -29
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- 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 +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -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 +123 -58
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +359 -344
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +557 -0
- package/dist/tables.d.ts +354 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +624 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +170 -45
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +69 -46
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +33 -10
- package/AGENTS.md +0 -215
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -377
package/dist/host.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { composeRuntime, } from './connection.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { queryKey } from './query.js';
|
|
3
|
+
import { described } from './failure.js';
|
|
4
|
+
import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
|
|
4
5
|
const NARROWED = new Set(['within', 'whole']);
|
|
5
6
|
function answered(md, app, writtenBy, member, input) {
|
|
6
7
|
switch (member) {
|
|
@@ -14,16 +15,30 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
14
15
|
return md.types(input[0]);
|
|
15
16
|
case 'save':
|
|
16
17
|
return md.save(input[0], input[1], writtenBy);
|
|
18
|
+
case 'saveParts':
|
|
19
|
+
return md.saveParts(input[0], input[1], writtenBy);
|
|
17
20
|
case 'history':
|
|
18
21
|
return md.history(input[0], input[1], input[2]);
|
|
22
|
+
case 'resolve':
|
|
23
|
+
return md.resolve(input[0], input[1], input[2]);
|
|
24
|
+
case 'binaryFile.read':
|
|
25
|
+
return md.binaryFile.read(input[0], input[1], input[2]);
|
|
26
|
+
case 'binaryFile.link':
|
|
27
|
+
return md.binaryFile.link(input[0], input[1], input[2]);
|
|
28
|
+
case 'binaryFile.part':
|
|
29
|
+
return md.binaryFile.part(input[0], input[1]);
|
|
19
30
|
case 'call':
|
|
20
31
|
return md.call(input[0], input[1]);
|
|
21
32
|
case 'reached':
|
|
22
33
|
return md.reached(input[0], input[1], input[2]);
|
|
23
34
|
case 'log':
|
|
24
35
|
return md.log();
|
|
36
|
+
case 'cleanUp':
|
|
37
|
+
return md.cleanUp();
|
|
25
38
|
case 'persistence':
|
|
26
39
|
return md.persistence();
|
|
40
|
+
case 'retry':
|
|
41
|
+
return md.retry();
|
|
27
42
|
case 'reauthorize':
|
|
28
43
|
return md.reauthorize();
|
|
29
44
|
case 'roomDraft.list':
|
|
@@ -31,13 +46,15 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
31
46
|
case 'roomDraft.read':
|
|
32
47
|
return md.roomDraft.read(input[0], input[1]);
|
|
33
48
|
case 'roomDraft.write':
|
|
34
|
-
return md.roomDraft.write(input[0], input[1], input[2], input[3]);
|
|
49
|
+
return md.roomDraft.write(input[0], input[1], input[2], input[3], input[4]);
|
|
35
50
|
case 'roomDraft.discard':
|
|
36
51
|
return md.roomDraft.discard(input[0], input[1], input[2]);
|
|
37
52
|
case 'presentation.read':
|
|
38
53
|
return md.presentation.read(app);
|
|
39
54
|
case 'presentation.write':
|
|
40
55
|
return md.presentation.write(app, input[0]);
|
|
56
|
+
case 'presentation.edit':
|
|
57
|
+
return md.presentation.edit(app, input[0]);
|
|
41
58
|
case 'conversation.list':
|
|
42
59
|
return md.conversation.list();
|
|
43
60
|
case 'conversation.read':
|
|
@@ -45,7 +62,9 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
45
62
|
case 'conversation.create':
|
|
46
63
|
return md.conversation.create(input[0]);
|
|
47
64
|
case 'conversation.send':
|
|
48
|
-
return md.conversation.send(input[0]);
|
|
65
|
+
return md.conversation.send(input[0], input[1], input[2]);
|
|
66
|
+
case 'conversation.attach':
|
|
67
|
+
return md.conversation.attach(input[0], input[1]);
|
|
49
68
|
case 'conversation.answer':
|
|
50
69
|
return md.conversation.answer(input[0], input[1]);
|
|
51
70
|
case 'conversation.interrupt':
|
|
@@ -57,11 +76,29 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
57
76
|
case 'conversation.delete':
|
|
58
77
|
return md.conversation.delete(input[0]);
|
|
59
78
|
case 'chatDraft.write':
|
|
60
|
-
return md.chatDraft.write(input[0], input[1]);
|
|
79
|
+
return md.chatDraft.write(input[0], input[1], input[2]);
|
|
80
|
+
case 'chatDraft.prepend':
|
|
81
|
+
return md.chatDraft.prepend(input[0], input[1]);
|
|
61
82
|
case 'chatDraft.discard':
|
|
62
83
|
return md.chatDraft.discard(input[0]);
|
|
63
84
|
}
|
|
64
85
|
}
|
|
86
|
+
function attempted(work) {
|
|
87
|
+
try {
|
|
88
|
+
return Promise.resolve(work());
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return Promise.reject(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function answeredResult(value) {
|
|
95
|
+
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
96
|
+
}
|
|
97
|
+
function answeredMessage(value) {
|
|
98
|
+
if (typeof value !== 'object' || value === null)
|
|
99
|
+
return false;
|
|
100
|
+
return !('result' in value) || answeredResult(value.result);
|
|
101
|
+
}
|
|
65
102
|
export function serveMdRuntime(options) {
|
|
66
103
|
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
67
104
|
const closing = new AbortController();
|
|
@@ -79,15 +116,27 @@ export function serveMdRuntime(options) {
|
|
|
79
116
|
deliver(structuredClone(deploymentFacts));
|
|
80
117
|
return () => { };
|
|
81
118
|
};
|
|
82
|
-
function attach(port, app, release, reach) {
|
|
119
|
+
function attach(port, app, release, reach, code = 'stored', search = 'unused') {
|
|
83
120
|
if (!authorized)
|
|
84
121
|
throw new Error(AUTHORIZATION_ENDED);
|
|
85
122
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
86
|
-
|
|
123
|
+
let facts = { target: app, code, space: null, search };
|
|
124
|
+
const view = runtime.within(reach ?? null, facts);
|
|
87
125
|
const observations = new Map();
|
|
126
|
+
const followed = new Set();
|
|
127
|
+
const answeredKeys = new Set();
|
|
128
|
+
let awaited = null;
|
|
88
129
|
let serving = true;
|
|
130
|
+
const answeredQuery = (query) => {
|
|
131
|
+
answeredKeys.add(queryKey(query));
|
|
132
|
+
if (awaited === null || !awaited.keys.every((key) => answeredKeys.has(key)))
|
|
133
|
+
return;
|
|
134
|
+
const { done } = awaited;
|
|
135
|
+
awaited = null;
|
|
136
|
+
done();
|
|
137
|
+
};
|
|
89
138
|
const send = (message) => {
|
|
90
|
-
port.postMessage(
|
|
139
|
+
port.postMessage(message);
|
|
91
140
|
};
|
|
92
141
|
const detach = () => {
|
|
93
142
|
if (!serving)
|
|
@@ -96,6 +145,8 @@ export function serveMdRuntime(options) {
|
|
|
96
145
|
for (const end of observations.values())
|
|
97
146
|
end();
|
|
98
147
|
observations.clear();
|
|
148
|
+
for (const end of [...followed])
|
|
149
|
+
end();
|
|
99
150
|
attachments.delete(detach);
|
|
100
151
|
};
|
|
101
152
|
const observe = (id, topic, input) => {
|
|
@@ -105,10 +156,26 @@ export function serveMdRuntime(options) {
|
|
|
105
156
|
return;
|
|
106
157
|
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
107
158
|
resolved = true;
|
|
159
|
+
if (topic === 'query' && answeredMessage(value))
|
|
160
|
+
answeredQuery(input[0]);
|
|
108
161
|
};
|
|
109
162
|
observations.set(id, topic === 'deployment-facts'
|
|
110
163
|
? watchFacts(deliver)
|
|
111
|
-
: (NARROWED.has(
|
|
164
|
+
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
|
|
165
|
+
};
|
|
166
|
+
const reply = async (id, query, pending) => {
|
|
167
|
+
try {
|
|
168
|
+
const value = await pending;
|
|
169
|
+
if (!serving)
|
|
170
|
+
return;
|
|
171
|
+
send({ kind: 'result', id, value });
|
|
172
|
+
if (query !== undefined && answeredResult(value))
|
|
173
|
+
answeredQuery(query);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (serving)
|
|
177
|
+
send({ kind: 'failure', id, ...described(error) });
|
|
178
|
+
}
|
|
112
179
|
};
|
|
113
180
|
const serve = async (message) => {
|
|
114
181
|
if (message.kind === 'hello')
|
|
@@ -126,32 +193,20 @@ export function serveMdRuntime(options) {
|
|
|
126
193
|
observe(message.id, message.topic, message.input);
|
|
127
194
|
return;
|
|
128
195
|
}
|
|
129
|
-
const value = await answered(NARROWED.has(WIRE_REACH.members[message.member]) ? view.md : md, app, writtenBy, message.member, message.input);
|
|
130
|
-
if (serving)
|
|
131
|
-
send({ kind: 'result', id: message.id, value });
|
|
132
196
|
}
|
|
133
197
|
catch (error) {
|
|
134
|
-
if (serving)
|
|
135
|
-
send({
|
|
136
|
-
|
|
137
|
-
id: message.id,
|
|
138
|
-
message: error instanceof Error ? error.message : String(error),
|
|
139
|
-
});
|
|
140
|
-
}
|
|
198
|
+
if (serving)
|
|
199
|
+
send({ kind: 'failure', id: message.id, ...described(error) });
|
|
200
|
+
return;
|
|
141
201
|
}
|
|
202
|
+
const { id, member, input } = message;
|
|
203
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? view.md : md, app, writtenBy, member, input));
|
|
204
|
+
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
142
205
|
};
|
|
143
206
|
port.addEventListener('message', (event) => {
|
|
144
207
|
if (!serving)
|
|
145
208
|
return;
|
|
146
|
-
const
|
|
147
|
-
if (wire === null)
|
|
148
|
-
return;
|
|
149
|
-
if (!wire.matching) {
|
|
150
|
-
send({ kind: 'refusal', refusal: PROTOCOL_MISMATCH });
|
|
151
|
-
detach();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const message = request(wire.message);
|
|
209
|
+
const message = request(event.data);
|
|
155
210
|
if (message === null)
|
|
156
211
|
return;
|
|
157
212
|
void serve(message);
|
|
@@ -165,22 +220,70 @@ export function serveMdRuntime(options) {
|
|
|
165
220
|
if (serving)
|
|
166
221
|
view.narrow(next);
|
|
167
222
|
},
|
|
223
|
+
code(next, space) {
|
|
224
|
+
if (!serving)
|
|
225
|
+
return;
|
|
226
|
+
facts = { ...facts, code: next, space };
|
|
227
|
+
view.facts(facts);
|
|
228
|
+
},
|
|
229
|
+
search(next) {
|
|
230
|
+
if (!serving)
|
|
231
|
+
return;
|
|
232
|
+
facts = { ...facts, search: next };
|
|
233
|
+
view.facts(facts);
|
|
234
|
+
},
|
|
235
|
+
answered(queries, done) {
|
|
236
|
+
const keys = queries.map(queryKey);
|
|
237
|
+
if (keys.every((key) => answeredKeys.has(key)))
|
|
238
|
+
done();
|
|
239
|
+
else
|
|
240
|
+
awaited = { keys, done };
|
|
241
|
+
},
|
|
242
|
+
readiness(deliver) {
|
|
243
|
+
if (!serving)
|
|
244
|
+
return () => { };
|
|
245
|
+
const stop = view.watch('readiness', [], (value) => {
|
|
246
|
+
if (serving)
|
|
247
|
+
deliver(value);
|
|
248
|
+
});
|
|
249
|
+
const end = () => {
|
|
250
|
+
followed.delete(end);
|
|
251
|
+
stop();
|
|
252
|
+
};
|
|
253
|
+
followed.add(end);
|
|
254
|
+
return end;
|
|
255
|
+
},
|
|
168
256
|
};
|
|
169
257
|
}
|
|
170
258
|
return {
|
|
171
259
|
attach,
|
|
172
|
-
|
|
260
|
+
seed(entry) {
|
|
261
|
+
runtime.seed(entry);
|
|
262
|
+
},
|
|
263
|
+
persisted(answer) {
|
|
264
|
+
runtime.persisted(answer);
|
|
265
|
+
},
|
|
266
|
+
shown(onScreen) {
|
|
267
|
+
runtime.shown(onScreen);
|
|
268
|
+
},
|
|
269
|
+
async endAuthorization(holder) {
|
|
173
270
|
authorized = false;
|
|
174
271
|
for (const [detach, send] of [...attachments]) {
|
|
175
272
|
send({ kind: 'ended' });
|
|
176
273
|
detach();
|
|
177
274
|
}
|
|
178
275
|
close();
|
|
179
|
-
await
|
|
180
|
-
|
|
276
|
+
if (!(await options.database.ask({ kind: 'authored.end', holder: holder ?? null }))) {
|
|
277
|
+
await options.shell.dropGeneration();
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
lose(locators) {
|
|
281
|
+
return runtime.lose(locators);
|
|
181
282
|
},
|
|
182
283
|
stop() {
|
|
183
284
|
return runtime.stop();
|
|
184
285
|
},
|
|
185
286
|
};
|
|
186
287
|
}
|
|
288
|
+
export { entrySeedOf } from './seed.js';
|
|
289
|
+
export { createRecovery, retryDelay, } from './recovery.js';
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
+
export declare function identityTime(identity: string): number;
|
|
2
3
|
export declare function roomDraftRevision(): string;
|
|
4
|
+
export declare function chatDraftRevision(): string;
|
|
5
|
+
export declare function transferIdentity(): string;
|
|
6
|
+
export declare function binaryLocalId(): string;
|
|
3
7
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/identity.js
CHANGED
|
@@ -10,8 +10,23 @@ export function changeBatchIdentity(at = Date.now()) {
|
|
|
10
10
|
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
11
11
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
13
|
+
export function identityTime(identity) {
|
|
14
|
+
return Number.parseInt(identity.replaceAll('-', '').slice(0, 12), 16);
|
|
15
|
+
}
|
|
16
|
+
function randomIdentity() {
|
|
14
17
|
const bytes = new Uint8Array(16);
|
|
15
18
|
crypto.getRandomValues(bytes);
|
|
16
19
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
17
20
|
}
|
|
21
|
+
export function roomDraftRevision() {
|
|
22
|
+
return randomIdentity();
|
|
23
|
+
}
|
|
24
|
+
export function chatDraftRevision() {
|
|
25
|
+
return randomIdentity();
|
|
26
|
+
}
|
|
27
|
+
export function transferIdentity() {
|
|
28
|
+
return randomIdentity();
|
|
29
|
+
}
|
|
30
|
+
export function binaryLocalId() {
|
|
31
|
+
return randomIdentity();
|
|
32
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction,
|
|
2
|
-
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
|
-
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
-
export type {
|
|
5
|
-
export type { AppRoom, AppTypedSelection, ConnectionRefusal,
|
|
1
|
+
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapInventory, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRevisions, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
|
+
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
3
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
+
export type { ChosenFile, FileDeclaration } from './file.js';
|
|
5
|
+
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { CallResult, QueueEntry, Submission } from './outcome.js';
|
|
8
|
-
export type {
|
|
7
|
+
export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
8
|
+
export type { BinaryFileRecord } from './binary.js';
|
|
9
|
+
export type { RuntimeError } from './failure.js';
|
|
10
|
+
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
9
11
|
export type { SaveRefusal } from './save.js';
|
|
10
|
-
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
12
|
+
export type { DocumentHit, DocumentPart, MessageHit, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
|
|
13
|
+
export { departure } from './change.js';
|
|
14
|
+
export { partsAfter } from './room-draft.js';
|
|
15
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
16
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
11
17
|
export { changeBatchIdentity } from './identity.js';
|
|
18
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
19
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
20
|
+
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
21
|
+
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
12
22
|
export type { RuntimeShell } from './durability.js';
|
|
23
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, Space, TargetCoverage, } from './readiness.js';
|
|
13
24
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
14
|
-
export type { Backlink, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, Predicate, QueryDocument, QueryGroup, QueryResult, Related, Select, Value, Where, } from './query.js';
|
|
25
|
+
export type { Awaits, Backlink, CoveredRoom, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, PendingResult, PendingRoom, Predicate, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, Related, Select, Value, Where, } from './query.js';
|
|
15
26
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
16
27
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
17
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,kBAAkB,EACl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,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
export { departure } from './change.js';
|
|
2
|
+
export { partsAfter } from './room-draft.js';
|
|
3
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
4
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
1
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
7
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
8
|
+
export { attempts, identities, intentOf, } from './attempt.js';
|
|
9
|
+
export { expectedList, expecting } from './expectation.js';
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
4
|
+
import type { QueryRoom } from './tables.js';
|
|
5
|
+
export type Cover = {
|
|
6
|
+
coverage: QueryCoverage;
|
|
7
|
+
rooms: readonly QueryRoom[];
|
|
8
|
+
} | PendingResult;
|
|
9
|
+
export type Ran = KeyedResult & {
|
|
10
|
+
readonly current: () => boolean;
|
|
11
|
+
};
|
|
12
|
+
export type Run = (plan: Plan, cover: () => Cover) => Promise<Ran>;
|
|
13
|
+
type Listener = (message: QueryMessage) => void;
|
|
14
|
+
export type LiveQueries = {
|
|
15
|
+
touched(set: ChangeSet): void;
|
|
16
|
+
recover(): void;
|
|
17
|
+
watch(plan: Plan, identity: string, cover: () => Cover, deliver: Listener): () => void;
|
|
18
|
+
close(): void;
|
|
19
|
+
};
|
|
20
|
+
export declare function createLiveQueries(run: Run): LiveQueries;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAmCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { changeOf, digestOf, } from './observation.js';
|
|
2
|
+
import { roomOfKey } from './rows.js';
|
|
3
|
+
function narrowed(plan) {
|
|
4
|
+
return (plan.paths !== null &&
|
|
5
|
+
plan.hop === null &&
|
|
6
|
+
plan.backlinks === null &&
|
|
7
|
+
!(plan.shape.kind === 'documents' && plan.shape.backlinks));
|
|
8
|
+
}
|
|
9
|
+
function reads(plan, locator) {
|
|
10
|
+
if (plan.locked.includes(locator))
|
|
11
|
+
return false;
|
|
12
|
+
if (plan.rooms !== null && !plan.rooms.includes(locator))
|
|
13
|
+
return false;
|
|
14
|
+
if (plan.reach === null)
|
|
15
|
+
return true;
|
|
16
|
+
return (plan.reach.rooms.includes(locator) ||
|
|
17
|
+
plan.reach.documents.some((document) => roomOfKey(document) === locator));
|
|
18
|
+
}
|
|
19
|
+
function affected(plan, set) {
|
|
20
|
+
if (set.rooms.some((locator) => reads(plan, locator)))
|
|
21
|
+
return true;
|
|
22
|
+
const paths = narrowed(plan) ? new Set(plan.paths) : null;
|
|
23
|
+
return set.documents.some(({ locator, path }) => reads(plan, locator) && (paths === null || path === null || paths.has(path)));
|
|
24
|
+
}
|
|
25
|
+
function shown(entry) {
|
|
26
|
+
const cover = entry.cover();
|
|
27
|
+
return JSON.stringify('pending' in cover ? cover : cover.coverage);
|
|
28
|
+
}
|
|
29
|
+
export function createLiveQueries(run) {
|
|
30
|
+
const entries = new Map();
|
|
31
|
+
let closed = false;
|
|
32
|
+
function deliver(entry, next) {
|
|
33
|
+
const previous = entry.digest;
|
|
34
|
+
entry.digest = digestOf(next);
|
|
35
|
+
entry.covered = JSON.stringify('pending' in next.result ? next.result : next.result.coverage);
|
|
36
|
+
const change = previous === undefined ? null : changeOf(previous, next);
|
|
37
|
+
if (change !== null) {
|
|
38
|
+
for (const listener of entry.ready)
|
|
39
|
+
listener(change);
|
|
40
|
+
}
|
|
41
|
+
for (const listener of entry.fresh) {
|
|
42
|
+
entry.ready.add(listener);
|
|
43
|
+
listener(next);
|
|
44
|
+
}
|
|
45
|
+
entry.fresh.clear();
|
|
46
|
+
}
|
|
47
|
+
function schedule(entry) {
|
|
48
|
+
if (closed || entry.listeners.size === 0)
|
|
49
|
+
return;
|
|
50
|
+
if (entry.running) {
|
|
51
|
+
entry.dirty = true;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
entry.running = true;
|
|
55
|
+
void (async () => {
|
|
56
|
+
try {
|
|
57
|
+
for (;;) {
|
|
58
|
+
entry.dirty = false;
|
|
59
|
+
const { current, ...next } = await run(entry.plan, entry.cover);
|
|
60
|
+
if (closed || entry.listeners.size === 0)
|
|
61
|
+
return;
|
|
62
|
+
deliver(entry, next);
|
|
63
|
+
if (!(entry.dirty && !current()) && shown(entry) === entry.covered)
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
entry.dirty = false;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
entry.running = false;
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
touched(set) {
|
|
77
|
+
for (const entry of entries.values()) {
|
|
78
|
+
if (affected(entry.plan, set))
|
|
79
|
+
schedule(entry);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
recover() {
|
|
83
|
+
for (const entry of entries.values()) {
|
|
84
|
+
if (entry.running)
|
|
85
|
+
continue;
|
|
86
|
+
if (entry.digest === undefined || shown(entry) !== entry.covered)
|
|
87
|
+
schedule(entry);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
watch(plan, identity, cover, listener) {
|
|
91
|
+
let entry = entries.get(identity);
|
|
92
|
+
if (entry === undefined) {
|
|
93
|
+
entry = {
|
|
94
|
+
plan,
|
|
95
|
+
cover,
|
|
96
|
+
listeners: new Set(),
|
|
97
|
+
fresh: new Set(),
|
|
98
|
+
ready: new Set(),
|
|
99
|
+
digest: undefined,
|
|
100
|
+
covered: '',
|
|
101
|
+
dirty: false,
|
|
102
|
+
running: false,
|
|
103
|
+
};
|
|
104
|
+
entries.set(identity, entry);
|
|
105
|
+
}
|
|
106
|
+
const held = entry;
|
|
107
|
+
held.listeners.add(listener);
|
|
108
|
+
held.fresh.add(listener);
|
|
109
|
+
schedule(held);
|
|
110
|
+
return () => {
|
|
111
|
+
held.listeners.delete(listener);
|
|
112
|
+
held.fresh.delete(listener);
|
|
113
|
+
held.ready.delete(listener);
|
|
114
|
+
if (held.listeners.size === 0 && entries.get(identity) === held)
|
|
115
|
+
entries.delete(identity);
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
close() {
|
|
119
|
+
closed = true;
|
|
120
|
+
entries.clear();
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
|
-
selectionModel?: ModelResult;
|
|
6
5
|
documents?: Readonly<Record<string, string>>;
|
|
7
6
|
revisions?: Readonly<Record<string, string>>;
|
|
7
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
8
8
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
|
+
folders?: readonly string[];
|
|
11
|
+
blobs?: Readonly<Record<string, Blob>>;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryConversation = {
|
|
13
14
|
conversation: string;
|
|
15
|
+
listed?: Omit<ListedConversation, 'conversation'>;
|
|
14
16
|
messages?: readonly AcceptedMessage[];
|
|
15
17
|
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
16
18
|
};
|
|
@@ -19,20 +21,32 @@ export type MemoryAdapterOptions = {
|
|
|
19
21
|
conversations?: readonly MemoryConversation[];
|
|
20
22
|
historyPageSize?: number;
|
|
21
23
|
pageSize?: number;
|
|
22
|
-
mdModel?: MdModelIdentity;
|
|
23
|
-
supportedVersions?: readonly number[];
|
|
24
24
|
capabilities?: readonly Capability[];
|
|
25
25
|
providerLimits?: readonly ProviderLimit[];
|
|
26
26
|
retention?: Retention;
|
|
27
|
+
member?: Member;
|
|
28
|
+
unopened?: boolean;
|
|
29
|
+
exhaustiveDiscovery?: true;
|
|
30
|
+
roomTypes?: string;
|
|
27
31
|
};
|
|
28
32
|
export type MemoryAdapter = Adapter & {
|
|
29
33
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
30
34
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
31
35
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
32
|
-
|
|
36
|
+
open(): void;
|
|
37
|
+
close(closing?: {
|
|
38
|
+
revoked?: boolean;
|
|
39
|
+
lost?: boolean;
|
|
40
|
+
}): void;
|
|
41
|
+
expire(locators: readonly string[]): void;
|
|
42
|
+
notifyRoomVersion(notification: {
|
|
43
|
+
locator: string;
|
|
44
|
+
roomVersion: string;
|
|
45
|
+
}): void;
|
|
46
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
33
47
|
notifyConversation(event: ConversationEvent): void;
|
|
34
48
|
notifyServiceMode(mode: ServiceMode): void;
|
|
35
|
-
|
|
49
|
+
heldRooms(): readonly string[];
|
|
36
50
|
replicatedConversations(): readonly string[];
|
|
37
51
|
};
|
|
38
52
|
export declare function createMemoryAdapter(options?: MemoryAdapterOptions): MemoryAdapter;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAGlB,KAAK,SAAS,EAGd,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,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