@agentshouse/mdruntime 0.1.0-cd507e16e5fc0 → 0.1.0-cd574a610e9c8
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 +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +75 -165
- 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 +118 -67
- package/dist/adapter.d.ts +90 -58
- 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 +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +13 -20
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -20
- package/dist/collection.d.ts +25 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- 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 +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -25
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +31 -24
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -12
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +23 -12
- 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 +37 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +320 -234
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +19 -44
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- 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 +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +59 -15
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +92 -111
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +54 -40
- package/dist/listing.d.ts +11 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +48 -72
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -33
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +6 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +68 -17
- package/dist/memory.d.ts +8 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +92 -33
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +30 -38
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -139
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +184 -85
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +5 -9
- package/dist/outcome.d.ts +13 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -115
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +156 -68
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +67 -31
- package/dist/query.d.ts +0 -1
- 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 +1 -7
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +88 -26
- package/dist/react.d.ts +8 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +11 -4
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -17
- 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 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +273 -66
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +22 -18
- 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 +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +9 -10
- package/dist/runtime.d.ts +9 -18
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +327 -229
- package/dist/saves.d.ts +4 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +143 -714
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -5
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +7 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +77 -63
- 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 +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +5 -16
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +18 -6
- 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 +18 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +58 -24
- 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/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +23 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +46 -17
- package/dist/stored.d.ts +25 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +83 -32
- package/dist/surface.d.ts +5 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +25 -23
- package/dist/sync.d.ts +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +96 -92
- package/dist/tables.d.ts +16 -57
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +91 -332
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +53 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -4
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -44
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/observation.js
CHANGED
|
@@ -6,49 +6,165 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const kept =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
export function pendingChange(message) {
|
|
10
|
+
return 'pending' in message;
|
|
11
|
+
}
|
|
12
|
+
export function unchanged(change) {
|
|
13
|
+
return change.changed.length === 0 && change.removed.length === 0 && change.order === null;
|
|
14
|
+
}
|
|
15
|
+
export function keyedChange(held, keys, rows, same) {
|
|
16
|
+
const present = new Set(keys);
|
|
17
|
+
const changed = keys.flatMap((key, at) => {
|
|
18
|
+
const was = held.get(key);
|
|
19
|
+
return was !== undefined && same(was, rows[at]) ? [] : [[key, rows[at]]];
|
|
20
|
+
});
|
|
21
|
+
const removed = [];
|
|
22
|
+
const kept = [];
|
|
23
|
+
for (const key of held.keys())
|
|
24
|
+
(present.has(key) ? kept : removed).push(key);
|
|
25
|
+
const moved = kept.length !== keys.length || kept.some((key, at) => keys[at] !== key);
|
|
26
|
+
return { changed, removed, order: moved ? keys : null };
|
|
27
|
+
}
|
|
28
|
+
export function keyedAt(held, at, same) {
|
|
29
|
+
const changed = [];
|
|
30
|
+
const removed = [];
|
|
31
|
+
for (const [key, now] of at) {
|
|
32
|
+
const was = held.get(key);
|
|
33
|
+
if (was === undefined) {
|
|
34
|
+
if (now !== null)
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
else if (now === null)
|
|
38
|
+
removed.push(key);
|
|
39
|
+
else if (!same(was, now))
|
|
40
|
+
changed.push([key, now]);
|
|
41
|
+
}
|
|
42
|
+
return { changed, removed, order: null };
|
|
43
|
+
}
|
|
44
|
+
export function keyedInto(held, change) {
|
|
45
|
+
for (const key of change.removed)
|
|
46
|
+
held.delete(key);
|
|
47
|
+
for (const [key, row] of change.changed)
|
|
48
|
+
held.set(key, row);
|
|
49
|
+
if (change.order === null)
|
|
50
|
+
return;
|
|
51
|
+
const placed = change.order.map((key) => [key, held.get(key)]);
|
|
52
|
+
held.clear();
|
|
53
|
+
for (const [key, row] of placed)
|
|
54
|
+
held.set(key, row);
|
|
55
|
+
}
|
|
56
|
+
export function samePending(was, now) {
|
|
57
|
+
return was.awaits === now.awaits;
|
|
58
|
+
}
|
|
59
|
+
function keyedRows(keys, rows) {
|
|
60
|
+
const held = new Map(keys.map((key, at) => [key, rows[at]]));
|
|
61
|
+
let shown = rows;
|
|
62
|
+
return {
|
|
63
|
+
rows: () => shown,
|
|
64
|
+
apply(change) {
|
|
65
|
+
if (unchanged(change))
|
|
66
|
+
return shown;
|
|
67
|
+
keyedInto(held, change);
|
|
68
|
+
shown = [...held.values()];
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
29
71
|
};
|
|
72
|
+
}
|
|
73
|
+
function located(rooms) {
|
|
74
|
+
return keyedRows(rooms.map(({ locator }) => locator), rooms);
|
|
75
|
+
}
|
|
76
|
+
function keyedRooms(first) {
|
|
77
|
+
let held = located(first);
|
|
78
|
+
return {
|
|
79
|
+
value: first,
|
|
80
|
+
next(message) {
|
|
81
|
+
if (!Array.isArray(message))
|
|
82
|
+
return held.apply(message);
|
|
83
|
+
held = located(message);
|
|
84
|
+
return held.rows();
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function covered(readiness) {
|
|
89
|
+
return keyedRows(readiness.coverage.rooms.map(({ room }) => room), readiness.coverage.rooms);
|
|
90
|
+
}
|
|
91
|
+
function keyedReadiness(first) {
|
|
92
|
+
let held = covered(first);
|
|
30
93
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
94
|
+
value: first,
|
|
95
|
+
next(message) {
|
|
96
|
+
if (!('shown' in message)) {
|
|
97
|
+
held = covered(message);
|
|
98
|
+
return message;
|
|
99
|
+
}
|
|
100
|
+
const { shown, rooms } = message;
|
|
101
|
+
return { ...shown, coverage: { ...shown.coverage, rooms: held.apply(rooms) } };
|
|
102
|
+
},
|
|
35
103
|
};
|
|
36
104
|
}
|
|
105
|
+
function awaiting(pending) {
|
|
106
|
+
return keyedRows(pending.map(({ room }) => room), pending);
|
|
107
|
+
}
|
|
37
108
|
function keyedResult(first) {
|
|
38
|
-
let
|
|
109
|
+
let result = first.result;
|
|
110
|
+
let rows = keyedRows([], []);
|
|
111
|
+
let pending = awaiting([]);
|
|
112
|
+
const take = ({ result: next, keys }) => {
|
|
113
|
+
result = next;
|
|
114
|
+
if ('pending' in next)
|
|
115
|
+
pending = awaiting(next.pending);
|
|
116
|
+
else
|
|
117
|
+
rows = keyedRows(keys, rowsOf(next));
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
take(first);
|
|
39
121
|
return {
|
|
40
122
|
value: first.result,
|
|
41
123
|
next(message) {
|
|
42
|
-
|
|
43
|
-
|
|
124
|
+
const asked = message;
|
|
125
|
+
if (whole(asked))
|
|
126
|
+
return take(asked);
|
|
127
|
+
if (pendingChange(asked)) {
|
|
128
|
+
if ('pending' in result)
|
|
129
|
+
result = { pending: pending.apply(asked.pending) };
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
if ('pending' in result)
|
|
133
|
+
return result;
|
|
134
|
+
const kept = rows.apply(asked);
|
|
135
|
+
const coverage = asked.coverage ?? result.coverage;
|
|
136
|
+
const next = asked.next === undefined ? result.next : (asked.next ?? undefined);
|
|
137
|
+
const total = asked.total ?? result.total;
|
|
138
|
+
const window = {
|
|
139
|
+
...(next === undefined ? {} : { next }),
|
|
140
|
+
...(total === undefined ? {} : { total }),
|
|
141
|
+
};
|
|
142
|
+
result =
|
|
143
|
+
'groups' in result
|
|
144
|
+
? { groups: kept, coverage, ...window }
|
|
145
|
+
: { documents: kept, coverage, ...window };
|
|
146
|
+
return result;
|
|
44
147
|
},
|
|
45
148
|
};
|
|
46
149
|
}
|
|
150
|
+
const FOLDS = {
|
|
151
|
+
query: (first) => keyedResult(first),
|
|
152
|
+
rooms: (first) => keyedRooms(first),
|
|
153
|
+
readiness: (first) => keyedReadiness(first),
|
|
154
|
+
};
|
|
155
|
+
const WHOLE = {
|
|
156
|
+
query: (message) => whole(message),
|
|
157
|
+
rooms: (message) => Array.isArray(message),
|
|
158
|
+
readiness: (message) => !('shown' in message),
|
|
159
|
+
};
|
|
160
|
+
export function replaces(topic, message) {
|
|
161
|
+
return WHOLE[topic]?.(message) ?? true;
|
|
162
|
+
}
|
|
47
163
|
function replaced(first) {
|
|
48
164
|
return { value: first, next: (message) => message };
|
|
49
165
|
}
|
|
50
|
-
export function observed(first, stop,
|
|
51
|
-
const reducer =
|
|
166
|
+
export function observed(first, stop, topic) {
|
|
167
|
+
const reducer = (FOLDS[topic] ?? replaced)(first);
|
|
52
168
|
let value = reducer.value;
|
|
53
169
|
let open = true;
|
|
54
170
|
const listeners = new Set();
|
|
@@ -86,34 +202,29 @@ export function observed(first, stop, keyed) {
|
|
|
86
202
|
end,
|
|
87
203
|
};
|
|
88
204
|
}
|
|
89
|
-
export function opened(watch,
|
|
205
|
+
export function opened(watch, topic) {
|
|
90
206
|
return new Promise((resolve, reject) => {
|
|
91
207
|
let handle;
|
|
92
208
|
let stop = () => { };
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
stop();
|
|
105
|
-
reject(error);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
209
|
+
stop = watch((message) => {
|
|
210
|
+
if (handle !== undefined) {
|
|
211
|
+
handle.receive(message);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
handle = observed(message, () => stop(), topic);
|
|
215
|
+
resolve(handle.observation);
|
|
216
|
+
}, (error) => {
|
|
217
|
+
if (handle !== undefined)
|
|
218
|
+
return;
|
|
219
|
+
stop();
|
|
109
220
|
reject(error);
|
|
110
|
-
}
|
|
221
|
+
});
|
|
111
222
|
});
|
|
112
223
|
}
|
|
113
224
|
export function observing(watch) {
|
|
114
225
|
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
115
226
|
deliver(structuredClone(message));
|
|
116
|
-
}, fail), topic
|
|
227
|
+
}, fail), topic);
|
|
117
228
|
}
|
|
118
229
|
export function hashed(text) {
|
|
119
230
|
let first = 0xdeadbeef;
|
|
@@ -134,10 +245,9 @@ function rowDigest(row) {
|
|
|
134
245
|
}
|
|
135
246
|
export function digestOf({ result, keys }) {
|
|
136
247
|
if ('pending' in result)
|
|
137
|
-
return { pending:
|
|
248
|
+
return { pending: new Map(result.pending.map((room) => [room.room, room])) };
|
|
138
249
|
const rows = rowsOf(result);
|
|
139
250
|
return {
|
|
140
|
-
keys,
|
|
141
251
|
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
142
252
|
coverage: JSON.stringify(result.coverage),
|
|
143
253
|
next: result.next,
|
|
@@ -145,16 +255,22 @@ export function digestOf({ result, keys }) {
|
|
|
145
255
|
};
|
|
146
256
|
}
|
|
147
257
|
export function digestApplied(digest, message) {
|
|
148
|
-
if (whole(message)
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
258
|
+
if (whole(message))
|
|
259
|
+
return digestOf(message);
|
|
260
|
+
if (pendingChange(message)) {
|
|
261
|
+
if ('pending' in digest)
|
|
262
|
+
keyedInto(digest.pending, message.pending);
|
|
263
|
+
return digest;
|
|
264
|
+
}
|
|
265
|
+
if ('pending' in digest)
|
|
266
|
+
return digest;
|
|
267
|
+
keyedInto(digest.rows, {
|
|
268
|
+
changed: message.changed.map(([key, row]) => [key, rowDigest(row)]),
|
|
269
|
+
removed: message.removed,
|
|
270
|
+
order: message.order,
|
|
271
|
+
});
|
|
155
272
|
return {
|
|
156
|
-
|
|
157
|
-
rows,
|
|
273
|
+
rows: digest.rows,
|
|
158
274
|
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
159
275
|
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
160
276
|
total: message.total ?? digest.total,
|
|
@@ -162,35 +278,18 @@ export function digestApplied(digest, message) {
|
|
|
162
278
|
}
|
|
163
279
|
export function changeOf(previous, next) {
|
|
164
280
|
const after = next.result;
|
|
165
|
-
if ('pending' in previous
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
: next;
|
|
281
|
+
if ('pending' in previous && 'pending' in after) {
|
|
282
|
+
const pending = keyedChange(previous.pending, after.pending.map(({ room }) => room), after.pending, samePending);
|
|
283
|
+
return unchanged(pending) ? null : { pending };
|
|
169
284
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
const row = later[index];
|
|
175
|
-
if (previous.rows.get(key) !== rowDigest(row))
|
|
176
|
-
changed.push([key, row]);
|
|
177
|
-
});
|
|
178
|
-
const removed = previous.keys.filter((key) => !present.has(key));
|
|
179
|
-
const kept = previous.keys.filter((key) => present.has(key));
|
|
180
|
-
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
181
|
-
const coverage = JSON.stringify(after.coverage);
|
|
182
|
-
const covered = previous.coverage !== coverage;
|
|
285
|
+
if ('pending' in previous || 'pending' in after)
|
|
286
|
+
return next;
|
|
287
|
+
const rows = keyedChange(previous.rows, next.keys, rowsOf(after), (was, row) => was === rowDigest(row));
|
|
288
|
+
const covered = previous.coverage !== JSON.stringify(after.coverage);
|
|
183
289
|
const framing = reframed(previous, after);
|
|
184
|
-
if (
|
|
290
|
+
if (unchanged(rows) && !covered && framing === null)
|
|
185
291
|
return null;
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
changed,
|
|
189
|
-
removed,
|
|
190
|
-
order: moved ? next.keys : null,
|
|
191
|
-
...(covered ? { coverage: after.coverage } : {}),
|
|
192
|
-
...framing,
|
|
193
|
-
};
|
|
292
|
+
return { ...rows, ...(covered ? { coverage: after.coverage } : {}), ...framing };
|
|
194
293
|
}
|
|
195
294
|
function reframed(before, after) {
|
|
196
295
|
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
package/dist/opened.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export type OpenedFiles = {
|
|
|
18
18
|
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
19
|
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
|
-
export declare function openedFiles(database: RuntimeDatabase,
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ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C;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -20,7 +20,7 @@ function taken(chunks, size) {
|
|
|
20
20
|
}
|
|
21
21
|
return part;
|
|
22
22
|
}
|
|
23
|
-
export function openedFiles(database,
|
|
23
|
+
export function openedFiles(database, lost) {
|
|
24
24
|
const fetching = new Map();
|
|
25
25
|
async function find(name) {
|
|
26
26
|
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
@@ -36,14 +36,14 @@ export function openedFiles(database, fenced) {
|
|
|
36
36
|
let part = 0;
|
|
37
37
|
const write = async (bytes) => {
|
|
38
38
|
if (!(await database.ask({ kind: 'opened.part', key, part, bytes }))) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error();
|
|
40
40
|
}
|
|
41
41
|
part += 1;
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
|
-
if (
|
|
44
|
+
if (lost(name.locator) ||
|
|
45
45
|
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
|
-
throw new Error(
|
|
46
|
+
throw new Error();
|
|
47
47
|
}
|
|
48
48
|
for (;;) {
|
|
49
49
|
const read = await reader.read();
|
|
@@ -61,7 +61,7 @@ export function openedFiles(database, fenced) {
|
|
|
61
61
|
await write(taken(chunks, held));
|
|
62
62
|
const received = hashed.hex();
|
|
63
63
|
if (sha256 !== undefined && sha256 !== received) {
|
|
64
|
-
throw new Error(
|
|
64
|
+
throw new Error();
|
|
65
65
|
}
|
|
66
66
|
const whole = await database.ask({
|
|
67
67
|
kind: 'opened.keep',
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAqCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { conversationsOpened } from './conversation.js';
|
|
2
2
|
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
3
4
|
import { sweep } from './install.js';
|
|
4
5
|
import { eraseFenced } from './lost.js';
|
|
5
6
|
import { prepare } from './preparation.js';
|
|
7
|
+
import { unpair } from './queue.js';
|
|
6
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
7
9
|
export async function open(runtime, opened) {
|
|
8
|
-
const { store, socket,
|
|
10
|
+
const { store, socket, shell, conversations, build, usableWhenHeld } = runtime;
|
|
9
11
|
if (socket.closed())
|
|
10
12
|
throw new Error('runtime closed');
|
|
11
13
|
const interrupted = await opened.fences();
|
|
@@ -40,18 +42,12 @@ export async function open(runtime, opened) {
|
|
|
40
42
|
await conversationsOpened(conversations, opened);
|
|
41
43
|
if (interrupted.length > 0) {
|
|
42
44
|
queueMicrotask(() => {
|
|
43
|
-
void eraseFenced(runtime, interrupted).catch(
|
|
44
|
-
journal.record('erasure failed');
|
|
45
|
-
});
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
statusShown(runtime);
|
|
49
49
|
prepare(runtime);
|
|
50
50
|
emitRooms(runtime);
|
|
51
|
-
void
|
|
52
|
-
.exclusive(() => runtime.unpair(opened))
|
|
53
|
-
.catch(() => {
|
|
54
|
-
journal.record('unpair failed');
|
|
55
|
-
});
|
|
51
|
+
void unpair(runtime).catch(uncaught);
|
|
56
52
|
return opened;
|
|
57
53
|
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
3
4
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
5
6
|
kind: Kind;
|
|
@@ -39,6 +40,10 @@ export type AttachAnswer = {
|
|
|
39
40
|
kind: 'attached';
|
|
40
41
|
path: string;
|
|
41
42
|
} | Offline | Refused<'rejected'> | Failure;
|
|
43
|
+
export type ConversationAttachAnswer = {
|
|
44
|
+
kind: 'attached';
|
|
45
|
+
link: string;
|
|
46
|
+
} | Offline | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
42
47
|
export type DownloadAnswer = {
|
|
43
48
|
kind: 'started';
|
|
44
49
|
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
@@ -56,9 +61,14 @@ export declare const UNREADABLE: Refused<'unreadable'>;
|
|
|
56
61
|
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
57
62
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
58
63
|
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
64
|
+
export declare function declaredType(blob: Blob): string;
|
|
65
|
+
export declare function blobOf(binary: Extract<BinaryAnswer, {
|
|
66
|
+
kind: 'binary';
|
|
67
|
+
}>): Promise<Blob>;
|
|
59
68
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
60
69
|
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
61
70
|
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
71
|
+
export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
|
|
62
72
|
export declare const ROOM_LOCKED = "room-locked";
|
|
63
73
|
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
64
74
|
locator: string;
|
|
@@ -69,7 +79,7 @@ export type Offline = {
|
|
|
69
79
|
export declare const OFFLINE: Offline;
|
|
70
80
|
export declare function answeredResult(value: unknown): boolean;
|
|
71
81
|
export declare const UNCERTAIN: Failure;
|
|
72
|
-
export declare function undeclared(name: string):
|
|
82
|
+
export declare function undeclared(name: string): Refused<'undeclared'>;
|
|
73
83
|
export declare function failure(result: AdapterFailure): Failure;
|
|
74
84
|
export declare function calledResult(result: ActionResult): CallResult;
|
|
75
85
|
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
@@ -84,5 +94,7 @@ export type QueueEntry = {
|
|
|
84
94
|
} & (Submission | {
|
|
85
95
|
readonly state: 'local';
|
|
86
96
|
});
|
|
97
|
+
export declare const UNANSWERED: ActionResult;
|
|
98
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
87
99
|
export {};
|
|
88
100
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["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agentshouse/mdmodel';
|
|
2
|
+
import { refusalError } from './failure.js';
|
|
1
3
|
export const UNREADABLE = {
|
|
2
4
|
kind: 'unreadable',
|
|
3
5
|
code: 'room-not-readable',
|
|
@@ -19,17 +21,22 @@ export const ABSENT_TARGET = {
|
|
|
19
21
|
export function absentBinary(path) {
|
|
20
22
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
23
|
}
|
|
24
|
+
export function declaredType(blob) {
|
|
25
|
+
return blob.type === '' ? MEDIA_TYPES.octetStream : blob.type;
|
|
26
|
+
}
|
|
27
|
+
export function blobOf(binary) {
|
|
28
|
+
return new Response(binary.stream, { headers: { 'content-type': binary.mediaType } }).blob();
|
|
29
|
+
}
|
|
22
30
|
export function binaryAnswer(result) {
|
|
23
31
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
32
|
}
|
|
25
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
26
33
|
export function binaryLinkAnswer(result, held) {
|
|
27
34
|
if (result.kind === 'link') {
|
|
28
35
|
return {
|
|
29
36
|
kind: 'link',
|
|
30
37
|
url: result.url,
|
|
31
38
|
name: result.name,
|
|
32
|
-
mediaType: result.mediaType ?? held ??
|
|
39
|
+
mediaType: result.mediaType ?? held ?? MEDIA_TYPES.octetStream,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
return result.kind === 'rejected' ? result : failure(result);
|
|
@@ -37,6 +44,15 @@ export function binaryLinkAnswer(result, held) {
|
|
|
37
44
|
export function attachAnswer(result) {
|
|
38
45
|
if (result.kind === 'attached')
|
|
39
46
|
return { kind: 'attached', path: result.path };
|
|
47
|
+
if (result.kind === 'linked')
|
|
48
|
+
return UNCERTAIN;
|
|
49
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
50
|
+
}
|
|
51
|
+
export function linkedAnswer(result) {
|
|
52
|
+
if (result.kind === 'linked')
|
|
53
|
+
return { kind: 'attached', link: result.link };
|
|
54
|
+
if (result.kind === 'attached')
|
|
55
|
+
return UNCERTAIN;
|
|
40
56
|
return result.kind === 'rejected' ? result : failure(result);
|
|
41
57
|
}
|
|
42
58
|
export const ROOM_LOCKED = 'room-locked';
|
|
@@ -82,3 +98,17 @@ export function historyAnswer(result) {
|
|
|
82
98
|
? result
|
|
83
99
|
: failure(result);
|
|
84
100
|
}
|
|
101
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
102
|
+
export function handedOutcome(retries, attempt, result) {
|
|
103
|
+
if (attempt !== undefined) {
|
|
104
|
+
const { step, instance } = attempt;
|
|
105
|
+
if (result.kind === 'action')
|
|
106
|
+
retries.succeeded(step, instance);
|
|
107
|
+
else if (result.kind === 'transport-uncertainty')
|
|
108
|
+
retries.uncertain(step, instance, result);
|
|
109
|
+
else if (result.kind === 'rejected' && result.retryable) {
|
|
110
|
+
retries.failed(step, instance, refusalError(result));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return calledResult(result);
|
|
114
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
|
-
import type
|
|
3
|
+
import { type Composition } from './collection.js';
|
|
4
|
+
import { type ChangeBatch } from './change.js';
|
|
3
5
|
export type Heads = {
|
|
4
6
|
revisions: Readonly<Record<string, string>>;
|
|
5
7
|
fileIds: Readonly<Record<string, string>>;
|
|
@@ -22,5 +24,7 @@ export type Layer = Heads & {
|
|
|
22
24
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
23
25
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
24
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
25
|
-
export declare function
|
|
27
|
+
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
+
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
29
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
26
30
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAAC,GAC7C;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE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