@agentshouse/mdruntime 0.1.0-cf08ada271a7f → 0.1.0-cf08df9b663d8
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 +57 -38
- 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 +173 -83
- package/dist/adapter.d.ts +210 -30
- 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 +345 -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 +29 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -64
- 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 +32 -17
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -11
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +24 -11
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +45 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +337 -203
- 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 +46 -48
- 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 +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- 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/holdings.d.ts.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +94 -30
- 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 +27 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/install.d.ts +10 -5
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -55
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +74 -51
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +27 -20
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +68 -69
- 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 +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +8 -20
- 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 +99 -37
- package/dist/messages.d.ts +21 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +48 -16
- 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 +18 -35
- 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 +6 -6
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +4 -4
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +22 -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/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 +5 -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 +207 -96
- 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 +137 -79
- 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 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +76 -49
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +196 -37
- package/dist/react.d.ts +17 -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 +5 -3
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +26 -14
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- 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 +2 -4
- 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 +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- 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 +11 -5
- 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 +120 -135
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +116 -65
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- 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 +8 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +95 -67
- 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 +9 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +17 -16
- package/dist/source.d.ts +42 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- 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 +31 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -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.d.ts +24 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +49 -17
- 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 +66 -32
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +109 -82
- package/dist/tables.d.ts +40 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +109 -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 +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +28 -11
- 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/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- 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 -41
- 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/compile.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { ARRAY_INDEX, bodied, byCodePoint, compared, cursorOf, heldKind, parse, pointerSegments, sql, } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentRecord } from './attachment.js';
|
|
3
|
+
import { definitionsAt, UNTYPED } from './collection.js';
|
|
3
4
|
import { documentKey, pathOfKey, roomOfKey } from './rows.js';
|
|
5
|
+
import { ROOM_HANDLE } from './stored.js';
|
|
4
6
|
import { FROM_START, MAXIMUM_WINDOW } from './windows.js';
|
|
5
7
|
const { all, any, exists, fragment, grouped, joined, listed } = sql;
|
|
6
|
-
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1
|
|
8
|
+
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1`;
|
|
7
9
|
function located(alias) {
|
|
8
10
|
return fragment(`(SELECT k.locator FROM replica_keys k WHERE k.key = ${alias}.key)`);
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
return fragment(`(${
|
|
12
|
-
|
|
13
|
-
`${
|
|
14
|
-
`${
|
|
12
|
+
function inside(path, folder) {
|
|
13
|
+
return fragment(`(${path} = ? OR (${path} >= ? AND ${path} < ?))`, [
|
|
14
|
+
folder,
|
|
15
|
+
`${folder}/`,
|
|
16
|
+
`${folder}0`,
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
19
|
+
export function within(alias, path) {
|
|
20
|
+
return inside(`${alias}.path`, path);
|
|
21
|
+
}
|
|
17
22
|
function ancestors(area) {
|
|
18
23
|
const depth = area.path.split('/').length;
|
|
19
24
|
return area.open.flatMap((open) => {
|
|
@@ -21,18 +26,18 @@ function ancestors(area) {
|
|
|
21
26
|
return segments.slice(depth - 1, -1).map((_, at) => segments.slice(0, depth + at).join('/'));
|
|
22
27
|
});
|
|
23
28
|
}
|
|
24
|
-
function fenced(
|
|
29
|
+
function fenced(key, path, held, area, folders) {
|
|
25
30
|
const opened = any([
|
|
26
|
-
...area.open.map((open) =>
|
|
27
|
-
...(folders ? ancestors(area).map((
|
|
31
|
+
...area.open.map((open) => inside(path, open)),
|
|
32
|
+
...(folders ? ancestors(area).map((ancestor) => fragment(`${path} = ?`, [ancestor])) : []),
|
|
28
33
|
]);
|
|
29
34
|
return all([
|
|
30
|
-
fragment(`${
|
|
31
|
-
|
|
35
|
+
fragment(`${key} = ?`, [held]),
|
|
36
|
+
inside(path, area.path),
|
|
32
37
|
fragment(`NOT ${grouped(opened).sql}`, opened.bind),
|
|
33
38
|
]);
|
|
34
39
|
}
|
|
35
|
-
function reached(bound,
|
|
40
|
+
function reached(bound, key, path) {
|
|
36
41
|
const reach = bound.reach;
|
|
37
42
|
if (reach === null)
|
|
38
43
|
return fragment('1');
|
|
@@ -45,49 +50,65 @@ function reached(bound, alias) {
|
|
|
45
50
|
return key === undefined ? [] : [[key, pathOfKey(held)]];
|
|
46
51
|
});
|
|
47
52
|
const outside = any(reach.areas.flatMap((area) => {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
53
|
+
const held = bound.keys.get(area.room);
|
|
54
|
+
return held === undefined ? [] : [fenced(key, path, held, area, false)];
|
|
50
55
|
}));
|
|
51
56
|
return all([
|
|
52
57
|
any([
|
|
53
|
-
...(rooms.length === 0 ? [] : [fragment(`${
|
|
58
|
+
...(rooms.length === 0 ? [] : [fragment(`${key} IN ${listed(rooms).sql}`, rooms)]),
|
|
54
59
|
...(documents.length === 0
|
|
55
60
|
? []
|
|
56
61
|
: [
|
|
57
|
-
fragment(`EXISTS (SELECT 1 FROM json_each(?) j WHERE j.value ->> 0 = ${
|
|
62
|
+
fragment(`EXISTS (SELECT 1 FROM json_each(?) j WHERE j.value ->> 0 = ${key} AND j.value ->> 1 = ${path})`, [JSON.stringify(documents)]),
|
|
58
63
|
]),
|
|
59
64
|
]),
|
|
60
65
|
...(reach.areas.length === 0 ? [] : [fragment(`NOT ${grouped(outside).sql}`, outside.bind)]),
|
|
61
66
|
]);
|
|
62
67
|
}
|
|
68
|
+
function handled(bound, link) {
|
|
69
|
+
return fragment(`FROM replica_rooms h WHERE ${ROOM_HANDLE('h')} = ${link}.handle AND h.key IN (SELECT value FROM json_each(?))`, [bound.follows]);
|
|
70
|
+
}
|
|
71
|
+
function followed(bound) {
|
|
72
|
+
return {
|
|
73
|
+
targets: (link, document) => {
|
|
74
|
+
const room = handled(bound, link);
|
|
75
|
+
return joined([
|
|
76
|
+
fragment(`replica_entries ${document} ON ${document}.key = CASE WHEN ${link}.handle IS NULL THEN d.key ELSE (SELECT h.key ${room.sql}) END AND ${document}.path = ${link}.target AND ${VISIBLE(document)} AND`, room.bind),
|
|
77
|
+
grouped(reached(bound, `${document}.key`, `${document}.path`)),
|
|
78
|
+
], ' ');
|
|
79
|
+
},
|
|
80
|
+
unfollowed: (link) => {
|
|
81
|
+
const own = reached(bound, 'd.key', `${link}.target`);
|
|
82
|
+
const room = handled(bound, link);
|
|
83
|
+
const other = reached(bound, 'h.key', `${link}.target`);
|
|
84
|
+
return fragment(`NOT ((${link}.handle IS NULL AND ${own.sql}) OR EXISTS (SELECT 1 ${room.sql} AND ${other.sql}))`, [...own.bind, ...room.bind, ...other.bind]);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
63
88
|
function related(bound, plan) {
|
|
64
89
|
const parts = [];
|
|
65
|
-
if (plan.hop !== null)
|
|
66
|
-
parts.push(
|
|
67
|
-
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries m ON m.key = d.key AND m.path = l.target AND ${VISIBLE('m')} WHERE l.doc = d.id AND l.kind = 'field' AND`),
|
|
68
|
-
grouped(sql.placed('l', plan.hop.field, 'link')),
|
|
69
|
-
fragment('AND'),
|
|
70
|
-
grouped(all([sql.scoped('m', plan.hop), reached(bound, 'm')])),
|
|
71
|
-
], ' ')));
|
|
72
|
-
}
|
|
90
|
+
if (plan.hop !== null)
|
|
91
|
+
parts.push(sql.hopped('d', plan.hop, followed(bound)));
|
|
73
92
|
if (plan.backlinks !== null) {
|
|
74
93
|
const field = plan.backlinks.field;
|
|
75
94
|
parts.push(exists(joined([
|
|
76
|
-
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE l.key = d.key AND l.target = d.path AND l.kind = 'field' AND`),
|
|
95
|
+
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE l.key = d.key AND l.handle IS NULL AND l.target = d.path AND l.kind = 'field' AND`),
|
|
77
96
|
...(field === null ? [] : [grouped(sql.placed('l', field, 'link')), fragment('AND')]),
|
|
78
|
-
grouped(all([sql.scoped('s', plan.backlinks), reached(bound, 's')])),
|
|
97
|
+
grouped(all([sql.scoped('s', plan.backlinks), reached(bound, 's.key', 's.path')])),
|
|
79
98
|
], ' ')));
|
|
80
99
|
}
|
|
81
100
|
return parts;
|
|
82
101
|
}
|
|
83
|
-
function
|
|
102
|
+
function tested(bound, plan) {
|
|
84
103
|
const keys = bound.rooms.map(({ key }) => key);
|
|
85
|
-
return
|
|
104
|
+
return [
|
|
86
105
|
fragment(`d.key IN ${listed(keys).sql} AND ${VISIBLE('d')}`, keys),
|
|
87
|
-
reached(bound, 'd'),
|
|
106
|
+
reached(bound, 'd.key', 'd.path'),
|
|
88
107
|
sql.tests('d', plan),
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function filtered(bound, plan) {
|
|
111
|
+
return all([...tested(bound, plan), ...related(bound, plan)]);
|
|
91
112
|
}
|
|
92
113
|
function orderingOf(options) {
|
|
93
114
|
const stringSort = options.stringSort ?? 'locale';
|
|
@@ -310,7 +331,16 @@ function sectionsOf(sections, names) {
|
|
|
310
331
|
return sections;
|
|
311
332
|
return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
|
|
312
333
|
}
|
|
313
|
-
function
|
|
334
|
+
function freeParts(room, path, type, content) {
|
|
335
|
+
const definitions = room.composition === undefined ? undefined : definitionsAt(room.composition, path);
|
|
336
|
+
const definition = definitions?.(type === UNTYPED ? undefined : type);
|
|
337
|
+
if (definition === undefined && type !== UNTYPED)
|
|
338
|
+
return null;
|
|
339
|
+
const read = parse(content, path, definition);
|
|
340
|
+
return read.ok ? read.document : null;
|
|
341
|
+
}
|
|
342
|
+
function documentOf(shape, queried, row, linked) {
|
|
343
|
+
const room = queried.locator;
|
|
314
344
|
const path = row.path;
|
|
315
345
|
const type = row.type;
|
|
316
346
|
const fileId = row.file_id;
|
|
@@ -324,7 +354,7 @@ function documentOf(shape, room, row, linked) {
|
|
|
324
354
|
...(binary === null
|
|
325
355
|
? {}
|
|
326
356
|
: {
|
|
327
|
-
|
|
357
|
+
attachment: attachmentRecord(path, binary, revision ?? undefined),
|
|
328
358
|
}),
|
|
329
359
|
...(shape.markdown && content !== null ? { markdown: content } : {}),
|
|
330
360
|
...(shape.change ? { change: changeOf(row) } : {}),
|
|
@@ -333,8 +363,9 @@ function documentOf(shape, room, row, linked) {
|
|
|
333
363
|
...heldFacts(shape, row),
|
|
334
364
|
};
|
|
335
365
|
}
|
|
336
|
-
const
|
|
337
|
-
|
|
366
|
+
const body = shape.sections !== null || shape.preamble
|
|
367
|
+
? freeParts(queried, path, type, row.content)
|
|
368
|
+
: null;
|
|
338
369
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
339
370
|
return {
|
|
340
371
|
room,
|
|
@@ -377,10 +408,10 @@ function backlinksOf(connection, bound, rows) {
|
|
|
377
408
|
held.push(row.path);
|
|
378
409
|
byKey.set(key, held);
|
|
379
410
|
}
|
|
380
|
-
const reach = reached(bound, 's');
|
|
411
|
+
const reach = reached(bound, 's.key', 's.path');
|
|
381
412
|
for (const [key, targets] of byKey) {
|
|
382
413
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
383
|
-
const found = connection.rows(`SELECT target, path, type, field FROM (SELECT l.target, s.path, s.type, l.field, ROW_NUMBER() OVER (PARTITION BY l.target ORDER BY s.path, l.field) AS rank FROM (SELECT DISTINCT doc, target, field FROM replica_links WHERE key = ? AND kind = 'field' AND target IN (SELECT value FROM json_each(?))) l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE ${reach.sql}) WHERE rank <= ? ORDER BY target, path, field`, [key, JSON.stringify(targets), ...reach.bind, MAXIMUM_WINDOW]);
|
|
414
|
+
const found = connection.rows(`SELECT target, path, type, field FROM (SELECT l.target, s.path, s.type, l.field, ROW_NUMBER() OVER (PARTITION BY l.target ORDER BY s.path, l.field) AS rank FROM (SELECT DISTINCT doc, target, field FROM replica_links WHERE key = ? AND kind = 'field' AND handle IS NULL AND target IN (SELECT value FROM json_each(?))) l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE ${reach.sql}) WHERE rank <= ? ORDER BY target, path, field`, [key, JSON.stringify(targets), ...reach.bind, MAXIMUM_WINDOW]);
|
|
384
415
|
for (const row of found) {
|
|
385
416
|
const at = documentKey(room, row.target);
|
|
386
417
|
const held = linked.get(at) ?? [];
|
|
@@ -428,8 +459,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
428
459
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
429
460
|
const cut = kept.length;
|
|
430
461
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
462
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
431
463
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
432
|
-
const found = kept.map((row) => documentOf(shape,
|
|
464
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
433
465
|
const last = kept.at(-1);
|
|
434
466
|
const cursorAt = (row) => cursorOf([
|
|
435
467
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -494,7 +526,7 @@ function storedFolders(bound, plan, subfolder) {
|
|
|
494
526
|
const key = bound.keys.get(area.room);
|
|
495
527
|
if (key === undefined)
|
|
496
528
|
return [];
|
|
497
|
-
const fence = fenced('f', key, area, true);
|
|
529
|
+
const fence = fenced('f.key', 'f.path', key, area, true);
|
|
498
530
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
499
531
|
});
|
|
500
532
|
const under = prefix === ''
|
|
@@ -690,16 +722,28 @@ function groups(connection, bound, plan, shape) {
|
|
|
690
722
|
...(total === undefined ? {} : { total }),
|
|
691
723
|
};
|
|
692
724
|
}
|
|
693
|
-
function boundOf(connection, plan, rooms) {
|
|
725
|
+
function boundOf(connection, plan, rooms, follows) {
|
|
694
726
|
return {
|
|
695
727
|
rooms: [...rooms].sort((left, right) => left.locator < right.locator ? -1 : left.locator > right.locator ? 1 : 0),
|
|
696
|
-
keys: new Map(rooms.map(({ locator, key }) => [locator, key])),
|
|
728
|
+
keys: new Map([...rooms, ...follows].map(({ locator, key }) => [locator, key])),
|
|
729
|
+
follows: JSON.stringify(follows.map(({ key }) => key)),
|
|
697
730
|
reach: plan.reach,
|
|
698
731
|
collate: collating(connection),
|
|
699
732
|
};
|
|
700
733
|
}
|
|
701
|
-
export function
|
|
702
|
-
|
|
734
|
+
export function namedHandles(connection, plan, rooms, handles) {
|
|
735
|
+
if (plan.hop === null)
|
|
736
|
+
return [];
|
|
737
|
+
const statement = joined([
|
|
738
|
+
fragment("SELECT DISTINCT l.handle FROM replica_entries d JOIN replica_links l ON l.doc = d.id AND l.kind = 'field' AND l.handle IN (SELECT value FROM json_each(?)) AND ", [JSON.stringify(handles)]),
|
|
739
|
+
grouped(sql.placed('l', plan.hop.field, 'link')),
|
|
740
|
+
fragment(' WHERE '),
|
|
741
|
+
all(tested(boundOf(connection, plan, rooms, []), plan)),
|
|
742
|
+
], '');
|
|
743
|
+
return connection.rows(statement.sql, statement.bind).map((row) => row.handle);
|
|
744
|
+
}
|
|
745
|
+
export function answerQuery(connection, plan, rooms, budget = null, follows = []) {
|
|
746
|
+
const bound = boundOf(connection, plan, rooms, follows);
|
|
703
747
|
if (rooms.length === 0) {
|
|
704
748
|
return plan.shape.kind === 'groups'
|
|
705
749
|
? { groups: [], ...(plan.total ? { total: 0 } : {}) }
|
package/dist/connection.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export type MdRuntimeOptions = {
|
|
|
10
10
|
authorization?: Authorization;
|
|
11
11
|
signal?: AbortSignal;
|
|
12
12
|
recovery?: Recovery;
|
|
13
|
-
usableWhenHeld?: readonly string[];
|
|
14
13
|
build?: string;
|
|
14
|
+
storeOnNeed?: boolean;
|
|
15
15
|
};
|
|
16
16
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
17
17
|
//# sourceMappingURL=connection.d.ts.map
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAsC,MAAM,cAAc,CAAC;AAI/F,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAUrE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9D,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAOrE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CA6GzE"}
|
package/dist/connection.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { notReadyWaitMs } from '@agentshouse/mdmodel';
|
|
1
2
|
import { submitLater } from './acceptance.js';
|
|
2
3
|
import { invokeAction, called, readConversationHistory, resendLater } from './actions.js';
|
|
3
|
-
import { builtInModel,
|
|
4
|
+
import { builtInModel, NO_ROOM_TYPES } from './attached-model.js';
|
|
4
5
|
import { createLiveConversations } from './conversation-live.js';
|
|
5
6
|
import { writeRule } from './declaration.js';
|
|
6
7
|
import { refusedForSpace } from './durability.js';
|
|
@@ -8,25 +9,32 @@ import { uncaught } from './failure.js';
|
|
|
8
9
|
import { createFigures } from './figures.js';
|
|
9
10
|
import { scheduleCurrency, spaceFreed, start } from './lifecycle.js';
|
|
10
11
|
import { createLiveQueries } from './live.js';
|
|
11
|
-
import { createLog } from './log.js';
|
|
12
12
|
import { open } from './opening.js';
|
|
13
13
|
import { deliverOwedReadiness, filled, prepare } from './preparation.js';
|
|
14
|
+
import { createPresence } from './presence.js';
|
|
14
15
|
import { answeredPlan, figuresCover, roomTallies } from './queries.js';
|
|
15
16
|
import { readAnswers } from './reads.js';
|
|
16
17
|
import { createRecovery } from './recovery.js';
|
|
18
|
+
import { createRetries } from './retried.js';
|
|
17
19
|
import { publishChangeSet, show } from './shown.js';
|
|
18
20
|
import { createSocket } from './socket.js';
|
|
19
21
|
import { createStore } from './store.js';
|
|
20
22
|
import { composedRuntime } from './surface.js';
|
|
23
|
+
import { adopt, discover } from './sync.js';
|
|
24
|
+
function writable(room) {
|
|
25
|
+
return room !== undefined && room.operations.write.length > 0;
|
|
26
|
+
}
|
|
21
27
|
const ROOM_ATTEMPTS = 16;
|
|
22
28
|
export function composeRuntime(options) {
|
|
23
29
|
const { adapter, shell } = options;
|
|
24
|
-
const roomTypes =
|
|
30
|
+
const roomTypes = adapter.roomTypes ?? NO_ROOM_TYPES;
|
|
25
31
|
const builtIn = builtInModel(roomTypes);
|
|
26
32
|
const typedPaths = adapter.typedPaths ?? [];
|
|
27
|
-
const
|
|
28
|
-
const socket = createSocket(adapter,
|
|
33
|
+
const retries = createRetries(shell);
|
|
34
|
+
const socket = createSocket(adapter, retries, options.authorization);
|
|
35
|
+
const presence = createPresence(notReadyWaitMs);
|
|
29
36
|
const store = createStore({
|
|
37
|
+
retries,
|
|
30
38
|
database: {
|
|
31
39
|
async ask(request) {
|
|
32
40
|
try {
|
|
@@ -43,11 +51,10 @@ export function composeRuntime(options) {
|
|
|
43
51
|
builtIn,
|
|
44
52
|
typedPaths,
|
|
45
53
|
persistence: shell.persistence,
|
|
54
|
+
lost: presence.lost,
|
|
55
|
+
losing: presence.losing,
|
|
46
56
|
opening: (local) => open(runtime, local),
|
|
47
|
-
unpublished
|
|
48
|
-
journal.record(`publication failed ${error instanceof Error ? error.name : 'unknown'}`);
|
|
49
|
-
uncaught(error);
|
|
50
|
-
},
|
|
57
|
+
unpublished: uncaught,
|
|
51
58
|
changed(set) {
|
|
52
59
|
if (set.unindexed.length > 0)
|
|
53
60
|
prepare(runtime, set.unindexed);
|
|
@@ -55,25 +62,28 @@ export function composeRuntime(options) {
|
|
|
55
62
|
submitLater(runtime, locator);
|
|
56
63
|
return publishChangeSet(runtime, set);
|
|
57
64
|
},
|
|
58
|
-
deliverReadiness: (owed) => deliverOwedReadiness(runtime, owed),
|
|
65
|
+
deliverReadiness: (owed, rooms) => deliverOwedReadiness(runtime, owed, rooms),
|
|
59
66
|
spaceFreed: () => spaceFreed(runtime),
|
|
60
67
|
});
|
|
61
68
|
const recovery = (options.recovery ?? createRecovery()).scope(ROOM_ATTEMPTS);
|
|
62
69
|
const runtime = {
|
|
63
70
|
store,
|
|
64
71
|
socket,
|
|
65
|
-
|
|
72
|
+
presence,
|
|
66
73
|
recovery,
|
|
74
|
+
retries,
|
|
67
75
|
shell,
|
|
68
|
-
|
|
76
|
+
savesLocally: (locator) => adapter.localSaves === true && !writable(presence.room(locator)),
|
|
69
77
|
roomTypes,
|
|
70
78
|
builtIn,
|
|
71
79
|
typedPaths,
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
renamedActions: adapter.renamedActions ?? new Map(),
|
|
81
|
+
rewrittenInputs: adapter.rewrittenInputs ?? new Map(),
|
|
82
|
+
keptInput: adapter.keptInput ?? ((input) => input),
|
|
83
|
+
writeRule: (declaration) => writeRule(declaration, adapter.pathRule ?? (() => true), adapter.localSaves === true && !writable(declaration)),
|
|
74
84
|
build: options.build ?? '',
|
|
75
85
|
conversations: createLiveConversations({
|
|
76
|
-
call: (name, input) => invokeAction(runtime, name, input),
|
|
86
|
+
call: (name, input, attempt) => invokeAction(runtime, name, input, { attempt }),
|
|
77
87
|
history: (request) => readConversationHistory(runtime, request),
|
|
78
88
|
durably: store.durably,
|
|
79
89
|
local: store.open,
|
|
@@ -89,7 +99,9 @@ export function composeRuntime(options) {
|
|
|
89
99
|
full: store.space.full,
|
|
90
100
|
closed: socket.closed,
|
|
91
101
|
unanswered: () => resendLater(runtime),
|
|
102
|
+
heard: (operation, lost) => socket.lanes.settle(operation, lost),
|
|
92
103
|
recovery: recovery.scope(),
|
|
104
|
+
retries,
|
|
93
105
|
}),
|
|
94
106
|
liveQueries: createLiveQueries((plan, cover) => answeredPlan(runtime, plan, cover), store.covering),
|
|
95
107
|
figures: createFigures({
|
|
@@ -103,14 +115,17 @@ export function composeRuntime(options) {
|
|
|
103
115
|
unkept: adapter.unkeptReads ?? [],
|
|
104
116
|
leading: adapter.leadingReads ?? [],
|
|
105
117
|
recovery: recovery.scope(),
|
|
106
|
-
|
|
118
|
+
retries,
|
|
119
|
+
call: (name, input, attempt) => called(runtime, name, input, attempt),
|
|
107
120
|
online: socket.reached,
|
|
108
121
|
streaming: socket.isOpen,
|
|
109
122
|
closed: socket.closed,
|
|
110
123
|
full: store.space.full,
|
|
111
124
|
filled: () => filled(runtime),
|
|
112
125
|
}),
|
|
126
|
+
discover: () => discover(runtime),
|
|
127
|
+
adopt: (unstored) => adopt(runtime, unstored),
|
|
113
128
|
};
|
|
114
|
-
start(runtime, options.signal);
|
|
129
|
+
start(runtime, options.signal, options.storeOnNeed === true);
|
|
115
130
|
return composedRuntime(runtime);
|
|
116
131
|
}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKpD"}
|
package/dist/context.js
CHANGED
|
@@ -5,9 +5,10 @@ import type { ChangeSet } from './change-set.js';
|
|
|
5
5
|
import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
|
|
6
6
|
import type { CallResult } from './outcome.js';
|
|
7
7
|
import type { Recovery } from './recovery.js';
|
|
8
|
+
import type { Attempt, Retries } from './retried.js';
|
|
8
9
|
import type { ChatDraftRecord, RuntimeStore } from './store.js';
|
|
9
10
|
export type ConversationDependencies = {
|
|
10
|
-
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
11
|
+
call(name: ConversationAction, input: unknown, attempt?: Attempt): Promise<CallResult>;
|
|
11
12
|
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
12
13
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
13
14
|
local(): Promise<RuntimeStore>;
|
|
@@ -19,7 +20,9 @@ export type ConversationDependencies = {
|
|
|
19
20
|
full(): boolean;
|
|
20
21
|
closed(): boolean;
|
|
21
22
|
unanswered(): void;
|
|
23
|
+
heard(operation: string, lost: boolean): void;
|
|
22
24
|
readonly recovery: Recovery;
|
|
25
|
+
readonly retries: Retries;
|
|
23
26
|
};
|
|
24
27
|
export type Live = {
|
|
25
28
|
turn: RunningTurn | null;
|
|
@@ -31,9 +34,7 @@ export type Live = {
|
|
|
31
34
|
options: readonly SessionOption[];
|
|
32
35
|
starting: string | null;
|
|
33
36
|
state: SessionState | null;
|
|
34
|
-
|
|
35
|
-
connected: boolean;
|
|
36
|
-
} | null;
|
|
37
|
+
deliveryWaiting: readonly string[];
|
|
37
38
|
deliveryUnknown: readonly string[];
|
|
38
39
|
};
|
|
39
40
|
export declare const QUIET: Live;
|
|
@@ -42,10 +43,14 @@ export declare const FACTS: readonly Fact[];
|
|
|
42
43
|
type Watcher = {
|
|
43
44
|
readonly notify: (view: ConversationView) => void;
|
|
44
45
|
};
|
|
45
|
-
type
|
|
46
|
-
readonly window: readonly AcceptedMessage[] | null;
|
|
46
|
+
export type Kept = {
|
|
47
47
|
readonly draft: ChatDraftRecord | null;
|
|
48
48
|
readonly ended: string | null;
|
|
49
|
+
readonly dismissed: string | null;
|
|
50
|
+
readonly pins: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
type HeldWindow = Kept & {
|
|
53
|
+
readonly window: readonly AcceptedMessage[] | null;
|
|
49
54
|
readonly more: boolean;
|
|
50
55
|
readonly total: number | null;
|
|
51
56
|
};
|
|
@@ -71,23 +76,31 @@ export type Audience<T> = {
|
|
|
71
76
|
};
|
|
72
77
|
type HeldFacts = {
|
|
73
78
|
readonly listKnown: boolean;
|
|
79
|
+
readonly listHeld: boolean;
|
|
80
|
+
readonly openingRead: boolean;
|
|
81
|
+
readonly openingListed: boolean;
|
|
82
|
+
readonly listRefused: boolean;
|
|
74
83
|
readonly listOwed: boolean;
|
|
75
84
|
readonly listTelling: boolean;
|
|
76
85
|
readonly agentsShown: string | null;
|
|
77
|
-
readonly
|
|
78
|
-
readonly agentsReading: boolean;
|
|
86
|
+
readonly listedShown: string | null;
|
|
79
87
|
readonly replicated: ReadonlySet<string>;
|
|
80
88
|
readonly handedReplicated: string | undefined;
|
|
81
89
|
};
|
|
82
90
|
export type Dispatch = Cell<{
|
|
83
91
|
readonly answered: boolean;
|
|
84
92
|
}>;
|
|
93
|
+
export type Relisted = {
|
|
94
|
+
readonly conversations: ReadonlyMap<string, ListedConversation>;
|
|
95
|
+
readonly agents: ReadonlyMap<string, ListedAgent>;
|
|
96
|
+
};
|
|
85
97
|
export type LiveConversations = {
|
|
86
98
|
readonly deps: ConversationDependencies;
|
|
87
99
|
readonly held: Cell<HeldFacts>;
|
|
88
100
|
readonly closing: AbortSignal;
|
|
89
101
|
readonly listeners: Audience<readonly ConversationEntry[]>;
|
|
90
102
|
readonly agentListeners: Audience<readonly ConversationAgent[]>;
|
|
103
|
+
readonly listedListeners: Audience<readonly ListedAgent[]>;
|
|
91
104
|
views(): Iterable<SharedView>;
|
|
92
105
|
viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
|
|
93
106
|
readonly view: SharedView;
|
|
@@ -106,7 +119,7 @@ export type LiveConversations = {
|
|
|
106
119
|
caughtUpTo(conversation: string): void;
|
|
107
120
|
gapOpened(conversation: string): void;
|
|
108
121
|
generation(conversation: string): number;
|
|
109
|
-
heardAt(conversation: string,
|
|
122
|
+
heardAt(conversation: string, change: string): void;
|
|
110
123
|
newestHeard(conversation: string): string | undefined;
|
|
111
124
|
catching(conversation: string): Promise<void> | undefined;
|
|
112
125
|
catchingUntil(conversation: string, ended: Promise<void>): void;
|
|
@@ -115,9 +128,9 @@ export type LiveConversations = {
|
|
|
115
128
|
isCreating(conversation: string): boolean;
|
|
116
129
|
relisting(): boolean;
|
|
117
130
|
relistBegun(): void;
|
|
118
|
-
relistHeard(entries: readonly ListedConversation[]): void;
|
|
131
|
+
relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
|
|
119
132
|
relistDropped(conversation: string): void;
|
|
120
|
-
relistTaken():
|
|
133
|
+
relistTaken(): Relisted | null;
|
|
121
134
|
sendingBegan(operation: string): Dispatch;
|
|
122
135
|
sendingEnded(operation: string, dispatch: Dispatch): void;
|
|
123
136
|
sending(operation: string): boolean;
|
|
@@ -126,6 +139,8 @@ export type LiveConversations = {
|
|
|
126
139
|
forget(conversation: string): void;
|
|
127
140
|
current(): boolean;
|
|
128
141
|
known(): boolean;
|
|
142
|
+
listHeld(): boolean;
|
|
143
|
+
listed(): boolean;
|
|
129
144
|
reopened(): void;
|
|
130
145
|
lost(): void;
|
|
131
146
|
close(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-live.d.ts","sourceRoot":"","sources":["../src/conversation-live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation-live.d.ts","sourceRoot":"","sources":["../src/conversation-live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,WAAW,CAA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
8
8
|
starting: null,
|
|
9
9
|
state: null,
|
|
10
|
-
|
|
10
|
+
deliveryWaiting: [],
|
|
11
11
|
deliveryUnknown: [],
|
|
12
12
|
};
|
|
13
13
|
export const FACTS = [
|
|
@@ -17,7 +17,7 @@ export const FACTS = [
|
|
|
17
17
|
'options',
|
|
18
18
|
'starting',
|
|
19
19
|
'state',
|
|
20
|
-
'
|
|
20
|
+
'deliveryWaiting',
|
|
21
21
|
'deliveryUnknown',
|
|
22
22
|
];
|
|
23
23
|
// A row is read at a glance and each telling clones the list to every observing tab, while a running line changes at each Kit flush.
|
|
@@ -61,6 +61,8 @@ function sharedView(conversation, asked) {
|
|
|
61
61
|
window: null,
|
|
62
62
|
draft: null,
|
|
63
63
|
ended: null,
|
|
64
|
+
dismissed: null,
|
|
65
|
+
pins: [],
|
|
64
66
|
more: false,
|
|
65
67
|
total: null,
|
|
66
68
|
}),
|
|
@@ -91,13 +93,17 @@ export function createLiveConversations(deps) {
|
|
|
91
93
|
const closing = new AbortController();
|
|
92
94
|
const listeners = createAudience();
|
|
93
95
|
const agentListeners = createAudience();
|
|
96
|
+
const listedListeners = createAudience();
|
|
94
97
|
const held = createCell({
|
|
95
98
|
listKnown: false,
|
|
99
|
+
listHeld: false,
|
|
100
|
+
openingRead: false,
|
|
101
|
+
openingListed: false,
|
|
102
|
+
listRefused: false,
|
|
96
103
|
listOwed: false,
|
|
97
104
|
listTelling: false,
|
|
98
105
|
agentsShown: null,
|
|
99
|
-
|
|
100
|
-
agentsReading: false,
|
|
106
|
+
listedShown: null,
|
|
101
107
|
replicated: new Set(),
|
|
102
108
|
handedReplicated: undefined,
|
|
103
109
|
});
|
|
@@ -110,6 +116,7 @@ export function createLiveConversations(deps) {
|
|
|
110
116
|
closing: closing.signal,
|
|
111
117
|
listeners,
|
|
112
118
|
agentListeners,
|
|
119
|
+
listedListeners,
|
|
113
120
|
views: () => views.values(),
|
|
114
121
|
viewJoined(key, conversation, asked, notify) {
|
|
115
122
|
const view = views.get(key) ?? sharedView(conversation, asked);
|
|
@@ -158,10 +165,10 @@ export function createLiveConversations(deps) {
|
|
|
158
165
|
behind.add(conversation);
|
|
159
166
|
},
|
|
160
167
|
generation: (conversation) => gaps.get(conversation) ?? 0,
|
|
161
|
-
heardAt(conversation,
|
|
168
|
+
heardAt(conversation, change) {
|
|
162
169
|
const heard = heardNewest.get(conversation);
|
|
163
|
-
if (heard === undefined ||
|
|
164
|
-
heardNewest.set(conversation,
|
|
170
|
+
if (heard === undefined || change > heard)
|
|
171
|
+
heardNewest.set(conversation, change);
|
|
165
172
|
},
|
|
166
173
|
newestHeard: (conversation) => heardNewest.get(conversation),
|
|
167
174
|
catching: (conversation) => catching.get(conversation),
|
|
@@ -181,14 +188,16 @@ export function createLiveConversations(deps) {
|
|
|
181
188
|
isCreating: (conversation) => creations.has(conversation),
|
|
182
189
|
relisting: () => relisting !== null,
|
|
183
190
|
relistBegun() {
|
|
184
|
-
relisting ??= new Map();
|
|
191
|
+
relisting ??= { conversations: new Map(), agents: new Map() };
|
|
185
192
|
},
|
|
186
|
-
relistHeard(entries) {
|
|
193
|
+
relistHeard(entries, agents) {
|
|
187
194
|
for (const entry of entries)
|
|
188
|
-
relisting?.set(entry.conversation, { ...entry });
|
|
195
|
+
relisting?.conversations.set(entry.conversation, { ...entry });
|
|
196
|
+
for (const agent of agents)
|
|
197
|
+
relisting?.agents.set(agent.id, { ...agent });
|
|
189
198
|
},
|
|
190
199
|
relistDropped(conversation) {
|
|
191
|
-
relisting?.delete(conversation);
|
|
200
|
+
relisting?.conversations.delete(conversation);
|
|
192
201
|
},
|
|
193
202
|
relistTaken() {
|
|
194
203
|
const whole = relisting;
|
|
@@ -223,8 +232,11 @@ export function createLiveConversations(deps) {
|
|
|
223
232
|
},
|
|
224
233
|
current: () => behind.size === 0,
|
|
225
234
|
known: () => held.now().listKnown,
|
|
235
|
+
listHeld: () => held.now().listHeld,
|
|
236
|
+
listed: () => deps.stream() === undefined || held.now().openingListed,
|
|
226
237
|
reopened() {
|
|
227
238
|
relisting = null;
|
|
239
|
+
held.set({ openingRead: false, openingListed: false, listRefused: false });
|
|
228
240
|
for (const [operation, dispatch] of sending)
|
|
229
241
|
if (!dispatch.now().answered)
|
|
230
242
|
sending.delete(operation);
|
|
@@ -242,6 +254,7 @@ export function createLiveConversations(deps) {
|
|
|
242
254
|
unsent.clear();
|
|
243
255
|
listeners.clear();
|
|
244
256
|
agentListeners.clear();
|
|
257
|
+
listedListeners.clear();
|
|
245
258
|
},
|
|
246
259
|
};
|
|
247
260
|
}
|