@agentshouse/mdruntime 0.1.0-c7fd3d0e03135 → 0.1.0-c835af48a82d3

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 (255) hide show
  1. package/README.md +19 -16
  2. package/dist/adapter.d.ts +139 -85
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +7 -10
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +40 -41
  7. package/dist/binary.d.ts +0 -5
  8. package/dist/binary.d.ts.map +1 -1
  9. package/dist/binary.js +1 -1
  10. package/dist/bootstrap.d.ts +30 -11
  11. package/dist/bootstrap.d.ts.map +1 -1
  12. package/dist/bootstrap.js +319 -111
  13. package/dist/chain.d.ts +12 -0
  14. package/dist/chain.d.ts.map +1 -0
  15. package/dist/chain.js +64 -0
  16. package/dist/change-set.d.ts +9 -16
  17. package/dist/change-set.d.ts.map +1 -1
  18. package/dist/change-set.js +11 -89
  19. package/dist/change.d.ts +32 -1
  20. package/dist/change.d.ts.map +1 -1
  21. package/dist/change.js +10 -1
  22. package/dist/chat-types.d.ts +3 -0
  23. package/dist/chat-types.d.ts.map +1 -0
  24. package/dist/chat-types.js +2 -0
  25. package/dist/client.d.ts +26 -11
  26. package/dist/client.d.ts.map +1 -1
  27. package/dist/client.js +85 -7
  28. package/dist/collection.d.ts +11 -21
  29. package/dist/collection.d.ts.map +1 -1
  30. package/dist/collection.js +39 -291
  31. package/dist/compile.d.ts +16 -0
  32. package/dist/compile.d.ts.map +1 -0
  33. package/dist/compile.js +717 -0
  34. package/dist/connection.d.ts +36 -19
  35. package/dist/connection.d.ts.map +1 -1
  36. package/dist/connection.js +3638 -1887
  37. package/dist/context.d.ts +2 -0
  38. package/dist/context.d.ts.map +1 -0
  39. package/dist/{chat/context.js → context.js} +1 -4
  40. package/dist/conversation-row.d.ts +33 -0
  41. package/dist/conversation-row.d.ts.map +1 -0
  42. package/dist/conversation-row.js +47 -0
  43. package/dist/conversation.d.ts +36 -18
  44. package/dist/conversation.d.ts.map +1 -1
  45. package/dist/conversation.js +606 -286
  46. package/dist/digest.d.ts +7 -0
  47. package/dist/digest.d.ts.map +1 -0
  48. package/dist/digest.js +113 -0
  49. package/dist/durability.d.ts +7 -4
  50. package/dist/durability.d.ts.map +1 -1
  51. package/dist/durability.js +5 -0
  52. package/dist/entry.d.ts +5 -2
  53. package/dist/entry.d.ts.map +1 -1
  54. package/dist/entry.js +33 -28
  55. package/dist/figures.d.ts +48 -0
  56. package/dist/figures.d.ts.map +1 -0
  57. package/dist/figures.js +197 -0
  58. package/dist/file.d.ts +2 -19
  59. package/dist/file.d.ts.map +1 -1
  60. package/dist/file.js +7 -122
  61. package/dist/host.d.ts +3 -10
  62. package/dist/host.d.ts.map +1 -1
  63. package/dist/host.js +67 -41
  64. package/dist/identity.d.ts +0 -2
  65. package/dist/identity.d.ts.map +1 -1
  66. package/dist/identity.js +0 -6
  67. package/dist/index.d.ts +24 -13
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +10 -2
  70. package/dist/job.d.ts +33 -0
  71. package/dist/job.d.ts.map +1 -0
  72. package/dist/job.js +54 -0
  73. package/dist/live.d.ts +23 -0
  74. package/dist/live.d.ts.map +1 -0
  75. package/dist/live.js +165 -0
  76. package/dist/media.d.ts +8 -0
  77. package/dist/media.d.ts.map +1 -0
  78. package/dist/media.js +218 -0
  79. package/dist/memory.d.ts +14 -7
  80. package/dist/memory.d.ts.map +1 -1
  81. package/dist/memory.js +238 -108
  82. package/dist/messages.d.ts +52 -0
  83. package/dist/messages.d.ts.map +1 -0
  84. package/dist/messages.js +168 -0
  85. package/dist/model.d.ts +8 -10
  86. package/dist/model.d.ts.map +1 -1
  87. package/dist/model.js +6 -18
  88. package/dist/name.d.ts +4 -0
  89. package/dist/name.d.ts.map +1 -0
  90. package/dist/name.js +122 -0
  91. package/dist/observation.d.ts +15 -2
  92. package/dist/observation.d.ts.map +1 -1
  93. package/dist/observation.js +91 -2
  94. package/dist/opened.d.ts +22 -0
  95. package/dist/opened.d.ts.map +1 -0
  96. package/dist/opened.js +107 -0
  97. package/dist/outcome.d.ts +41 -8
  98. package/dist/outcome.d.ts.map +1 -1
  99. package/dist/outcome.js +41 -2
  100. package/dist/overlay.d.ts +3 -5
  101. package/dist/overlay.d.ts.map +1 -1
  102. package/dist/overlay.js +98 -172
  103. package/dist/{chat/parts.d.ts → parts.d.ts} +11 -9
  104. package/dist/parts.d.ts.map +1 -0
  105. package/dist/{chat/parts.js → parts.js} +45 -46
  106. package/dist/paths.d.ts +1 -0
  107. package/dist/paths.d.ts.map +1 -1
  108. package/dist/paths.js +4 -0
  109. package/dist/query.d.ts +21 -206
  110. package/dist/query.d.ts.map +1 -1
  111. package/dist/query.js +3 -493
  112. package/dist/{chat/questions.d.ts → questions.d.ts} +3 -2
  113. package/dist/questions.d.ts.map +1 -0
  114. package/dist/{chat/questions.js → questions.js} +8 -1
  115. package/dist/reach.d.ts +18 -9
  116. package/dist/reach.d.ts.map +1 -1
  117. package/dist/reach.js +287 -102
  118. package/dist/react.d.ts +4 -3
  119. package/dist/react.d.ts.map +1 -1
  120. package/dist/react.js +2 -14
  121. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  122. package/dist/read.d.ts.map +1 -0
  123. package/dist/{chat/read.js → read.js} +4 -0
  124. package/dist/readiness.d.ts +14 -17
  125. package/dist/readiness.d.ts.map +1 -1
  126. package/dist/readiness.js +2 -8
  127. package/dist/reads.d.ts +34 -10
  128. package/dist/reads.d.ts.map +1 -1
  129. package/dist/reads.js +114 -84
  130. package/dist/recovery.d.ts +3 -2
  131. package/dist/recovery.d.ts.map +1 -1
  132. package/dist/recovery.js +43 -8
  133. package/dist/refresh.d.ts +18 -15
  134. package/dist/refresh.d.ts.map +1 -1
  135. package/dist/refresh.js +143 -58
  136. package/dist/replica.d.ts +57 -36
  137. package/dist/replica.d.ts.map +1 -1
  138. package/dist/replica.js +313 -188
  139. package/dist/room-draft.d.ts +25 -6
  140. package/dist/room-draft.d.ts.map +1 -1
  141. package/dist/room-draft.js +158 -71
  142. package/dist/rows.d.ts +31 -31
  143. package/dist/rows.d.ts.map +1 -1
  144. package/dist/rows.js +59 -123
  145. package/dist/save.d.ts +52 -14
  146. package/dist/save.d.ts.map +1 -1
  147. package/dist/save.js +518 -187
  148. package/dist/search.d.ts +12 -95
  149. package/dist/search.d.ts.map +1 -1
  150. package/dist/search.js +10 -266
  151. package/dist/shared.d.ts +7 -3
  152. package/dist/shared.d.ts.map +1 -1
  153. package/dist/shared.js +119 -66
  154. package/dist/source.d.ts +61 -0
  155. package/dist/source.d.ts.map +1 -0
  156. package/dist/source.js +81 -0
  157. package/dist/status.d.ts +4 -5
  158. package/dist/status.d.ts.map +1 -1
  159. package/dist/status.js +3 -7
  160. package/dist/store.d.ts +151 -114
  161. package/dist/store.d.ts.map +1 -1
  162. package/dist/store.js +360 -720
  163. package/dist/stored.d.ts +156 -0
  164. package/dist/stored.d.ts.map +1 -0
  165. package/dist/stored.js +637 -0
  166. package/dist/tables.d.ts +407 -0
  167. package/dist/tables.d.ts.map +1 -0
  168. package/dist/tables.js +724 -0
  169. package/dist/tallies.d.ts +18 -0
  170. package/dist/tallies.d.ts.map +1 -0
  171. package/dist/tallies.js +129 -0
  172. package/dist/transfer.d.ts +0 -5
  173. package/dist/transfer.d.ts.map +1 -1
  174. package/dist/turn.d.ts +5 -3
  175. package/dist/turn.d.ts.map +1 -1
  176. package/dist/turn.js +51 -21
  177. package/dist/validation.d.ts +29 -0
  178. package/dist/validation.d.ts.map +1 -0
  179. package/dist/validation.js +104 -0
  180. package/dist/windows.d.ts +1 -16
  181. package/dist/windows.d.ts.map +1 -1
  182. package/dist/windows.js +2 -79
  183. package/dist/wire.d.ts +40 -5
  184. package/dist/wire.d.ts.map +1 -1
  185. package/dist/wire.js +13 -2
  186. package/package.json +18 -19
  187. package/AGENTS.md +0 -299
  188. package/dist/acquisition.d.ts +0 -14
  189. package/dist/acquisition.d.ts.map +0 -1
  190. package/dist/acquisition.js +0 -24
  191. package/dist/chat/acts.d.ts +0 -33
  192. package/dist/chat/acts.d.ts.map +0 -1
  193. package/dist/chat/acts.js +0 -36
  194. package/dist/chat/context.d.ts +0 -3
  195. package/dist/chat/context.d.ts.map +0 -1
  196. package/dist/chat/earlier.d.ts +0 -10
  197. package/dist/chat/earlier.d.ts.map +0 -1
  198. package/dist/chat/earlier.js +0 -54
  199. package/dist/chat/input.d.ts +0 -9
  200. package/dist/chat/input.d.ts.map +0 -1
  201. package/dist/chat/input.js +0 -99
  202. package/dist/chat/kit.d.ts +0 -61
  203. package/dist/chat/kit.d.ts.map +0 -1
  204. package/dist/chat/kit.js +0 -123
  205. package/dist/chat/lasting.d.ts +0 -6
  206. package/dist/chat/lasting.d.ts.map +0 -1
  207. package/dist/chat/lasting.js +0 -19
  208. package/dist/chat/list.d.ts +0 -27
  209. package/dist/chat/list.d.ts.map +0 -1
  210. package/dist/chat/list.js +0 -99
  211. package/dist/chat/markdown.d.ts +0 -20
  212. package/dist/chat/markdown.d.ts.map +0 -1
  213. package/dist/chat/markdown.js +0 -188
  214. package/dist/chat/message.d.ts +0 -6
  215. package/dist/chat/message.d.ts.map +0 -1
  216. package/dist/chat/message.js +0 -192
  217. package/dist/chat/messages.d.ts +0 -22
  218. package/dist/chat/messages.d.ts.map +0 -1
  219. package/dist/chat/messages.js +0 -155
  220. package/dist/chat/name.d.ts +0 -6
  221. package/dist/chat/name.d.ts.map +0 -1
  222. package/dist/chat/name.js +0 -37
  223. package/dist/chat/opened.d.ts +0 -11
  224. package/dist/chat/opened.d.ts.map +0 -1
  225. package/dist/chat/opened.js +0 -17
  226. package/dist/chat/overlay.d.ts +0 -31
  227. package/dist/chat/overlay.d.ts.map +0 -1
  228. package/dist/chat/overlay.js +0 -97
  229. package/dist/chat/parts.d.ts.map +0 -1
  230. package/dist/chat/process.d.ts +0 -20
  231. package/dist/chat/process.d.ts.map +0 -1
  232. package/dist/chat/process.js +0 -32
  233. package/dist/chat/provider.d.ts +0 -63
  234. package/dist/chat/provider.d.ts.map +0 -1
  235. package/dist/chat/provider.js +0 -635
  236. package/dist/chat/question.d.ts +0 -9
  237. package/dist/chat/question.d.ts.map +0 -1
  238. package/dist/chat/question.js +0 -69
  239. package/dist/chat/questions.d.ts.map +0 -1
  240. package/dist/chat/read.d.ts.map +0 -1
  241. package/dist/chat/ready.d.ts +0 -34
  242. package/dist/chat/ready.d.ts.map +0 -1
  243. package/dist/chat/ready.js +0 -91
  244. package/dist/chat/style.d.ts +0 -4
  245. package/dist/chat/style.d.ts.map +0 -1
  246. package/dist/chat/style.js +0 -302
  247. package/dist/chat.d.ts +0 -14
  248. package/dist/chat.d.ts.map +0 -1
  249. package/dist/chat.js +0 -8
  250. package/dist/fence.d.ts +0 -6
  251. package/dist/fence.d.ts.map +0 -1
  252. package/dist/fence.js +0 -10
  253. package/dist/read-side.d.ts +0 -25
  254. package/dist/read-side.d.ts.map +0 -1
  255. package/dist/read-side.js +0 -767
@@ -0,0 +1,18 @@
1
+ import { type QueryRoom } from './compile.js';
2
+ import type { GroupTotal, Plan } from './query.js';
3
+ import type { Connection } from './tables.js';
4
+ export type RoomTally = {
5
+ readonly key: number;
6
+ readonly documents: GroupTotal;
7
+ readonly files: GroupTotal;
8
+ readonly documentTimes: readonly (readonly [string | null, string | null])[];
9
+ readonly chatTimes: readonly string[];
10
+ readonly messageTimes: readonly string[];
11
+ };
12
+ export type ConversationTally = {
13
+ readonly conversation: string;
14
+ readonly said: readonly string[];
15
+ };
16
+ export declare function roomTallies(connection: Connection, totals: Plan, rooms: readonly QueryRoom[], since: string): RoomTally[];
17
+ export declare function conversationTallies(connection: Connection, conversations: readonly string[] | null, since: string): ConversationTally[];
18
+ //# sourceMappingURL=tallies.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,129 @@
1
+ import { instantKey, sql } from '@agentshouse/mdmodel';
2
+ import { CHAT_MESSAGE_TYPE, CHAT_TYPE } from './chat-types.js';
3
+ import { answerQuery, VISIBLE, within } from './compile.js';
4
+ import { HOUSE_DIRECTORY } from './figures.js';
5
+ const NONE = { count: 0, size: 0 };
6
+ const { all, fragment, joined } = sql;
7
+ function instant(value) {
8
+ return typeof value === 'string' ? value : null;
9
+ }
10
+ function held(alias, keys) {
11
+ const reserved = within(alias, HOUSE_DIRECTORY);
12
+ return all([
13
+ fragment(`${alias}.key IN (SELECT value FROM json_each(?))`, [JSON.stringify(keys)]),
14
+ fragment(VISIBLE(alias)),
15
+ fragment(`NOT ${reserved.sql}`, reserved.bind),
16
+ ]);
17
+ }
18
+ function valued(alias, document, field) {
19
+ return joined([
20
+ fragment(`${alias}.doc = ${document}.id AND `),
21
+ sql.grouped(sql.placed(alias, field, 'exact')),
22
+ fragment(` AND ${alias}.item = -1`),
23
+ ], '');
24
+ }
25
+ function inboxed(card) {
26
+ return joined([
27
+ fragment('EXISTS (SELECT 1 FROM replica_values i WHERE '),
28
+ valued('i', card, '/inbox'),
29
+ fragment(" AND i.kind = 'string')"),
30
+ ], '');
31
+ }
32
+ function rowsOf(connection, query) {
33
+ return connection.rows(query.sql, query.bind);
34
+ }
35
+ function documentTimes(connection, keys, since) {
36
+ return rowsOf(connection, joined([
37
+ fragment('SELECT d.key AS key, d.created_instant AS created, d.changed_instant AS changed FROM replica_entries d WHERE '),
38
+ held('d', keys),
39
+ fragment(" AND d.binary IS NULL AND COALESCE(d.type, '') NOT IN (?, ?) AND (d.created_instant >= ? OR d.changed_instant >= ?)", [CHAT_TYPE, CHAT_MESSAGE_TYPE, since, since]),
40
+ ], ''));
41
+ }
42
+ function chatTimes(connection, keys, since) {
43
+ return rowsOf(connection, joined([
44
+ fragment('SELECT d.key AS key, d.created_instant AS at FROM replica_entries d WHERE '),
45
+ held('d', keys),
46
+ fragment(' AND d.type = ? AND d.created_instant >= ? AND ', [CHAT_TYPE, since]),
47
+ inboxed('d'),
48
+ ], ''));
49
+ }
50
+ function messageTimes(connection, keys, since) {
51
+ return rowsOf(connection, joined([
52
+ fragment('SELECT m.key AS key, s.instant AS at FROM replica_entries m JOIN replica_values s ON '),
53
+ valued('s', 'm', '/sent_at'),
54
+ fragment(' AND s.instant >= ? JOIN replica_values r ON ', [since]),
55
+ valued('r', 'm', '/direction'),
56
+ fragment(" AND r.kind = 'string' AND r.value = 'in' WHERE "),
57
+ held('m', keys),
58
+ fragment(` AND m.type = ? AND EXISTS (SELECT 1 FROM replica_entries c WHERE c.key = m.key AND c.type = ? AND ${VISIBLE('c')} AND c.folder = m.folder AND `, [CHAT_MESSAGE_TYPE, CHAT_TYPE]),
59
+ inboxed('c'),
60
+ fragment(')'),
61
+ ], ''));
62
+ }
63
+ function byKey(rows, read) {
64
+ const kept = new Map();
65
+ for (const row of rows) {
66
+ const key = Number(row.key);
67
+ const list = kept.get(key) ?? [];
68
+ list.push(read(row));
69
+ kept.set(key, list);
70
+ }
71
+ return kept;
72
+ }
73
+ export function roomTallies(connection, totals, rooms, since) {
74
+ const keys = rooms.map(({ key }) => key);
75
+ const from = instantKey(since);
76
+ const answered = answerQuery(connection, totals, rooms);
77
+ const summed = new Map(('groups' in answered ? answered.groups : []).map((group) => [String(group.key[0]), group]));
78
+ const documents = byKey(documentTimes(connection, keys, from), (row) => [instant(row.created), instant(row.changed)]);
79
+ const chats = byKey(chatTimes(connection, keys, from), (row) => instant(row.at));
80
+ const messages = byKey(messageTimes(connection, keys, from), (row) => instant(row.at));
81
+ return rooms.map(({ locator, key }) => {
82
+ const total = summed.get(locator);
83
+ return {
84
+ key,
85
+ documents: total?.documents ?? NONE,
86
+ files: total?.files ?? NONE,
87
+ documentTimes: documents.get(key) ?? [],
88
+ chatTimes: chats.get(key) ?? [],
89
+ messageTimes: messages.get(key) ?? [],
90
+ };
91
+ });
92
+ }
93
+ const ACCEPTED = "message ->> '$.accepted_at'";
94
+ const NEWER = 'ORDER BY n.position DESC, n.identity DESC LIMIT 1';
95
+ const SAID = `WITH RECURSIVE
96
+ named(conversation) AS (SELECT value FROM json_each(?)),
97
+ walk(id, conversation, position, identity, at) AS (
98
+ SELECT m.id, m.conversation, m.position, m.identity, m.${ACCEPTED}
99
+ FROM named JOIN conversation_messages m ON m.id = (
100
+ SELECT n.id FROM conversation_messages n WHERE n.conversation = named.conversation ${NEWER}
101
+ )
102
+ UNION ALL
103
+ SELECT m.id, m.conversation, m.position, m.identity, m.${ACCEPTED}
104
+ FROM walk JOIN conversation_messages m ON m.id = (
105
+ SELECT n.id FROM conversation_messages n WHERE n.conversation = walk.conversation
106
+ AND (n.position < walk.position OR (n.position = walk.position AND n.identity < walk.identity))
107
+ ${NEWER}
108
+ )
109
+ WHERE julianday(walk.at) >= julianday(?)
110
+ )
111
+ SELECT walk.conversation AS conversation, walk.at AS at
112
+ FROM walk JOIN conversation_messages m ON m.id = walk.id
113
+ WHERE m.message ->> '$.role' IN ('user', 'assistant') AND julianday(walk.at) >= julianday(?)`;
114
+ export function conversationTallies(connection, conversations, since) {
115
+ const named = conversations ??
116
+ connection
117
+ .rows('SELECT DISTINCT conversation FROM conversation_messages')
118
+ .map((row) => String(row.conversation));
119
+ const from = instantKey(since);
120
+ const said = new Map();
121
+ for (const row of connection.rows(SAID, [JSON.stringify(named), since, since])) {
122
+ const at = instantKey(row.at);
123
+ if (at === null || at < from)
124
+ continue;
125
+ const conversation = String(row.conversation);
126
+ said.set(conversation, [...(said.get(conversation) ?? []), at]);
127
+ }
128
+ return named.map((conversation) => ({ conversation, said: said.get(conversation) ?? [] }));
129
+ }
@@ -1,10 +1,5 @@
1
- import type { Refusal } from '@agentshouse/mdmodel';
2
1
  export type Unconfirmed = {
3
2
  kind: 'unconfirmed';
4
3
  };
5
- export type Refused = {
6
- kind: 'refused';
7
- refusal: Refusal;
8
- };
9
4
  export declare const unconfirmed: Unconfirmed;
10
5
  //# sourceMappingURL=transfer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D,eAAO,MAAM,WAAW,EAAE,WAAqC,CAAC"}
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAElD,eAAO,MAAM,WAAW,EAAE,WAAqC,CAAC"}
package/dist/turn.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export declare function yielded(): Promise<void>;
2
2
  export declare const ROW_WEIGHT = 256;
3
3
  export type Later<T> = T | Promise<T>;
4
- export declare function after<T, R>(value: Later<T>, next: (value: T) => R): Later<R>;
5
- export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number): Later<void>;
6
- export declare function inChunks<T>(items: readonly T[], weigh: (item: T) => number, each: (chunk: readonly T[]) => void): Promise<void>;
4
+ export declare function after<T, R>(value: Later<T>, next: (value: T) => Later<R>): Later<R>;
5
+ export declare function paced(): (weight: number) => Later<void>;
6
+ export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number, ended?: () => void, paused?: () => Promise<void>): Later<void>;
7
+ export declare function finished<R>(steps: Generator<number, R, void>): R;
8
+ export declare function stepped<R>(steps: Generator<number, R, void>): Later<R>;
7
9
  //# sourceMappingURL=turn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../src/turn.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CASvC;AAID,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE5E;AAaD,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAOrF;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC1B,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC,CAUf"}
1
+ {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../src/turn.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CASvC;AAOD,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAEnF;AAmBD,wBAAgB,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,CAGvD;AAsBD,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EACzB,KAAK,GAAE,MAAM,IAAe,EAC5B,MAAM,GAAE,MAAM,OAAO,CAAC,IAAI,CAAW,GACpC,KAAK,CAAC,IAAI,CAAC,CAUb;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAIhE;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAStE"}
package/dist/turn.js CHANGED
@@ -5,41 +5,71 @@ export function yielded() {
5
5
  channel.port1.close();
6
6
  resolve();
7
7
  };
8
- channel.port2.postMessage(null);
8
+ structuredClone(channel.port2, { transfer: [channel.port2] }).postMessage(null);
9
9
  });
10
10
  }
11
11
  const UNIT = 1 << 20;
12
+ // A unit of runtime work ends within one 60 Hz frame so a port's next message waits at most a frame.
13
+ const SLICE_MS = 16;
12
14
  export const ROW_WEIGHT = 256;
13
15
  export function after(value, next) {
14
16
  return value instanceof Promise ? value.then(next) : next(value);
15
17
  }
16
- async function resumed(iterator, each) {
17
- let spent = UNIT;
18
- for (let next = iterator.next(); next.done !== true; next = iterator.next()) {
19
- if (spent >= UNIT) {
20
- await yielded();
18
+ function spending() {
19
+ let spent = 0;
20
+ let since = performance.now();
21
+ return {
22
+ spend(weight) {
23
+ spent += weight;
24
+ return spent >= UNIT || performance.now() - since >= SLICE_MS;
25
+ },
26
+ restart() {
21
27
  spent = 0;
28
+ since = performance.now();
29
+ },
30
+ };
31
+ }
32
+ export function paced() {
33
+ const spent = spending();
34
+ return (weight) => (spent.spend(weight) ? yielded().then(() => spent.restart()) : undefined);
35
+ }
36
+ async function resumed(iterator, each, ended, paused) {
37
+ const spent = spending();
38
+ for (let due = true;;) {
39
+ if (due) {
40
+ await paused();
41
+ spent.restart();
22
42
  }
23
- spent += each(next.value);
43
+ const next = iterator.next();
44
+ if (next.done === true)
45
+ break;
46
+ due = spent.spend(each(next.value));
47
+ if (due)
48
+ ended();
24
49
  }
50
+ ended();
25
51
  }
26
- export function inUnits(items, each) {
52
+ export function inUnits(items, each, ended = () => { }, paused = yielded) {
27
53
  const iterator = items[Symbol.iterator]();
28
- let spent = 0;
54
+ const spent = spending();
29
55
  for (let next = iterator.next(); next.done !== true; next = iterator.next()) {
30
- spent += each(next.value);
31
- if (spent >= UNIT)
32
- return resumed(iterator, each);
56
+ if (spent.spend(each(next.value))) {
57
+ ended();
58
+ return resumed(iterator, each, ended, paused);
59
+ }
33
60
  }
61
+ ended();
34
62
  }
35
- export async function inChunks(items, weigh, each) {
36
- for (let at = 0; at < items.length;) {
37
- await yielded();
38
- const chunk = [];
39
- for (let spent = 0; at < items.length && spent < UNIT; at += 1) {
40
- chunk.push(items[at]);
41
- spent += weigh(items[at]);
42
- }
43
- each(chunk);
63
+ export function finished(steps) {
64
+ for (let step = steps.next();; step = steps.next()) {
65
+ if (step.done === true)
66
+ return step.value;
44
67
  }
45
68
  }
69
+ export function stepped(steps) {
70
+ let result;
71
+ const driven = function* () {
72
+ result = yield* steps;
73
+ };
74
+ return after(inUnits(driven(), (weight) => weight), () => result);
75
+ }
@@ -0,0 +1,29 @@
1
+ import { type Validation } from '@agentshouse/mdmodel';
2
+ import { type Composition } from './collection.js';
3
+ type Examined = {
4
+ readonly path: string;
5
+ readonly content: string | null;
6
+ };
7
+ export type Typed = {
8
+ readonly type: string | undefined;
9
+ readonly binary: boolean;
10
+ };
11
+ export type Walk = (after: string | null) => Promise<{
12
+ readonly entries: readonly Examined[];
13
+ readonly next: string | null;
14
+ }>;
15
+ export type Lookup = (paths: readonly string[]) => Promise<ReadonlyMap<string, Typed>>;
16
+ export declare function validatedCollection(walk: Walk, lookup: Lookup, composition: Composition): Promise<Validation>;
17
+ export type Changed = {
18
+ readonly path: string;
19
+ readonly was: string | null | undefined;
20
+ readonly now: string | null | undefined;
21
+ };
22
+ type Neighbourhood = {
23
+ readonly lookup: Lookup;
24
+ readonly texts: (paths: readonly string[]) => Promise<ReadonlyMap<string, string | null>>;
25
+ readonly referrers: (targets: readonly string[]) => Promise<readonly string[]>;
26
+ };
27
+ export declare function validatedNeighbourhood(changes: readonly Changed[], composition: Composition, source: Neighbourhood): Promise<Validation>;
28
+ export {};
29
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM7D,KAAK,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,IAAI,GAAG,CACjB,KAAK,EAAE,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAAC;AAEtF,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAwBvF,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,UAAU,CAAC,CA6CrB;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1F,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;CAChF,CAAC;AAkBF,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
@@ -0,0 +1,104 @@
1
+ import { assess, parse, parseFrontmatter, verdicts, } from '@agentshouse/mdmodel';
2
+ import { selected } from './collection.js';
3
+ import { paced, ROW_WEIGHT, yielded } from './turn.js';
4
+ const NO_TYPES = { types: {} };
5
+ function modelOf(model) {
6
+ return model.status === 'unavailable' ? NO_TYPES : { types: model.types };
7
+ }
8
+ function typedText(read) {
9
+ return read.ok && read.document.type !== undefined && read.document.type !== 'any';
10
+ }
11
+ function partVerdict(part) {
12
+ return part.unmodeled !== null
13
+ ? { verdict: 'refuse', rule: 'model-unavailable', file: part.unmodeled }
14
+ : part.judged.verdict();
15
+ }
16
+ export async function validatedCollection(walk, lookup, composition) {
17
+ const collection = { model: composition.model, judged: verdicts(), unmodeled: null };
18
+ const selection = composition.selection === null
19
+ ? null
20
+ : { model: composition.selection.model, judged: verdicts(), unmodeled: null };
21
+ const partOf = (path) => selection !== null && selected(composition, path) ? selection : collection;
22
+ const pace = paced();
23
+ for (let after = null;;) {
24
+ const { entries, next } = await walk(after);
25
+ const assessed = [];
26
+ for (const { path, content } of entries) {
27
+ if (content === null)
28
+ continue;
29
+ const part = partOf(path);
30
+ const parsed = parse(content, path);
31
+ if (part.model.status === 'unavailable' && part.unmodeled === null && typedText(parsed)) {
32
+ part.unmodeled = path;
33
+ }
34
+ const assessment = assess(path, parsed, false, modelOf(part.model), {
35
+ anyRoom: true,
36
+ typedPaths: composition.typedPaths,
37
+ });
38
+ assessed.push({ part, assessment });
39
+ await pace(content.length + assessment.targets.length * ROW_WEIGHT);
40
+ }
41
+ const targets = [...new Set(assessed.flatMap(({ assessment }) => assessment.targets))];
42
+ const known = await lookup(targets);
43
+ for (const { part, assessment } of assessed) {
44
+ const within = (path) => partOf(path) === part;
45
+ part.judged.add(assessment, (path) => (within(path) ? known.get(path)?.type : undefined), (path) => within(path) && known.get(path)?.binary === true);
46
+ await pace((assessment.targets.length + 1) * ROW_WEIGHT);
47
+ }
48
+ if (next === null)
49
+ break;
50
+ after = next;
51
+ await yielded();
52
+ }
53
+ const judged = [partVerdict(collection), ...(selection === null ? [] : [partVerdict(selection)])];
54
+ const refusals = judged.filter((verdict) => verdict.verdict === 'refuse');
55
+ if (refusals.length === 0)
56
+ return judged[0];
57
+ return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
58
+ }
59
+ function declared(content) {
60
+ if (content === undefined || content === null)
61
+ return undefined;
62
+ const read = parseFrontmatter(content);
63
+ return read.ok ? (read.frontmatter.type ?? 'any') : undefined;
64
+ }
65
+ function shifted({ was, now }) {
66
+ return ((now === undefined) !== (was === undefined) ||
67
+ (now === null) !== (was === null) ||
68
+ declared(now) !== declared(was));
69
+ }
70
+ const PAGE_TEXT = 1 << 20;
71
+ export async function validatedNeighbourhood(changes, composition, source) {
72
+ const pace = paced();
73
+ const changedAt = new Set();
74
+ const moved = [];
75
+ for (const change of changes) {
76
+ changedAt.add(change.path);
77
+ if (shifted(change))
78
+ moved.push(change.path);
79
+ await pace((change.now?.length ?? 0) + (change.was?.length ?? 0) + ROW_WEIGHT);
80
+ }
81
+ const referring = moved.length === 0
82
+ ? []
83
+ : (await source.referrers(moved)).filter((path) => !changedAt.has(path));
84
+ const texts = await source.texts(referring);
85
+ const total = changes.length + referring.length;
86
+ let at = 0;
87
+ const walk = async () => {
88
+ const entries = [];
89
+ let text = 0;
90
+ while (at < total && text < PAGE_TEXT) {
91
+ const change = changes[at];
92
+ const path = change?.path ?? referring[at - changes.length];
93
+ const content = change === undefined ? texts.get(path) : change.now;
94
+ at += 1;
95
+ text += ROW_WEIGHT;
96
+ if (content === undefined || content === null)
97
+ continue;
98
+ entries.push({ path, content });
99
+ text += content.length;
100
+ }
101
+ return { entries, next: at < total ? String(at) : null };
102
+ };
103
+ return validatedCollection(walk, source.lookup, composition);
104
+ }
package/dist/windows.d.ts CHANGED
@@ -1,26 +1,11 @@
1
1
  export declare const MAXIMUM_WINDOW = 1000;
2
- export declare const FROM_START = "[]";
2
+ export declare const FROM_START: string;
3
3
  export declare function capped(limit: number | null | undefined): number;
4
- export type Ordering = {
5
- readonly direction: 'asc' | 'desc';
6
- readonly nulls: 'first' | 'last';
7
- readonly stringSort: 'lexical' | 'locale';
8
- readonly locale: string | undefined;
9
- readonly localeOptions: Intl.CollatorOptions | undefined;
10
- };
11
- export type Windowed<T> = {
12
- readonly kept: readonly T[];
13
- readonly next: string | undefined;
14
- };
15
4
  interface Placed {
16
5
  readonly position: string;
17
6
  readonly identity: string;
18
7
  }
19
8
  export declare function messageOrder(left: Placed, right: Placed): number;
20
9
  export declare function precedes(message: Placed, before: readonly [string, string] | null): boolean;
21
- export declare function beyond(values: readonly unknown[], cursor: readonly unknown[], orderings: readonly Ordering[]): boolean;
22
- export declare function cursorOf(values: readonly unknown[]): string;
23
- export declare function decodedCursor(text: string): readonly unknown[] | null;
24
- export declare function windowed<T>(entries: readonly T[], limit: number | null, after: string | undefined, cursor: (entry: T) => string): Windowed<T>;
25
10
  export {};
26
11
  //# sourceMappingURL=windows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../src/windows.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,UAAU,OAAO,CAAC;AAE/B,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAE/D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE7F,UAAU,MAAM;IACd,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAE3F;AA0CD,wBAAgB,MAAM,CACpB,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,SAAS,EAAE,SAAS,QAAQ,EAAE,GAC7B,OAAO,CAMT;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAE3D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,GAAG,IAAI,CAOrE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EACxB,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAC3B,QAAQ,CAAC,CAAC,CAAC,CAOb"}
1
+ {"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../src/windows.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,UAAU,QAAe,CAAC;AAEvC,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAE/D;AAED,UAAU,MAAM;IACd,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAE3F"}
package/dist/windows.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { cursorOf } from '@agentshouse/mdmodel';
1
2
  export const MAXIMUM_WINDOW = 1000;
2
- export const FROM_START = '[]';
3
+ export const FROM_START = cursorOf([]);
3
4
  export function capped(limit) {
4
5
  return limit == null ? MAXIMUM_WINDOW : Math.min(limit, MAXIMUM_WINDOW);
5
6
  }
@@ -13,81 +14,3 @@ export function messageOrder(left, right) {
13
14
  export function precedes(message, before) {
14
15
  return before === null || messageOrder(message, { position: before[0], identity: before[1] }) < 0;
15
16
  }
16
- function ascending(left, right, ordering) {
17
- if (left == null && right == null)
18
- return 0;
19
- if (left == null)
20
- return ordering.nulls === 'first' ? -1 : 1;
21
- if (right == null)
22
- return ordering.nulls === 'first' ? 1 : -1;
23
- if (typeof left === 'string' && typeof right === 'string' && ordering.stringSort === 'locale') {
24
- return left.localeCompare(right, ordering.locale, ordering.localeOptions);
25
- }
26
- if (Array.isArray(left) && Array.isArray(right)) {
27
- for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
28
- const result = ascending(left[at], right[at], ordering);
29
- if (result !== 0)
30
- return result;
31
- }
32
- return left.length - right.length;
33
- }
34
- if (typeof left === 'object')
35
- return typeof right === 'object' ? 0 : 1;
36
- if (typeof right === 'object')
37
- return -1;
38
- const held = left;
39
- const other = right;
40
- if (held < other)
41
- return -1;
42
- if (held > other)
43
- return 1;
44
- return 0;
45
- }
46
- function compared(left, right, ordering) {
47
- if (ordering.direction === 'asc')
48
- return ascending(left, right, ordering);
49
- return ascending(right, left, {
50
- ...ordering,
51
- nulls: ordering.nulls === 'first' ? 'last' : 'first',
52
- });
53
- }
54
- function keyCompared(left, right) {
55
- if (typeof left !== typeof right)
56
- return typeof left === 'string' ? -1 : 1;
57
- const held = left;
58
- const other = right;
59
- if (held < other)
60
- return -1;
61
- if (held > other)
62
- return 1;
63
- return 0;
64
- }
65
- export function beyond(values, cursor, orderings) {
66
- for (let at = 0; at < orderings.length; at += 1) {
67
- const result = compared(values[at], cursor[at], orderings[at]);
68
- if (result !== 0)
69
- return result > 0;
70
- }
71
- return keyCompared(values[orderings.length], cursor[orderings.length]) > 0;
72
- }
73
- export function cursorOf(values) {
74
- return JSON.stringify(values);
75
- }
76
- export function decodedCursor(text) {
77
- try {
78
- const decoded = JSON.parse(text);
79
- return Array.isArray(decoded) ? decoded : null;
80
- }
81
- catch {
82
- return null;
83
- }
84
- }
85
- export function windowed(entries, limit, after, cursor) {
86
- if (limit === null || entries.length <= limit)
87
- return { kept: entries, next: undefined };
88
- const kept = entries.slice(0, limit);
89
- return {
90
- kept,
91
- next: kept.length === 0 ? (after ?? FROM_START) : cursor(kept[kept.length - 1]),
92
- };
93
- }
package/dist/wire.d.ts CHANGED
@@ -34,10 +34,18 @@ declare const MEMBERS: {
34
34
  readonly reach: 'within';
35
35
  readonly effect: 'write';
36
36
  };
37
+ readonly saveParts: {
38
+ readonly reach: 'within';
39
+ readonly effect: 'write';
40
+ };
37
41
  readonly history: {
38
42
  readonly reach: 'within';
39
43
  readonly effect: 'read';
40
44
  };
45
+ readonly resolve: {
46
+ readonly reach: 'within';
47
+ readonly effect: 'read';
48
+ };
41
49
  readonly 'binaryFile.read': {
42
50
  readonly reach: 'within';
43
51
  readonly effect: 'read';
@@ -46,7 +54,15 @@ declare const MEMBERS: {
46
54
  readonly reach: 'within';
47
55
  readonly effect: 'read';
48
56
  };
49
- readonly 'binaryFile.readReference': {
57
+ readonly 'binaryFile.show': {
58
+ readonly reach: 'within';
59
+ readonly effect: 'read';
60
+ };
61
+ readonly 'binaryFile.attach': {
62
+ readonly reach: 'within';
63
+ readonly effect: 'action';
64
+ };
65
+ readonly 'binaryFile.part': {
50
66
  readonly reach: 'within';
51
67
  readonly effect: 'read';
52
68
  };
@@ -62,6 +78,22 @@ declare const MEMBERS: {
62
78
  readonly reach: 'whole';
63
79
  readonly effect: 'read';
64
80
  };
81
+ readonly cleanUp: {
82
+ readonly reach: 'whole';
83
+ readonly effect: 'write';
84
+ };
85
+ readonly unsent: {
86
+ readonly reach: 'whole';
87
+ readonly effect: 'read';
88
+ };
89
+ readonly reset: {
90
+ readonly reach: 'whole';
91
+ readonly effect: 'write';
92
+ };
93
+ readonly readAgain: {
94
+ readonly reach: 'whole';
95
+ readonly effect: 'read';
96
+ };
65
97
  readonly persistence: {
66
98
  readonly reach: 'runtime';
67
99
  readonly effect: 'read';
@@ -130,10 +162,6 @@ declare const MEMBERS: {
130
162
  readonly reach: 'within';
131
163
  readonly effect: 'action';
132
164
  };
133
- readonly 'conversation.cancel': {
134
- readonly reach: 'within';
135
- readonly effect: 'action';
136
- };
137
165
  readonly 'conversation.delete': {
138
166
  readonly reach: 'within';
139
167
  readonly effect: 'action';
@@ -142,6 +170,10 @@ declare const MEMBERS: {
142
170
  readonly reach: 'within';
143
171
  readonly effect: 'write';
144
172
  };
173
+ readonly 'chatDraft.prepend': {
174
+ readonly reach: 'within';
175
+ readonly effect: 'write';
176
+ };
145
177
  readonly 'chatDraft.discard': {
146
178
  readonly reach: 'within';
147
179
  readonly effect: 'write';
@@ -156,6 +188,7 @@ declare const TOPICS: {
156
188
  readonly 'sync-status': 'within';
157
189
  readonly 'service-mode': 'runtime';
158
190
  readonly member: 'runtime';
191
+ readonly 'authority-changes': 'runtime';
159
192
  readonly query: 'within';
160
193
  readonly queue: 'within';
161
194
  readonly 'room-drafts': 'within';
@@ -163,6 +196,8 @@ declare const TOPICS: {
163
196
  readonly conversation: 'within';
164
197
  readonly conversations: 'within';
165
198
  readonly agents: 'within';
199
+ readonly figures: 'whole';
200
+ readonly read: 'whole';
166
201
  };
167
202
  export declare const WIRE: {
168
203
  readonly members: Readonly<Record<string, WireCall>>;