@agentshouse/mdruntime 0.1.0-cc2e934017fb1 → 0.1.0-cc3efa51a7546
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 +21 -19
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +45 -25
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +161 -71
- package/dist/adapter.d.ts +137 -29
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +21 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +33 -61
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +88 -44
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +23 -16
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +23 -10
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -8
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +34 -16
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +274 -207
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +36 -9
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +25 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +111 -34
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +82 -36
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +24 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +50 -32
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +181 -34
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +80 -32
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +29 -10
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -10
- package/dist/outcome.d.ts +33 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -6
- package/dist/overlay.d.ts +21 -7
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +112 -39
- package/dist/parts.d.ts +4 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +198 -87
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +133 -73
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +73 -48
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +168 -43
- package/dist/react.d.ts +11 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +22 -7
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +31 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +262 -36
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +24 -10
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +7 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -124
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -57
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +79 -43
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -9
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +30 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -26
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +17 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +18 -6
- package/dist/stored.d.ts +41 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +215 -57
- package/dist/surface.d.ts +14 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +59 -27
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +76 -40
- package/dist/tables.d.ts +28 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +95 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +3 -4
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +39 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +21 -14
- package/package.json +4 -4
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/surface.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { called, located, readHistory, resolveReference } from './actions.js';
|
|
2
|
-
import { chatDraftSurface, conversationSurface, watchConversation, watchConversationAgents, watchConversationList, } from './conversation.js';
|
|
1
|
+
import { answeredCall, called, located, readHistory, resolveReference, } from './actions.js';
|
|
2
|
+
import { chatDraftSurface, conversationSurface, watchConversation, watchConversationAgents, watchListedAgents, watchConversationList, } from './conversation.js';
|
|
3
|
+
import { leftToSend } from './durability.js';
|
|
3
4
|
import { uncaught } from './failure.js';
|
|
5
|
+
import { watchRoomList } from './room-list.js';
|
|
4
6
|
import { CLEANED_TOPIC, watchHoldings } from './holdings.js';
|
|
5
7
|
import { reachedBy, writtenAfter } from './install.js';
|
|
6
|
-
import { declarationOf, listingNow, modelIn, shownRooms } from './listing.js';
|
|
8
|
+
import { declarationOf, listingNow, modelIn, shownRooms, } from './listing.js';
|
|
7
9
|
import { stop } from './lifecycle.js';
|
|
8
10
|
import { locked, lockedRooms, watchLocks } from './locks.js';
|
|
9
11
|
import { modelTypes } from './model.js';
|
|
@@ -12,10 +14,11 @@ import { watchReadiness } from './preparation.js';
|
|
|
12
14
|
import { planned, rowsQuery, searched, watchPlan, watchPlanned } from './queries.js';
|
|
13
15
|
import { narrowed, } from './reach.js';
|
|
14
16
|
import { presentationSurface, roomDraftSurface, watchPresentation, watchRoomDrafts, } from './room-drafts.js';
|
|
15
|
-
import {
|
|
17
|
+
import { attachmentSurface, conversationFiles, saveParts, saveRoomDrafts, } from './saves.js';
|
|
18
|
+
import { queriedHouse, } from './house-query.js';
|
|
16
19
|
import { keepEntrySeed } from './seed.js';
|
|
17
|
-
import { AUTHORITY_TOPIC, emitKnownRooms, entriesOf, MEMBER_TOPIC, queueTopic, REFUSAL_TOPIC, ROOMS_TOPIC, SERVICE_MODE_TOPIC, STATUS_TOPIC, STORAGE_LOSS_TOPIC, } from './shown.js';
|
|
18
|
-
import { OPENING_LANE
|
|
20
|
+
import { AUTHORITY_TOPIC, emitKnownRooms, emitStorageLoss, entriesOf, MEMBER_TOPIC, queueTopic, REFUSAL_TOPIC, ROOMS_TOPIC, SERVICE_MODE_TOPIC, STATUS_TOPIC, STORAGE_LOSS_TOPIC, storageLossNow, TIME_ZONE_TOPIC, } from './shown.js';
|
|
21
|
+
import { OPENING_LANE } from './sync.js';
|
|
19
22
|
function told(store, topic, deliver, current) {
|
|
20
23
|
const watcher = store.watch(topic, deliver);
|
|
21
24
|
deliver(current);
|
|
@@ -28,17 +31,17 @@ function watchRooms(runtime, deliver) {
|
|
|
28
31
|
return () => {
|
|
29
32
|
watcher.stop();
|
|
30
33
|
if (store.watching(ROOMS_TOPIC, 'ready').length === 0)
|
|
31
|
-
store.
|
|
34
|
+
store.roomsShown.show(null);
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
|
-
function
|
|
35
|
-
const watcher = store.watch(
|
|
37
|
+
function watchFact({ store }, topic, fact, deliver) {
|
|
38
|
+
const watcher = store.watch(topic, deliver);
|
|
36
39
|
void store
|
|
37
40
|
.open()
|
|
38
41
|
.then((local) => local.facts())
|
|
39
|
-
.then((
|
|
42
|
+
.then((facts) => {
|
|
40
43
|
if (watcher.held())
|
|
41
|
-
deliver(
|
|
44
|
+
deliver(facts[fact]);
|
|
42
45
|
}, uncaught);
|
|
43
46
|
return watcher.stop;
|
|
44
47
|
}
|
|
@@ -67,6 +70,10 @@ function watching(runtime) {
|
|
|
67
70
|
return watchConversationList(conversations, deliver);
|
|
68
71
|
if (topic === 'agents')
|
|
69
72
|
return watchConversationAgents(conversations, deliver);
|
|
73
|
+
if (topic === 'listed-agents')
|
|
74
|
+
return watchListedAgents(conversations, deliver);
|
|
75
|
+
if (topic === 'room-list')
|
|
76
|
+
return watchRoomList(runtime, deliver);
|
|
70
77
|
if (topic === 'figures')
|
|
71
78
|
return figures.watch(deliver, fail);
|
|
72
79
|
if (topic === 'holdings')
|
|
@@ -76,7 +83,7 @@ function watching(runtime) {
|
|
|
76
83
|
if (topic === 'presentation')
|
|
77
84
|
return watchPresentation(runtime, input[0], deliver);
|
|
78
85
|
if (topic === 'readiness') {
|
|
79
|
-
return watchReadiness(runtime, { target: '', code: 'stored' }, null, deliver);
|
|
86
|
+
return watchReadiness(runtime, { target: '', code: 'stored', first: null, inboxed: null }, null, deliver);
|
|
80
87
|
}
|
|
81
88
|
if (topic === 'rooms')
|
|
82
89
|
return watchRooms(runtime, deliver);
|
|
@@ -84,7 +91,7 @@ function watching(runtime) {
|
|
|
84
91
|
return told(store, REFUSAL_TOPIC, deliver, session.refusal);
|
|
85
92
|
}
|
|
86
93
|
if (topic === 'storage-loss') {
|
|
87
|
-
return told(store, STORAGE_LOSS_TOPIC, deliver,
|
|
94
|
+
return told(store, STORAGE_LOSS_TOPIC, deliver, storageLossNow(runtime));
|
|
88
95
|
}
|
|
89
96
|
if (topic === 'sync-status') {
|
|
90
97
|
return told(store, STATUS_TOPIC, deliver, store.device.now().status);
|
|
@@ -93,7 +100,9 @@ function watching(runtime) {
|
|
|
93
100
|
return told(store, SERVICE_MODE_TOPIC, deliver, session.serviceMode);
|
|
94
101
|
}
|
|
95
102
|
if (topic === 'member')
|
|
96
|
-
return
|
|
103
|
+
return watchFact(runtime, MEMBER_TOPIC, 'member', deliver);
|
|
104
|
+
if (topic === 'time-zone')
|
|
105
|
+
return watchFact(runtime, TIME_ZONE_TOPIC, 'timeZone', deliver);
|
|
97
106
|
if (topic === 'authority-changes') {
|
|
98
107
|
return told(store, AUTHORITY_TOPIC, deliver, session.authorityChanges);
|
|
99
108
|
}
|
|
@@ -105,7 +114,7 @@ function watching(runtime) {
|
|
|
105
114
|
function roomsOnce(runtime) {
|
|
106
115
|
const { store, socket } = runtime;
|
|
107
116
|
if (socket.closed())
|
|
108
|
-
return Promise.resolve([]);
|
|
117
|
+
return Promise.resolve({ rooms: [], models: {} });
|
|
109
118
|
return new Promise((settle) => {
|
|
110
119
|
const watcher = store.watch(ROOMS_TOPIC, (value) => {
|
|
111
120
|
watcher.stop();
|
|
@@ -123,44 +132,66 @@ async function typesOf(runtime, locator) {
|
|
|
123
132
|
typedSelection: (room?.typedSelection ?? null) === null ? null : modelTypes(builtIn),
|
|
124
133
|
};
|
|
125
134
|
}
|
|
135
|
+
async function sentAll(runtime) {
|
|
136
|
+
const { store } = runtime;
|
|
137
|
+
for (;;) {
|
|
138
|
+
let moved;
|
|
139
|
+
const status = new Promise((resolve) => {
|
|
140
|
+
moved = resolve;
|
|
141
|
+
});
|
|
142
|
+
const watcher = store.watch(STATUS_TOPIC, () => moved());
|
|
143
|
+
try {
|
|
144
|
+
if (!leftToSend(await store.ask({ kind: 'authored.unsent' })))
|
|
145
|
+
return;
|
|
146
|
+
const calls = await (await store.open()).calls();
|
|
147
|
+
await Promise.race([
|
|
148
|
+
status,
|
|
149
|
+
...calls.map(({ operation }) => answeredCall(runtime, operation)),
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
watcher.stop();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
126
157
|
async function reauthorized(runtime) {
|
|
127
|
-
const { store, socket
|
|
158
|
+
const { store, socket } = runtime;
|
|
128
159
|
const { refusal } = socket.session.now();
|
|
129
160
|
if (refusal === null || !refusal.reauthorizationOffered)
|
|
130
161
|
return;
|
|
131
|
-
journal.record('connection reauthorize');
|
|
132
162
|
await socket.lanes.current();
|
|
133
163
|
await store.written();
|
|
134
164
|
socket.session.set({ authorization: undefined, paused: false });
|
|
135
165
|
if (!socket.streamed)
|
|
136
|
-
await
|
|
166
|
+
await runtime.discover();
|
|
137
167
|
else
|
|
138
168
|
await socket.lanes.task(OPENING_LANE, () => socket.authorize());
|
|
139
169
|
}
|
|
140
170
|
function mdRuntime(runtime, watch) {
|
|
141
|
-
const { store, socket,
|
|
171
|
+
const { store, socket, shell, conversations, lastAnswers } = runtime;
|
|
142
172
|
return {
|
|
143
173
|
loaded: () => store.open().then(() => undefined),
|
|
144
174
|
rooms: () => roomsOnce(runtime),
|
|
145
175
|
query: ((input) => planned(runtime, input, null).then((plan) => rowsQuery(runtime, plan))),
|
|
146
176
|
search: (input) => searched(runtime, input, null),
|
|
177
|
+
queryHouse: (input, options) => queriedHouse(runtime, input, null, options),
|
|
147
178
|
types: (locator) => typesOf(runtime, locator),
|
|
148
179
|
roomDraft: roomDraftSurface(runtime),
|
|
149
|
-
conversation: conversationSurface(conversations),
|
|
180
|
+
conversation: conversationSurface(conversations, conversationFiles(runtime)),
|
|
150
181
|
chatDraft: chatDraftSurface(conversations),
|
|
151
182
|
presentation: presentationSurface(runtime),
|
|
152
183
|
save: (room, named, writtenBy) => saveRoomDrafts(runtime, room, named, writtenBy),
|
|
153
184
|
saveParts: (room, parts, writtenBy) => saveParts(runtime, room, parts, writtenBy),
|
|
154
185
|
history: (locator, path, query) => readHistory(runtime, locator, path, query),
|
|
155
186
|
resolve: (room, path, destination) => resolveReference(runtime, room, path, destination),
|
|
156
|
-
|
|
187
|
+
attachment: attachmentSurface(runtime),
|
|
157
188
|
call: (name, input) => called(runtime, name, input),
|
|
189
|
+
answered: (operation) => answeredCall(runtime, operation),
|
|
158
190
|
async reached(locator, roomVersion, path) {
|
|
159
191
|
return path === undefined
|
|
160
192
|
? reachedBy(runtime, locator, roomVersion)
|
|
161
193
|
: writtenAfter(runtime, locator, roomVersion, path);
|
|
162
194
|
},
|
|
163
|
-
log: () => journal.export(),
|
|
164
195
|
async cleanUp() {
|
|
165
196
|
const freed = await store.ask({ kind: 'opened.clean' });
|
|
166
197
|
const tidied = (await shell.cleanUp?.()) ?? 0;
|
|
@@ -168,13 +199,13 @@ function mdRuntime(runtime, watch) {
|
|
|
168
199
|
return freed + tidied;
|
|
169
200
|
},
|
|
170
201
|
unsent: () => store.ask({ kind: 'authored.unsent' }),
|
|
202
|
+
sent: () => sentAll(runtime),
|
|
171
203
|
reset: () => shell.reset(),
|
|
172
204
|
async readAgain() {
|
|
173
205
|
lastAnswers.again();
|
|
174
206
|
},
|
|
175
207
|
persistence: () => store.device.now().persistence === 'granted',
|
|
176
208
|
async retry() {
|
|
177
|
-
journal.record('retry');
|
|
178
209
|
store.prepareAgain();
|
|
179
210
|
store.readiness.queue();
|
|
180
211
|
if (store.space.full())
|
|
@@ -185,7 +216,7 @@ function mdRuntime(runtime, watch) {
|
|
|
185
216
|
};
|
|
186
217
|
}
|
|
187
218
|
export function composedRuntime(runtime) {
|
|
188
|
-
const { store
|
|
219
|
+
const { store } = runtime;
|
|
189
220
|
const watch = watching(runtime);
|
|
190
221
|
const md = mdRuntime(runtime, watch);
|
|
191
222
|
const reachable = {
|
|
@@ -195,12 +226,14 @@ export function composedRuntime(runtime) {
|
|
|
195
226
|
query: (plan) => rowsQuery(runtime, plan),
|
|
196
227
|
watchPlan: (plan, deliver, fail) => watchPlan(runtime, plan, deliver, fail),
|
|
197
228
|
search: (input, reach) => searched(runtime, input, reach),
|
|
229
|
+
queryHouse: (input, reach, options) => queriedHouse(runtime, input, reach, options),
|
|
230
|
+
queried: () => runtime.socket.session.now().queriesOnly,
|
|
198
231
|
watchReadiness: (port, reach, deliver) => watchReadiness(runtime, port, reach, deliver),
|
|
199
232
|
locked: (locator) => locked(runtime, locator),
|
|
200
233
|
lockedRooms: () => lockedRooms(runtime),
|
|
201
234
|
watchLocks: (notify) => watchLocks(runtime, notify),
|
|
202
235
|
located: (room, path, destination) => located(runtime, room, path, destination),
|
|
203
|
-
room: async (locator) => shownRooms(runtime, await listingNow(runtime)).find((one) => one.locator === locator),
|
|
236
|
+
room: async (locator) => shownRooms(runtime, await listingNow(runtime)).rooms.find((one) => one.locator === locator),
|
|
204
237
|
};
|
|
205
238
|
return {
|
|
206
239
|
md,
|
|
@@ -211,8 +244,7 @@ export function composedRuntime(runtime) {
|
|
|
211
244
|
if (answer === store.device.now().persistence)
|
|
212
245
|
return;
|
|
213
246
|
store.device.set({ persistence: answer });
|
|
214
|
-
|
|
215
|
-
store.readiness.queue();
|
|
247
|
+
emitStorageLoss(runtime);
|
|
216
248
|
},
|
|
217
249
|
within(reach, port) {
|
|
218
250
|
if (store.space.full())
|
package/dist/sync.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export declare function withhold(runtime: Runtime, withheld: Withheld, room: Dis
|
|
|
11
11
|
export declare function loadRoom(runtime: Runtime, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress, live: Live, unheld?: Unheld): Promise<void>;
|
|
12
12
|
export declare function reload(runtime: Runtime, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress, live: Live): Promise<void>;
|
|
13
13
|
export declare function finishOpening(runtime: Runtime, progress: CycleProgress, live: Live): Promise<void>;
|
|
14
|
-
export declare function sync(runtime: Runtime, attempt: Attempt, found: Discovery | null): Promise<
|
|
14
|
+
export declare function sync(runtime: Runtime, attempt: Attempt, found: Discovery | null, current?: () => boolean): Promise<boolean>;
|
|
15
|
+
export declare function discover(runtime: Runtime): Promise<void>;
|
|
16
|
+
export declare function adopt(runtime: Runtime, unstored: Discovery): Promise<void>;
|
|
15
17
|
export declare function resynchronize(runtime: Runtime): Promise<void>;
|
|
16
|
-
export declare function countAuthorityChange({ store, socket, lastAnswers }: Runtime): void;
|
|
18
|
+
export declare function countAuthorityChange({ store, socket, lastAnswers }: Runtime, listed?: Promise<unknown>): void;
|
|
17
19
|
export declare function changeAuthority(runtime: Runtime, change: AuthorityChange): Promise<void>;
|
|
18
20
|
export declare function applyRoom(runtime: Runtime, change: RoomChange): Promise<void>;
|
|
19
21
|
//# sourceMappingURL=sync.d.ts.map
|
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACX,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACX,MAAM,cAAc,CAAC;AAMtB,OAAO,EASL,KAAK,MAAM,EACX,KAAK,QAAQ,EACd,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAE7D,eAAO,MAAM,YAAY,YAAY,CAAC;AA2FtC,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAI1B;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CA+Bf;AA+GD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,MAAM,iBAmBhB;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,iBA0BX;AAsDD,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,iBAiCxF;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,OAAO,GAAE,MAAM,OAAoB,GAClC,OAAO,CAAC,OAAO,CAAC,CA0ClB;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAW9D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7D;AAED,wBAAgB,oBAAoB,CAClC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,OAAO,EACvC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,QAM1B;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BxF;AAyDD,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA4D7E"}
|
package/dist/sync.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { resendCalls, resendLater } from './actions.js';
|
|
2
|
-
import { catchUpConversations,
|
|
2
|
+
import { catchUpConversations, reconcileOpening, resendConversations } from './conversation.js';
|
|
3
3
|
import { declared, sameDeclaration } from './declaration.js';
|
|
4
|
-
import { applyDiscovery, discoverRooms, malformed, signIn } from './discovery.js';
|
|
4
|
+
import { applyDiscovery, discoverRooms, DISCOVERY, malformed, signIn, zoned } from './discovery.js';
|
|
5
5
|
import { behind, caughtUpTo, publish, pullBootstrap, pullRefresh, reachedBy, replaced, standingAt, } from './install.js';
|
|
6
6
|
import { heldRooms, name } from './listing.js';
|
|
7
7
|
import { retainModel, revoked, scoped } from './models.js';
|
|
8
|
+
import { refusalError } from './failure.js';
|
|
8
9
|
import { refuse } from './refusal.js';
|
|
10
|
+
import { roomListChanged } from './room-list.js';
|
|
9
11
|
import { emitRooms, moveTo, rest, roomUnreadable, submissionDue, transferring, AUTHORITY_TOPIC, } from './shown.js';
|
|
10
12
|
import { unconfirmed } from './transfer.js';
|
|
11
13
|
export const OPENING_LANE = 'opening';
|
|
14
|
+
const FINISHING = 'finishing';
|
|
12
15
|
async function advance(runtime, room, local, authorized, running, unheld) {
|
|
13
16
|
const { store, socket, presence } = runtime;
|
|
14
17
|
const live = () => running() && !store.space.full();
|
|
@@ -17,6 +20,7 @@ async function advance(runtime, room, local, authorized, running, unheld) {
|
|
|
17
20
|
const held = unheld === undefined ? await store.record(room.locator) : undefined;
|
|
18
21
|
if (socket.streamed && (held !== undefined || !store.installs.of(room.locator).beyondHorizon)) {
|
|
19
22
|
presence.stood(room.locator, false);
|
|
23
|
+
runtime.retries.succeeded('download', room.locator);
|
|
20
24
|
await name(runtime, room.locator);
|
|
21
25
|
return null;
|
|
22
26
|
}
|
|
@@ -51,8 +55,9 @@ async function refreshedRoom(runtime, room, local, authorized, held, live, hold,
|
|
|
51
55
|
return unconfirmed;
|
|
52
56
|
if (refreshed.kind === 'still-current') {
|
|
53
57
|
presence.stood(room.locator, false);
|
|
58
|
+
runtime.retries.succeeded('download', room.locator);
|
|
54
59
|
if (presence.readable(room.locator))
|
|
55
|
-
emitRooms(runtime);
|
|
60
|
+
emitRooms(runtime, [room.locator]);
|
|
56
61
|
return null;
|
|
57
62
|
}
|
|
58
63
|
if (refreshed.kind === 'advanced') {
|
|
@@ -75,7 +80,7 @@ export function advanced(runtime, room, local, authorized) {
|
|
|
75
80
|
return runtime.socket.lanes.inRoom(room.locator, (live) => advance(runtime, room, local, authorized, live));
|
|
76
81
|
}
|
|
77
82
|
export async function withhold(runtime, withheld, room, local, progress) {
|
|
78
|
-
const { presence
|
|
83
|
+
const { presence } = runtime;
|
|
79
84
|
if (withheld.kind === 'unconfirmed' || presence.lost(room.locator))
|
|
80
85
|
return;
|
|
81
86
|
if (withheld.kind === 'not-ready') {
|
|
@@ -83,6 +88,12 @@ export async function withhold(runtime, withheld, room, local, progress) {
|
|
|
83
88
|
askAgain(runtime, room.locator);
|
|
84
89
|
return;
|
|
85
90
|
}
|
|
91
|
+
if (withheld.kind === 'transport-uncertainty') {
|
|
92
|
+
runtime.retries.uncertain('download', room.locator, withheld);
|
|
93
|
+
}
|
|
94
|
+
else if (withheld.kind === 'retryable-refusal') {
|
|
95
|
+
runtime.retries.failed('download', room.locator, refusalError(withheld));
|
|
96
|
+
}
|
|
86
97
|
if (withheld.kind === 'transport-uncertainty' || withheld.kind === 'retryable-refusal') {
|
|
87
98
|
const reset = withheld.kind === 'retryable-refusal' ? withheld.reset : undefined;
|
|
88
99
|
presence.stood(room.locator, true, { reset });
|
|
@@ -96,9 +107,6 @@ export async function withhold(runtime, withheld, room, local, progress) {
|
|
|
96
107
|
else if (withheld.kind === 'transport-uncertainty') {
|
|
97
108
|
progress.reachable = false;
|
|
98
109
|
}
|
|
99
|
-
else if (withheld.kind === 'retryable-refusal') {
|
|
100
|
-
journal.record(`refusal ${withheld.kind} ${withheld.code}`);
|
|
101
|
-
}
|
|
102
110
|
else if (withheld.kind === 'room-not-readable') {
|
|
103
111
|
roomUnreadable(runtime, room.locator);
|
|
104
112
|
}
|
|
@@ -123,15 +131,14 @@ function askAgain(runtime, locator) {
|
|
|
123
131
|
});
|
|
124
132
|
}
|
|
125
133
|
async function prepareRoom(runtime, room, progress, prior) {
|
|
126
|
-
const { socket
|
|
134
|
+
const { socket } = runtime;
|
|
127
135
|
const { session } = socket;
|
|
128
136
|
if (socket.closed() || session.now().authorization === undefined) {
|
|
129
137
|
progress.complete = false;
|
|
130
138
|
return false;
|
|
131
139
|
}
|
|
132
140
|
if (prior !== undefined && prior.declaration.replica.selection !== room.replica.selection) {
|
|
133
|
-
emitRooms(runtime);
|
|
134
|
-
journal.record(`selection changed ${room.locator}`);
|
|
141
|
+
emitRooms(runtime, [room.locator]);
|
|
135
142
|
progress.complete = false;
|
|
136
143
|
return false;
|
|
137
144
|
}
|
|
@@ -144,8 +151,14 @@ async function prepareRoom(runtime, room, progress, prior) {
|
|
|
144
151
|
return false;
|
|
145
152
|
return room.replica.admission === 'admitted';
|
|
146
153
|
}
|
|
147
|
-
async function synchronize(runtime, listed,
|
|
154
|
+
async function synchronize(runtime, listed, progress, attempt, live) {
|
|
148
155
|
const { store, socket } = runtime;
|
|
156
|
+
if (listed.length === 0) {
|
|
157
|
+
if (attempt === 'opened')
|
|
158
|
+
socket.hand([]);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const local = await store.open();
|
|
149
162
|
const heldNow = await store.rooms(listed.map(({ locator }) => locator));
|
|
150
163
|
const prepared = await Promise.allSettled(listed.map((room) => prepareRoom(runtime, room, progress, heldNow.get(room.locator)?.record)));
|
|
151
164
|
if (!live())
|
|
@@ -281,29 +294,33 @@ async function repairPass(runtime, locator, signal) {
|
|
|
281
294
|
return repairable.reset === undefined ? 'again' : { at: Date.parse(repairable.reset) };
|
|
282
295
|
}
|
|
283
296
|
export async function finishOpening(runtime, progress, live) {
|
|
284
|
-
const { socket, presence, conversations, recovery } = runtime;
|
|
297
|
+
const { store, socket, presence, conversations, recovery } = runtime;
|
|
285
298
|
try {
|
|
286
299
|
if (!live()) {
|
|
287
300
|
progress.complete = false;
|
|
288
301
|
return;
|
|
289
302
|
}
|
|
303
|
+
const kept = store.needed();
|
|
290
304
|
await submissionDue(runtime);
|
|
291
305
|
for (const locator of presence.repairsOwed())
|
|
292
306
|
repairLater(runtime, locator, {});
|
|
293
|
-
await
|
|
307
|
+
await reconcileOpening(conversations);
|
|
294
308
|
const reading = { complete: true, reachable: true };
|
|
295
309
|
await catchUpConversations(conversations, reading);
|
|
296
|
-
if (progress.reachable && reading.reachable)
|
|
310
|
+
if (kept && progress.reachable && reading.reachable) {
|
|
297
311
|
await resendConversations(conversations, reading);
|
|
298
|
-
|
|
312
|
+
}
|
|
313
|
+
if (kept && progress.reachable) {
|
|
299
314
|
void recovery.attempt('calls', (signal) => resendCalls(runtime, signal));
|
|
300
315
|
}
|
|
301
316
|
if (!reading.reachable) {
|
|
302
317
|
progress.reachable = false;
|
|
303
318
|
resendLater(runtime);
|
|
304
319
|
}
|
|
320
|
+
runtime.retries.succeeded('conversations', FINISHING);
|
|
305
321
|
}
|
|
306
|
-
catch {
|
|
322
|
+
catch (error) {
|
|
323
|
+
runtime.retries.failed('conversations', FINISHING, error);
|
|
307
324
|
progress.complete = false;
|
|
308
325
|
}
|
|
309
326
|
finally {
|
|
@@ -313,14 +330,17 @@ export async function finishOpening(runtime, progress, live) {
|
|
|
313
330
|
}
|
|
314
331
|
}
|
|
315
332
|
}
|
|
316
|
-
export function sync(runtime, attempt, found) {
|
|
317
|
-
const {
|
|
333
|
+
export async function sync(runtime, attempt, found, current = () => true) {
|
|
334
|
+
const { socket } = runtime;
|
|
318
335
|
const { session } = socket;
|
|
319
|
-
|
|
336
|
+
let answered = true;
|
|
337
|
+
await socket.lanes.task(OPENING_LANE, async (live) => {
|
|
320
338
|
if (!live()) {
|
|
321
339
|
socket.readyFromStore();
|
|
322
340
|
return;
|
|
323
341
|
}
|
|
342
|
+
if (!current())
|
|
343
|
+
return;
|
|
324
344
|
const progress = { complete: true, reachable: true };
|
|
325
345
|
session.set({
|
|
326
346
|
underway: attempt === 'opened' ? progress : null,
|
|
@@ -330,17 +350,17 @@ export function sync(runtime, attempt, found) {
|
|
|
330
350
|
});
|
|
331
351
|
moveTo(runtime, transferring(runtime));
|
|
332
352
|
try {
|
|
333
|
-
const local = await store.open();
|
|
334
|
-
if (!live())
|
|
335
|
-
return;
|
|
336
353
|
await socket.authorize();
|
|
337
354
|
if (!live())
|
|
338
355
|
return;
|
|
339
|
-
const listed = await discoverRooms(runtime,
|
|
356
|
+
const listed = await discoverRooms(runtime, progress, live, found);
|
|
357
|
+
answered = progress.reachable;
|
|
340
358
|
if (listed !== null)
|
|
341
|
-
await synchronize(runtime, listed,
|
|
359
|
+
await synchronize(runtime, listed, progress, attempt, live);
|
|
360
|
+
runtime.retries.succeeded('connection', OPENING_LANE);
|
|
342
361
|
}
|
|
343
|
-
catch {
|
|
362
|
+
catch (error) {
|
|
363
|
+
runtime.retries.failed('connection', OPENING_LANE, error);
|
|
344
364
|
progress.complete = false;
|
|
345
365
|
if (attempt === 'opened' && !socket.isHanded())
|
|
346
366
|
progress.reachable = false;
|
|
@@ -359,40 +379,52 @@ export function sync(runtime, attempt, found) {
|
|
|
359
379
|
session.set({ underway: null });
|
|
360
380
|
await rest(runtime, progress, live);
|
|
361
381
|
});
|
|
382
|
+
return answered;
|
|
383
|
+
}
|
|
384
|
+
export async function discover(runtime) {
|
|
385
|
+
const { recovery } = runtime;
|
|
386
|
+
if (await sync(runtime, 'unstreamed', null)) {
|
|
387
|
+
recovery.cancel(DISCOVERY);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
void recovery.attempt(DISCOVERY, async () => ((await sync(runtime, 'unstreamed', null)) ? 'done' : 'again'), { again: true, attempts: Infinity });
|
|
391
|
+
}
|
|
392
|
+
export function adopt(runtime, unstored) {
|
|
393
|
+
const { session } = runtime.socket;
|
|
394
|
+
return sync(runtime, 'unstreamed', unstored, () => session.now().unstored === unstored).then(() => undefined);
|
|
362
395
|
}
|
|
363
396
|
export function resynchronize(runtime) {
|
|
364
|
-
const {
|
|
397
|
+
const { socket, presence } = runtime;
|
|
365
398
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
366
399
|
if (!live() || !socket.isAnnounced())
|
|
367
400
|
return;
|
|
368
401
|
const progress = { complete: true, reachable: true };
|
|
369
402
|
moveTo(runtime, transferring(runtime));
|
|
370
403
|
try {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
return;
|
|
374
|
-
await synchronize(runtime, presence.rooms(), local, progress, 'unstreamed', live);
|
|
404
|
+
await synchronize(runtime, presence.rooms(), progress, 'unstreamed', live);
|
|
405
|
+
runtime.retries.succeeded('download', OPENING_LANE);
|
|
375
406
|
}
|
|
376
|
-
catch {
|
|
407
|
+
catch (error) {
|
|
408
|
+
runtime.retries.failed('download', OPENING_LANE, error);
|
|
377
409
|
progress.complete = false;
|
|
378
410
|
}
|
|
379
411
|
if (live())
|
|
380
412
|
await finishOpening(runtime, progress, live);
|
|
381
413
|
});
|
|
382
414
|
}
|
|
383
|
-
export function countAuthorityChange({ store, socket, lastAnswers }) {
|
|
415
|
+
export function countAuthorityChange({ store, socket, lastAnswers }, listed) {
|
|
384
416
|
const authorityChanges = socket.session.now().authorityChanges + 1;
|
|
385
417
|
socket.session.set({ authorityChanges });
|
|
386
418
|
store.tell(AUTHORITY_TOPIC, authorityChanges);
|
|
387
|
-
lastAnswers.again();
|
|
419
|
+
lastAnswers.again(listed);
|
|
388
420
|
}
|
|
389
421
|
export function changeAuthority(runtime, change) {
|
|
390
|
-
const { store, socket
|
|
422
|
+
const { store, socket } = runtime;
|
|
391
423
|
const { session } = socket;
|
|
392
424
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
393
425
|
if (!live() || !socket.isAnnounced())
|
|
394
426
|
return;
|
|
395
|
-
countAuthorityChange(runtime);
|
|
427
|
+
countAuthorityChange(runtime, roomListChanged(runtime, change.roomList));
|
|
396
428
|
const progress = { complete: true, reachable: true };
|
|
397
429
|
moveTo(runtime, transferring(runtime));
|
|
398
430
|
try {
|
|
@@ -401,18 +433,21 @@ export function changeAuthority(runtime, change) {
|
|
|
401
433
|
return;
|
|
402
434
|
const invalid = malformed(change.rooms);
|
|
403
435
|
if (invalid !== null) {
|
|
404
|
-
journal.record(invalid);
|
|
405
436
|
await refuse(runtime, 'missing-required-guarantee');
|
|
406
437
|
return;
|
|
407
438
|
}
|
|
408
439
|
if (change.member !== undefined)
|
|
409
440
|
await signIn(runtime, local, change.member);
|
|
441
|
+
if (change.timeZone !== undefined)
|
|
442
|
+
await zoned(runtime, local, change.timeZone);
|
|
410
443
|
const discoveries = session.now().discoveries + 1;
|
|
411
444
|
session.set({ discoveries });
|
|
412
445
|
const listed = await applyDiscovery(runtime, change.rooms, discoveries, change.left);
|
|
413
|
-
await synchronize(runtime, listed,
|
|
446
|
+
await synchronize(runtime, listed, progress, 'authorized', live);
|
|
447
|
+
runtime.retries.succeeded('connection', OPENING_LANE);
|
|
414
448
|
}
|
|
415
|
-
catch {
|
|
449
|
+
catch (error) {
|
|
450
|
+
runtime.retries.failed('connection', OPENING_LANE, error);
|
|
416
451
|
progress.complete = false;
|
|
417
452
|
}
|
|
418
453
|
if (!live())
|
|
@@ -443,7 +478,7 @@ async function installCarried(runtime, room, local, change, live, progress) {
|
|
|
443
478
|
...(page.fileIds === undefined ? {} : { fileIds: page.fileIds }),
|
|
444
479
|
...(page.created === undefined ? {} : { created: page.created }),
|
|
445
480
|
changes: page.changes,
|
|
446
|
-
|
|
481
|
+
attachments: page.attachments,
|
|
447
482
|
...(page.folders === undefined ? {} : { folders: page.folders }),
|
|
448
483
|
}),
|
|
449
484
|
reached: socket.reads.reached,
|
|
@@ -510,7 +545,8 @@ export function applyRoom(runtime, change) {
|
|
|
510
545
|
}
|
|
511
546
|
}
|
|
512
547
|
}
|
|
513
|
-
catch {
|
|
548
|
+
catch (error) {
|
|
549
|
+
runtime.retries.failed('download', locator, error);
|
|
514
550
|
if (!presence.standing(locator).stale)
|
|
515
551
|
void name(runtime, locator);
|
|
516
552
|
presence.stood(locator, true);
|