@agentshouse/mdruntime 0.1.0-c2aaa9c0e3ca4 → 0.1.0-c2e8a6f99866d

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 (214) hide show
  1. package/AGENTS.md +289 -276
  2. package/README.md +9 -8
  3. package/dist/adapter.d.ts +91 -23
  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/attempt.d.ts.map +1 -1
  9. package/dist/attempt.js +14 -1
  10. package/dist/bootstrap.d.ts +16 -8
  11. package/dist/bootstrap.d.ts.map +1 -1
  12. package/dist/bootstrap.js +102 -47
  13. package/dist/chain.d.ts +11 -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 -8
  17. package/dist/change-set.d.ts.map +1 -1
  18. package/dist/change-set.js +10 -59
  19. package/dist/change.d.ts +31 -1
  20. package/dist/change.d.ts.map +1 -1
  21. package/dist/change.js +10 -1
  22. package/dist/chat/acts.d.ts +3 -4
  23. package/dist/chat/acts.d.ts.map +1 -1
  24. package/dist/chat/acts.js +10 -10
  25. package/dist/chat/earlier.d.ts +10 -0
  26. package/dist/chat/earlier.d.ts.map +1 -0
  27. package/dist/chat/earlier.js +54 -0
  28. package/dist/chat/house.d.ts +25 -0
  29. package/dist/chat/house.d.ts.map +1 -0
  30. package/dist/chat/house.js +38 -0
  31. package/dist/chat/input.d.ts +3 -1
  32. package/dist/chat/input.d.ts.map +1 -1
  33. package/dist/chat/input.js +11 -18
  34. package/dist/chat/kit.d.ts +2 -1
  35. package/dist/chat/kit.d.ts.map +1 -1
  36. package/dist/chat/kit.js +3 -3
  37. package/dist/chat/list.d.ts +9 -1
  38. package/dist/chat/list.d.ts.map +1 -1
  39. package/dist/chat/list.js +53 -9
  40. package/dist/chat/markdown.d.ts +3 -1
  41. package/dist/chat/markdown.d.ts.map +1 -1
  42. package/dist/chat/markdown.js +85 -26
  43. package/dist/chat/message.d.ts +1 -0
  44. package/dist/chat/message.d.ts.map +1 -1
  45. package/dist/chat/message.js +65 -13
  46. package/dist/chat/messages.d.ts +10 -1
  47. package/dist/chat/messages.d.ts.map +1 -1
  48. package/dist/chat/messages.js +70 -23
  49. package/dist/chat/name.d.ts +1 -0
  50. package/dist/chat/name.d.ts.map +1 -1
  51. package/dist/chat/name.js +1 -1
  52. package/dist/chat/opened.d.ts +1 -0
  53. package/dist/chat/opened.d.ts.map +1 -1
  54. package/dist/chat/opened.js +2 -0
  55. package/dist/chat/overlay.d.ts +1 -0
  56. package/dist/chat/overlay.d.ts.map +1 -1
  57. package/dist/chat/overlay.js +11 -5
  58. package/dist/chat/parts.d.ts +1 -0
  59. package/dist/chat/parts.d.ts.map +1 -1
  60. package/dist/chat/parts.js +3 -2
  61. package/dist/chat/pieces.d.ts +62 -0
  62. package/dist/chat/pieces.d.ts.map +1 -0
  63. package/dist/chat/pieces.js +1110 -0
  64. package/dist/chat/provider.d.ts +9 -2
  65. package/dist/chat/provider.d.ts.map +1 -1
  66. package/dist/chat/provider.js +146 -156
  67. package/dist/chat/question.d.ts +1 -1
  68. package/dist/chat/question.d.ts.map +1 -1
  69. package/dist/chat/question.js +7 -18
  70. package/dist/chat/ready.d.ts +5 -1
  71. package/dist/chat/ready.d.ts.map +1 -1
  72. package/dist/chat/ready.js +9 -7
  73. package/dist/chat/room-file.d.ts +8 -0
  74. package/dist/chat/room-file.d.ts.map +1 -0
  75. package/dist/chat/room-file.js +72 -0
  76. package/dist/chat/steady.d.ts +3 -0
  77. package/dist/chat/steady.d.ts.map +1 -0
  78. package/dist/chat/steady.js +26 -0
  79. package/dist/chat/style.d.ts.map +1 -1
  80. package/dist/chat/style.js +8 -4
  81. package/dist/chat.d.ts +3 -2
  82. package/dist/chat.d.ts.map +1 -1
  83. package/dist/chat.js +2 -2
  84. package/dist/client.d.ts +22 -9
  85. package/dist/client.d.ts.map +1 -1
  86. package/dist/client.js +48 -8
  87. package/dist/collection.d.ts +7 -6
  88. package/dist/collection.d.ts.map +1 -1
  89. package/dist/collection.js +31 -77
  90. package/dist/compile.d.ts +11 -0
  91. package/dist/compile.d.ts.map +1 -0
  92. package/dist/compile.js +712 -0
  93. package/dist/connection.d.ts +41 -13
  94. package/dist/connection.d.ts.map +1 -1
  95. package/dist/connection.js +3264 -690
  96. package/dist/conversation.d.ts +28 -9
  97. package/dist/conversation.d.ts.map +1 -1
  98. package/dist/conversation.js +520 -176
  99. package/dist/digest.d.ts +7 -0
  100. package/dist/digest.d.ts.map +1 -0
  101. package/dist/digest.js +113 -0
  102. package/dist/durability.d.ts +8 -1
  103. package/dist/durability.d.ts.map +1 -1
  104. package/dist/entry.d.ts +19 -0
  105. package/dist/entry.d.ts.map +1 -0
  106. package/dist/entry.js +151 -0
  107. package/dist/fence.d.ts +6 -0
  108. package/dist/fence.d.ts.map +1 -0
  109. package/dist/fence.js +10 -0
  110. package/dist/file.d.ts +2 -10
  111. package/dist/file.d.ts.map +1 -1
  112. package/dist/file.js +3 -120
  113. package/dist/host.d.ts +15 -3
  114. package/dist/host.d.ts.map +1 -1
  115. package/dist/host.js +103 -13
  116. package/dist/identity.d.ts +2 -0
  117. package/dist/identity.d.ts.map +1 -1
  118. package/dist/identity.js +6 -0
  119. package/dist/index.d.ts +15 -9
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +5 -0
  122. package/dist/live.d.ts +22 -0
  123. package/dist/live.d.ts.map +1 -0
  124. package/dist/live.js +123 -0
  125. package/dist/memory.d.ts +9 -2
  126. package/dist/memory.d.ts.map +1 -1
  127. package/dist/memory.js +55 -12
  128. package/dist/model.d.ts +4 -2
  129. package/dist/model.d.ts.map +1 -1
  130. package/dist/model.js +10 -1
  131. package/dist/name.d.ts +4 -0
  132. package/dist/name.d.ts.map +1 -0
  133. package/dist/name.js +122 -0
  134. package/dist/observation.d.ts +19 -2
  135. package/dist/observation.d.ts.map +1 -1
  136. package/dist/observation.js +113 -12
  137. package/dist/opened.d.ts +22 -0
  138. package/dist/opened.d.ts.map +1 -0
  139. package/dist/opened.js +107 -0
  140. package/dist/outcome.d.ts +39 -4
  141. package/dist/outcome.d.ts.map +1 -1
  142. package/dist/outcome.js +29 -0
  143. package/dist/overlay.d.ts +3 -4
  144. package/dist/overlay.d.ts.map +1 -1
  145. package/dist/overlay.js +99 -181
  146. package/dist/query.d.ts +57 -4
  147. package/dist/query.d.ts.map +1 -1
  148. package/dist/query.js +37 -7
  149. package/dist/reach.d.ts +11 -4
  150. package/dist/reach.d.ts.map +1 -1
  151. package/dist/reach.js +182 -51
  152. package/dist/react.d.ts +8 -6
  153. package/dist/react.d.ts.map +1 -1
  154. package/dist/react.js +7 -17
  155. package/dist/readiness.d.ts +53 -0
  156. package/dist/readiness.d.ts.map +1 -0
  157. package/dist/readiness.js +33 -0
  158. package/dist/reads.d.ts +11 -0
  159. package/dist/reads.d.ts.map +1 -0
  160. package/dist/reads.js +98 -0
  161. package/dist/recovery.d.ts +25 -0
  162. package/dist/recovery.d.ts.map +1 -0
  163. package/dist/recovery.js +198 -0
  164. package/dist/refresh.d.ts +12 -15
  165. package/dist/refresh.d.ts.map +1 -1
  166. package/dist/refresh.js +74 -44
  167. package/dist/replica.d.ts +55 -33
  168. package/dist/replica.d.ts.map +1 -1
  169. package/dist/replica.js +295 -149
  170. package/dist/room-draft.d.ts +16 -2
  171. package/dist/room-draft.d.ts.map +1 -1
  172. package/dist/room-draft.js +32 -25
  173. package/dist/rows.d.ts +28 -37
  174. package/dist/rows.d.ts.map +1 -1
  175. package/dist/rows.js +113 -72
  176. package/dist/save.d.ts +50 -9
  177. package/dist/save.d.ts.map +1 -1
  178. package/dist/save.js +528 -166
  179. package/dist/search.d.ts +50 -7
  180. package/dist/search.d.ts.map +1 -1
  181. package/dist/search.js +273 -45
  182. package/dist/seed.d.ts +16 -0
  183. package/dist/seed.d.ts.map +1 -0
  184. package/dist/seed.js +75 -0
  185. package/dist/shared.d.ts +16 -0
  186. package/dist/shared.d.ts.map +1 -0
  187. package/dist/shared.js +431 -0
  188. package/dist/status.d.ts +4 -0
  189. package/dist/status.d.ts.map +1 -1
  190. package/dist/store.d.ts +128 -67
  191. package/dist/store.d.ts.map +1 -1
  192. package/dist/store.js +537 -432
  193. package/dist/stored.d.ts +143 -0
  194. package/dist/stored.d.ts.map +1 -0
  195. package/dist/stored.js +561 -0
  196. package/dist/tables.d.ts +320 -0
  197. package/dist/tables.d.ts.map +1 -0
  198. package/dist/tables.js +537 -0
  199. package/dist/turn.d.ts +9 -0
  200. package/dist/turn.d.ts.map +1 -0
  201. package/dist/turn.js +75 -0
  202. package/dist/validation.d.ts +30 -0
  203. package/dist/validation.d.ts.map +1 -0
  204. package/dist/validation.js +162 -0
  205. package/dist/windows.d.ts +22 -0
  206. package/dist/windows.d.ts.map +1 -0
  207. package/dist/windows.js +89 -0
  208. package/dist/wire.d.ts +168 -32
  209. package/dist/wire.d.ts.map +1 -1
  210. package/dist/wire.js +56 -31
  211. package/package.json +10 -3
  212. package/dist/read-side.d.ts +0 -18
  213. package/dist/read-side.d.ts.map +0 -1
  214. package/dist/read-side.js +0 -440
package/dist/search.d.ts CHANGED
@@ -1,12 +1,16 @@
1
+ import type { ProviderRefusal } from './adapter.js';
1
2
  import type { ChangeSet } from './change-set.js';
2
- import { type Filter } from './query.js';
3
+ import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
3
4
  import type { Open } from './open.js';
4
5
  export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
5
6
  export type SearchRequest = {
6
7
  text: string;
7
8
  documents?: Filter;
9
+ collection?: true;
8
10
  conversations?: readonly string[];
9
11
  limit?: number;
12
+ after?: string;
13
+ total?: true;
10
14
  };
11
15
  export type DocumentHit = {
12
16
  room: string;
@@ -21,10 +25,38 @@ export type MessageHit = {
21
25
  score: number;
22
26
  matches: Readonly<Record<string, readonly Open<'text'>[]>>;
23
27
  };
24
- export type SearchResult = {
28
+ export type SearchCoverage = {
29
+ rooms: readonly CoveredRoom[];
30
+ conversations: readonly string[];
31
+ index: string;
32
+ overlay: readonly string[];
33
+ };
34
+ export type PendingConversation = {
35
+ conversation: string;
36
+ awaits: Open<'index'>;
37
+ };
38
+ export type SearchHits = {
25
39
  documents: readonly DocumentHit[];
26
40
  messages: readonly MessageHit[];
27
41
  };
42
+ export type SearchWindow = SearchHits & {
43
+ next?: string;
44
+ total?: {
45
+ documents: number;
46
+ messages: number;
47
+ };
48
+ };
49
+ export type SearchPending = SearchHits & {
50
+ pending: readonly (PendingRoom | PendingConversation)[];
51
+ coverage: SearchCoverage;
52
+ };
53
+ export type SearchUndeclared = ProviderRefusal & {
54
+ kind: 'undeclared';
55
+ };
56
+ export type SearchResult = (SearchWindow & {
57
+ coverage: SearchCoverage;
58
+ }) | SearchPending | SearchUndeclared;
59
+ export declare function undeclaredSearch(): SearchUndeclared;
28
60
  export type SearchedDocument = {
29
61
  room: string;
30
62
  path: string;
@@ -39,24 +71,35 @@ export type SearchedMessage = {
39
71
  text: string;
40
72
  };
41
73
  export type SearchSource = {
42
- documents(): readonly SearchedDocument[];
43
- document(room: string, path: string): SearchedDocument | null;
44
- messages(): readonly SearchedMessage[];
45
- message(conversation: string, identity: string): SearchedMessage | null;
74
+ room(room: string): AsyncIterable<readonly SearchedDocument[]>;
75
+ documents(room: string, paths: readonly string[]): Promise<readonly SearchedDocument[]>;
46
76
  };
77
+ type HitCursor = readonly [number, string, string] | readonly [] | null;
47
78
  export type SearchPlan = {
48
79
  text: string;
49
80
  documents: unknown;
81
+ collection: boolean;
50
82
  conversations: readonly string[] | null;
51
83
  limit: number | null;
84
+ after: readonly [HitCursor, HitCursor] | null;
85
+ total: boolean;
52
86
  };
53
87
  export type SearchIndex = {
88
+ generation(): string;
89
+ rooms(): ReadonlySet<string>;
90
+ conversations(): ReadonlySet<string>;
91
+ indexRoom(room: string): Promise<void>;
92
+ indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
93
+ forget(rooms: readonly string[]): void;
54
94
  changed(set: ChangeSet): void;
95
+ changes(): number;
96
+ caughtUp(): Promise<void>;
55
97
  search(plan: SearchPlan, documents: readonly {
56
98
  room: string;
57
99
  path: string;
58
- }[] | null): SearchResult;
100
+ }[] | null, conversations: readonly string[], rooms: ReadonlySet<string> | null, selections: ReadonlyMap<string, readonly string[]> | null): SearchWindow;
59
101
  };
60
102
  export declare function searchPlanOf(input: unknown): SearchPlan;
61
103
  export declare function createSearchIndex(source: SearchSource): SearchIndex;
104
+ export {};
62
105
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAkC,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,E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 +1,20 @@
1
1
  import MiniSearch from 'minisearch';
2
- import { invalid, known, limitOf, plain } from './query.js';
2
+ import { indexGeneration } from './identity.js';
3
+ import { flag, invalid, known, limitOf, plain, } from './query.js';
4
+ import { beneath } from './paths.js';
5
+ import { inUnits, ROW_WEIGHT, yielded } from './turn.js';
6
+ import { decodedCursor } from './windows.js';
7
+ export function undeclaredSearch() {
8
+ return {
9
+ kind: 'undeclared',
10
+ code: 'search-undeclared',
11
+ fields: { name: 'local_search' },
12
+ retryable: false,
13
+ };
14
+ }
3
15
  const FIELDS = ['fields', 'sections', 'preamble', 'path', 'text'];
16
+ const VACUUM_CONDITIONS = { minDirtCount: 20, minDirtFactor: 0.1 };
17
+ const CHANGED_BATCH = 256;
4
18
  function documentId(room, path) {
5
19
  return JSON.stringify(['document', room, path]);
6
20
  }
@@ -16,10 +30,36 @@ function scalars(value) {
16
30
  return Object.values(value).flatMap(scalars);
17
31
  return [String(value)];
18
32
  }
33
+ function hitCursor(input) {
34
+ if (input === null)
35
+ return null;
36
+ if (!Array.isArray(input))
37
+ return undefined;
38
+ if (input.length === 0)
39
+ return [];
40
+ const [score, first, second] = input;
41
+ return input.length === 3 &&
42
+ typeof score === 'number' &&
43
+ typeof first === 'string' &&
44
+ typeof second === 'string'
45
+ ? [score, first, second]
46
+ : undefined;
47
+ }
48
+ function searchAfter(input) {
49
+ if (input === undefined)
50
+ return null;
51
+ const decoded = typeof input === 'string' ? decodedCursor(input) : null;
52
+ const documents = decoded?.length === 2 ? hitCursor(decoded[0]) : undefined;
53
+ const messages = decoded?.length === 2 ? hitCursor(decoded[1]) : undefined;
54
+ if (documents === undefined || messages === undefined) {
55
+ invalid('after', 'expects the next an earlier search returned');
56
+ }
57
+ return [documents, messages];
58
+ }
19
59
  export function searchPlanOf(input) {
20
60
  if (!plain(input))
21
61
  invalid('search', 'expects a search object');
22
- known(input, ['text', 'documents', 'conversations', 'limit'], '');
62
+ known(input, ['text', 'documents', 'collection', 'conversations', 'limit', 'after', 'total'], '');
23
63
  if (typeof input.text !== 'string')
24
64
  invalid('text', 'expects text');
25
65
  const conversations = input.conversations;
@@ -30,20 +70,58 @@ export function searchPlanOf(input) {
30
70
  return {
31
71
  text: input.text,
32
72
  documents: input.documents,
73
+ collection: flag(input.collection, 'collection'),
33
74
  conversations: conversations ?? null,
34
75
  limit: limitOf(input.limit),
76
+ after: searchAfter(input.after),
77
+ total: flag(input.total, 'total'),
35
78
  };
36
79
  }
80
+ function pair(left, right) {
81
+ if (left[0] !== right[0])
82
+ return left[0] < right[0] ? -1 : 1;
83
+ if (left[1] !== right[1])
84
+ return left[1] < right[1] ? -1 : 1;
85
+ return 0;
86
+ }
87
+ function hitWindow(found, cursor, limit, tie) {
88
+ if (cursor === null)
89
+ return { kept: [], cursor: null };
90
+ const start = cursor.length === 0
91
+ ? 0
92
+ : found.findIndex((hit) => hit.score < cursor[0] ||
93
+ (hit.score === cursor[0] && pair(tie(hit), [cursor[1], cursor[2]]) > 0));
94
+ const following = start === -1 ? [] : found.slice(start);
95
+ if (limit === null || following.length <= limit)
96
+ return { kept: following, cursor: null };
97
+ const kept = following.slice(0, limit);
98
+ const last = kept[kept.length - 1];
99
+ return { kept, cursor: last === undefined ? cursor : [last.score, ...tie(last)] };
100
+ }
37
101
  export function createSearchIndex(source) {
38
- let index = null;
102
+ const generation = indexGeneration();
103
+ const index = new MiniSearch({ fields: FIELDS, autoVacuum: false });
39
104
  const documents = new Map();
40
105
  const messages = new Map();
106
+ const rooms = new Set();
107
+ const filling = new Set();
108
+ const conversations = new Set();
109
+ const acquiring = new Set();
41
110
  const changedDocuments = new Map();
42
- const changedMessages = new Map();
43
- function addDocument(built, document) {
111
+ const refilling = new Set();
112
+ const arrived = new Map();
113
+ let vacuuming = null;
114
+ let changes = 0;
115
+ function added(entry) {
116
+ if (vacuuming === null)
117
+ index.add(entry);
118
+ else
119
+ arrived.set(entry.id, entry);
120
+ }
121
+ function addDocument(document) {
44
122
  const id = documentId(document.room, document.path);
45
- documents.set(id, { room: document.room, path: document.path, type: document.type });
46
- built.add({
123
+ discard(id, documents);
124
+ added({
47
125
  id,
48
126
  fields: scalars(document.fields).join('\n'),
49
127
  sections: Object.entries(document.sections)
@@ -52,73 +130,223 @@ export function createSearchIndex(source) {
52
130
  preamble: document.preamble,
53
131
  path: document.path,
54
132
  });
133
+ documents.set(id, { room: document.room, path: document.path, type: document.type });
55
134
  }
56
- function addMessage(built, message) {
135
+ function addMessage(message) {
57
136
  const id = messageId(message.conversation, message.identity);
137
+ discard(id, messages);
138
+ added({ id, text: message.text });
58
139
  messages.set(id, { conversation: message.conversation, identity: message.identity });
59
- built.add({ id, text: message.text });
60
140
  }
61
- function current() {
62
- if (index === null) {
63
- const built = new MiniSearch({ fields: FIELDS });
64
- for (const document of source.documents())
65
- addDocument(built, document);
66
- for (const message of source.messages())
67
- addMessage(built, message);
68
- index = built;
69
- return built;
141
+ function discard(id, entries) {
142
+ if (!entries.delete(id) || arrived.delete(id))
143
+ return;
144
+ index.discard(id);
145
+ vacuum();
146
+ }
147
+ function vacuum() {
148
+ if (vacuuming !== null ||
149
+ index.dirtCount < VACUUM_CONDITIONS.minDirtCount ||
150
+ index.dirtFactor < VACUUM_CONDITIONS.minDirtFactor) {
151
+ return;
152
+ }
153
+ changes += 1;
154
+ vacuuming = index
155
+ .vacuum()
156
+ .then(() => inUnits(arrivals(), (id) => {
157
+ const entry = arrived.get(id);
158
+ if (entry === undefined)
159
+ return ROW_WEIGHT;
160
+ arrived.delete(id);
161
+ index.add(entry);
162
+ return Object.values(entry).reduce((total, value) => total + value.length, ROW_WEIGHT);
163
+ }))
164
+ .finally(() => {
165
+ vacuuming = null;
166
+ vacuum();
167
+ });
168
+ }
169
+ function* arrivals() {
170
+ for (;;) {
171
+ const next = arrived.keys().next();
172
+ if (next.done === true)
173
+ return;
174
+ yield next.value;
175
+ }
176
+ }
177
+ async function vacuumed() {
178
+ while (vacuuming !== null)
179
+ await vacuuming;
180
+ }
181
+ async function paused() {
182
+ await yielded();
183
+ await vacuumed();
184
+ }
185
+ let catching = null;
186
+ async function refill(room) {
187
+ for (const [id, entry] of documents)
188
+ if (entry.room === room)
189
+ discard(id, documents);
190
+ for await (const batch of source.room(room)) {
191
+ if (!rooms.has(room) && !filling.has(room))
192
+ return;
193
+ for (const document of batch)
194
+ addDocument(document);
195
+ await paused();
196
+ }
197
+ }
198
+ async function catchUp() {
199
+ for (const room of refilling) {
200
+ refilling.delete(room);
201
+ await refill(room);
70
202
  }
71
- const built = index;
72
- for (const [id, { room, path }] of changedDocuments) {
73
- if (documents.delete(id))
74
- built.discard(id);
75
- const document = source.document(room, path);
76
- if (document !== null)
77
- addDocument(built, document);
203
+ while (changedDocuments.size > 0) {
204
+ await paused();
205
+ const batch = new Map();
206
+ for (const [id, { room, path }] of changedDocuments) {
207
+ changedDocuments.delete(id);
208
+ const held = batch.get(room) ?? new Map();
209
+ held.set(path, id);
210
+ batch.set(room, held);
211
+ if (held.size >= CHANGED_BATCH)
212
+ break;
213
+ }
214
+ for (const [room, held] of batch) {
215
+ for (const id of held.values())
216
+ discard(id, documents);
217
+ for (const document of await source.documents(room, [...held.keys()])) {
218
+ if (rooms.has(room) || filling.has(room))
219
+ addDocument(document);
220
+ }
221
+ }
78
222
  }
79
- changedDocuments.clear();
80
- for (const [id, { conversation, identity }] of changedMessages) {
81
- if (messages.delete(id))
82
- built.discard(id);
83
- const message = source.message(conversation, identity);
84
- if (message !== null)
85
- addMessage(built, message);
223
+ await vacuumed();
224
+ }
225
+ function caughtUp() {
226
+ if (catching !== null)
227
+ return catching;
228
+ if (changedDocuments.size === 0 && refilling.size === 0 && vacuuming === null) {
229
+ return Promise.resolve();
86
230
  }
87
- changedMessages.clear();
88
- return built;
231
+ catching = catchUp().finally(() => {
232
+ catching = null;
233
+ });
234
+ return catching;
89
235
  }
90
- function ranked(built, text, entries, keep, limit) {
91
- const found = built.search(text, {
236
+ function ranked(text, entries, keep, tie) {
237
+ const found = index.search(text, {
92
238
  filter: ({ id }) => {
93
239
  const entry = entries.get(id);
94
240
  return entry !== undefined && keep(entry, id);
95
241
  },
96
242
  });
97
- return (limit === null ? found : found.slice(0, limit)).map(({ id, score, match }) => ({
243
+ found.sort((left, right) => right.score - left.score ||
244
+ pair(tie(entries.get(left.id)), tie(entries.get(right.id))));
245
+ return found.map(({ id, score, match }) => ({
98
246
  ...entries.get(id),
99
247
  score,
100
248
  match,
101
249
  }));
102
250
  }
103
251
  return {
104
- changed(set) {
105
- if (index === null)
252
+ generation: () => generation,
253
+ rooms: () => rooms,
254
+ conversations: () => conversations,
255
+ async indexRoom(room) {
256
+ if (rooms.has(room) || filling.has(room))
106
257
  return;
258
+ filling.add(room);
259
+ try {
260
+ for await (const batch of source.room(room)) {
261
+ if (!filling.has(room))
262
+ return;
263
+ for (const document of batch)
264
+ addDocument(document);
265
+ await paused();
266
+ }
267
+ if (filling.has(room))
268
+ rooms.add(room);
269
+ }
270
+ finally {
271
+ filling.delete(room);
272
+ }
273
+ },
274
+ indexMessages(conversation, arriving, whole) {
275
+ for (const message of arriving)
276
+ addMessage(message);
277
+ if (!whole) {
278
+ acquiring.add(conversation);
279
+ return;
280
+ }
281
+ acquiring.delete(conversation);
282
+ conversations.add(conversation);
283
+ },
284
+ forget(leaving) {
285
+ const gone = new Set(leaving);
286
+ for (const [id, entry] of documents)
287
+ if (gone.has(entry.room))
288
+ discard(id, documents);
289
+ for (const room of leaving) {
290
+ rooms.delete(room);
291
+ filling.delete(room);
292
+ refilling.delete(room);
293
+ }
294
+ },
295
+ changed(set) {
296
+ changes += 1;
107
297
  for (const { locator, path } of set.documents) {
298
+ if (!rooms.has(locator) && !filling.has(locator))
299
+ continue;
300
+ if (path === null) {
301
+ for (const [id, entry] of changedDocuments) {
302
+ if (entry.room === locator)
303
+ changedDocuments.delete(id);
304
+ }
305
+ refilling.add(locator);
306
+ continue;
307
+ }
108
308
  changedDocuments.set(documentId(locator, path), { room: locator, path });
109
309
  }
110
- for (const { conversation, identity } of set.messages) {
111
- changedMessages.set(messageId(conversation, identity), { conversation, identity });
310
+ for (const { conversation, identity, text } of set.messages) {
311
+ if (!conversations.has(conversation) && !acquiring.has(conversation))
312
+ continue;
313
+ const id = messageId(conversation, identity);
314
+ if (text === null)
315
+ discard(id, messages);
316
+ else
317
+ addMessage({ conversation, identity, text });
112
318
  }
113
319
  },
114
- search({ text, conversations, limit }, selected) {
115
- const built = current();
320
+ changes: () => changes,
321
+ caughtUp,
322
+ search({ text, limit, after, total }, selected, named, within, selections) {
116
323
  const chosen = selected === null
117
324
  ? null
118
325
  : new Set(selected.map(({ room, path }) => documentId(room, path)));
326
+ const asked = new Set(named);
327
+ const documentTie = ({ room, path }) => [room, path];
328
+ const messageTie = ({ conversation, identity }) => [conversation, identity];
329
+ const foundDocuments = ranked(text, documents, ({ room, path }, id) => (chosen === null || chosen.has(id)) &&
330
+ (within === null || within.has(room)) &&
331
+ !(selections?.get(room) ?? []).some((root) => beneath(root, path)), documentTie);
332
+ const foundMessages = ranked(text, messages, ({ conversation }) => asked.has(conversation), messageTie);
333
+ const [documentsAfter, messagesAfter] = after ?? [[], []];
334
+ const documentWindow = hitWindow(foundDocuments, documentsAfter, limit, documentTie);
335
+ const messageWindow = hitWindow(foundMessages, messagesAfter, limit, messageTie);
336
+ const more = documentWindow.cursor !== null || messageWindow.cursor !== null;
119
337
  return {
120
- documents: ranked(built, text, documents, (_entry, id) => chosen === null || chosen.has(id), limit).map(({ match, ...hit }) => ({ ...hit, matches: match })),
121
- messages: ranked(built, text, messages, ({ conversation }) => conversations === null || conversations.includes(conversation), limit).map(({ match, ...hit }) => ({ ...hit, matches: match })),
338
+ documents: documentWindow.kept.map(({ match, ...hit }) => ({
339
+ ...hit,
340
+ matches: match,
341
+ })),
342
+ messages: messageWindow.kept.map(({ match, ...hit }) => ({
343
+ ...hit,
344
+ matches: match,
345
+ })),
346
+ ...(more ? { next: JSON.stringify([documentWindow.cursor, messageWindow.cursor]) } : {}),
347
+ ...(total
348
+ ? { total: { documents: foundDocuments.length, messages: foundMessages.length } }
349
+ : {}),
122
350
  };
123
351
  },
124
352
  };
package/dist/seed.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { KeyedResult } from './observation.js';
2
+ import type { QueryRows } from './query.js';
3
+ export type EntrySeed = {
4
+ readonly at: Readonly<Record<string, string>>;
5
+ readonly queries: readonly {
6
+ readonly query: unknown;
7
+ readonly rows: QueryRows;
8
+ }[];
9
+ };
10
+ export type Seeded = {
11
+ readonly rows: QueryRows;
12
+ readonly at: Readonly<Record<string, string>>;
13
+ };
14
+ export declare function entrySeedOf(value: unknown): EntrySeed | null;
15
+ export declare function seededResult(seed: Seeded): KeyedResult;
16
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAA4C,SAAS,EAAE,MAAM,YAAY,CAAC;AAGtF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CACpF,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAwCjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAe5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAoBtD"}
package/dist/seed.js ADDED
@@ -0,0 +1,75 @@
1
+ import { documentKey } from './rows.js';
2
+ function plain(value) {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
5
+ function windowOf(value) {
6
+ const { next, total } = value;
7
+ if (next !== undefined && typeof next !== 'string')
8
+ return null;
9
+ if (total !== undefined && !Number.isSafeInteger(total))
10
+ return null;
11
+ return {
12
+ ...(next === undefined ? {} : { next }),
13
+ ...(total === undefined ? {} : { total: total }),
14
+ };
15
+ }
16
+ function rowsOf(value) {
17
+ if (!plain(value))
18
+ return null;
19
+ const window = windowOf(value);
20
+ if (window === null)
21
+ return null;
22
+ if (Array.isArray(value.groups)) {
23
+ const groups = value.groups;
24
+ return groups.every((group) => plain(group) && Array.isArray(group.key) && typeof group.count === 'number')
25
+ ? { groups: groups, ...window }
26
+ : null;
27
+ }
28
+ if (!Array.isArray(value.documents))
29
+ return null;
30
+ const documents = value.documents;
31
+ return documents.every((document) => plain(document) && typeof document.room === 'string' && typeof document.path === 'string')
32
+ ? { documents: documents, ...window }
33
+ : null;
34
+ }
35
+ export function entrySeedOf(value) {
36
+ if (!plain(value) || !plain(value.at) || !Array.isArray(value.queries))
37
+ return null;
38
+ const at = {};
39
+ for (const [room, version] of Object.entries(value.at)) {
40
+ if (typeof version !== 'string')
41
+ return null;
42
+ at[room] = version;
43
+ }
44
+ const queries = [];
45
+ for (const entry of value.queries) {
46
+ if (!plain(entry) || !plain(entry.query))
47
+ return null;
48
+ const rows = rowsOf(entry.rows);
49
+ if (rows === null)
50
+ return null;
51
+ queries.push({ query: entry.query, rows });
52
+ }
53
+ return { at, queries };
54
+ }
55
+ export function seededResult(seed) {
56
+ const coverage = {
57
+ rooms: Object.entries(seed.at).map(([room, generation]) => ({
58
+ room,
59
+ generation,
60
+ current: false,
61
+ })),
62
+ indexes: [],
63
+ overlay: [],
64
+ };
65
+ if ('groups' in seed.rows) {
66
+ return {
67
+ result: { ...seed.rows, coverage },
68
+ keys: seed.rows.groups.map((_group, index) => index),
69
+ };
70
+ }
71
+ return {
72
+ result: { ...seed.rows, coverage },
73
+ keys: seed.rows.documents.map((document) => documentKey(document.room, document.path)),
74
+ };
75
+ }
@@ -0,0 +1,16 @@
1
+ export type Paths<V> = Readonly<Record<string, V>>;
2
+ export declare function entriesIn<V>(map: Paths<V>): Generator<readonly [string, V]>;
3
+ export declare function keysIn(...maps: readonly Paths<unknown>[]): Generator<number, Set<string>, void>;
4
+ export declare function sortedKeys(map: Paths<unknown>): Generator<number, readonly string[], void>;
5
+ export declare function sorting(keys: Iterable<string>): Generator<number, readonly string[], void>;
6
+ export declare function sharing<V>(map: Paths<V>): Generator<number, Paths<V>, void>;
7
+ export declare function shared<V>(map: Paths<V>): Paths<V>;
8
+ export declare function patched<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Paths<V>;
9
+ export declare function patching<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Generator<number, Paths<V>, void>;
10
+ export declare function sizeOf<V>(map: Paths<V>): number;
11
+ export declare function differences<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): Generator<number, ReadonlySet<string>, void>;
12
+ export declare function differing<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): ReadonlySet<string>;
13
+ export declare function drafted<V>(base: Paths<V>): Record<string, V>;
14
+ export declare function settled<V>(draft: Record<string, V>): Paths<V>;
15
+ export declare function settling<V>(draft: Record<string, V>): Generator<number, Paths<V>, void>;
16
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AA+LnD,wBAAiB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CA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