@agentshouse/mdruntime 0.1.0-cd71aba4d0215 → 0.1.0-cd8d184c6fbe0
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 +32 -22
- package/dist/act-lanes.d.ts +11 -14
- package/dist/act-lanes.d.ts.map +1 -1
- package/dist/act-lanes.js +53 -5
- package/dist/actions.d.ts +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +135 -55
- package/dist/adapter.d.ts +168 -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 +27 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -57
- 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 +15 -14
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +21 -9
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +19 -8
- package/dist/conversation-row.d.ts +20 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +30 -7
- package/dist/conversation.d.ts +30 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +273 -193
- 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 +30 -8
- 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 +2 -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.map +1 -1
- package/dist/failure.js +3 -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 +77 -31
- 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 +23 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -7
- package/dist/install.d.ts +9 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +44 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +42 -29
- 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 +66 -22
- package/dist/messages.d.ts +21 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +43 -13
- 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 +22 -10
- package/dist/outcome.d.ts +30 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +21 -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 +1 -1
- 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 +180 -39
- package/dist/react.d.ts +16 -11
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +22 -4
- 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 +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +17 -6
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- 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/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 +47 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +24 -10
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +5 -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 +10 -3
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +29 -6
- 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 +6 -4
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +10 -9
- package/dist/source.d.ts +18 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +36 -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 +15 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- 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 +20 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +62 -27
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +52 -35
- package/dist/tables.d.ts +41 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +110 -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 +40 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +22 -14
- package/package.json +4 -4
- 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/expectation.js
CHANGED
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
const
|
|
1
|
+
const NOWHERE = new Set();
|
|
2
|
+
const NOTHING = new Map();
|
|
3
|
+
export function expectation(descriptor, made) {
|
|
4
|
+
return {
|
|
5
|
+
key: made.key,
|
|
6
|
+
descriptor,
|
|
7
|
+
places: new Set(made.at.map((one) => descriptor.place(one))),
|
|
8
|
+
draw: (value) => made.draw(value),
|
|
9
|
+
shown: (value) => made.shown(value),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
2
12
|
export function expectedList(expected) {
|
|
3
13
|
if (expected === null)
|
|
4
14
|
return [];
|
|
5
15
|
return 'key' in expected ? [expected] : expected;
|
|
6
16
|
}
|
|
17
|
+
function asks(reader, one) {
|
|
18
|
+
return (reader.descriptor === one.descriptor && [...one.places].some((at) => reader.places.has(at)));
|
|
19
|
+
}
|
|
20
|
+
function shows(reader, one) {
|
|
21
|
+
return (reader.descriptor === one.descriptor &&
|
|
22
|
+
[...reader.held].some(([at, value]) => one.places.has(at) && one.shown(value)));
|
|
23
|
+
}
|
|
7
24
|
function superseded(entries, at) {
|
|
8
|
-
const key = entries[at]?.
|
|
9
|
-
return entries.slice(at + 1).some((later) => later.
|
|
25
|
+
const key = entries[at]?.one.key;
|
|
26
|
+
return entries.slice(at + 1).some((later) => later.one.key === key);
|
|
10
27
|
}
|
|
11
28
|
function unended(entries, ends) {
|
|
12
29
|
const ended = new Set();
|
|
13
30
|
const kept = [];
|
|
14
|
-
for (const
|
|
15
|
-
if (ended.has(one.
|
|
31
|
+
for (const entry of [...entries].reverse()) {
|
|
32
|
+
if (ended.has(entry.one.key))
|
|
16
33
|
continue;
|
|
17
|
-
if (ends(
|
|
18
|
-
ended.add(one.
|
|
34
|
+
if (ends(entry))
|
|
35
|
+
ended.add(entry.one.key);
|
|
19
36
|
else
|
|
20
|
-
kept.unshift(
|
|
37
|
+
kept.unshift(entry);
|
|
21
38
|
}
|
|
22
39
|
return kept;
|
|
23
40
|
}
|
|
@@ -38,14 +55,13 @@ export function expecting() {
|
|
|
38
55
|
const settle = (next) => {
|
|
39
56
|
for (const entry of next)
|
|
40
57
|
for (const [id, reader] of readers)
|
|
41
|
-
if (
|
|
58
|
+
if (asks(reader, entry.one) && shows(reader, entry.one))
|
|
42
59
|
entry.seen.add(id);
|
|
43
60
|
set(unended(next, (entry) => {
|
|
44
|
-
const asking = [...readers].filter(([, reader]) =>
|
|
61
|
+
const asking = [...readers].filter(([, reader]) => asks(reader, entry.one));
|
|
45
62
|
const seen = asking.filter(([id]) => entry.seen.has(id));
|
|
46
63
|
return (seen.length > 0 &&
|
|
47
|
-
(seen.length === asking.length ||
|
|
48
|
-
seen.some(([, reader]) => !reader.shown(entry.expectation))));
|
|
64
|
+
(seen.length === asking.length || seen.some(([, reader]) => !shows(reader, entry.one))));
|
|
49
65
|
}));
|
|
50
66
|
};
|
|
51
67
|
return {
|
|
@@ -66,19 +82,27 @@ export function expecting() {
|
|
|
66
82
|
return;
|
|
67
83
|
const keys = new Set(fresh.map((one) => one.key));
|
|
68
84
|
settle([
|
|
69
|
-
...entries.filter((
|
|
70
|
-
...fresh.map((
|
|
85
|
+
...entries.filter((entry) => entry.act !== act || !keys.has(entry.one.key)),
|
|
86
|
+
...fresh.map((one) => ({ act, one, seen: new Set() })),
|
|
71
87
|
]);
|
|
72
88
|
},
|
|
73
89
|
drop(act) {
|
|
74
|
-
set(entries.filter((
|
|
90
|
+
set(entries.filter((entry) => entry.act !== act));
|
|
75
91
|
},
|
|
76
|
-
reads(reader,
|
|
77
|
-
readers.set(reader, {
|
|
92
|
+
reads(reader, descriptor, places) {
|
|
93
|
+
readers.set(reader, {
|
|
94
|
+
descriptor,
|
|
95
|
+
places: new Set(places.map((one) => descriptor.place(one))),
|
|
96
|
+
held: readers.get(reader)?.held ?? NOTHING,
|
|
97
|
+
});
|
|
78
98
|
settle(entries);
|
|
79
99
|
},
|
|
80
|
-
heard(reader,
|
|
81
|
-
readers.set(reader, {
|
|
100
|
+
heard(reader, descriptor, held) {
|
|
101
|
+
readers.set(reader, {
|
|
102
|
+
descriptor,
|
|
103
|
+
places: readers.get(reader)?.places ?? NOWHERE,
|
|
104
|
+
held: new Map([...held].map(([place, value]) => [descriptor.place(place), value])),
|
|
105
|
+
});
|
|
82
106
|
settle(entries);
|
|
83
107
|
},
|
|
84
108
|
left(reader) {
|
|
@@ -87,6 +111,13 @@ export function expecting() {
|
|
|
87
111
|
entry.seen.delete(reader);
|
|
88
112
|
settle(entries);
|
|
89
113
|
},
|
|
90
|
-
|
|
114
|
+
draw(descriptor, place, held) {
|
|
115
|
+
const at = descriptor.place(place);
|
|
116
|
+
return entries.reduce((now, entry, index) => entry.one.descriptor === descriptor &&
|
|
117
|
+
entry.one.places.has(at) &&
|
|
118
|
+
!superseded(entries, index)
|
|
119
|
+
? entry.one.draw(now)
|
|
120
|
+
: now, held);
|
|
121
|
+
},
|
|
91
122
|
};
|
|
92
123
|
}
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAEnE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|
package/dist/failure.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
1
2
|
export function runtimeError(code, message = code, retryable = false) {
|
|
2
3
|
return Object.assign(new Error(message), { code, retryable });
|
|
3
4
|
}
|
|
@@ -17,7 +18,8 @@ export function failed(error) {
|
|
|
17
18
|
return runtimeError('runtime-failure', error instanceof Error ? error.message : String(error));
|
|
18
19
|
}
|
|
19
20
|
export function uncaught(error) {
|
|
20
|
-
|
|
21
|
+
if (!refusedForSpace(error))
|
|
22
|
+
reportError(error);
|
|
21
23
|
}
|
|
22
24
|
export function described(error) {
|
|
23
25
|
const { message, code, retryable } = failed(error);
|
package/dist/figures.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { GroupTotal, PendingResult } from './query.js';
|
|
|
3
3
|
import type { Deliver, Fail } from './reach.js';
|
|
4
4
|
import type { ConversationTally, RoomTally } from './tallies.js';
|
|
5
5
|
import type { QueryRoom } from './tables.js';
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const HOUSE_FOLDER = "house";
|
|
7
7
|
export declare const ROOM_TOTALS: {
|
|
8
8
|
readonly outside: readonly ["house"];
|
|
9
9
|
readonly groupBy: readonly ["room"];
|
package/dist/figures.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figures.d.ts","sourceRoot":"","sources":["../src/figures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"figures.d.ts","sourceRoot":"","sources":["../src/figures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;iBAGZ,IAAI;;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AO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,IAAI,CAAC;IAChD,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAgDF,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAwIlE"}
|
package/dist/figures.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { instantKey } from '@agentshouse/mdmodel';
|
|
2
|
-
export const
|
|
2
|
+
export const HOUSE_FOLDER = 'house';
|
|
3
3
|
export const ROOM_TOTALS = {
|
|
4
|
-
outside: [
|
|
4
|
+
outside: [HOUSE_FOLDER],
|
|
5
5
|
groupBy: ['room'],
|
|
6
6
|
select: { size: true },
|
|
7
7
|
};
|
|
@@ -72,8 +72,9 @@ export function createFigures(sources) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async function tallied(rooms, since) {
|
|
75
|
+
const covered = new Set(rooms.map(({ locator }) => locator));
|
|
75
76
|
for (const locator of held.rooms.keys()) {
|
|
76
|
-
if (!
|
|
77
|
+
if (!covered.has(locator))
|
|
77
78
|
held.rooms.delete(locator);
|
|
78
79
|
}
|
|
79
80
|
const asked = rooms.filter(({ locator, key }) => held.staleRooms.has(locator) || held.rooms.get(locator)?.key !== key);
|
|
@@ -90,8 +91,9 @@ export function createFigures(sources) {
|
|
|
90
91
|
]);
|
|
91
92
|
if (kept !== held)
|
|
92
93
|
return false;
|
|
94
|
+
const byKey = new Map(asked.map((room) => [room.key, room]));
|
|
93
95
|
for (const tally of roomTallies) {
|
|
94
|
-
const room =
|
|
96
|
+
const room = byKey.get(tally.key);
|
|
95
97
|
if (room !== undefined)
|
|
96
98
|
held.rooms.set(room.locator, tally);
|
|
97
99
|
}
|
package/dist/file.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AttachRequest } from './adapter.js';
|
|
2
|
-
export declare function attachedFile(locator: string, file: File): Promise<AttachRequest>;
|
|
2
|
+
export declare function attachedFile(locator: string | null, file: File): Promise<AttachRequest>;
|
|
3
3
|
//# sourceMappingURL=file.d.ts.map
|
package/dist/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,CAS7F"}
|
package/dist/file.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { sha256 } from './digest.js';
|
|
2
|
+
import { declaredType } from './outcome.js';
|
|
2
3
|
export async function attachedFile(locator, file) {
|
|
3
4
|
return {
|
|
4
|
-
locator,
|
|
5
|
+
...(locator === null ? {} : { locator }),
|
|
5
6
|
name: file.name,
|
|
6
|
-
mediaType: file
|
|
7
|
+
mediaType: declaredType(file),
|
|
7
8
|
byteLength: file.size,
|
|
8
9
|
sha256: await sha256(file),
|
|
9
10
|
blob: file,
|
package/dist/host.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
|
-
import type { CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
3
|
+
import type { CodeAvailability, FirstTier, Persistence, Readiness } from './readiness.js';
|
|
4
4
|
import type { EntrySeed } from './seed.js';
|
|
5
5
|
import { type CallResult } from './outcome.js';
|
|
6
6
|
import { type RuntimePort } from './wire.js';
|
|
7
7
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
8
8
|
deploymentFacts?: unknown;
|
|
9
|
+
saveMessages?: Readonly<Record<string, string>>;
|
|
9
10
|
};
|
|
10
11
|
export type Admitted = {
|
|
11
12
|
readonly admitted: unknown;
|
|
@@ -19,10 +20,12 @@ export type AttachOptions = {
|
|
|
19
20
|
readonly reach?: PortReach;
|
|
20
21
|
readonly admission?: ActionAdmission;
|
|
21
22
|
readonly code?: CodeAvailability;
|
|
23
|
+
readonly first?: FirstTier;
|
|
22
24
|
};
|
|
23
25
|
export type AttachedPort = {
|
|
24
26
|
detach(): void;
|
|
25
27
|
narrow(reach: PortReach): void;
|
|
28
|
+
code(code: CodeAvailability): void;
|
|
26
29
|
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
27
30
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
28
31
|
};
|
|
@@ -36,9 +39,11 @@ export type MdRuntimeHost = {
|
|
|
36
39
|
};
|
|
37
40
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
38
41
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
42
|
+
export type { QueriedRoom } from './adapter.js';
|
|
39
43
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
40
|
-
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
44
|
+
export type { CodeAvailability, FirstTier, Persistence, Space } from './readiness.js';
|
|
41
45
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
46
|
+
export { replaces } from './observation.js';
|
|
42
47
|
export { undeclared } from './outcome.js';
|
|
43
48
|
export { wireAnswer, wireRequest, type RuntimePort, type WireAnswer, type WireRequest, } from './wire.js';
|
|
44
49
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../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gB,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -2,10 +2,21 @@ import { queryKey } from '@agentshouse/mdmodel';
|
|
|
2
2
|
import { composeRuntime } from './connection.js';
|
|
3
3
|
import { untilAnswered } from './recovery.js';
|
|
4
4
|
import { described } from './failure.js';
|
|
5
|
+
import { observed } from './observation.js';
|
|
5
6
|
import { answeredResult } from './outcome.js';
|
|
6
7
|
import { AUTHORIZATION_ENDED, WIRE, wireRequest, } from './wire.js';
|
|
7
8
|
const NARROWED = new Set(['within', 'whole']);
|
|
8
|
-
|
|
9
|
+
const UNWAITED_MEMBERS = new Set(['call', 'queryHouse']);
|
|
10
|
+
const UNWAITED_TOPICS = new Set([
|
|
11
|
+
'deployment-facts',
|
|
12
|
+
'room-drafts',
|
|
13
|
+
'sync-status',
|
|
14
|
+
'connection-refusal',
|
|
15
|
+
'storage-loss',
|
|
16
|
+
'service-mode',
|
|
17
|
+
'authority-changes',
|
|
18
|
+
]);
|
|
19
|
+
function answered(md, app, writtenBy, member, input, said) {
|
|
9
20
|
switch (member) {
|
|
10
21
|
case 'rooms':
|
|
11
22
|
return md.rooms();
|
|
@@ -13,36 +24,44 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
13
24
|
return md.query(input[0]);
|
|
14
25
|
case 'search':
|
|
15
26
|
return md.search(input[0]);
|
|
27
|
+
case 'queryHouse':
|
|
28
|
+
return md.queryHouse(input[0], input[1]);
|
|
16
29
|
case 'types':
|
|
17
30
|
return md.types(input[0]);
|
|
18
31
|
case 'save':
|
|
19
|
-
return md
|
|
32
|
+
return md
|
|
33
|
+
.save(input[0], input[1], writtenBy)
|
|
34
|
+
.then(said);
|
|
20
35
|
case 'saveParts':
|
|
21
|
-
return md
|
|
36
|
+
return md
|
|
37
|
+
.saveParts(input[0], input[1], writtenBy)
|
|
38
|
+
.then(said);
|
|
22
39
|
case 'history':
|
|
23
40
|
return md.history(input[0], input[1], input[2]);
|
|
24
41
|
case 'resolve':
|
|
25
42
|
return md.resolve(input[0], input[1], input[2]);
|
|
26
|
-
case '
|
|
27
|
-
return md.
|
|
28
|
-
case '
|
|
29
|
-
return md.
|
|
30
|
-
case '
|
|
31
|
-
return md.
|
|
32
|
-
case '
|
|
33
|
-
return md.
|
|
34
|
-
case '
|
|
35
|
-
return md.
|
|
43
|
+
case 'attachment.read':
|
|
44
|
+
return md.attachment.read(input[0], input[1], input[2]);
|
|
45
|
+
case 'attachment.link':
|
|
46
|
+
return md.attachment.link(input[0], input[1], input[2]);
|
|
47
|
+
case 'attachment.show':
|
|
48
|
+
return md.attachment.show(input[0], input[1], input[2]);
|
|
49
|
+
case 'attachment.attach':
|
|
50
|
+
return md.attachment.attach(input[0], input[1]);
|
|
51
|
+
case 'attachment.part':
|
|
52
|
+
return md.attachment.part(input[0], input[1]);
|
|
36
53
|
case 'call':
|
|
37
54
|
return md.call(input[0], input[1]);
|
|
55
|
+
case 'answered':
|
|
56
|
+
return md.answered(input[0]);
|
|
38
57
|
case 'reached':
|
|
39
58
|
return md.reached(input[0], input[1], input[2]);
|
|
40
|
-
case 'log':
|
|
41
|
-
return md.log();
|
|
42
59
|
case 'cleanUp':
|
|
43
60
|
return md.cleanUp();
|
|
44
61
|
case 'unsent':
|
|
45
62
|
return md.unsent();
|
|
63
|
+
case 'sent':
|
|
64
|
+
return md.sent();
|
|
46
65
|
case 'reset':
|
|
47
66
|
return md.reset();
|
|
48
67
|
case 'readAgain':
|
|
@@ -89,22 +108,26 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
89
108
|
return md.conversation.decide(input[0], input[1], input[2]);
|
|
90
109
|
case 'conversation.rename':
|
|
91
110
|
return md.conversation.rename(input[0], input[1], input[2]);
|
|
92
|
-
case 'conversation.
|
|
93
|
-
return md.conversation.
|
|
111
|
+
case 'conversation.set':
|
|
112
|
+
return md.conversation.set(input[0], input[1], input[2]);
|
|
94
113
|
case 'conversation.retry':
|
|
95
114
|
return md.conversation.retry(input[0], input[1], input[2]);
|
|
96
|
-
case 'conversation.pins':
|
|
97
|
-
return md.conversation.pins();
|
|
98
115
|
case 'conversation.pin':
|
|
99
116
|
return md.conversation.pin(input[0]);
|
|
100
|
-
case 'conversation.openedTurns':
|
|
101
|
-
return md.conversation.openedTurns();
|
|
102
117
|
case 'conversation.openTurn':
|
|
103
118
|
return md.conversation.openTurn(input[0], input[1]);
|
|
119
|
+
case 'conversation.dismissSuggestion':
|
|
120
|
+
return md.conversation.dismissSuggestion(input[0], input[1]);
|
|
121
|
+
case 'conversation.attach':
|
|
122
|
+
return md.conversation.attach(input[0]);
|
|
123
|
+
case 'conversation.attachment':
|
|
124
|
+
return md.conversation.attachment(input[0]);
|
|
104
125
|
case 'chatDraft.write':
|
|
105
126
|
return md.chatDraft.write(input[0], input[1], input[2]);
|
|
106
127
|
case 'chatDraft.prepend':
|
|
107
128
|
return md.chatDraft.prepend(input[0], input[1]);
|
|
129
|
+
case 'chatDraft.append':
|
|
130
|
+
return md.chatDraft.append(input[0], input[1]);
|
|
108
131
|
case 'chatDraft.discard':
|
|
109
132
|
return md.chatDraft.discard(input[0]);
|
|
110
133
|
}
|
|
@@ -120,10 +143,17 @@ function attempted(work) {
|
|
|
120
143
|
function answeredMessage(value) {
|
|
121
144
|
if (typeof value !== 'object' || value === null)
|
|
122
145
|
return false;
|
|
123
|
-
return
|
|
146
|
+
return 'result' in value ? answeredResult(value.result) : !('pending' in value);
|
|
124
147
|
}
|
|
125
148
|
export function serveMdRuntime(options) {
|
|
126
149
|
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
150
|
+
const saveMessages = new Map(Object.entries(options.saveMessages ?? {}));
|
|
151
|
+
const said = (result) => {
|
|
152
|
+
if (result.outcome !== 'refused')
|
|
153
|
+
return result;
|
|
154
|
+
const message = saveMessages.get(result.code);
|
|
155
|
+
return message === undefined ? result : { ...result, message };
|
|
156
|
+
};
|
|
127
157
|
const closing = new AbortController();
|
|
128
158
|
const close = () => {
|
|
129
159
|
closing.abort();
|
|
@@ -144,9 +174,9 @@ export function serveMdRuntime(options) {
|
|
|
144
174
|
function attach(port, options) {
|
|
145
175
|
if (!authorized)
|
|
146
176
|
throw new Error(AUTHORIZATION_ENDED);
|
|
147
|
-
const { app, release, reach, admission, code = 'stored' } = options;
|
|
177
|
+
const { app, release, reach, admission, code = 'stored', first = null } = options;
|
|
148
178
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
149
|
-
const view = runtime.within(reach ?? null, { target: app, code });
|
|
179
|
+
const view = runtime.within(reach ?? null, { target: app, code, first, inboxed: null });
|
|
150
180
|
const observations = new Map();
|
|
151
181
|
const followed = new Set();
|
|
152
182
|
const answeredKeys = new Set();
|
|
@@ -172,6 +202,7 @@ export function serveMdRuntime(options) {
|
|
|
172
202
|
observations.clear();
|
|
173
203
|
for (const end of [...followed])
|
|
174
204
|
end();
|
|
205
|
+
view.close();
|
|
175
206
|
attachments.delete(detach);
|
|
176
207
|
};
|
|
177
208
|
const observe = (id, topic, input) => {
|
|
@@ -227,10 +258,12 @@ export function serveMdRuntime(options) {
|
|
|
227
258
|
return;
|
|
228
259
|
}
|
|
229
260
|
try {
|
|
230
|
-
if (message.kind
|
|
261
|
+
if (message.kind === 'observe') {
|
|
262
|
+
if (!UNWAITED_TOPICS.has(message.topic))
|
|
263
|
+
await opened();
|
|
264
|
+
}
|
|
265
|
+
else if (!UNWAITED_MEMBERS.has(message.member))
|
|
231
266
|
await md.loaded();
|
|
232
|
-
else if (message.topic !== 'room-drafts')
|
|
233
|
-
await opened();
|
|
234
267
|
if (message.kind === 'observe') {
|
|
235
268
|
if (serving)
|
|
236
269
|
observe(message.id, message.topic, message.input);
|
|
@@ -243,7 +276,7 @@ export function serveMdRuntime(options) {
|
|
|
243
276
|
return;
|
|
244
277
|
}
|
|
245
278
|
const { id, member, input } = message;
|
|
246
|
-
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? admitted : md, app, writtenBy, member, input));
|
|
279
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? admitted : md, app, writtenBy, member, input, said));
|
|
247
280
|
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
248
281
|
};
|
|
249
282
|
port.addEventListener('message', (event) => {
|
|
@@ -263,6 +296,10 @@ export function serveMdRuntime(options) {
|
|
|
263
296
|
if (serving)
|
|
264
297
|
view.narrow(next);
|
|
265
298
|
},
|
|
299
|
+
code(next) {
|
|
300
|
+
if (serving)
|
|
301
|
+
view.code(next);
|
|
302
|
+
},
|
|
266
303
|
answered(queries, done) {
|
|
267
304
|
const keys = queries.map(queryKey);
|
|
268
305
|
if (keys.every((key) => answeredKeys.has(key)))
|
|
@@ -273,9 +310,17 @@ export function serveMdRuntime(options) {
|
|
|
273
310
|
readiness(deliver) {
|
|
274
311
|
if (!serving)
|
|
275
312
|
return () => { };
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
313
|
+
let shown = null;
|
|
314
|
+
const stop = view.watch('readiness', [], (message) => {
|
|
315
|
+
if (!serving)
|
|
316
|
+
return;
|
|
317
|
+
if (shown !== null) {
|
|
318
|
+
shown.receive(message);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
shown = observed(message, () => { }, 'readiness');
|
|
322
|
+
shown.observation.subscribe((value) => deliver(value));
|
|
323
|
+
deliver(shown.observation.current());
|
|
279
324
|
}, () => { });
|
|
280
325
|
const end = () => {
|
|
281
326
|
followed.delete(end);
|
|
@@ -315,5 +360,6 @@ export function serveMdRuntime(options) {
|
|
|
315
360
|
}
|
|
316
361
|
export { entrySeedOf } from './seed.js';
|
|
317
362
|
export { createRecovery, retryDelay, } from './recovery.js';
|
|
363
|
+
export { replaces } from './observation.js';
|
|
318
364
|
export { undeclared } from './outcome.js';
|
|
319
365
|
export { wireAnswer, wireRequest, } from './wire.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DocumentQuery, type GroupQuery } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { HouseQueryGroups, HouseQueryRows, ProviderRefusal } from './adapter.js';
|
|
3
|
+
import { type Failure, type Offline } from './outcome.js';
|
|
4
|
+
import { type PortReach } from './reach.js';
|
|
5
|
+
import type { Runtime } from './runtime.js';
|
|
6
|
+
type HouseViewQuery = {
|
|
7
|
+
readonly rooms: readonly [string];
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly after?: string;
|
|
10
|
+
};
|
|
11
|
+
export type HouseQuery = ((DocumentQuery | GroupQuery) & {
|
|
12
|
+
rooms: readonly [string];
|
|
13
|
+
}) | HouseViewQuery;
|
|
14
|
+
export type HouseQueryOptions = {
|
|
15
|
+
readonly fresh?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type HouseQueryResult = HouseQueryRows | HouseQueryGroups | Offline | (ProviderRefusal & {
|
|
18
|
+
kind: 'rejected';
|
|
19
|
+
}) | (ProviderRefusal & {
|
|
20
|
+
kind: 'undeclared';
|
|
21
|
+
}) | Failure;
|
|
22
|
+
export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=house-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"house-query.d.ts","sourceRoot":"","sources":["../src/house-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAA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OrHeld } from './listing.js';
|
|
3
|
+
import { normalize } from './paths.js';
|
|
4
|
+
import { failure, OFFLINE, UNCERTAIN, undeclared } from './outcome.js';
|
|
5
|
+
import { askedOnline, offline } from './online.js';
|
|
6
|
+
import { holds, queriedOnly } from './reach.js';
|
|
7
|
+
import { documentKey } from './rows.js';
|
|
8
|
+
const HELD_ON_DEVICE = {
|
|
9
|
+
kind: 'rejected',
|
|
10
|
+
code: 'held-on-device',
|
|
11
|
+
fields: {},
|
|
12
|
+
retryable: false,
|
|
13
|
+
};
|
|
14
|
+
function freshOf(options) {
|
|
15
|
+
if (options === undefined)
|
|
16
|
+
return false;
|
|
17
|
+
if (!plain(options))
|
|
18
|
+
invalid('options', 'expects { fresh }');
|
|
19
|
+
known(options, ['fresh'], 'options');
|
|
20
|
+
const { fresh = false } = options;
|
|
21
|
+
if (typeof fresh !== 'boolean')
|
|
22
|
+
invalid('fresh', 'expects true or false');
|
|
23
|
+
return fresh;
|
|
24
|
+
}
|
|
25
|
+
function viewOf(query) {
|
|
26
|
+
known(query, ['path', 'after'], '');
|
|
27
|
+
const { path, after } = query;
|
|
28
|
+
if (typeof path !== 'string' || path === '' || normalize(path) !== path)
|
|
29
|
+
invalid('path', 'names a View by its Path in the Room');
|
|
30
|
+
if (after === undefined)
|
|
31
|
+
return { path };
|
|
32
|
+
if (typeof after !== 'string')
|
|
33
|
+
invalid('after', 'expects the next an earlier page answered');
|
|
34
|
+
return { path, after };
|
|
35
|
+
}
|
|
36
|
+
function followedOf(reach) {
|
|
37
|
+
if (reach === null)
|
|
38
|
+
return {};
|
|
39
|
+
const whole = new Set([
|
|
40
|
+
...reach.rooms,
|
|
41
|
+
...(reach.queriesOnly ?? []).map(({ locator }) => locator),
|
|
42
|
+
]);
|
|
43
|
+
const documents = new Map(reach.documents
|
|
44
|
+
.filter(({ room }) => !whole.has(room))
|
|
45
|
+
.map(({ room, path }) => [documentKey(room, path), { room, path }]));
|
|
46
|
+
const followed = new Set([...whole, ...[...documents.values()].map(({ room }) => room)]);
|
|
47
|
+
const areas = new Map((reach.areas ?? [])
|
|
48
|
+
.filter(({ room }) => followed.has(room))
|
|
49
|
+
.map(({ room, path, open }) => [
|
|
50
|
+
documentKey(room, path),
|
|
51
|
+
{ room, path, open: [...new Set(open)].sort() },
|
|
52
|
+
]));
|
|
53
|
+
return {
|
|
54
|
+
follows: [
|
|
55
|
+
...[...whole].sort(),
|
|
56
|
+
...[...documents.keys()].sort().map((key) => documents.get(key)),
|
|
57
|
+
...[...areas.keys()].sort().map((key) => areas.get(key)),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function houseQueryOf(input, options, reach) {
|
|
62
|
+
if (!plain(input))
|
|
63
|
+
invalid('query', 'expects a query object');
|
|
64
|
+
const { rooms, ...query } = input;
|
|
65
|
+
if (!Array.isArray(rooms) || rooms.length !== 1 || typeof rooms[0] !== 'string')
|
|
66
|
+
invalid('rooms', 'names the one Room House answers');
|
|
67
|
+
const asked = { room: rooms[0], fresh: freshOf(options), ...followedOf(reach) };
|
|
68
|
+
return query.path === undefined ? { ...asked, query } : { ...asked, ...viewOf(query) };
|
|
69
|
+
}
|
|
70
|
+
async function heldHere(runtime, reach, room) {
|
|
71
|
+
return holds(reach, room) && listedOrHeld(runtime, await runtime.store.rooms([room]), room);
|
|
72
|
+
}
|
|
73
|
+
async function searchListed(runtime, room) {
|
|
74
|
+
const { roomList } = await (await runtime.store.open()).facts(['roomList']);
|
|
75
|
+
return roomList?.rooms.some((one) => one.room_ref === room && one.level === 'search') === true;
|
|
76
|
+
}
|
|
77
|
+
async function queriedHere(runtime, reach, room) {
|
|
78
|
+
if (queriedOnly(reach, runtime.socket.session.now().queriesOnly, room))
|
|
79
|
+
return true;
|
|
80
|
+
return reach === null && (await searchListed(runtime, room));
|
|
81
|
+
}
|
|
82
|
+
export async function queriedHouse(runtime, input, reach, options) {
|
|
83
|
+
const { socket } = runtime;
|
|
84
|
+
const query = socket.queryHouse();
|
|
85
|
+
if (query === undefined)
|
|
86
|
+
return undeclared('queryHouse');
|
|
87
|
+
const asked = houseQueryOf(input, options, reach);
|
|
88
|
+
await socket.ready;
|
|
89
|
+
if (!(await queriedHere(runtime, reach, asked.room))) {
|
|
90
|
+
return (await heldHere(runtime, reach, asked.room))
|
|
91
|
+
? HELD_ON_DEVICE
|
|
92
|
+
: failure({ kind: 'room-not-readable', locator: asked.room });
|
|
93
|
+
}
|
|
94
|
+
if (await offline(runtime))
|
|
95
|
+
return OFFLINE;
|
|
96
|
+
const answer = await askedOnline(runtime, (authorization) => query(authorization, asked));
|
|
97
|
+
if (answer === null)
|
|
98
|
+
return UNCERTAIN;
|
|
99
|
+
return answer.kind === 'rows' || answer.kind === 'groups' || answer.kind === 'rejected'
|
|
100
|
+
? answer
|
|
101
|
+
: failure(answer);
|
|
102
|
+
}
|
package/dist/identity.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export declare function changeBatchIdentity(at?: number): string;
|
|
|
2
2
|
export declare function roomDraftRevision(): string;
|
|
3
3
|
export declare function chatDraftRevision(): string;
|
|
4
4
|
export declare function transferIdentity(): string;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function attachmentLocalId(): string;
|
|
6
6
|
//# 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;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|