@agentshouse/mdruntime 0.1.0-c112fd663ab59 → 0.1.0-c11a2e8d6df41

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 (295) hide show
  1. package/README.md +21 -19
  2. package/dist/acceptance.d.ts +0 -3
  3. package/dist/acceptance.d.ts.map +1 -1
  4. package/dist/acceptance.js +72 -158
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +8 -2
  9. package/dist/actions.d.ts.map +1 -1
  10. package/dist/actions.js +174 -75
  11. package/dist/adapter.d.ts +145 -68
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +0 -1
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +2 -7
  16. package/dist/authored.d.ts +88 -0
  17. package/dist/authored.d.ts.map +1 -0
  18. package/dist/authored.js +347 -0
  19. package/dist/binary.d.ts +6 -2
  20. package/dist/binary.d.ts.map +1 -1
  21. package/dist/binary.js +10 -3
  22. package/dist/bootstrap.d.ts +1 -1
  23. package/dist/bootstrap.d.ts.map +1 -1
  24. package/dist/bootstrap.js +6 -19
  25. package/dist/chain.d.ts +1 -1
  26. package/dist/chain.d.ts.map +1 -1
  27. package/dist/chain.js +5 -2
  28. package/dist/change-set.d.ts +4 -0
  29. package/dist/change-set.d.ts.map +1 -1
  30. package/dist/change-set.js +6 -0
  31. package/dist/change.d.ts +6 -2
  32. package/dist/change.d.ts.map +1 -1
  33. package/dist/change.js +3 -0
  34. package/dist/chat-types.d.ts +0 -2
  35. package/dist/chat-types.d.ts.map +1 -1
  36. package/dist/chat-types.js +2 -4
  37. package/dist/client.d.ts +22 -23
  38. package/dist/client.d.ts.map +1 -1
  39. package/dist/client.js +51 -66
  40. package/dist/collection.d.ts +27 -4
  41. package/dist/collection.d.ts.map +1 -1
  42. package/dist/collection.js +34 -10
  43. package/dist/column.d.ts +5 -0
  44. package/dist/column.d.ts.map +1 -0
  45. package/dist/column.js +9 -0
  46. package/dist/compile.d.ts +4 -1
  47. package/dist/compile.d.ts.map +1 -1
  48. package/dist/compile.js +87 -43
  49. package/dist/connection.d.ts +1 -1
  50. package/dist/connection.d.ts.map +1 -1
  51. package/dist/connection.js +36 -27
  52. package/dist/context.d.ts.map +1 -1
  53. package/dist/context.js +1 -1
  54. package/dist/conversation-live.d.ts +28 -15
  55. package/dist/conversation-live.d.ts.map +1 -1
  56. package/dist/conversation-live.js +25 -14
  57. package/dist/conversation-row.d.ts +8 -1
  58. package/dist/conversation-row.d.ts.map +1 -1
  59. package/dist/conversation-row.js +20 -7
  60. package/dist/conversation.d.ts +46 -16
  61. package/dist/conversation.d.ts.map +1 -1
  62. package/dist/conversation.js +334 -239
  63. package/dist/declaration.d.ts +10 -0
  64. package/dist/declaration.d.ts.map +1 -0
  65. package/dist/declaration.js +24 -0
  66. package/dist/discovery.d.ts +3 -1
  67. package/dist/discovery.d.ts.map +1 -1
  68. package/dist/discovery.js +47 -47
  69. package/dist/download.d.ts +6 -0
  70. package/dist/download.d.ts.map +1 -0
  71. package/dist/download.js +42 -0
  72. package/dist/durability.d.ts +5 -0
  73. package/dist/durability.d.ts.map +1 -1
  74. package/dist/durability.js +7 -0
  75. package/dist/entry.d.ts +16 -1
  76. package/dist/entry.d.ts.map +1 -1
  77. package/dist/entry.js +75 -30
  78. package/dist/expectation.d.ts +25 -14
  79. package/dist/expectation.d.ts.map +1 -1
  80. package/dist/expectation.js +51 -20
  81. package/dist/failure.d.ts +2 -0
  82. package/dist/failure.d.ts.map +1 -1
  83. package/dist/failure.js +6 -1
  84. package/dist/figures.d.ts.map +1 -1
  85. package/dist/figures.js +4 -2
  86. package/dist/file.d.ts +1 -1
  87. package/dist/file.d.ts.map +1 -1
  88. package/dist/file.js +3 -2
  89. package/dist/host.d.ts +24 -4
  90. package/dist/host.d.ts.map +1 -1
  91. package/dist/host.js +108 -32
  92. package/dist/house-query.d.ts +24 -0
  93. package/dist/house-query.d.ts.map +1 -0
  94. package/dist/house-query.js +82 -0
  95. package/dist/index.d.ts +23 -14
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +16 -8
  98. package/dist/install.d.ts +10 -6
  99. package/dist/install.d.ts.map +1 -1
  100. package/dist/install.js +89 -108
  101. package/dist/lifecycle.d.ts +2 -2
  102. package/dist/lifecycle.d.ts.map +1 -1
  103. package/dist/lifecycle.js +74 -54
  104. package/dist/listing.d.ts +29 -22
  105. package/dist/listing.d.ts.map +1 -1
  106. package/dist/listing.js +71 -79
  107. package/dist/live.d.ts +19 -3
  108. package/dist/live.d.ts.map +1 -1
  109. package/dist/live.js +94 -36
  110. package/dist/loaded.d.ts +7 -0
  111. package/dist/loaded.d.ts.map +1 -0
  112. package/dist/loaded.js +46 -0
  113. package/dist/locks.d.ts +2 -4
  114. package/dist/locks.d.ts.map +1 -1
  115. package/dist/locks.js +10 -38
  116. package/dist/lost.d.ts.map +1 -1
  117. package/dist/lost.js +11 -23
  118. package/dist/media.d.ts +19 -3
  119. package/dist/media.d.ts.map +1 -1
  120. package/dist/media.js +167 -33
  121. package/dist/memory.d.ts +10 -4
  122. package/dist/memory.d.ts.map +1 -1
  123. package/dist/memory.js +98 -37
  124. package/dist/messages.d.ts +17 -6
  125. package/dist/messages.d.ts.map +1 -1
  126. package/dist/messages.js +34 -27
  127. package/dist/modal.d.ts +2 -0
  128. package/dist/modal.d.ts.map +1 -0
  129. package/dist/modal.js +11 -0
  130. package/dist/model.d.ts +4 -3
  131. package/dist/model.d.ts.map +1 -1
  132. package/dist/model.js +6 -5
  133. package/dist/models.d.ts +4 -8
  134. package/dist/models.d.ts.map +1 -1
  135. package/dist/models.js +94 -138
  136. package/dist/name.d.ts +0 -1
  137. package/dist/name.d.ts.map +1 -1
  138. package/dist/name.js +3 -7
  139. package/dist/observation.d.ts +29 -12
  140. package/dist/observation.d.ts.map +1 -1
  141. package/dist/observation.js +206 -69
  142. package/dist/online.d.ts +7 -0
  143. package/dist/online.d.ts.map +1 -0
  144. package/dist/online.js +29 -0
  145. package/dist/opened.d.ts +1 -1
  146. package/dist/opened.d.ts.map +1 -1
  147. package/dist/opened.js +2 -2
  148. package/dist/opening.d.ts.map +1 -1
  149. package/dist/opening.js +21 -12
  150. package/dist/outcome.d.ts +24 -4
  151. package/dist/outcome.d.ts.map +1 -1
  152. package/dist/outcome.js +33 -3
  153. package/dist/overlay.d.ts +9 -5
  154. package/dist/overlay.d.ts.map +1 -1
  155. package/dist/overlay.js +37 -24
  156. package/dist/page-metadata.d.ts +8 -0
  157. package/dist/page-metadata.d.ts.map +1 -0
  158. package/dist/page-metadata.js +19 -0
  159. package/dist/parts.d.ts +5 -59
  160. package/dist/parts.d.ts.map +1 -1
  161. package/dist/parts.js +32 -122
  162. package/dist/preparation.d.ts +33 -7
  163. package/dist/preparation.d.ts.map +1 -1
  164. package/dist/preparation.js +207 -96
  165. package/dist/presence.d.ts +58 -0
  166. package/dist/presence.d.ts.map +1 -0
  167. package/dist/presence.js +231 -0
  168. package/dist/queries.d.ts +2 -2
  169. package/dist/queries.d.ts.map +1 -1
  170. package/dist/queries.js +136 -78
  171. package/dist/query.d.ts +2 -2
  172. package/dist/questions.d.ts +1 -5
  173. package/dist/questions.d.ts.map +1 -1
  174. package/dist/questions.js +3 -8
  175. package/dist/queue.d.ts +40 -0
  176. package/dist/queue.d.ts.map +1 -0
  177. package/dist/queue.js +480 -0
  178. package/dist/reach.d.ts +15 -6
  179. package/dist/reach.d.ts.map +1 -1
  180. package/dist/reach.js +182 -38
  181. package/dist/react.d.ts +11 -5
  182. package/dist/react.d.ts.map +1 -1
  183. package/dist/react.js +28 -5
  184. package/dist/readiness.d.ts +20 -4
  185. package/dist/readiness.d.ts.map +1 -1
  186. package/dist/readiness.js +17 -10
  187. package/dist/reads.d.ts +4 -2
  188. package/dist/reads.d.ts.map +1 -1
  189. package/dist/reads.js +9 -4
  190. package/dist/recovery.d.ts +4 -1
  191. package/dist/recovery.d.ts.map +1 -1
  192. package/dist/recovery.js +31 -8
  193. package/dist/reference-forms.d.ts +4 -0
  194. package/dist/reference-forms.d.ts.map +1 -0
  195. package/dist/reference-forms.js +74 -0
  196. package/dist/refresh.d.ts +1 -1
  197. package/dist/refresh.js +6 -6
  198. package/dist/refusal.d.ts.map +1 -1
  199. package/dist/refusal.js +2 -4
  200. package/dist/replica.d.ts +5 -11
  201. package/dist/replica.d.ts.map +1 -1
  202. package/dist/replica.js +16 -18
  203. package/dist/retried.d.ts +30 -0
  204. package/dist/retried.d.ts.map +1 -0
  205. package/dist/retried.js +72 -0
  206. package/dist/room-draft.d.ts +30 -5
  207. package/dist/room-draft.d.ts.map +1 -1
  208. package/dist/room-draft.js +275 -65
  209. package/dist/room-drafts.d.ts.map +1 -1
  210. package/dist/room-drafts.js +11 -6
  211. package/dist/room-list.d.ts +10 -0
  212. package/dist/room-list.d.ts.map +1 -0
  213. package/dist/room-list.js +45 -0
  214. package/dist/rows.d.ts +11 -2
  215. package/dist/rows.d.ts.map +1 -1
  216. package/dist/rows.js +27 -14
  217. package/dist/running.d.ts +5 -0
  218. package/dist/running.d.ts.map +1 -0
  219. package/dist/running.js +10 -0
  220. package/dist/runtime.d.ts +13 -19
  221. package/dist/runtime.d.ts.map +1 -1
  222. package/dist/save.d.ts +43 -90
  223. package/dist/save.d.ts.map +1 -1
  224. package/dist/save.js +314 -223
  225. package/dist/saves.d.ts +6 -42
  226. package/dist/saves.d.ts.map +1 -1
  227. package/dist/saves.js +176 -718
  228. package/dist/seed.d.ts.map +1 -1
  229. package/dist/seed.js +4 -4
  230. package/dist/shown.d.ts +9 -5
  231. package/dist/shown.d.ts.map +1 -1
  232. package/dist/shown.js +93 -57
  233. package/dist/socket/lanes.d.ts +12 -4
  234. package/dist/socket/lanes.d.ts.map +1 -1
  235. package/dist/socket/lanes.js +34 -8
  236. package/dist/socket/session.d.ts +4 -1
  237. package/dist/socket/session.d.ts.map +1 -1
  238. package/dist/socket/session.js +3 -0
  239. package/dist/socket.d.ts +4 -6
  240. package/dist/socket.d.ts.map +1 -1
  241. package/dist/socket.js +4 -14
  242. package/dist/source.d.ts +7 -7
  243. package/dist/source.d.ts.map +1 -1
  244. package/dist/source.js +15 -2
  245. package/dist/store/installs.d.ts +2 -2
  246. package/dist/store/installs.d.ts.map +1 -1
  247. package/dist/store/installs.js +10 -4
  248. package/dist/store/readiness.d.ts +5 -4
  249. package/dist/store/readiness.d.ts.map +1 -1
  250. package/dist/store/readiness.js +28 -12
  251. package/dist/store/records.d.ts +24 -7
  252. package/dist/store/records.d.ts.map +1 -1
  253. package/dist/store/records.js +67 -24
  254. package/dist/store/rooms-shown.d.ts +8 -0
  255. package/dist/store/rooms-shown.d.ts.map +1 -0
  256. package/dist/store/rooms-shown.js +13 -0
  257. package/dist/store.d.ts +25 -15
  258. package/dist/store.d.ts.map +1 -1
  259. package/dist/store.js +50 -18
  260. package/dist/stored.d.ts +39 -14
  261. package/dist/stored.d.ts.map +1 -1
  262. package/dist/stored.js +217 -59
  263. package/dist/surface.d.ts +14 -8
  264. package/dist/surface.d.ts.map +1 -1
  265. package/dist/surface.js +65 -34
  266. package/dist/sync.d.ts +4 -2
  267. package/dist/sync.d.ts.map +1 -1
  268. package/dist/sync.js +127 -102
  269. package/dist/tables.d.ts +28 -56
  270. package/dist/tables.d.ts.map +1 -1
  271. package/dist/tables.js +95 -329
  272. package/dist/tallies.d.ts.map +1 -1
  273. package/dist/tallies.js +1 -2
  274. package/dist/validation.d.ts +2 -0
  275. package/dist/validation.d.ts.map +1 -1
  276. package/dist/validation.js +51 -11
  277. package/dist/wire.d.ts +71 -12
  278. package/dist/wire.d.ts.map +1 -1
  279. package/dist/wire.js +30 -14
  280. package/package.json +4 -3
  281. package/dist/attempt.d.ts +0 -16
  282. package/dist/attempt.d.ts.map +0 -1
  283. package/dist/attempt.js +0 -70
  284. package/dist/job.d.ts +0 -33
  285. package/dist/job.d.ts.map +0 -1
  286. package/dist/job.js +0 -54
  287. package/dist/log.d.ts +0 -6
  288. package/dist/log.d.ts.map +0 -1
  289. package/dist/log.js +0 -14
  290. package/dist/socket/rooms.d.ts +0 -44
  291. package/dist/socket/rooms.d.ts.map +0 -1
  292. package/dist/socket/rooms.js +0 -90
  293. package/dist/store/fences.d.ts +0 -16
  294. package/dist/store/fences.d.ts.map +0 -1
  295. package/dist/store/fences.js +0 -26
package/dist/tables.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { sql } from '@agentshouse/mdmodel';
2
- import { answerQuery } from './compile.js';
3
- import { conversationRows, droppedMessages, forgottenMessages, heldConversations, jobMarkers, keptMessages, messageCount, messageWindow, MESSAGE_TABLES, turnArrived, } from './messages.js';
2
+ import { answerQuery, namedHandles } from './compile.js';
3
+ import { amended, authoredLocators, authoredPart, call, callRecords, chatDraft, chatDraftConversations, chatDraftRecord, chatDraftRecords, chatDraftsDropped, claim, fact, fenced, fencedWork, fences, FILE_PART_BYTES, authoredEmptied, heldOrder, kept, moving, pendingBatch, pendingState, queuedLocators, queueOf, queues, remember, roomDraft, roomDraftRecords, spooled, unfenced, unsent, unsentStatus, } from './authored.js';
4
+ import { count, text, texts } from './column.js';
5
+ import { conversationFacts, conversationRows, forgottenConversations, heldConversations, keptFact, keptMessages, messageCount, messageWindow, MESSAGE_TABLES, turnArrived, } from './messages.js';
4
6
  import { keptRead, READ_TABLES, readsOfOtherBuildsForgotten, storedRead, } from './reads.js';
5
7
  import { conversationTallies, roomTallies, } from './tallies.js';
6
- import { abandon, release, commit, covering, demoted, ended, entries, erase, facts, fenceRooms, folders, heldLocators, heldRoom, heldRooms, offlineMode, opened, overlaid, presentation, rederive, referrers, refreshing, REPLICA_TABLES, resume, stage, typed, stagedLocators, typedWithin, unrefresh, } from './stored.js';
8
+ import { abandon, release, commit, covering, demoted, ended, entries, erase, facts, fenceRooms, folders, heldLocators, heldRoom, heldRooms, holders, offlineMode, opened, overlaid, presentation, rederive, referrers, refreshing, REPLICA_TABLES, resume, stage, typed, stagedLocators, tablesOf, typedWithin, unrefresh, } from './stored.js';
9
+ export { kindedRevision } from './reference-forms.js';
10
+ export { authoredEmptied, authoredTable, FILE_PART_BYTES, formatted, heldTables, } from './authored.js';
7
11
  const STATEMENTS_HELD = 256;
8
12
  export function sqliteConnection(engine, database) {
9
13
  const decoder = new TextDecoder();
@@ -71,36 +75,16 @@ export function sqliteConnection(engine, database) {
71
75
  },
72
76
  };
73
77
  }
74
- export const FILE_PART_BYTES = 1_048_576;
75
78
  const PROBE_BYTES = 4 * FILE_PART_BYTES;
76
- const TABLES = [
77
- ['authored_facts', 'name TEXT PRIMARY KEY, value TEXT NOT NULL'],
78
- ['authored_queues', 'locator TEXT PRIMARY KEY, ids TEXT NOT NULL'],
79
- [
80
- 'authored_pending',
81
- 'locator TEXT NOT NULL, id TEXT NOT NULL, batch TEXT NOT NULL, state TEXT NOT NULL, files TEXT NOT NULL, paths TEXT NOT NULL, moving INTEGER NOT NULL, PRIMARY KEY (locator, id)',
82
- ],
83
- [
84
- 'authored_room_drafts',
85
- 'locator TEXT NOT NULL, path TEXT NOT NULL, record TEXT NOT NULL, files TEXT NOT NULL, PRIMARY KEY (locator, path)',
86
- ],
87
- ['authored_chat_drafts', 'conversation TEXT PRIMARY KEY, record TEXT NOT NULL'],
88
- ['authored_calls', 'operation TEXT PRIMARY KEY, record TEXT NOT NULL, files TEXT NOT NULL'],
89
- ['authored_fences', 'locator TEXT PRIMARY KEY'],
90
- ];
91
79
  export const RUNTIME_TABLES = [
92
- ...TABLES.map(([name, columns]) => `CREATE TABLE ${name} (${columns}) WITHOUT ROWID`),
93
- 'CREATE TABLE file_parts (key TEXT NOT NULL, part INTEGER NOT NULL, bytes BLOB NOT NULL, PRIMARY KEY (key, part))',
94
80
  'CREATE TABLE opened_files (key TEXT PRIMARY KEY, locator TEXT NOT NULL, path TEXT NOT NULL, revision TEXT NOT NULL, media_type TEXT NOT NULL, sha256 TEXT, byte_length INTEGER) WITHOUT ROWID',
95
81
  'CREATE INDEX opened_files_name ON opened_files (locator, path, revision)',
82
+ 'CREATE TABLE opened_parts (key TEXT NOT NULL, part INTEGER NOT NULL, bytes BLOB NOT NULL, PRIMARY KEY (key, part))',
96
83
  ...REPLICA_TABLES,
97
84
  ...MESSAGE_TABLES,
98
85
  ...READ_TABLES,
99
86
  ];
100
- const OWNERS = ['authored_pending', 'authored_room_drafts', 'authored_calls'];
101
- const AUTHORED_KEYS = OWNERS.map((table) => `SELECT value FROM ${table}, json_each(${table}.files)`).join(' UNION ');
102
- const UNOWNED_PARTS = `DELETE FROM file_parts WHERE key NOT IN (${AUTHORED_KEYS} UNION SELECT key FROM opened_files)`;
103
- const CLEANABLE_BYTES = `SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM file_parts WHERE key NOT IN (${AUTHORED_KEYS})`;
87
+ const UNOPENED_PARTS = 'DELETE FROM opened_parts WHERE key NOT IN (SELECT key FROM opened_files)';
104
88
  const READS = new Set([
105
89
  'authored.status',
106
90
  'authored.moving',
@@ -125,10 +109,12 @@ const READS = new Set([
125
109
  'replica.facts',
126
110
  'replica.presentation',
127
111
  'replica.query',
112
+ 'replica.named',
128
113
  'replica.tallies',
129
114
  'replica.entries',
130
115
  'replica.typed',
131
116
  'replica.referrers',
117
+ 'replica.holders',
132
118
  'replica.folders',
133
119
  'replica.typedWithin',
134
120
  'opened.find',
@@ -139,8 +125,9 @@ const READS = new Set([
139
125
  'conversation.count',
140
126
  'conversation.turn',
141
127
  'conversation.rows',
142
- 'conversation.jobs',
143
128
  'conversation.tallies',
129
+ 'conversation.facts',
130
+ 'conversation.stored',
144
131
  'read.stored',
145
132
  ]);
146
133
  const KINDS = new Set([
@@ -172,6 +159,7 @@ const KINDS = new Set([
172
159
  'opened.drop',
173
160
  'opened.clean',
174
161
  'conversation.keep',
162
+ 'conversation.fact',
175
163
  'conversation.drop',
176
164
  'space.probe',
177
165
  'read.keep',
@@ -183,290 +171,75 @@ export function isRuntime(request) {
183
171
  export function readsRuntime(request) {
184
172
  return READS.has(request.kind);
185
173
  }
186
- function text(value) {
187
- return typeof value === 'string' ? value : String(value);
188
- }
189
- function texts(rows, column) {
190
- return rows.map((row) => text(row[column]));
191
- }
192
- function owned(files) {
193
- return JSON.stringify([...new Set(files)]);
194
- }
195
- function fact(connection, name) {
196
- const [held] = connection.rows('SELECT value FROM authored_facts WHERE name = ?', [name]);
197
- return held === undefined ? null : text(held.value);
198
- }
199
- function remember(connection, name, value) {
200
- connection.run('INSERT OR REPLACE INTO authored_facts (name, value) VALUES (?, ?)', [
201
- name,
202
- value,
203
- ]);
204
- return null;
205
- }
206
- function fenced(connection, locator) {
207
- return connection.rows('SELECT 1 FROM authored_fences WHERE locator = ?', [locator]).length > 0;
208
- }
209
- function stored(connection, key) {
210
- return connection.rows('SELECT 1 FROM file_parts WHERE key = ? LIMIT 1', [key]).length > 0;
211
- }
212
- function storedPart(connection, key, part, bytes) {
213
- connection.run('INSERT INTO file_parts (key, part, bytes) VALUES (?, ?, ?)', [key, part, bytes]);
214
- }
215
- async function storedFiles(connection, files) {
216
- for (const { key, blob } of files) {
217
- if (stored(connection, key))
218
- continue;
219
- for (let at = 0, part = 0; at < blob.size; at += FILE_PART_BYTES, part += 1) {
220
- const bytes = new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer());
221
- storedPart(connection, key, part, bytes);
222
- }
223
- }
224
- }
225
- function filePart(connection, key, part) {
226
- const [held] = connection.rows('SELECT bytes FROM file_parts WHERE key = ? AND part = ?', [
227
- key,
228
- part,
229
- ]);
230
- return held?.bytes instanceof Uint8Array ? held.bytes : null;
231
- }
232
- function* fileParts(connection, key) {
233
- for (let part = 0;; part += 1) {
234
- const bytes = filePart(connection, key, part);
235
- if (bytes === null)
236
- return;
237
- yield bytes;
238
- }
239
- }
240
- async function spooled(connection, spool, { key, type }) {
241
- for (const held of [...spool.held()]) {
242
- if (held !== key && !stored(connection, held))
243
- await spool.drop(held);
244
- }
245
- return spool.spool(key, type, fileParts(connection, key));
246
- }
247
- function unowned(connection) {
248
- connection.run(UNOWNED_PARTS);
249
- }
250
- function queued(connection) {
251
- return connection.rows('SELECT locator, ids FROM authored_queues').map((row) => ({
252
- locator: text(row.locator),
253
- ids: JSON.parse(text(row.ids)),
254
- }));
255
- }
256
174
  function heldWork(connection, locator) {
257
175
  const room = heldRoom(connection, locator);
258
- const pending = new Map(connection
259
- .rows('SELECT id, batch, state FROM authored_pending WHERE locator = ?', [locator])
260
- .map((row) => [
261
- text(row.id),
262
- { id: text(row.id), batch: text(row.batch), state: text(row.state) },
263
- ]));
264
176
  return {
265
177
  room: room === null ? null : { ...room, overlaid: overlaid(connection, room.key) },
266
- queue: heldOrder(connection, locator).map((id) => {
267
- const held = pending.get(id);
268
- if (held === undefined)
269
- throw new Error(`Missing Pending Change ${locator}/${id}`);
270
- return held;
271
- }),
178
+ queue: queueOf(connection, locator),
272
179
  };
273
180
  }
274
181
  function status(connection) {
275
- const [completed] = connection.rows("SELECT value FROM replica_facts WHERE name = 'lastCompleted'");
276
182
  return {
277
- queued: texts(connection.rows('SELECT locator FROM authored_queues'), 'locator'),
278
- lastCompleted: completed === undefined ? null : text(completed.value),
279
- changes: connection
280
- .rows('SELECT p.locator, c.value AS path FROM authored_pending p, json_each(p.paths) c')
281
- .map((row) => ({ locator: text(row.locator), path: text(row.path) })),
282
- resets: connection
283
- .rows(`SELECT locator, json_extract(state, '$.submission.reset') AS reset FROM authored_pending
284
- WHERE json_extract(state, '$.submission.state') = 'reset'`)
285
- .map((row) => ({ locator: text(row.locator), reset: text(row.reset) })),
286
- returned: texts(connection.rows(`SELECT record FROM authored_room_drafts WHERE json_type(record, '$.returned') = 'object'`), 'record'),
183
+ ...unsentStatus(connection),
184
+ lastCompleted: facts(connection, ['lastCompleted']).lastCompleted ?? null,
287
185
  };
288
186
  }
289
187
  function pendingOf(connection, locator, id) {
290
- const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
291
188
  return {
292
- state: held === undefined ? null : text(held.state),
189
+ state: pendingState(connection, locator, id),
293
190
  room: connection.rows('SELECT 1 FROM replica_rooms WHERE locator = ?', [locator]).length > 0,
294
191
  };
295
192
  }
296
- function roomDraftRecords(connection, locator, paths) {
297
- if (locator === null) {
298
- return texts(connection.rows('SELECT record FROM authored_room_drafts'), 'record');
299
- }
300
- if (paths === null) {
301
- return texts(connection.rows('SELECT record FROM authored_room_drafts WHERE locator = ?', [locator]), 'record');
302
- }
303
- return texts(connection.rows('SELECT record FROM authored_room_drafts WHERE locator = ? AND path IN (SELECT value FROM json_each(?))', [locator, JSON.stringify(paths)]), 'record');
304
- }
305
- function chatDraftRecord(connection, conversation) {
306
- const [held] = connection.rows('SELECT record FROM authored_chat_drafts WHERE conversation = ?', [
307
- conversation,
308
- ]);
309
- return held === undefined ? null : text(held.record);
310
- }
311
- function heldOrder(connection, locator) {
312
- const [held] = connection.rows('SELECT ids FROM authored_queues WHERE locator = ?', [locator]);
313
- return held === undefined ? [] : JSON.parse(text(held.ids));
314
- }
315
- function keptRows(connection, { locator, order, added, founded, roomDrafts, consumedRoomDrafts }) {
316
- for (const path of consumedRoomDrafts ?? []) {
317
- connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
318
- locator,
319
- path,
320
- ]);
321
- }
322
- for (const { path, record, files } of roomDrafts ?? []) {
323
- connection.run('INSERT OR REPLACE INTO authored_room_drafts (locator, path, record, files) VALUES (?, ?, ?, ?)', [locator, path, record, owned(files)]);
324
- }
325
- if (order === undefined)
326
- return;
327
- const before = new Set(heldOrder(connection, locator));
328
- const after = new Set(order);
329
- if (after.size === 0)
330
- connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
331
- else {
332
- connection.run('INSERT OR REPLACE INTO authored_queues (locator, ids) VALUES (?, ?)', [
333
- locator,
334
- JSON.stringify([...after]),
335
- ]);
336
- }
337
- for (const id of before) {
338
- if (!after.has(id)) {
339
- connection.run('DELETE FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
340
- }
341
- }
342
- for (const { id, batch, state, files, paths, moving } of added ?? []) {
343
- if (before.has(id))
344
- continue;
345
- connection.run('INSERT OR REPLACE INTO authored_pending (locator, id, batch, state, files, paths, moving) VALUES (?, ?, ?, ?, ?, ?, ?)', [locator, id, batch, state, owned(files), JSON.stringify(paths), moving ? 1 : 0]);
346
- }
347
- for (const { id, batch, files, paths, moving } of founded ?? []) {
348
- const [held] = connection.rows('SELECT files FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
349
- if (held === undefined || !before.has(id))
350
- continue;
351
- connection.run('UPDATE authored_pending SET batch = ?, files = ?, paths = ?, moving = ? WHERE locator = ? AND id = ?', [
352
- batch,
353
- owned([...JSON.parse(text(held.files)), ...files]),
354
- JSON.stringify(paths),
355
- moving ? 1 : 0,
356
- locator,
357
- id,
358
- ]);
359
- }
360
- }
361
- async function kept(connection, { writes, files, whole }) {
362
- const refused = writes.find(({ locator }) => fenced(connection, locator));
363
- if (refused !== undefined && whole)
364
- return refused.locator;
365
- await storedFiles(connection, files);
366
- for (const write of writes) {
367
- if (!fenced(connection, write.locator))
368
- keptRows(connection, write);
369
- }
370
- unowned(connection);
371
- return refused?.locator ?? null;
372
- }
373
- function amended(connection, { locator, id, amendment }) {
374
- if (fenced(connection, locator))
375
- return null;
376
- const [held] = connection.rows('SELECT state FROM authored_pending WHERE locator = ? AND id = ?', [locator, id]);
377
- if (held === undefined)
378
- return null;
379
- connection.run('UPDATE authored_pending SET state = ? WHERE locator = ? AND id = ?', [
380
- JSON.stringify({
381
- ...JSON.parse(text(held.state)),
382
- ...JSON.parse(amendment),
383
- }),
384
- locator,
385
- id,
386
- ]);
387
- return null;
388
- }
389
- async function roomDraft(connection, { locator, path, kept: draft, files }) {
390
- if (fenced(connection, locator))
391
- return locator;
392
- await storedFiles(connection, files);
393
- if (draft === null) {
394
- connection.run('DELETE FROM authored_room_drafts WHERE locator = ? AND path = ?', [
395
- locator,
396
- path,
193
+ function storedConversations(connection, conversations) {
194
+ const named = conversations === null ? '' : ' WHERE conversation IN (SELECT value FROM json_each(?))';
195
+ const bound = conversations === null ? [] : [JSON.stringify(conversations)];
196
+ return [
197
+ ...new Set([
198
+ ...tablesOf(MESSAGE_TABLES).flatMap((table) => texts(connection.rows(`SELECT DISTINCT conversation FROM ${table}${named}`, bound), 'conversation')),
199
+ ...chatDraftConversations(connection, conversations),
200
+ ]),
201
+ ];
202
+ }
203
+ function droppedConversations(connection, conversations) {
204
+ const held = storedConversations(connection, conversations);
205
+ for (const table of tablesOf(MESSAGE_TABLES)) {
206
+ connection.run(`DELETE FROM ${table} WHERE conversation IN (SELECT value FROM json_each(?))`, [
207
+ JSON.stringify(conversations),
397
208
  ]);
398
209
  }
399
- else {
400
- connection.run('INSERT OR REPLACE INTO authored_room_drafts (locator, path, record, files) VALUES (?, ?, ?, ?)', [locator, path, draft.record, owned(draft.files)]);
401
- }
402
- unowned(connection);
403
- return null;
404
- }
405
- function chatDraft(connection, { kept: drafts, dropped }) {
406
- for (const conversation of dropped) {
407
- connection.run('DELETE FROM authored_chat_drafts WHERE conversation = ?', [conversation]);
408
- }
409
- for (const { conversation, record } of drafts) {
410
- connection.run('INSERT OR REPLACE INTO authored_chat_drafts (conversation, record) VALUES (?, ?)', [conversation, record]);
411
- }
412
- return null;
210
+ chatDraftsDropped(connection, conversations);
211
+ return held;
413
212
  }
414
- async function call(connection, { operation, kept: held, files }) {
415
- await storedFiles(connection, files);
416
- if (held === null)
417
- connection.run('DELETE FROM authored_calls WHERE operation = ?', [operation]);
418
- else {
419
- connection.run('INSERT OR REPLACE INTO authored_calls (operation, record, files) VALUES (?, ?, ?)', [operation, held.record, owned(held.files)]);
420
- }
421
- unowned(connection);
422
- return null;
423
- }
424
- function roomWork(connection, locator) {
425
- connection.run('DELETE FROM authored_queues WHERE locator = ?', [locator]);
426
- connection.run('DELETE FROM authored_pending WHERE locator = ?', [locator]);
213
+ function unopened(connection) {
214
+ connection.run(UNOPENED_PARTS);
427
215
  }
428
216
  function fence(connection, locators) {
217
+ fencedWork(connection, locators);
429
218
  for (const locator of locators) {
430
- connection.run('INSERT OR REPLACE INTO authored_fences (locator) VALUES (?)', [locator]);
431
- roomWork(connection, locator);
432
- connection.run('DELETE FROM authored_room_drafts WHERE locator = ?', [locator]);
433
219
  connection.run('DELETE FROM opened_files WHERE locator = ?', [locator]);
434
220
  }
435
- unowned(connection);
221
+ unopened(connection);
436
222
  return fenceRooms(connection, locators);
437
223
  }
438
224
  function erased(connection, { locator, limit }) {
439
225
  return erase(connection, locator, limit);
440
226
  }
441
- function unfenced(connection, locators) {
227
+ function unfencedRooms(connection, locators) {
442
228
  const erased = locators.filter((locator) => connection.rows('SELECT 1 FROM replica_erasing WHERE locator = ? LIMIT 1', [locator])
443
229
  .length === 0);
444
- for (const locator of erased) {
445
- connection.run('DELETE FROM authored_fences WHERE locator = ?', [locator]);
446
- }
230
+ unfenced(connection, erased);
447
231
  return erased;
448
232
  }
449
- function claim(connection, holder) {
450
- const held = fact(connection, 'holder');
451
- if (held !== null)
452
- return held === holder;
453
- remember(connection, 'holder', holder);
454
- return true;
455
- }
456
233
  function end(connection, holder) {
457
234
  ended(connection);
458
- forgottenMessages(connection);
235
+ forgottenConversations(connection);
459
236
  if (holder !== null && claim(connection, holder))
460
237
  return true;
461
- for (const [table] of TABLES)
462
- connection.run(`DELETE FROM ${table}`);
238
+ authoredEmptied(connection);
463
239
  connection.run('DELETE FROM opened_files');
464
- connection.run('DELETE FROM file_parts');
240
+ connection.run('DELETE FROM opened_parts');
465
241
  return false;
466
242
  }
467
- function count(value) {
468
- return typeof value === 'bigint' ? Number(value) : typeof value === 'number' ? value : 0;
469
- }
470
243
  function openedFile(connection, { locator, path, revision }) {
471
244
  const [held] = connection.rows('SELECT key, media_type, byte_length FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NOT NULL', [locator, path, revision]);
472
245
  return held === undefined
@@ -481,7 +254,7 @@ function opening(connection, { key, locator, path, revision, mediaType }) {
481
254
  if (fenced(connection, locator))
482
255
  return false;
483
256
  connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND byte_length IS NULL', [locator, path, revision]);
484
- unowned(connection);
257
+ unopened(connection);
485
258
  connection.run('INSERT INTO opened_files (key, locator, path, revision, media_type) VALUES (?, ?, ?, ?, ?)', [key, locator, path, revision, mediaType]);
486
259
  return true;
487
260
  }
@@ -494,19 +267,23 @@ function fetching(connection, key) {
494
267
  function openedPart(connection, { key, part, bytes }) {
495
268
  if (fetching(connection, key) === null)
496
269
  return false;
497
- storedPart(connection, key, part, bytes);
270
+ connection.run('INSERT INTO opened_parts (key, part, bytes) VALUES (?, ?, ?)', [
271
+ key,
272
+ part,
273
+ bytes,
274
+ ]);
498
275
  return true;
499
276
  }
500
277
  function dropped(connection, key) {
501
278
  connection.run('DELETE FROM opened_files WHERE key = ?', [key]);
502
- connection.run('DELETE FROM file_parts WHERE key = ?', [key]);
279
+ connection.run('DELETE FROM opened_parts WHERE key = ?', [key]);
503
280
  return null;
504
281
  }
505
282
  function keptOpened(connection, { key, sha256, byteLength, parts }) {
506
283
  const fetched = fetching(connection, key);
507
284
  if (fetched === null)
508
285
  return false;
509
- const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM file_parts WHERE key = ?', [key]);
286
+ const [held] = connection.rows('SELECT count(*) AS parts, min(part) AS first, max(part) AS last, coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts WHERE key = ?', [key]);
510
287
  const whole = count(held.parts) === parts &&
511
288
  count(held.bytes) === byteLength &&
512
289
  (parts === 0 || (count(held.first) === 0 && count(held.last) === parts - 1));
@@ -520,27 +297,24 @@ function keptOpened(connection, { key, sha256, byteLength, parts }) {
520
297
  key,
521
298
  ]);
522
299
  connection.run('DELETE FROM opened_files WHERE locator = ? AND path = ? AND revision = ? AND key <> ?', [fetched.locator, fetched.path, fetched.revision, key]);
523
- unowned(connection);
300
+ unopened(connection);
524
301
  return true;
525
302
  }
526
- const UNSENT = [
527
- ['pending-change', 'authored_pending'],
528
- ['call', 'authored_calls'],
529
- ['room-draft', 'authored_room_drafts'],
530
- ['chat-draft', 'authored_chat_drafts'],
531
- ];
532
- function unsent(connection) {
533
- const [held] = connection.rows(`SELECT ${UNSENT.map(([kind, table]) => `(SELECT count(*) FROM ${table}) AS "${kind}"`).join(', ')}`);
534
- return UNSENT.map(([kind]) => ({ kind, count: count(held[kind]) })).filter((work) => work.count > 0);
303
+ function heldPart(connection, key, part) {
304
+ const [held] = connection.rows('SELECT bytes FROM opened_parts WHERE key = ? AND part = ?', [
305
+ key,
306
+ part,
307
+ ]);
308
+ return held?.bytes instanceof Uint8Array ? held.bytes : authoredPart(connection, key, part);
535
309
  }
536
310
  function cleanable(connection) {
537
- const [held] = connection.rows(CLEANABLE_BYTES);
311
+ const [held] = connection.rows('SELECT coalesce(sum(length(bytes)), 0) AS bytes FROM opened_parts');
538
312
  return count(held.bytes);
539
313
  }
540
314
  function cleaned(connection) {
541
315
  connection.run('DELETE FROM opened_files');
542
316
  const freed = cleanable(connection);
543
- unowned(connection);
317
+ unopened(connection);
544
318
  return freed;
545
319
  }
546
320
  function openedHeld(connection) {
@@ -566,51 +340,39 @@ export function answerRuntime(connection, request, spool) {
566
340
  case 'authored.status':
567
341
  return status(connection);
568
342
  case 'authored.moving':
569
- return {
570
- queues: queued(connection),
571
- pending: connection
572
- .rows('SELECT locator, id, batch, state FROM authored_pending WHERE moving = 1 ORDER BY locator')
573
- .map((row) => ({
574
- locator: text(row.locator),
575
- id: text(row.id),
576
- batch: text(row.batch),
577
- state: text(row.state),
578
- })),
579
- };
343
+ return moving(connection);
580
344
  case 'authored.pending':
581
345
  return pendingOf(connection, request.locator, request.id);
582
- case 'authored.batch': {
583
- const [held] = connection.rows('SELECT batch FROM authored_pending WHERE locator = ? AND id = ?', [request.locator, request.id]);
584
- return held === undefined ? null : text(held.batch);
585
- }
346
+ case 'authored.batch':
347
+ return pendingBatch(connection, request.locator, request.id);
586
348
  case 'authored.order':
587
349
  return heldOrder(connection, request.locator);
588
350
  case 'authored.queued':
589
- return texts(connection.rows('SELECT locator FROM authored_queues'), 'locator');
351
+ return queuedLocators(connection);
590
352
  case 'authored.roomDrafts':
591
353
  return roomDraftRecords(connection, request.locator, request.paths);
592
354
  case 'authored.chatDraft.read':
593
355
  return chatDraftRecord(connection, request.conversation);
594
356
  case 'authored.chatDrafts':
595
- return texts(connection.rows('SELECT record FROM authored_chat_drafts'), 'record');
357
+ return chatDraftRecords(connection);
596
358
  case 'authored.calls':
597
- return texts(connection.rows('SELECT record FROM authored_calls'), 'record');
359
+ return callRecords(connection);
598
360
  case 'authored.fences':
599
- return texts(connection.rows('SELECT locator FROM authored_fences'), 'locator');
361
+ return fences(connection);
600
362
  case 'authored.unsent':
601
363
  return unsent(connection);
602
364
  case 'authored.fact':
603
365
  return fact(connection, request.name);
604
366
  case 'authored.file':
605
- return spooled(connection, spool, request);
367
+ return spooled(connection, spool, request.key, request.type);
606
368
  case 'authored.amend':
607
- return amended(connection, request);
369
+ return amended(connection, request.locator, request.id, request.amendment);
608
370
  case 'authored.roomDraft':
609
- return roomDraft(connection, request);
371
+ return roomDraft(connection, request.locator, request.path, request.kept, request.files);
610
372
  case 'authored.chatDraft':
611
- return chatDraft(connection, request);
373
+ return chatDraft(connection, request.kept, request.dropped);
612
374
  case 'authored.call':
613
- return call(connection, request);
375
+ return call(connection, request.operation, request.kept, request.files);
614
376
  case 'authored.remember':
615
377
  return remember(connection, request.name, request.value);
616
378
  case 'authored.claim':
@@ -624,22 +386,24 @@ export function answerRuntime(connection, request, spool) {
624
386
  case 'replica.room':
625
387
  return heldWork(connection, request.locator);
626
388
  case 'replica.covering':
627
- return {
628
- rooms: covering(connection),
629
- queues: queued(connection),
630
- };
389
+ return { ...covering(connection, request.since), queues: queues(connection) };
631
390
  case 'replica.offline':
632
391
  return offlineMode(connection, request.locator);
633
392
  case 'replica.held':
634
- return { held: heldLocators(connection), staged: stagedLocators(connection) };
393
+ return {
394
+ held: [...new Set([...heldLocators(connection), ...authoredLocators(connection)])],
395
+ staged: stagedLocators(connection),
396
+ };
635
397
  case 'replica.demote':
636
398
  return demoted(connection);
637
399
  case 'replica.facts':
638
- return facts(connection);
400
+ return facts(connection, request.names);
639
401
  case 'replica.presentation':
640
402
  return presentation(connection, request.app);
641
403
  case 'replica.query':
642
- return answerQuery(connection, request.plan, request.rooms, request.budget);
404
+ return answerQuery(connection, request.plan, request.rooms, request.budget, request.follows);
405
+ case 'replica.named':
406
+ return namedHandles(connection, request.plan, request.rooms, request.handles);
643
407
  case 'replica.tallies':
644
408
  return roomTallies(connection, request.totals, request.rooms, request.since);
645
409
  case 'replica.entries':
@@ -648,6 +412,8 @@ export function answerRuntime(connection, request, spool) {
648
412
  return typed(connection, request.key, request.view, request.paths);
649
413
  case 'replica.referrers':
650
414
  return referrers(connection, request.key, request.view, request.targets);
415
+ case 'replica.holders':
416
+ return holders(connection, request.key, request.view, request.sought);
651
417
  case 'replica.folders':
652
418
  return folders(connection, request.key, request.paths);
653
419
  case 'replica.typedWithin':
@@ -669,7 +435,7 @@ export function answerRuntime(connection, request, spool) {
669
435
  case 'replica.abandon':
670
436
  return abandon(connection, request.locator);
671
437
  case 'replica.unfence':
672
- return unfenced(connection, request.locators);
438
+ return unfencedRooms(connection, request.locators);
673
439
  case 'replica.release':
674
440
  return release(connection, request.key);
675
441
  case 'replica.rederive':
@@ -701,7 +467,7 @@ export function answerRuntime(connection, request, spool) {
701
467
  case 'opened.held':
702
468
  return openedHeld(connection);
703
469
  case 'file.part':
704
- return filePart(connection, request.key, request.part);
470
+ return heldPart(connection, request.key, request.part);
705
471
  case 'conversation.held':
706
472
  return heldConversations(connection, request.conversations);
707
473
  case 'conversation.keep': {
@@ -716,18 +482,18 @@ export function answerRuntime(connection, request, spool) {
716
482
  return turnArrived(connection, request.conversation, request.turn);
717
483
  case 'conversation.rows':
718
484
  return conversationRows(connection, request.conversations);
719
- case 'conversation.jobs':
720
- return jobMarkers(connection, request.conversation);
721
485
  case 'conversation.tallies':
722
486
  return conversationTallies(connection, request.conversations, request.since);
487
+ case 'conversation.facts':
488
+ return conversationFacts(connection);
489
+ case 'conversation.fact': {
490
+ const { kind: _kind, ...fact } = request;
491
+ return keptFact(connection, fact);
492
+ }
493
+ case 'conversation.stored':
494
+ return storedConversations(connection, null);
723
495
  case 'conversation.drop':
724
- chatDraft(connection, {
725
- kind: 'authored.chatDraft',
726
- kept: [],
727
- dropped: request.conversations,
728
- });
729
- droppedMessages(connection, request.conversations);
730
- return null;
496
+ return droppedConversations(connection, request.conversations);
731
497
  case 'space.probe':
732
498
  return spool.probe(PROBE_BYTES).then(() => null);
733
499
  case 'read.stored':
@@ -1 +1 @@
1
- {"version":3,"file":"tallies.d.ts","sourceRoot":"","sources":["../src/tallies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAI1D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;IAC7E,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAmHpG,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAwBb;AA0BD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,GACZ,iBAAiB,EAAE,CAerB"}
1
+ {"version":3,"file":"tallies.d.ts","sourceRoot":"","sources":["../src/tallies.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAI1D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;IAC7E,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAmHpG,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAwBb;AA0BD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,GACZ,iBAAiB,EAAE,CAerB"}
package/dist/tallies.js CHANGED
@@ -1,5 +1,4 @@
1
- import { instantKey, sql } from '@agentshouse/mdmodel';
2
- import { CHAT_MESSAGE_TYPE, CHAT_TYPE } from './chat-types.js';
1
+ import { CHAT_MESSAGE_TYPE, CHAT_TYPE, instantKey, sql } from '@agentshouse/mdmodel';
3
2
  import { answerQuery, VISIBLE, within } from './compile.js';
4
3
  import { HOUSE_DIRECTORY } from './figures.js';
5
4
  const NONE = { count: 0, size: 0 };
@@ -1,5 +1,6 @@
1
1
  import { type Validation } from '@agentshouse/mdmodel';
2
2
  import { type Composition } from './collection.js';
3
+ import type { Holder, Sought } from './stored.js';
3
4
  type Examined = {
4
5
  readonly path: string;
5
6
  readonly content: string | null;
@@ -23,6 +24,7 @@ type Neighbourhood = {
23
24
  readonly lookup: Lookup;
24
25
  readonly texts: (paths: readonly string[]) => Promise<ReadonlyMap<string, string | null>>;
25
26
  readonly referrers: (targets: readonly string[]) => Promise<readonly string[]>;
27
+ readonly holders: (sought: readonly Sought[]) => Promise<readonly Holder[]>;
26
28
  };
27
29
  export declare function validatedNeighbourhood(changes: readonly Changed[], composition: Composition, source: Neighbourhood): Promise<Validation>;
28
30
  export {};