@agentshouse/mdruntime 0.1.0-c8f07dbee1c62 → 0.1.0-c8f16d1da438a
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 +171 -75
- package/dist/adapter.d.ts +147 -67
- 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/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- 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 +6 -2
- 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 +2 -4
- package/dist/client.d.ts +23 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -68
- package/dist/collection.d.ts +27 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +34 -10
- 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 +100 -62
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +41 -27
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +149 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- 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 +64 -49
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +987 -1035
- 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 +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +47 -47
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +16 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +75 -30
- 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 +8 -0
- package/dist/figures.d.ts +1 -0
- 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 +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +108 -32
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +82 -0
- package/dist/index.d.ts +24 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +93 -116
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +79 -56
- package/dist/listing.d.ts +29 -22
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +71 -78
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +97 -39
- 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 +12 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +170 -36
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +99 -37
- package/dist/messages.d.ts +17 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +39 -38
- 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 +4 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -137
- 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 +217 -85
- 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 +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 +24 -11
- package/dist/outcome.d.ts +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -3
- package/dist/overlay.d.ts +9 -5
- 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 +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +210 -92
- 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 -3
- 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 +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +184 -40
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +20 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- package/dist/reads.d.ts +5 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +33 -5
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +6 -6
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -19
- 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 +278 -68
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +28 -22
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +27 -14
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +15 -20
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +43 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +324 -223
- package/dist/saves.d.ts +6 -42
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +177 -718
- 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 +9 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +99 -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 -2
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +6 -16
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +20 -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 +26 -9
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +92 -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/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 +26 -16
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +50 -18
- package/dist/stored.d.ts +40 -15
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +236 -66
- package/dist/surface.d.ts +15 -9
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +71 -38
- package/dist/sync.d.ts +4 -3
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +136 -110
- package/dist/tables.d.ts +31 -58
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +100 -334
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +51 -11
- package/dist/wire.d.ts +71 -12
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +30 -14
- package/package.json +4 -3
- 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 -43
- 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
2
|
import { binaryRecord } from './binary.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, directory) {
|
|
13
|
+
return fragment(`(${path} = ? OR (${path} >= ? AND ${path} < ?))`, [
|
|
14
|
+
directory,
|
|
15
|
+
`${directory}/`,
|
|
16
|
+
`${directory}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,11 +331,20 @@ 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
|
-
const fileId = row.file_id
|
|
317
|
-
const revision = row.revision
|
|
346
|
+
const fileId = row.file_id;
|
|
347
|
+
const revision = row.revision;
|
|
318
348
|
if (type === null) {
|
|
319
349
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
320
350
|
const content = row.content ?? null;
|
|
@@ -324,7 +354,7 @@ function documentOf(shape, room, row, linked) {
|
|
|
324
354
|
...(binary === null
|
|
325
355
|
? {}
|
|
326
356
|
: {
|
|
327
|
-
|
|
357
|
+
attachment: binaryRecord(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,
|
|
@@ -365,7 +396,7 @@ function changeOf(row) {
|
|
|
365
396
|
function heldFacts(shape, row) {
|
|
366
397
|
return {
|
|
367
398
|
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
368
|
-
...(shape.created ? { created: row.created
|
|
399
|
+
...(shape.created ? { created: row.created } : {}),
|
|
369
400
|
};
|
|
370
401
|
}
|
|
371
402
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -377,10 +408,10 @@ function backlinksOf(connection, bound, rows) {
|
|
|
377
408
|
held.push(row.path);
|
|
378
409
|
byKey.set(key, held);
|
|
379
410
|
}
|
|
411
|
+
const reach = reached(bound, 's.key', 's.path');
|
|
380
412
|
for (const [key, targets] of byKey) {
|
|
381
|
-
const reach = reached(bound, 's');
|
|
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) ?? [];
|
|
@@ -395,22 +426,19 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
395
426
|
const filter = filtered(bound, plan);
|
|
396
427
|
const cursor = plan.after?.values ?? null;
|
|
397
428
|
const room = located('d');
|
|
398
|
-
const
|
|
429
|
+
const after = cursor === null
|
|
399
430
|
? null
|
|
400
431
|
: (() => {
|
|
401
432
|
const key = cursor[shape.orderBy.length];
|
|
402
|
-
return any([
|
|
433
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
403
434
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
404
435
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
405
436
|
...room.bind,
|
|
406
437
|
roomOfKey(key),
|
|
407
438
|
pathOfKey(key),
|
|
408
439
|
]),
|
|
409
|
-
]);
|
|
440
|
+
]));
|
|
410
441
|
})();
|
|
411
|
-
const after = cursor === null || tie === null
|
|
412
|
-
? null
|
|
413
|
-
: sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), tie);
|
|
414
442
|
const selected = joined([
|
|
415
443
|
fragment('SELECT d.id, d.key, d.path, d.type, d.binary, d.revision, d.fields, d.change, d.file_id, d.bytes, d.created'),
|
|
416
444
|
...terms.map(({ term }, index) => joined([
|
|
@@ -431,8 +459,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
431
459
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
432
460
|
const cut = kept.length;
|
|
433
461
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
462
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
434
463
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
435
|
-
const found = kept.map((row) => documentOf(shape,
|
|
464
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
436
465
|
const last = kept.at(-1);
|
|
437
466
|
const cursorAt = (row) => cursorOf([
|
|
438
467
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -497,7 +526,7 @@ function storedFolders(bound, plan, subfolder) {
|
|
|
497
526
|
const key = bound.keys.get(area.room);
|
|
498
527
|
if (key === undefined)
|
|
499
528
|
return [];
|
|
500
|
-
const fence = fenced('f', key, area, true);
|
|
529
|
+
const fence = fenced('f.key', 'f.path', key, area, true);
|
|
501
530
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
502
531
|
});
|
|
503
532
|
const under = prefix === ''
|
|
@@ -645,17 +674,14 @@ function groups(connection, bound, plan, shape) {
|
|
|
645
674
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
646
675
|
]);
|
|
647
676
|
const cursor = plan.after?.values ?? null;
|
|
648
|
-
const
|
|
677
|
+
const after = cursor === null
|
|
649
678
|
? null
|
|
650
|
-
:
|
|
651
|
-
value,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
: sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
657
|
-
.slice(0, -1)
|
|
658
|
-
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
679
|
+
: (() => {
|
|
680
|
+
const tieValues = cursor[shape.orderBy.length].flatMap((value) => [value, heldKind(value ?? null)]);
|
|
681
|
+
return sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
682
|
+
.slice(0, -1)
|
|
683
|
+
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
684
|
+
})();
|
|
659
685
|
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
660
686
|
const windowed = joined([
|
|
661
687
|
fragment('SELECT * FROM ('),
|
|
@@ -696,16 +722,28 @@ function groups(connection, bound, plan, shape) {
|
|
|
696
722
|
...(total === undefined ? {} : { total }),
|
|
697
723
|
};
|
|
698
724
|
}
|
|
699
|
-
function boundOf(connection, plan, rooms) {
|
|
725
|
+
function boundOf(connection, plan, rooms, follows) {
|
|
700
726
|
return {
|
|
701
727
|
rooms: [...rooms].sort((left, right) => left.locator < right.locator ? -1 : left.locator > right.locator ? 1 : 0),
|
|
702
|
-
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)),
|
|
703
730
|
reach: plan.reach,
|
|
704
731
|
collate: collating(connection),
|
|
705
732
|
};
|
|
706
733
|
}
|
|
707
|
-
export function
|
|
708
|
-
|
|
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);
|
|
709
747
|
if (rooms.length === 0) {
|
|
710
748
|
return plan.shape.kind === 'groups'
|
|
711
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,EAAsB,MAAM,cAAc,CAAC;AAI/E,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;AAGrE,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,CAwGzE"}
|
package/dist/connection.js
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { notReadyWaitMs } from '@agentshouse/mdmodel';
|
|
2
|
+
import { submitLater } from './acceptance.js';
|
|
2
3
|
import { invokeAction, called, readConversationHistory, resendLater } from './actions.js';
|
|
3
|
-
import { builtInModel,
|
|
4
|
-
import {
|
|
4
|
+
import { builtInModel, NO_ROOM_TYPES } from './attached-model.js';
|
|
5
|
+
import { createLiveConversations } from './conversation-live.js';
|
|
6
|
+
import { writeRule } from './declaration.js';
|
|
5
7
|
import { refusedForSpace } from './durability.js';
|
|
8
|
+
import { uncaught } from './failure.js';
|
|
6
9
|
import { createFigures } from './figures.js';
|
|
7
10
|
import { scheduleCurrency, spaceFreed, start } from './lifecycle.js';
|
|
8
11
|
import { createLiveQueries } from './live.js';
|
|
9
|
-
import { createLog } from './log.js';
|
|
10
|
-
import { scoped } from './models.js';
|
|
11
12
|
import { open } from './opening.js';
|
|
12
|
-
import { deliverOwedReadiness, filled } from './preparation.js';
|
|
13
|
+
import { deliverOwedReadiness, filled, prepare } from './preparation.js';
|
|
14
|
+
import { createPresence } from './presence.js';
|
|
13
15
|
import { answeredPlan, figuresCover, roomTallies } from './queries.js';
|
|
14
16
|
import { readAnswers } from './reads.js';
|
|
15
17
|
import { createRecovery } from './recovery.js';
|
|
16
|
-
import {
|
|
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';
|
|
21
|
-
import {
|
|
23
|
+
import { adopt, discover } from './sync.js';
|
|
22
24
|
const ROOM_ATTEMPTS = 16;
|
|
23
25
|
export function composeRuntime(options) {
|
|
24
26
|
const { adapter, shell } = options;
|
|
25
|
-
const roomTypes =
|
|
27
|
+
const roomTypes = adapter.roomTypes ?? NO_ROOM_TYPES;
|
|
26
28
|
const builtIn = builtInModel(roomTypes);
|
|
27
29
|
const typedPaths = adapter.typedPaths ?? [];
|
|
28
|
-
const
|
|
29
|
-
const socket = createSocket(adapter,
|
|
30
|
+
const retries = createRetries(shell);
|
|
31
|
+
const socket = createSocket(adapter, retries, options.authorization);
|
|
32
|
+
const presence = createPresence(notReadyWaitMs);
|
|
30
33
|
const store = createStore({
|
|
34
|
+
retries,
|
|
31
35
|
database: {
|
|
32
36
|
async ask(request) {
|
|
33
37
|
try {
|
|
@@ -44,29 +48,38 @@ export function composeRuntime(options) {
|
|
|
44
48
|
builtIn,
|
|
45
49
|
typedPaths,
|
|
46
50
|
persistence: shell.persistence,
|
|
51
|
+
lost: presence.lost,
|
|
52
|
+
losing: presence.losing,
|
|
47
53
|
opening: (local) => open(runtime, local),
|
|
48
|
-
unpublished
|
|
49
|
-
|
|
54
|
+
unpublished: uncaught,
|
|
55
|
+
changed(set) {
|
|
56
|
+
if (set.unindexed.length > 0)
|
|
57
|
+
prepare(runtime, set.unindexed);
|
|
58
|
+
for (const locator of set.due)
|
|
59
|
+
submitLater(runtime, locator);
|
|
60
|
+
return publishChangeSet(runtime, set);
|
|
50
61
|
},
|
|
51
|
-
|
|
52
|
-
deliverReadiness: (owed) => deliverOwedReadiness(runtime, owed),
|
|
62
|
+
deliverReadiness: (owed, rooms) => deliverOwedReadiness(runtime, owed, rooms),
|
|
53
63
|
spaceFreed: () => spaceFreed(runtime),
|
|
54
64
|
});
|
|
55
65
|
const recovery = (options.recovery ?? createRecovery()).scope(ROOM_ATTEMPTS);
|
|
56
66
|
const runtime = {
|
|
57
67
|
store,
|
|
58
68
|
socket,
|
|
59
|
-
|
|
69
|
+
presence,
|
|
60
70
|
recovery,
|
|
71
|
+
retries,
|
|
61
72
|
shell,
|
|
62
73
|
localSaves: adapter.localSaves === true,
|
|
63
74
|
roomTypes,
|
|
64
75
|
builtIn,
|
|
65
76
|
typedPaths,
|
|
66
|
-
|
|
77
|
+
renamedActions: adapter.renamedActions ?? new Map(),
|
|
78
|
+
rewrittenInputs: adapter.rewrittenInputs ?? new Map(),
|
|
79
|
+
writeRule: (declaration) => writeRule(declaration, adapter.pathRule ?? (() => true), adapter.localSaves === true),
|
|
67
80
|
build: options.build ?? '',
|
|
68
|
-
conversations:
|
|
69
|
-
call: (name, input) => invokeAction(runtime, name, input),
|
|
81
|
+
conversations: createLiveConversations({
|
|
82
|
+
call: (name, input, attempt) => invokeAction(runtime, name, input, { attempt }),
|
|
70
83
|
history: (request) => readConversationHistory(runtime, request),
|
|
71
84
|
durably: store.durably,
|
|
72
85
|
local: store.open,
|
|
@@ -82,6 +95,9 @@ export function composeRuntime(options) {
|
|
|
82
95
|
full: store.space.full,
|
|
83
96
|
closed: socket.closed,
|
|
84
97
|
unanswered: () => resendLater(runtime),
|
|
98
|
+
heard: (operation, lost) => socket.lanes.settle(operation, lost),
|
|
99
|
+
recovery: recovery.scope(),
|
|
100
|
+
retries,
|
|
85
101
|
}),
|
|
86
102
|
liveQueries: createLiveQueries((plan, cover) => answeredPlan(runtime, plan, cover), store.covering),
|
|
87
103
|
figures: createFigures({
|
|
@@ -95,19 +111,17 @@ export function composeRuntime(options) {
|
|
|
95
111
|
unkept: adapter.unkeptReads ?? [],
|
|
96
112
|
leading: adapter.leadingReads ?? [],
|
|
97
113
|
recovery: recovery.scope(),
|
|
98
|
-
|
|
114
|
+
retries,
|
|
115
|
+
call: (name, input, attempt) => called(runtime, name, input, attempt),
|
|
99
116
|
online: socket.reached,
|
|
117
|
+
streaming: socket.isOpen,
|
|
100
118
|
closed: socket.closed,
|
|
101
119
|
full: store.space.full,
|
|
102
120
|
filled: () => filled(runtime),
|
|
103
121
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
submitLater: (locator) => submitLater(runtime, locator),
|
|
107
|
-
unpair: (local) => unpair(runtime, local),
|
|
108
|
-
advanced: (...held) => advanced(runtime, ...held),
|
|
109
|
-
withhold: (...held) => withhold(runtime, ...held),
|
|
122
|
+
discover: () => discover(runtime),
|
|
123
|
+
adopt: (unstored) => adopt(runtime, unstored),
|
|
110
124
|
};
|
|
111
|
-
start(runtime, options.signal);
|
|
125
|
+
start(runtime, options.signal, options.storeOnNeed === true);
|
|
112
126
|
return composedRuntime(runtime);
|
|
113
127
|
}
|
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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { SessionState } from '@agentshouse/session-content';
|
|
2
|
+
import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, SessionOption } from './adapter.js';
|
|
3
|
+
import { type Cell } from './cell.js';
|
|
4
|
+
import type { ChangeSet } from './change-set.js';
|
|
5
|
+
import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
|
|
6
|
+
import type { CallResult } from './outcome.js';
|
|
7
|
+
import type { Recovery } from './recovery.js';
|
|
8
|
+
import type { Attempt, Retries } from './retried.js';
|
|
9
|
+
import type { ChatDraftRecord, RuntimeStore } from './store.js';
|
|
10
|
+
export type ConversationDependencies = {
|
|
11
|
+
call(name: ConversationAction, input: unknown, attempt?: Attempt): Promise<CallResult>;
|
|
12
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
13
|
+
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
14
|
+
local(): Promise<RuntimeStore>;
|
|
15
|
+
again(): void;
|
|
16
|
+
settled(): void;
|
|
17
|
+
stream(): ConversationStream | undefined;
|
|
18
|
+
publish(set: ChangeSet): void;
|
|
19
|
+
online(): boolean;
|
|
20
|
+
full(): boolean;
|
|
21
|
+
closed(): boolean;
|
|
22
|
+
unanswered(): void;
|
|
23
|
+
heard(operation: string, lost: boolean): void;
|
|
24
|
+
readonly recovery: Recovery;
|
|
25
|
+
readonly retries: Retries;
|
|
26
|
+
};
|
|
27
|
+
export type Live = {
|
|
28
|
+
turn: RunningTurn | null;
|
|
29
|
+
questions: readonly unknown[];
|
|
30
|
+
process: {
|
|
31
|
+
running: boolean;
|
|
32
|
+
} | null;
|
|
33
|
+
commands: readonly ProcessCommand[];
|
|
34
|
+
options: readonly SessionOption[];
|
|
35
|
+
starting: string | null;
|
|
36
|
+
state: SessionState | null;
|
|
37
|
+
deliveryWaiting: readonly string[];
|
|
38
|
+
deliveryUnknown: readonly string[];
|
|
39
|
+
};
|
|
40
|
+
export declare const QUIET: Live;
|
|
41
|
+
export type Fact = Exclude<keyof Live, 'turn'>;
|
|
42
|
+
export declare const FACTS: readonly Fact[];
|
|
43
|
+
type Watcher = {
|
|
44
|
+
readonly notify: (view: ConversationView) => void;
|
|
45
|
+
};
|
|
46
|
+
export type Kept = {
|
|
47
|
+
readonly draft: ChatDraftRecord | null;
|
|
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;
|
|
54
|
+
readonly more: boolean;
|
|
55
|
+
readonly total: number | null;
|
|
56
|
+
};
|
|
57
|
+
export type SharedView = {
|
|
58
|
+
readonly conversation: string;
|
|
59
|
+
readonly asked: Asked;
|
|
60
|
+
readonly held: Cell<HeldWindow>;
|
|
61
|
+
ready(): readonly Watcher[];
|
|
62
|
+
join(watcher: Watcher): void;
|
|
63
|
+
admit(watcher: Watcher): boolean;
|
|
64
|
+
leave(watcher: Watcher): boolean;
|
|
65
|
+
empty(): boolean;
|
|
66
|
+
};
|
|
67
|
+
type Listing<T> = (value: T) => void;
|
|
68
|
+
export type Audience<T> = {
|
|
69
|
+
waiting(): boolean;
|
|
70
|
+
told(): boolean;
|
|
71
|
+
join(watcher: Listing<T>): void;
|
|
72
|
+
leave(watcher: Listing<T>): void;
|
|
73
|
+
tell(value: T): void;
|
|
74
|
+
welcome(value: T): void;
|
|
75
|
+
clear(): void;
|
|
76
|
+
};
|
|
77
|
+
type HeldFacts = {
|
|
78
|
+
readonly listKnown: boolean;
|
|
79
|
+
readonly listHeld: boolean;
|
|
80
|
+
readonly openingRead: boolean;
|
|
81
|
+
readonly openingListed: boolean;
|
|
82
|
+
readonly listOwed: boolean;
|
|
83
|
+
readonly listTelling: boolean;
|
|
84
|
+
readonly agentsShown: string | null;
|
|
85
|
+
readonly listedShown: string | null;
|
|
86
|
+
readonly replicated: ReadonlySet<string>;
|
|
87
|
+
readonly handedReplicated: string | undefined;
|
|
88
|
+
};
|
|
89
|
+
export type Dispatch = Cell<{
|
|
90
|
+
readonly answered: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
export type Relisted = {
|
|
93
|
+
readonly conversations: ReadonlyMap<string, ListedConversation>;
|
|
94
|
+
readonly agents: ReadonlyMap<string, ListedAgent>;
|
|
95
|
+
};
|
|
96
|
+
export type LiveConversations = {
|
|
97
|
+
readonly deps: ConversationDependencies;
|
|
98
|
+
readonly held: Cell<HeldFacts>;
|
|
99
|
+
readonly closing: AbortSignal;
|
|
100
|
+
readonly listeners: Audience<readonly ConversationEntry[]>;
|
|
101
|
+
readonly agentListeners: Audience<readonly ConversationAgent[]>;
|
|
102
|
+
readonly listedListeners: Audience<readonly ListedAgent[]>;
|
|
103
|
+
views(): Iterable<SharedView>;
|
|
104
|
+
viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
|
|
105
|
+
readonly view: SharedView;
|
|
106
|
+
readonly watcher: Watcher;
|
|
107
|
+
};
|
|
108
|
+
viewLeft(key: string, view: SharedView, watcher: Watcher): void;
|
|
109
|
+
liveOf(conversation: string): Live;
|
|
110
|
+
liveHeld(conversation: string): Live | undefined;
|
|
111
|
+
holdLive(conversation: string, next: Live | null): void;
|
|
112
|
+
factsOwed(conversation: string): void;
|
|
113
|
+
factsHeard(conversation: string, facts: readonly Fact[]): void;
|
|
114
|
+
factsTaken(): readonly (readonly [string, ReadonlySet<Fact>])[];
|
|
115
|
+
behind(conversation: string): boolean;
|
|
116
|
+
behindAll(): readonly string[];
|
|
117
|
+
fellBehind(conversation: string): void;
|
|
118
|
+
caughtUpTo(conversation: string): void;
|
|
119
|
+
gapOpened(conversation: string): void;
|
|
120
|
+
generation(conversation: string): number;
|
|
121
|
+
heardAt(conversation: string, change: string): void;
|
|
122
|
+
newestHeard(conversation: string): string | undefined;
|
|
123
|
+
catching(conversation: string): Promise<void> | undefined;
|
|
124
|
+
catchingUntil(conversation: string, ended: Promise<void>): void;
|
|
125
|
+
creating(conversation: string): void;
|
|
126
|
+
created(conversation: string): void;
|
|
127
|
+
isCreating(conversation: string): boolean;
|
|
128
|
+
relisting(): boolean;
|
|
129
|
+
relistBegun(): void;
|
|
130
|
+
relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
|
|
131
|
+
relistDropped(conversation: string): void;
|
|
132
|
+
relistTaken(): Relisted | null;
|
|
133
|
+
sendingBegan(operation: string): Dispatch;
|
|
134
|
+
sendingEnded(operation: string, dispatch: Dispatch): void;
|
|
135
|
+
sending(operation: string): boolean;
|
|
136
|
+
rowSoon(tell: () => void): void;
|
|
137
|
+
inOrder(work: () => Promise<void>): void;
|
|
138
|
+
forget(conversation: string): void;
|
|
139
|
+
current(): boolean;
|
|
140
|
+
known(): boolean;
|
|
141
|
+
listHeld(): boolean;
|
|
142
|
+
listed(): boolean;
|
|
143
|
+
reopened(): void;
|
|
144
|
+
lost(): void;
|
|
145
|
+
close(): void;
|
|
146
|
+
};
|
|
147
|
+
export declare function createLiveConversations(deps: ConversationDependencies): LiveConversations;
|
|
148
|
+
export {};
|
|
149
|
+
//# sourceMappingURL=conversation-live.d.ts.map
|
|
@@ -0,0 +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,CA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