@agentshouse/mdruntime 0.1.0-c5d3fa6fb67bc → 0.1.0-c63ad08fad0c3

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.
Files changed (211) hide show
  1. package/AGENTS.md +240 -220
  2. package/README.md +9 -8
  3. package/dist/adapter.d.ts +72 -24
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/attached-model.d.ts +4 -1
  6. package/dist/attached-model.d.ts.map +1 -1
  7. package/dist/attached-model.js +13 -3
  8. package/dist/bootstrap.d.ts +26 -7
  9. package/dist/bootstrap.d.ts.map +1 -1
  10. package/dist/bootstrap.js +167 -82
  11. package/dist/chain.d.ts +11 -0
  12. package/dist/chain.d.ts.map +1 -0
  13. package/dist/chain.js +64 -0
  14. package/dist/change-set.d.ts +9 -16
  15. package/dist/change-set.d.ts.map +1 -1
  16. package/dist/change-set.js +11 -89
  17. package/dist/change.d.ts +31 -1
  18. package/dist/change.d.ts.map +1 -1
  19. package/dist/change.js +10 -1
  20. package/dist/chat/earlier.d.ts +10 -0
  21. package/dist/chat/earlier.d.ts.map +1 -0
  22. package/dist/chat/earlier.js +54 -0
  23. package/dist/chat/house.d.ts +25 -0
  24. package/dist/chat/house.d.ts.map +1 -0
  25. package/dist/chat/house.js +38 -0
  26. package/dist/chat/input.d.ts +3 -1
  27. package/dist/chat/input.d.ts.map +1 -1
  28. package/dist/chat/input.js +11 -18
  29. package/dist/chat/kit.js +1 -1
  30. package/dist/chat/list.d.ts +2 -1
  31. package/dist/chat/list.d.ts.map +1 -1
  32. package/dist/chat/list.js +45 -5
  33. package/dist/chat/markdown.d.ts +1 -0
  34. package/dist/chat/markdown.d.ts.map +1 -1
  35. package/dist/chat/markdown.js +78 -20
  36. package/dist/chat/message.d.ts +1 -0
  37. package/dist/chat/message.d.ts.map +1 -1
  38. package/dist/chat/message.js +73 -11
  39. package/dist/chat/messages.d.ts +14 -1
  40. package/dist/chat/messages.d.ts.map +1 -1
  41. package/dist/chat/messages.js +79 -24
  42. package/dist/chat/name.d.ts +1 -0
  43. package/dist/chat/name.d.ts.map +1 -1
  44. package/dist/chat/name.js +1 -1
  45. package/dist/chat/opened.d.ts +1 -0
  46. package/dist/chat/opened.d.ts.map +1 -1
  47. package/dist/chat/opened.js +2 -0
  48. package/dist/chat/overlay.d.ts +1 -0
  49. package/dist/chat/overlay.d.ts.map +1 -1
  50. package/dist/chat/overlay.js +11 -5
  51. package/dist/chat/parts.d.ts +1 -0
  52. package/dist/chat/parts.d.ts.map +1 -1
  53. package/dist/chat/parts.js +3 -2
  54. package/dist/chat/pieces.d.ts +62 -0
  55. package/dist/chat/pieces.d.ts.map +1 -0
  56. package/dist/chat/pieces.js +1110 -0
  57. package/dist/chat/provider.d.ts +8 -1
  58. package/dist/chat/provider.d.ts.map +1 -1
  59. package/dist/chat/provider.js +98 -92
  60. package/dist/chat/question.d.ts +1 -1
  61. package/dist/chat/question.d.ts.map +1 -1
  62. package/dist/chat/question.js +7 -18
  63. package/dist/chat/ready.d.ts +5 -2
  64. package/dist/chat/ready.d.ts.map +1 -1
  65. package/dist/chat/ready.js +7 -5
  66. package/dist/chat/room-file.d.ts +8 -0
  67. package/dist/chat/room-file.d.ts.map +1 -0
  68. package/dist/chat/room-file.js +72 -0
  69. package/dist/chat/steady.d.ts +3 -0
  70. package/dist/chat/steady.d.ts.map +1 -0
  71. package/dist/chat/steady.js +26 -0
  72. package/dist/chat/style.d.ts.map +1 -1
  73. package/dist/chat/style.js +6 -1
  74. package/dist/chat.d.ts +3 -2
  75. package/dist/chat.d.ts.map +1 -1
  76. package/dist/chat.js +2 -2
  77. package/dist/client.d.ts +11 -2
  78. package/dist/client.d.ts.map +1 -1
  79. package/dist/client.js +45 -7
  80. package/dist/collection.d.ts +6 -19
  81. package/dist/collection.d.ts.map +1 -1
  82. package/dist/collection.js +30 -287
  83. package/dist/compile.d.ts +16 -0
  84. package/dist/compile.d.ts.map +1 -0
  85. package/dist/compile.js +721 -0
  86. package/dist/connection.d.ts +22 -8
  87. package/dist/connection.d.ts.map +1 -1
  88. package/dist/connection.js +2509 -830
  89. package/dist/conversation.d.ts +15 -3
  90. package/dist/conversation.d.ts.map +1 -1
  91. package/dist/conversation.js +238 -94
  92. package/dist/digest.d.ts +7 -0
  93. package/dist/digest.d.ts.map +1 -0
  94. package/dist/digest.js +113 -0
  95. package/dist/durability.d.ts +3 -1
  96. package/dist/durability.d.ts.map +1 -1
  97. package/dist/entry.d.ts +3 -1
  98. package/dist/entry.d.ts.map +1 -1
  99. package/dist/entry.js +18 -23
  100. package/dist/file.d.ts +2 -10
  101. package/dist/file.d.ts.map +1 -1
  102. package/dist/file.js +3 -120
  103. package/dist/fulltext.d.ts +27 -0
  104. package/dist/fulltext.d.ts.map +1 -0
  105. package/dist/fulltext.js +368 -0
  106. package/dist/host.d.ts +5 -4
  107. package/dist/host.d.ts.map +1 -1
  108. package/dist/host.js +57 -7
  109. package/dist/identity.d.ts +0 -1
  110. package/dist/identity.d.ts.map +1 -1
  111. package/dist/identity.js +0 -3
  112. package/dist/index.d.ts +12 -8
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +4 -0
  115. package/dist/live.d.ts +22 -0
  116. package/dist/live.d.ts.map +1 -0
  117. package/dist/live.js +123 -0
  118. package/dist/memory.d.ts +7 -3
  119. package/dist/memory.d.ts.map +1 -1
  120. package/dist/memory.js +39 -17
  121. package/dist/messages.d.ts +28 -0
  122. package/dist/messages.d.ts.map +1 -0
  123. package/dist/messages.js +90 -0
  124. package/dist/name.d.ts +4 -0
  125. package/dist/name.d.ts.map +1 -0
  126. package/dist/name.js +122 -0
  127. package/dist/observation.d.ts +14 -0
  128. package/dist/observation.d.ts.map +1 -1
  129. package/dist/observation.js +93 -3
  130. package/dist/opened.d.ts +22 -0
  131. package/dist/opened.d.ts.map +1 -0
  132. package/dist/opened.js +107 -0
  133. package/dist/outcome.d.ts +35 -4
  134. package/dist/outcome.d.ts.map +1 -1
  135. package/dist/outcome.js +28 -0
  136. package/dist/overlay.d.ts +2 -5
  137. package/dist/overlay.d.ts.map +1 -1
  138. package/dist/overlay.js +86 -171
  139. package/dist/query.d.ts +29 -2
  140. package/dist/query.d.ts.map +1 -1
  141. package/dist/query.js +46 -7
  142. package/dist/reach.d.ts +5 -1
  143. package/dist/reach.d.ts.map +1 -1
  144. package/dist/reach.js +167 -48
  145. package/dist/react.d.ts +3 -3
  146. package/dist/react.d.ts.map +1 -1
  147. package/dist/react.js +7 -17
  148. package/dist/readiness.d.ts +18 -3
  149. package/dist/readiness.d.ts.map +1 -1
  150. package/dist/readiness.js +1 -1
  151. package/dist/reads.d.ts +11 -0
  152. package/dist/reads.d.ts.map +1 -0
  153. package/dist/reads.js +100 -0
  154. package/dist/recovery.d.ts +2 -2
  155. package/dist/recovery.d.ts.map +1 -1
  156. package/dist/recovery.js +8 -7
  157. package/dist/refresh.d.ts +13 -15
  158. package/dist/refresh.d.ts.map +1 -1
  159. package/dist/refresh.js +78 -51
  160. package/dist/replica.d.ts +57 -33
  161. package/dist/replica.d.ts.map +1 -1
  162. package/dist/replica.js +295 -186
  163. package/dist/room-draft.d.ts +15 -1
  164. package/dist/room-draft.d.ts.map +1 -1
  165. package/dist/room-draft.js +32 -25
  166. package/dist/rows.d.ts +29 -30
  167. package/dist/rows.d.ts.map +1 -1
  168. package/dist/rows.js +113 -64
  169. package/dist/save.d.ts +51 -14
  170. package/dist/save.d.ts.map +1 -1
  171. package/dist/save.js +518 -180
  172. package/dist/search.d.ts +25 -42
  173. package/dist/search.d.ts.map +1 -1
  174. package/dist/search.js +30 -169
  175. package/dist/seed.d.ts +16 -0
  176. package/dist/seed.d.ts.map +1 -0
  177. package/dist/seed.js +75 -0
  178. package/dist/shared.d.ts +8 -3
  179. package/dist/shared.d.ts.map +1 -1
  180. package/dist/shared.js +129 -66
  181. package/dist/store.d.ts +97 -88
  182. package/dist/store.d.ts.map +1 -1
  183. package/dist/store.js +335 -659
  184. package/dist/stored.d.ts +145 -0
  185. package/dist/stored.d.ts.map +1 -0
  186. package/dist/stored.js +567 -0
  187. package/dist/tables.d.ts +342 -0
  188. package/dist/tables.d.ts.map +1 -0
  189. package/dist/tables.js +576 -0
  190. package/dist/turn.d.ts +5 -3
  191. package/dist/turn.d.ts.map +1 -1
  192. package/dist/turn.js +51 -21
  193. package/dist/validation.d.ts +30 -0
  194. package/dist/validation.d.ts.map +1 -0
  195. package/dist/validation.js +162 -0
  196. package/dist/windows.d.ts +22 -0
  197. package/dist/windows.d.ts.map +1 -0
  198. package/dist/windows.js +89 -0
  199. package/dist/wire.d.ts +32 -0
  200. package/dist/wire.d.ts.map +1 -1
  201. package/dist/wire.js +8 -0
  202. package/dist/words.d.ts +19 -0
  203. package/dist/words.d.ts.map +1 -0
  204. package/dist/words.js +150 -0
  205. package/package.json +10 -4
  206. package/dist/acquisition.d.ts +0 -14
  207. package/dist/acquisition.d.ts.map +0 -1
  208. package/dist/acquisition.js +0 -24
  209. package/dist/read-side.d.ts +0 -25
  210. package/dist/read-side.d.ts.map +0 -1
  211. package/dist/read-side.js +0 -642
@@ -0,0 +1,368 @@
1
+ import { parse } from '@agentshouse/mdmodel';
2
+ import { selected } from './compile.js';
3
+ import { markdownPath } from './rows.js';
4
+ import { indexed, matchClauses, matched, matchExpression, queryTerms, snippet, } from './words.js';
5
+ const TOKENIZER = "porter unicode61 remove_diacritics 2 categories 'L* N* Co M*'";
6
+ const CONTENTLESS = `content='', contentless_delete=1, detail=full, tokenize="${TOKENIZER}"`;
7
+ const DOCUMENTS = 'replica_search';
8
+ const MESSAGES = 'conversation_search';
9
+ export const SEARCH_TABLES = [
10
+ `CREATE VIRTUAL TABLE ${DOCUMENTS} USING fts5(path, fields, sections, preamble, ${CONTENTLESS})`,
11
+ `CREATE VIRTUAL TABLE ${MESSAGES} USING fts5(text, ${CONTENTLESS})`,
12
+ ];
13
+ const CHUNKS = 4096;
14
+ const CHUNK_CHARACTERS = 32_768;
15
+ const CANDIDATES = 5_000;
16
+ const LEAST_WINDOW = 32;
17
+ const SNIPPET_REACH = 80;
18
+ function scalars(value) {
19
+ if (value === null || value === undefined)
20
+ return [];
21
+ if (Array.isArray(value))
22
+ return value.flatMap(scalars);
23
+ if (typeof value === 'object')
24
+ return Object.values(value).flatMap(scalars);
25
+ return [String(value)];
26
+ }
27
+ function partsOf(path, content) {
28
+ if (!markdownPath(path))
29
+ return null;
30
+ const read = parse(content, path);
31
+ if (!read.ok)
32
+ return null;
33
+ return {
34
+ fields: scalars(read.document.fields).join('\n'),
35
+ sections: Object.entries(read.document.sections)
36
+ .map(([heading, text]) => `${heading}\n${text}`)
37
+ .join('\n'),
38
+ preamble: read.document.preamble,
39
+ path,
40
+ };
41
+ }
42
+ function chunked(text) {
43
+ const chunks = [];
44
+ let start = 0;
45
+ do {
46
+ let end = Math.min(text.length, start + CHUNK_CHARACTERS);
47
+ if (end < text.length) {
48
+ const space = text.lastIndexOf(' ', end);
49
+ if (space > start + CHUNK_CHARACTERS / 2)
50
+ end = space;
51
+ else if (/[\ud800-\udbff]/u.test(text[end - 1]))
52
+ end -= 1;
53
+ }
54
+ chunks.push(text.slice(start, end));
55
+ start = end;
56
+ } while (start < text.length && chunks.length < CHUNKS);
57
+ return chunks;
58
+ }
59
+ function rowOf(id, chunk) {
60
+ return id * CHUNKS + chunk;
61
+ }
62
+ export function indexDocument(connection, id, path, content) {
63
+ const parts = partsOf(path, content);
64
+ if (parts === null)
65
+ return;
66
+ chunked(parts.sections).forEach((sections, chunk) => {
67
+ const head = chunk === 0;
68
+ connection.run(`INSERT INTO ${DOCUMENTS} (rowid, path, fields, sections, preamble) VALUES (?, ?, ?, ?, ?)`, [
69
+ rowOf(id, chunk),
70
+ head ? indexed(parts.path) : null,
71
+ head ? indexed(parts.fields) : null,
72
+ indexed(sections),
73
+ head ? indexed(parts.preamble) : null,
74
+ ]);
75
+ });
76
+ }
77
+ export function indexMessage(connection, id, text) {
78
+ chunked(text).forEach((chunk, at) => {
79
+ connection.run(`INSERT INTO ${MESSAGES} (rowid, text) VALUES (?, ?)`, [
80
+ rowOf(id, at),
81
+ indexed(chunk),
82
+ ]);
83
+ });
84
+ }
85
+ function unindexed(connection, table, ids) {
86
+ for (const id of ids) {
87
+ connection.run(`DELETE FROM ${table} WHERE rowid >= ? AND rowid < ?`, [
88
+ rowOf(id, 0),
89
+ rowOf(id + 1, 0),
90
+ ]);
91
+ }
92
+ }
93
+ export function unindexDocuments(connection, ids) {
94
+ unindexed(connection, DOCUMENTS, ids);
95
+ }
96
+ export function unindexMessages(connection, ids) {
97
+ unindexed(connection, MESSAGES, ids);
98
+ }
99
+ export function unindexAll(connection) {
100
+ for (const table of [DOCUMENTS, MESSAGES]) {
101
+ connection.run(`INSERT INTO ${table} (${table}) VALUES ('delete-all')`);
102
+ }
103
+ }
104
+ function pair(left, right) {
105
+ if (left[0] !== right[0])
106
+ return left[0] < right[0] ? -1 : 1;
107
+ if (left[1] !== right[1])
108
+ return left[1] < right[1] ? -1 : 1;
109
+ return 0;
110
+ }
111
+ function byRank(left, right) {
112
+ return right.score - left.score || pair(left.tie, right.tie);
113
+ }
114
+ function beyond(hit, cursor) {
115
+ if (cursor.length === 0)
116
+ return true;
117
+ return (hit.score < cursor[0] || (hit.score === cursor[0] && pair(hit.tie, [cursor[1], cursor[2]]) > 0));
118
+ }
119
+ function rankedWithin(connection, listed, sources, cursor, needed) {
120
+ const { table } = listed;
121
+ let window = Math.max(needed * 2, LEAST_WINDOW);
122
+ for (;;) {
123
+ const rows = [];
124
+ const boundaries = [];
125
+ for (const source of sources) {
126
+ const found = connection.rows(`SELECT rowid, bm25(${table}) AS score FROM ${table} WHERE ${table} MATCH ? ${source.sql} ORDER BY score, rowid LIMIT ?`, [source.expression, ...source.bind, window]);
127
+ for (const row of found)
128
+ rows.push([Number(row.rowid), Number(row.score)]);
129
+ if (found.length === window)
130
+ boundaries.push(-Number(found.at(-1).score));
131
+ }
132
+ rows.sort((left, right) => left[1] - right[1] || left[0] - right[0]);
133
+ const best = new Map();
134
+ for (const [row, score] of rows) {
135
+ const id = Math.floor(row / CHUNKS);
136
+ if (!best.has(id))
137
+ best.set(id, { chunk: row % CHUNKS, score: -score });
138
+ }
139
+ const ties = listed.ties([...best.keys()]);
140
+ const kept = [...best]
141
+ .flatMap(([id, held]) => {
142
+ const tie = ties.get(id);
143
+ return tie === undefined ? [] : [{ id, ...held, tie }];
144
+ })
145
+ .sort(byRank)
146
+ .filter((hit) => beyond(hit, cursor))
147
+ .slice(0, needed);
148
+ const last = kept.at(-1);
149
+ if (boundaries.length === 0)
150
+ return kept;
151
+ if (kept.length === needed &&
152
+ last !== undefined &&
153
+ boundaries.every((boundary) => boundary < last.score)) {
154
+ return kept;
155
+ }
156
+ window *= 4;
157
+ }
158
+ }
159
+ function reaches(connection, listed, expression, reach) {
160
+ const { table, scope } = listed;
161
+ const [counted] = connection.rows(`SELECT count(*) AS held FROM (SELECT rowid FROM ${table} WHERE ${table} MATCH ? AND ${scope.sql} LIMIT ?)`, [expression, ...scope.bind, reach + 1]);
162
+ return Number(counted?.held ?? 0) > reach;
163
+ }
164
+ function candidates(connection, listed, clauses, cursor, needed) {
165
+ const { table, scope } = listed;
166
+ const expression = matchExpression(clauses);
167
+ const within = { sql: `AND ${scope.sql}`, bind: scope.bind };
168
+ let reach = CANDIDATES;
169
+ for (;;) {
170
+ const [edge] = connection.rows(`SELECT rowid FROM ${table} WHERE ${table} MATCH ? ${within.sql} ORDER BY rowid LIMIT 1 OFFSET ?`, [expression, ...within.bind, reach]);
171
+ const floor = edge === undefined ? null : Number(edge.rowid);
172
+ const sources = [
173
+ floor === null
174
+ ? { expression, ...within }
175
+ : { expression, sql: `${within.sql} AND rowid < ?`, bind: [...within.bind, floor] },
176
+ ];
177
+ if (floor !== null) {
178
+ const common = new Set();
179
+ const selective = [];
180
+ const frequent = [];
181
+ for (const clause of clauses) {
182
+ if (clause.kind === 'phrase')
183
+ continue;
184
+ if (clause.kind !== 'term' && common.has(clause.term)) {
185
+ frequent.push(clause);
186
+ continue;
187
+ }
188
+ if (reaches(connection, listed, clause.text, reach)) {
189
+ if (clause.kind === 'term')
190
+ common.add(clause.term);
191
+ frequent.push(clause);
192
+ }
193
+ else
194
+ selective.push(clause);
195
+ }
196
+ const phrase = clauses.find((clause) => clause.kind === 'phrase');
197
+ if (phrase !== undefined) {
198
+ const rare = !clauses
199
+ .filter((clause) => clause.kind === 'term')
200
+ .every((clause) => common.has(clause.term)) ||
201
+ !reaches(connection, listed, phrase.text, reach);
202
+ (rare ? selective : frequent).push(phrase);
203
+ }
204
+ if (selective.length > 0) {
205
+ const chosen = `(${matchExpression(selective)})`;
206
+ const tail = { sql: `${within.sql} AND rowid >= ?`, bind: [...within.bind, floor] };
207
+ if (frequent.length === 0)
208
+ sources.push({ ...tail, expression: chosen });
209
+ else {
210
+ const rest = `(${matchExpression(frequent)})`;
211
+ sources.push({ ...tail, expression: `${chosen} AND ${rest}` }, { ...tail, expression: `${chosen} NOT ${rest}` });
212
+ }
213
+ }
214
+ }
215
+ const kept = rankedWithin(connection, listed, sources, cursor, needed);
216
+ if (floor === null || kept.length >= needed)
217
+ return kept;
218
+ reach *= 4;
219
+ }
220
+ }
221
+ function windowOf(connection, listed, clauses, cursor, limit) {
222
+ if (cursor === null || listed === null || clauses === null)
223
+ return { kept: [], cursor: null };
224
+ const found = candidates(connection, listed, clauses, cursor, limit + 1);
225
+ if (found.length <= limit)
226
+ return { kept: found, cursor: null };
227
+ const kept = found.slice(0, limit);
228
+ const last = kept.at(-1);
229
+ return { kept, cursor: last === undefined ? cursor : [last.score, ...last.tie] };
230
+ }
231
+ function totalOf(connection, listed, clauses) {
232
+ if (listed === null || clauses === null)
233
+ return 0;
234
+ const { table, scope } = listed;
235
+ const [counted] = connection.rows(`SELECT count(DISTINCT rowid / ${CHUNKS}) AS held FROM ${table} WHERE ${table} MATCH ? AND ${scope.sql}`, [matchExpression(clauses), ...scope.bind]);
236
+ return Number(counted?.held ?? 0);
237
+ }
238
+ function ids(found) {
239
+ return JSON.stringify(found);
240
+ }
241
+ function documentsListed(connection, documents) {
242
+ if (documents.rooms.length === 0)
243
+ return null;
244
+ const filter = selected(connection, documents.plan, documents.rooms);
245
+ const outside = documents.beneath.flatMap(({ key, roots }) => roots.map((root) => ({
246
+ sql: 'NOT (d.key = ? AND (d.path = ? OR (d.path >= ? AND d.path < ?)))',
247
+ bind: [key, root, `${root}/`, `${root}0`],
248
+ })));
249
+ const conditions = [filter, ...outside];
250
+ const locators = new Map(documents.rooms.map(({ key, locator }) => [key, locator]));
251
+ return {
252
+ table: DOCUMENTS,
253
+ scope: {
254
+ sql: `EXISTS (SELECT 1 FROM replica_entries d WHERE d.id = ${DOCUMENTS}.rowid / ${CHUNKS} AND d.type IS NOT NULL AND ${conditions.map(({ sql }) => `(${sql})`).join(' AND ')})`,
255
+ bind: conditions.flatMap(({ bind }) => bind),
256
+ },
257
+ ties(found) {
258
+ const tied = new Map();
259
+ for (const row of connection.rows('SELECT id, key, path FROM replica_entries WHERE id IN (SELECT value FROM json_each(?))', [ids(found)])) {
260
+ const locator = locators.get(Number(row.key));
261
+ if (locator !== undefined)
262
+ tied.set(Number(row.id), [locator, String(row.path)]);
263
+ }
264
+ return tied;
265
+ },
266
+ };
267
+ }
268
+ function messagesListed(connection, conversations) {
269
+ if (conversations.length === 0)
270
+ return null;
271
+ return {
272
+ table: MESSAGES,
273
+ scope: {
274
+ sql: `EXISTS (SELECT 1 FROM conversation_messages m WHERE m.id = ${MESSAGES}.rowid / ${CHUNKS} AND m.conversation IN (SELECT value FROM json_each(?)))`,
275
+ bind: [JSON.stringify(conversations)],
276
+ },
277
+ ties(found) {
278
+ return new Map(connection
279
+ .rows('SELECT id, conversation, identity FROM conversation_messages WHERE id IN (SELECT value FROM json_each(?))', [ids(found)])
280
+ .map((row) => [Number(row.id), [String(row.conversation), String(row.identity)]]));
281
+ },
282
+ };
283
+ }
284
+ function cut(candidates, terms) {
285
+ for (const [part, text] of candidates) {
286
+ const found = snippet(text, terms, SNIPPET_REACH);
287
+ if (found !== null)
288
+ return { snippet: { part, text: found.text, at: [...found.at] } };
289
+ }
290
+ return {};
291
+ }
292
+ function documentHit(connection, hit, terms) {
293
+ const [row] = connection.rows('SELECT type, content FROM replica_entries WHERE id = ?', [hit.id]);
294
+ if (row === undefined)
295
+ return null;
296
+ const [room, path] = hit.tie;
297
+ const parts = typeof row.content === 'string' ? partsOf(path, row.content) : null;
298
+ const whole = parts === null
299
+ ? []
300
+ : [
301
+ ['fields', parts.fields],
302
+ ['sections', parts.sections],
303
+ ['preamble', parts.preamble],
304
+ ['path', parts.path],
305
+ ];
306
+ const matches = {};
307
+ for (const [part, text] of whole) {
308
+ for (const term of matched(text, terms))
309
+ (matches[term] ??= []).push(part);
310
+ }
311
+ const sections = parts === null ? [] : chunked(parts.sections);
312
+ const chunk = parts === null
313
+ ? []
314
+ : hit.chunk === 0
315
+ ? [
316
+ ['fields', parts.fields],
317
+ ['sections', sections[0] ?? ''],
318
+ ['preamble', parts.preamble],
319
+ ['path', parts.path],
320
+ ]
321
+ : [['sections', sections[hit.chunk] ?? '']];
322
+ return {
323
+ room,
324
+ path,
325
+ type: String(row.type),
326
+ score: hit.score,
327
+ matches,
328
+ ...cut(chunk, terms),
329
+ };
330
+ }
331
+ function messageHit(connection, hit, terms) {
332
+ const [row] = connection.rows('SELECT text FROM conversation_messages WHERE id = ?', [hit.id]);
333
+ const text = typeof row?.text === 'string' ? row.text : '';
334
+ const matches = {};
335
+ for (const term of matched(text, terms))
336
+ matches[term] = ['text'];
337
+ const [conversation, identity] = hit.tie;
338
+ return {
339
+ conversation,
340
+ identity,
341
+ score: hit.score,
342
+ matches,
343
+ ...cut([['text', chunked(text)[hit.chunk] ?? '']], terms),
344
+ };
345
+ }
346
+ export function searched(connection, ask) {
347
+ const clauses = matchClauses(ask.text);
348
+ const terms = queryTerms(ask.text);
349
+ const documents = ask.documents === null ? null : documentsListed(connection, ask.documents);
350
+ const messages = messagesListed(connection, ask.conversations);
351
+ const [documentsAfter, messagesAfter] = ask.after ?? [[], []];
352
+ const documentWindow = windowOf(connection, documents, clauses, documentsAfter, ask.limit);
353
+ const messageWindow = windowOf(connection, messages, clauses, messagesAfter, ask.limit);
354
+ const more = documentWindow.cursor !== null || messageWindow.cursor !== null;
355
+ return {
356
+ documents: documentWindow.kept.flatMap((hit) => documentHit(connection, hit, terms) ?? []),
357
+ messages: messageWindow.kept.map((hit) => messageHit(connection, hit, terms)),
358
+ ...(more ? { next: JSON.stringify([documentWindow.cursor, messageWindow.cursor]) } : {}),
359
+ ...(ask.total
360
+ ? {
361
+ total: {
362
+ documents: totalOf(connection, documents, clauses),
363
+ messages: totalOf(connection, messages, clauses),
364
+ },
365
+ }
366
+ : {}),
367
+ };
368
+ }
package/dist/host.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type MdRuntimeOptions } from './connection.js';
2
- import type { RuntimeDemand } from './acquisition.js';
3
2
  import type { PortReach } from './reach.js';
4
3
  import type { CapacityCause, CodeAvailability, Persistence, Readiness, SearchObligation } from './readiness.js';
4
+ import type { EntrySeed } from './seed.js';
5
5
  import { type RuntimePort } from './wire.js';
6
6
  export type MdRuntimeHostOptions = MdRuntimeOptions & {
7
7
  deploymentFacts?: unknown;
@@ -10,22 +10,23 @@ export type AttachedPort = {
10
10
  detach(): void;
11
11
  narrow(reach: PortReach): void;
12
12
  readiness(deliver: (readiness: Readiness) => void): () => void;
13
+ answered(queries: readonly unknown[], done: () => void): void;
13
14
  code(code: CodeAvailability, capacity: CapacityCause | null): void;
14
15
  search(search: SearchObligation): void;
15
16
  };
16
17
  export type MdRuntimeHost = {
17
18
  attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability, search?: SearchObligation): AttachedPort;
18
- acquire(demand: RuntimeDemand): void;
19
+ seed(entry: EntrySeed): void;
19
20
  persisted(answer: Persistence): void;
21
+ shown(onScreen: boolean): void;
20
22
  endAuthorization(holder?: string): Promise<void>;
21
23
  lose(locators: readonly string[]): Promise<void>;
22
24
  stop(): Promise<void>;
23
25
  };
24
26
  export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
25
- export type { RuntimeDemand } from './acquisition.js';
27
+ export { entrySeedOf, type EntrySeed } from './seed.js';
26
28
  export type { PortReach, ReachedDocument } from './reach.js';
27
29
  export type { CapacityCause, CodeAvailability, Persistence, SearchObligation, } from './readiness.js';
28
30
  export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
29
- export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
30
31
  export type { RuntimePort } from './wire.js';
31
32
  //# sourceMappingURL=host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAGL,KAAK,WAAW,EAOjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/D,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,QA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,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAyHF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA2K3E;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,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,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/host.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { composeRuntime, } from './connection.js';
2
+ import { queryKey } from './query.js';
2
3
  import { described } from './failure.js';
3
- import { removeRuntimeStore } from './store.js';
4
4
  import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
5
5
  const NARROWED = new Set(['within', 'whole']);
6
6
  function answered(md, app, writtenBy, member, input) {
@@ -15,18 +15,28 @@ function answered(md, app, writtenBy, member, input) {
15
15
  return md.types(input[0]);
16
16
  case 'save':
17
17
  return md.save(input[0], input[1], writtenBy);
18
+ case 'saveParts':
19
+ return md.saveParts(input[0], input[1], writtenBy);
18
20
  case 'history':
19
21
  return md.history(input[0], input[1], input[2]);
22
+ case 'resolve':
23
+ return md.resolve(input[0], input[1], input[2]);
20
24
  case 'binaryFile.read':
21
25
  return md.binaryFile.read(input[0], input[1], input[2]);
26
+ case 'binaryFile.link':
27
+ return md.binaryFile.link(input[0], input[1], input[2]);
22
28
  case 'binaryFile.readReference':
23
29
  return md.binaryFile.readReference(input[0]);
30
+ case 'binaryFile.part':
31
+ return md.binaryFile.part(input[0], input[1]);
24
32
  case 'call':
25
33
  return md.call(input[0], input[1]);
26
34
  case 'reached':
27
35
  return md.reached(input[0], input[1], input[2]);
28
36
  case 'log':
29
37
  return md.log();
38
+ case 'cleanUp':
39
+ return md.cleanUp();
30
40
  case 'persistence':
31
41
  return md.persistence();
32
42
  case 'retry':
@@ -45,6 +55,8 @@ function answered(md, app, writtenBy, member, input) {
45
55
  return md.presentation.read(app);
46
56
  case 'presentation.write':
47
57
  return md.presentation.write(app, input[0]);
58
+ case 'presentation.edit':
59
+ return md.presentation.edit(app, input[0]);
48
60
  case 'conversation.list':
49
61
  return md.conversation.list();
50
62
  case 'conversation.read':
@@ -53,6 +65,8 @@ function answered(md, app, writtenBy, member, input) {
53
65
  return md.conversation.create(input[0]);
54
66
  case 'conversation.send':
55
67
  return md.conversation.send(input[0], input[1], input[2]);
68
+ case 'conversation.attach':
69
+ return md.conversation.attach(input[0], input[1]);
56
70
  case 'conversation.answer':
57
71
  return md.conversation.answer(input[0], input[1]);
58
72
  case 'conversation.interrupt':
@@ -65,10 +79,20 @@ function answered(md, app, writtenBy, member, input) {
65
79
  return md.conversation.delete(input[0]);
66
80
  case 'chatDraft.write':
67
81
  return md.chatDraft.write(input[0], input[1], input[2]);
82
+ case 'chatDraft.prepend':
83
+ return md.chatDraft.prepend(input[0], input[1]);
68
84
  case 'chatDraft.discard':
69
85
  return md.chatDraft.discard(input[0]);
70
86
  }
71
87
  }
88
+ function answeredResult(value) {
89
+ return typeof value === 'object' && value !== null && !('pending' in value);
90
+ }
91
+ function answeredMessage(value) {
92
+ if (typeof value !== 'object' || value === null)
93
+ return false;
94
+ return !('result' in value) || answeredResult(value.result);
95
+ }
72
96
  export function serveMdRuntime(options) {
73
97
  const deploymentFacts = structuredClone(options.deploymentFacts);
74
98
  const closing = new AbortController();
@@ -94,7 +118,17 @@ export function serveMdRuntime(options) {
94
118
  const view = runtime.within(reach ?? null, facts);
95
119
  const observations = new Map();
96
120
  const followed = new Set();
121
+ const answeredKeys = new Set();
122
+ let awaited = null;
97
123
  let serving = true;
124
+ const answeredQuery = (query) => {
125
+ answeredKeys.add(queryKey(query));
126
+ if (awaited === null || !awaited.keys.every((key) => answeredKeys.has(key)))
127
+ return;
128
+ const { done } = awaited;
129
+ awaited = null;
130
+ done();
131
+ };
98
132
  const send = (message) => {
99
133
  port.postMessage(message);
100
134
  };
@@ -116,6 +150,8 @@ export function serveMdRuntime(options) {
116
150
  return;
117
151
  send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
118
152
  resolved = true;
153
+ if (topic === 'query' && answeredMessage(value))
154
+ answeredQuery(input[0]);
119
155
  };
120
156
  observations.set(id, topic === 'deployment-facts'
121
157
  ? watchFacts(deliver)
@@ -138,8 +174,11 @@ export function serveMdRuntime(options) {
138
174
  return;
139
175
  }
140
176
  const value = await answered(NARROWED.has(WIRE.members[message.member].reach) ? view.md : md, app, writtenBy, message.member, message.input);
141
- if (serving)
142
- send({ kind: 'result', id: message.id, value });
177
+ if (!serving)
178
+ return;
179
+ send({ kind: 'result', id: message.id, value });
180
+ if (message.member === 'query' && answeredResult(value))
181
+ answeredQuery(message.input[0]);
143
182
  }
144
183
  catch (error) {
145
184
  if (serving)
@@ -175,6 +214,13 @@ export function serveMdRuntime(options) {
175
214
  facts = { ...facts, search: next };
176
215
  view.facts(facts);
177
216
  },
217
+ answered(queries, done) {
218
+ const keys = queries.map(queryKey);
219
+ if (keys.every((key) => answeredKeys.has(key)))
220
+ done();
221
+ else
222
+ awaited = { keys, done };
223
+ },
178
224
  readiness(deliver) {
179
225
  if (!serving)
180
226
  return () => { };
@@ -193,12 +239,15 @@ export function serveMdRuntime(options) {
193
239
  }
194
240
  return {
195
241
  attach,
196
- acquire(demand) {
197
- runtime.acquire(demand);
242
+ seed(entry) {
243
+ runtime.seed(entry);
198
244
  },
199
245
  persisted(answer) {
200
246
  runtime.persisted(answer);
201
247
  },
248
+ shown(onScreen) {
249
+ runtime.shown(onScreen);
250
+ },
202
251
  async endAuthorization(holder) {
203
252
  authorized = false;
204
253
  for (const [detach, send] of [...attachments]) {
@@ -206,8 +255,9 @@ export function serveMdRuntime(options) {
206
255
  detach();
207
256
  }
208
257
  close();
209
- if (!(await removeRuntimeStore(holder)))
258
+ if (!(await options.database.ask({ kind: 'authored.end', holder: holder ?? null }))) {
210
259
  await options.shell.dropGeneration();
260
+ }
211
261
  },
212
262
  lose(locators) {
213
263
  return runtime.lose(locators);
@@ -217,5 +267,5 @@ export function serveMdRuntime(options) {
217
267
  },
218
268
  };
219
269
  }
270
+ export { entrySeedOf } from './seed.js';
220
271
  export { createRecovery, retryDelay, } from './recovery.js';
221
- export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
@@ -3,6 +3,5 @@ export declare function identityTime(identity: string): number;
3
3
  export declare function roomDraftRevision(): string;
4
4
  export declare function chatDraftRevision(): string;
5
5
  export declare function transferIdentity(): string;
6
- export declare function indexGeneration(): string;
7
6
  export declare function binaryLocalId(): string;
8
7
  //# sourceMappingURL=identity.d.ts.map
@@ -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;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
package/dist/identity.js CHANGED
@@ -27,9 +27,6 @@ export function chatDraftRevision() {
27
27
  export function transferIdentity() {
28
28
  return randomIdentity();
29
29
  }
30
- export function indexGeneration() {
31
- return randomIdentity();
32
- }
33
30
  export function binaryLocalId() {
34
31
  return randomIdentity();
35
32
  }
package/dist/index.d.ts CHANGED
@@ -1,22 +1,26 @@
1
- export type { AcquiredDemand, AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
2
- export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
1
+ export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, ReferrerScope, BootstrapInventory, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRevisions, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
2
+ export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
3
3
  export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
4
- export type { ChatDraftFile, FileDeclaration } from './file.js';
5
- export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
4
+ export type { ChosenFile, FileDeclaration } from './file.js';
5
+ export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
6
6
  export type { Observation } from './observation.js';
7
- export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
7
+ export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
8
8
  export type { BinaryFileRecord, BinaryReference } from './binary.js';
9
9
  export type { RuntimeError } from './failure.js';
10
- export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
10
+ export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
11
11
  export type { SaveRefusal } from './save.js';
12
- export type { DocumentHit, DocumentPart, MessageHit, PendingConversation, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, } from './search.js';
12
+ export type { DocumentHit, DocumentPart, MessageHit, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
13
13
  export { departure } from './change.js';
14
+ export { partsAfter } from './room-draft.js';
15
+ export { cutName, nameFrom, transliterated } from './name.js';
14
16
  export { SESSION_STARTED } from './conversation.js';
15
17
  export { changeBatchIdentity } from './identity.js';
18
+ export { ROW_WEIGHT, stepped } from './turn.js';
19
+ export { entriesIn, patching, sortedKeys } from './shared.js';
16
20
  export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
17
21
  export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
18
22
  export type { RuntimeShell, StorageEstimate } from './durability.js';
19
- export type { CapacityCause, CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, TargetCoverage, } from './readiness.js';
23
+ export type { CapacityCause, CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, TargetCoverage, } from './readiness.js';
20
24
  export type { AttentionEntry, SyncStatus } from './status.js';
21
25
  export type { Awaits, Backlink, CoveredRoom, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, PendingResult, PendingRoom, Predicate, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, Related, Select, Value, Where, } from './query.js';
22
26
  export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAA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,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1F,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,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