@agentshouse/mdruntime 0.1.0-c1db74d14e5fa → 0.1.0-c1ffd2bc60355

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 (220) hide show
  1. package/AGENTS.md +268 -251
  2. package/README.md +9 -8
  3. package/dist/adapter.d.ts +76 -40
  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/binary.d.ts +0 -5
  9. package/dist/binary.d.ts.map +1 -1
  10. package/dist/binary.js +1 -1
  11. package/dist/bootstrap.d.ts +26 -7
  12. package/dist/bootstrap.d.ts.map +1 -1
  13. package/dist/bootstrap.js +148 -78
  14. package/dist/chain.d.ts +11 -0
  15. package/dist/chain.d.ts.map +1 -0
  16. package/dist/chain.js +64 -0
  17. package/dist/change-set.d.ts +9 -16
  18. package/dist/change-set.d.ts.map +1 -1
  19. package/dist/change-set.js +11 -88
  20. package/dist/change.d.ts +31 -1
  21. package/dist/change.d.ts.map +1 -1
  22. package/dist/change.js +10 -1
  23. package/dist/chat/earlier.d.ts +10 -0
  24. package/dist/chat/earlier.d.ts.map +1 -0
  25. package/dist/chat/earlier.js +54 -0
  26. package/dist/chat/house.d.ts +25 -0
  27. package/dist/chat/house.d.ts.map +1 -0
  28. package/dist/chat/house.js +38 -0
  29. package/dist/chat/input.d.ts +3 -1
  30. package/dist/chat/input.d.ts.map +1 -1
  31. package/dist/chat/input.js +11 -18
  32. package/dist/chat/kit.d.ts +2 -1
  33. package/dist/chat/kit.d.ts.map +1 -1
  34. package/dist/chat/kit.js +3 -3
  35. package/dist/chat/list.d.ts +3 -1
  36. package/dist/chat/list.d.ts.map +1 -1
  37. package/dist/chat/list.js +47 -6
  38. package/dist/chat/markdown.d.ts +2 -2
  39. package/dist/chat/markdown.d.ts.map +1 -1
  40. package/dist/chat/markdown.js +80 -39
  41. package/dist/chat/message.d.ts +1 -0
  42. package/dist/chat/message.d.ts.map +1 -1
  43. package/dist/chat/message.js +73 -11
  44. package/dist/chat/messages.d.ts +15 -1
  45. package/dist/chat/messages.d.ts.map +1 -1
  46. package/dist/chat/messages.js +82 -23
  47. package/dist/chat/name.d.ts +1 -0
  48. package/dist/chat/name.d.ts.map +1 -1
  49. package/dist/chat/name.js +1 -1
  50. package/dist/chat/opened.d.ts +1 -0
  51. package/dist/chat/opened.d.ts.map +1 -1
  52. package/dist/chat/opened.js +2 -0
  53. package/dist/chat/overlay.d.ts +1 -0
  54. package/dist/chat/overlay.d.ts.map +1 -1
  55. package/dist/chat/overlay.js +11 -5
  56. package/dist/chat/parts.d.ts +1 -0
  57. package/dist/chat/parts.d.ts.map +1 -1
  58. package/dist/chat/parts.js +3 -2
  59. package/dist/chat/pieces.d.ts +62 -0
  60. package/dist/chat/pieces.d.ts.map +1 -0
  61. package/dist/chat/pieces.js +1110 -0
  62. package/dist/chat/provider.d.ts +9 -2
  63. package/dist/chat/provider.d.ts.map +1 -1
  64. package/dist/chat/provider.js +121 -106
  65. package/dist/chat/question.d.ts +1 -1
  66. package/dist/chat/question.d.ts.map +1 -1
  67. package/dist/chat/question.js +7 -18
  68. package/dist/chat/ready.d.ts +5 -1
  69. package/dist/chat/ready.d.ts.map +1 -1
  70. package/dist/chat/ready.js +7 -5
  71. package/dist/chat/room-file.d.ts +8 -0
  72. package/dist/chat/room-file.d.ts.map +1 -0
  73. package/dist/chat/room-file.js +72 -0
  74. package/dist/chat/steady.d.ts +3 -0
  75. package/dist/chat/steady.d.ts.map +1 -0
  76. package/dist/chat/steady.js +26 -0
  77. package/dist/chat/style.d.ts.map +1 -1
  78. package/dist/chat/style.js +6 -1
  79. package/dist/chat.d.ts +3 -2
  80. package/dist/chat.d.ts.map +1 -1
  81. package/dist/chat.js +2 -2
  82. package/dist/client.d.ts +15 -6
  83. package/dist/client.d.ts.map +1 -1
  84. package/dist/client.js +47 -8
  85. package/dist/collection.d.ts +6 -19
  86. package/dist/collection.d.ts.map +1 -1
  87. package/dist/collection.js +30 -287
  88. package/dist/compile.d.ts +16 -0
  89. package/dist/compile.d.ts.map +1 -0
  90. package/dist/compile.js +721 -0
  91. package/dist/connection.d.ts +25 -12
  92. package/dist/connection.d.ts.map +1 -1
  93. package/dist/connection.js +2615 -946
  94. package/dist/conversation.d.ts +18 -3
  95. package/dist/conversation.d.ts.map +1 -1
  96. package/dist/conversation.js +341 -107
  97. package/dist/digest.d.ts +7 -0
  98. package/dist/digest.d.ts.map +1 -0
  99. package/dist/digest.js +113 -0
  100. package/dist/durability.d.ts +3 -5
  101. package/dist/durability.d.ts.map +1 -1
  102. package/dist/durability.js +5 -0
  103. package/dist/entry.d.ts +3 -1
  104. package/dist/entry.d.ts.map +1 -1
  105. package/dist/entry.js +18 -23
  106. package/dist/file.d.ts +2 -10
  107. package/dist/file.d.ts.map +1 -1
  108. package/dist/file.js +3 -120
  109. package/dist/fulltext.d.ts +27 -0
  110. package/dist/fulltext.d.ts.map +1 -0
  111. package/dist/fulltext.js +368 -0
  112. package/dist/host.d.ts +10 -8
  113. package/dist/host.d.ts.map +1 -1
  114. package/dist/host.js +95 -18
  115. package/dist/identity.d.ts +0 -1
  116. package/dist/identity.d.ts.map +1 -1
  117. package/dist/identity.js +0 -3
  118. package/dist/index.d.ts +15 -11
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +5 -1
  121. package/dist/live.d.ts +22 -0
  122. package/dist/live.d.ts.map +1 -0
  123. package/dist/live.js +123 -0
  124. package/dist/memory.d.ts +8 -3
  125. package/dist/memory.d.ts.map +1 -1
  126. package/dist/memory.js +43 -25
  127. package/dist/messages.d.ts +28 -0
  128. package/dist/messages.d.ts.map +1 -0
  129. package/dist/messages.js +90 -0
  130. package/dist/model.d.ts +3 -2
  131. package/dist/model.d.ts.map +1 -1
  132. package/dist/model.js +1 -1
  133. package/dist/name.d.ts +4 -0
  134. package/dist/name.d.ts.map +1 -0
  135. package/dist/name.js +122 -0
  136. package/dist/observation.d.ts +14 -0
  137. package/dist/observation.d.ts.map +1 -1
  138. package/dist/observation.js +93 -3
  139. package/dist/opened.d.ts +22 -0
  140. package/dist/opened.d.ts.map +1 -0
  141. package/dist/opened.js +107 -0
  142. package/dist/outcome.d.ts +34 -4
  143. package/dist/outcome.d.ts.map +1 -1
  144. package/dist/outcome.js +25 -0
  145. package/dist/overlay.d.ts +3 -5
  146. package/dist/overlay.d.ts.map +1 -1
  147. package/dist/overlay.js +95 -156
  148. package/dist/query.d.ts +33 -2
  149. package/dist/query.d.ts.map +1 -1
  150. package/dist/query.js +48 -7
  151. package/dist/reach.d.ts +6 -5
  152. package/dist/reach.d.ts.map +1 -1
  153. package/dist/reach.js +170 -62
  154. package/dist/react.d.ts +3 -3
  155. package/dist/react.d.ts.map +1 -1
  156. package/dist/react.js +7 -17
  157. package/dist/readiness.d.ts +20 -9
  158. package/dist/readiness.d.ts.map +1 -1
  159. package/dist/readiness.js +6 -6
  160. package/dist/reads.d.ts +11 -0
  161. package/dist/reads.d.ts.map +1 -0
  162. package/dist/reads.js +100 -0
  163. package/dist/recovery.d.ts +2 -2
  164. package/dist/recovery.d.ts.map +1 -1
  165. package/dist/recovery.js +8 -7
  166. package/dist/refresh.d.ts +16 -15
  167. package/dist/refresh.d.ts.map +1 -1
  168. package/dist/refresh.js +112 -45
  169. package/dist/replica.d.ts +57 -33
  170. package/dist/replica.d.ts.map +1 -1
  171. package/dist/replica.js +295 -177
  172. package/dist/room-draft.d.ts +17 -2
  173. package/dist/room-draft.d.ts.map +1 -1
  174. package/dist/room-draft.js +65 -25
  175. package/dist/rows.d.ts +29 -29
  176. package/dist/rows.d.ts.map +1 -1
  177. package/dist/rows.js +113 -62
  178. package/dist/save.d.ts +51 -14
  179. package/dist/save.d.ts.map +1 -1
  180. package/dist/save.js +518 -180
  181. package/dist/search.d.ts +32 -43
  182. package/dist/search.d.ts.map +1 -1
  183. package/dist/search.js +37 -168
  184. package/dist/seed.d.ts +16 -0
  185. package/dist/seed.d.ts.map +1 -0
  186. package/dist/seed.js +75 -0
  187. package/dist/shared.d.ts +8 -3
  188. package/dist/shared.d.ts.map +1 -1
  189. package/dist/shared.js +129 -66
  190. package/dist/store.d.ts +99 -88
  191. package/dist/store.d.ts.map +1 -1
  192. package/dist/store.js +335 -641
  193. package/dist/stored.d.ts +145 -0
  194. package/dist/stored.d.ts.map +1 -0
  195. package/dist/stored.js +567 -0
  196. package/dist/tables.d.ts +354 -0
  197. package/dist/tables.d.ts.map +1 -0
  198. package/dist/tables.js +624 -0
  199. package/dist/turn.d.ts +5 -3
  200. package/dist/turn.d.ts.map +1 -1
  201. package/dist/turn.js +51 -21
  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 +163 -33
  209. package/dist/wire.d.ts.map +1 -1
  210. package/dist/wire.js +54 -32
  211. package/dist/words.d.ts +19 -0
  212. package/dist/words.d.ts.map +1 -0
  213. package/dist/words.js +150 -0
  214. package/package.json +11 -5
  215. package/dist/acquisition.d.ts +0 -14
  216. package/dist/acquisition.d.ts.map +0 -1
  217. package/dist/acquisition.js +0 -24
  218. package/dist/read-side.d.ts +0 -25
  219. package/dist/read-side.d.ts.map +0 -1
  220. package/dist/read-side.js +0 -639
package/dist/wire.js CHANGED
@@ -1,35 +1,43 @@
1
+ import { UNCERTAIN } from './outcome.js';
1
2
  const MEMBERS = {
2
- rooms: 'within',
3
- query: 'within',
4
- search: 'within',
5
- types: 'within',
6
- save: 'within',
7
- history: 'within',
8
- 'binaryFile.read': 'within',
9
- 'binaryFile.readReference': 'within',
10
- call: 'actions',
11
- reached: 'within',
12
- log: 'whole',
13
- persistence: 'runtime',
14
- retry: 'runtime',
15
- reauthorize: 'runtime',
16
- 'roomDraft.list': 'within',
17
- 'roomDraft.read': 'within',
18
- 'roomDraft.write': 'within',
19
- 'roomDraft.discard': 'within',
20
- 'presentation.read': 'app',
21
- 'presentation.write': 'app',
22
- 'conversation.list': 'within',
23
- 'conversation.read': 'within',
24
- 'conversation.create': 'within',
25
- 'conversation.send': 'within',
26
- 'conversation.answer': 'within',
27
- 'conversation.interrupt': 'within',
28
- 'conversation.kill': 'within',
29
- 'conversation.cancel': 'within',
30
- 'conversation.delete': 'within',
31
- 'chatDraft.write': 'within',
32
- 'chatDraft.discard': 'within',
3
+ rooms: { reach: 'within', effect: 'read' },
4
+ query: { reach: 'within', effect: 'read' },
5
+ search: { reach: 'within', effect: 'read' },
6
+ types: { reach: 'within', effect: 'read' },
7
+ save: { reach: 'within', effect: 'write' },
8
+ saveParts: { reach: 'within', effect: 'write' },
9
+ history: { reach: 'within', effect: 'read' },
10
+ resolve: { reach: 'within', effect: 'read' },
11
+ 'binaryFile.read': { reach: 'within', effect: 'read' },
12
+ 'binaryFile.link': { reach: 'within', effect: 'read' },
13
+ 'binaryFile.part': { reach: 'within', effect: 'read' },
14
+ call: { reach: 'actions', effect: 'action' },
15
+ reached: { reach: 'within', effect: 'read' },
16
+ log: { reach: 'whole', effect: 'read' },
17
+ cleanUp: { reach: 'whole', effect: 'write' },
18
+ persistence: { reach: 'runtime', effect: 'read' },
19
+ retry: { reach: 'runtime', effect: 'write' },
20
+ reauthorize: { reach: 'runtime', effect: 'write' },
21
+ 'roomDraft.list': { reach: 'within', effect: 'read' },
22
+ 'roomDraft.read': { reach: 'within', effect: 'read' },
23
+ 'roomDraft.write': { reach: 'within', effect: 'write' },
24
+ 'roomDraft.discard': { reach: 'within', effect: 'write' },
25
+ 'presentation.read': { reach: 'app', effect: 'read' },
26
+ 'presentation.write': { reach: 'app', effect: 'write' },
27
+ 'presentation.edit': { reach: 'app', effect: 'write' },
28
+ 'conversation.list': { reach: 'within', effect: 'read' },
29
+ 'conversation.read': { reach: 'within', effect: 'read' },
30
+ 'conversation.create': { reach: 'within', effect: 'action' },
31
+ 'conversation.send': { reach: 'within', effect: 'action' },
32
+ 'conversation.attach': { reach: 'within', effect: 'action' },
33
+ 'conversation.answer': { reach: 'within', effect: 'action' },
34
+ 'conversation.interrupt': { reach: 'within', effect: 'action' },
35
+ 'conversation.kill': { reach: 'within', effect: 'action' },
36
+ 'conversation.cancel': { reach: 'within', effect: 'action' },
37
+ 'conversation.delete': { reach: 'within', effect: 'action' },
38
+ 'chatDraft.write': { reach: 'within', effect: 'write' },
39
+ 'chatDraft.prepend': { reach: 'within', effect: 'write' },
40
+ 'chatDraft.discard': { reach: 'within', effect: 'write' },
33
41
  };
34
42
  const TOPICS = {
35
43
  rooms: 'within',
@@ -48,7 +56,21 @@ const TOPICS = {
48
56
  conversations: 'within',
49
57
  agents: 'within',
50
58
  };
51
- export const WIRE_REACH = { members: MEMBERS, topics: TOPICS };
59
+ export const WIRE = { members: MEMBERS, topics: TOPICS };
60
+ export function unanswered(call) {
61
+ const { effect } = MEMBERS[call.member];
62
+ if (effect === 'read')
63
+ return null;
64
+ if (effect === 'action')
65
+ return { kind: 'result', id: call.id, value: UNCERTAIN };
66
+ return {
67
+ kind: 'failure',
68
+ id: call.id,
69
+ message: UNCERTAIN.code,
70
+ code: UNCERTAIN.code,
71
+ retryable: UNCERTAIN.retryable,
72
+ };
73
+ }
52
74
  export const AUTHORIZATION_ENDED = 'the host authorization ended';
53
75
  export const PORT_CLOSED = 'the port closed';
54
76
  function body(message) {
@@ -0,0 +1,19 @@
1
+ export type Clause = {
2
+ readonly text: string;
3
+ readonly kind: 'term' | 'stem' | 'prefix' | 'phrase';
4
+ readonly term: string;
5
+ };
6
+ export type Located = {
7
+ readonly start: number;
8
+ readonly end: number;
9
+ };
10
+ export declare function indexed(text: string): string;
11
+ export declare function matchClauses(text: string): Clause[] | null;
12
+ export declare function matchExpression(clauses: readonly Clause[]): string;
13
+ export declare function queryTerms(text: string): string[];
14
+ export declare function snippet(part: string, terms: readonly string[], reach: number): {
15
+ readonly text: string;
16
+ readonly at: readonly [number, number];
17
+ } | null;
18
+ export declare function matched(part: string, terms: readonly string[]): string[];
19
+ //# sourceMappingURL=words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAYvE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAgBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAiB1D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAElE;AAMD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjD;AAyDD,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CAW1E;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxE"}
package/dist/words.js ADDED
@@ -0,0 +1,150 @@
1
+ const SPACELESS = /(?:[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}\p{Script=Hangul}]\p{M}*)+/gu;
2
+ const SPACELESS_TERM = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}\p{Script=Hangul}]/u;
3
+ const TOKEN = /[\p{L}\p{N}\p{M}\p{Co}]+/gu;
4
+ const MARKED = /([\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}])\p{M}+/gu;
5
+ const INFLECTED = /^[\p{Script=Cyrillic}\p{Script=Greek}]+$/u;
6
+ const FOLD = /\p{M}+/gu;
7
+ const ASCII = /^[\x00-\x7f]$/;
8
+ const PREFIXED_LETTERS = 2;
9
+ const INFLECTED_LETTERS = 4;
10
+ const PHRASE_TERMS = { least: 2, most: 6 };
11
+ const GRAPHEMES = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
12
+ function bigrams(run) {
13
+ const characters = Array.from(run);
14
+ if (characters.length < 2)
15
+ return ` ${run} `;
16
+ const pairs = [];
17
+ for (let index = 0; index + 1 < characters.length; index += 1) {
18
+ pairs.push(characters[index] + characters[index + 1]);
19
+ }
20
+ return ` ${pairs.join(' ')} `;
21
+ }
22
+ export function indexed(text) {
23
+ return text.normalize('NFKD').replace(MARKED, '$1').normalize('NFKC').replace(SPACELESS, bigrams);
24
+ }
25
+ function tokens(text) {
26
+ return [...text.matchAll(TOKEN)].map(([token]) => token.toLowerCase());
27
+ }
28
+ function quoted(token) {
29
+ return `"${token.replaceAll('"', '""')}"`;
30
+ }
31
+ function truncated(term) {
32
+ const letters = Array.from(term);
33
+ if (!INFLECTED.test(term) || letters.length < INFLECTED_LETTERS)
34
+ return null;
35
+ return letters.slice(0, letters.length - (letters.length >= 6 ? 2 : 1)).join('');
36
+ }
37
+ export function matchClauses(text) {
38
+ const terms = tokens(indexed(text));
39
+ if (terms.length === 0)
40
+ return null;
41
+ const unique = [...new Set(terms)];
42
+ const clauses = unique.map((term) => ({ text: quoted(term), kind: 'term', term }));
43
+ for (const term of unique) {
44
+ const stem = truncated(term);
45
+ if (stem !== null)
46
+ clauses.push({ text: `${quoted(stem)}*`, kind: 'stem', term });
47
+ }
48
+ const last = terms[terms.length - 1];
49
+ if (!/\s$/u.test(text) && Array.from(last).length >= PREFIXED_LETTERS) {
50
+ clauses.push({ text: `${quoted(last)}*`, kind: 'prefix', term: last });
51
+ }
52
+ if (terms.length >= PHRASE_TERMS.least && terms.length <= PHRASE_TERMS.most) {
53
+ clauses.push({ text: quoted(terms.join(' ')), kind: 'phrase', term: terms.join(' ') });
54
+ }
55
+ return clauses;
56
+ }
57
+ export function matchExpression(clauses) {
58
+ return clauses.map(({ text }) => text).join(' OR ');
59
+ }
60
+ function folded(text) {
61
+ return text.normalize('NFKD').replace(FOLD, '').toLowerCase();
62
+ }
63
+ export function queryTerms(text) {
64
+ return [...new Set(tokens(text.normalize('NFKC')).map(folded))];
65
+ }
66
+ function agrees(token, term) {
67
+ if (SPACELESS_TERM.test(term))
68
+ return token.includes(term);
69
+ if (token.startsWith(term))
70
+ return true;
71
+ return token.length >= 3 && term.startsWith(token.slice(0, Math.max(3, token.length - 2)));
72
+ }
73
+ function inside(token, offset, term) {
74
+ const pieces = [...GRAPHEMES.segment(token)];
75
+ const owner = [];
76
+ let joined = '';
77
+ for (const [at, { segment }] of pieces.entries()) {
78
+ const part = folded(segment);
79
+ joined += part;
80
+ for (let index = 0; index < part.length; index += 1)
81
+ owner.push(at);
82
+ }
83
+ const found = joined.indexOf(term);
84
+ if (found < 0)
85
+ return null;
86
+ const first = pieces[owner[found]];
87
+ const last = pieces[owner[found + term.length - 1]];
88
+ return { start: offset + first.index, end: offset + last.index + last.segment.length };
89
+ }
90
+ function locate(part, terms) {
91
+ for (const match of part.matchAll(TOKEN)) {
92
+ const token = folded(match[0]);
93
+ for (const term of terms) {
94
+ if (!agrees(token, term))
95
+ continue;
96
+ if (!SPACELESS_TERM.test(term)) {
97
+ return { start: match.index, end: match.index + match[0].length };
98
+ }
99
+ const found = inside(match[0], match.index, term);
100
+ if (found !== null)
101
+ return found;
102
+ }
103
+ }
104
+ return null;
105
+ }
106
+ function settled(part, index) {
107
+ if (index <= 0 || index >= part.length)
108
+ return true;
109
+ const before = part[index - 1];
110
+ const after = part[index];
111
+ if (before === '\n')
112
+ return true;
113
+ return ASCII.test(before) && ASCII.test(after) && !(before === '\r' && after === '\n');
114
+ }
115
+ function edgesAround(part, low, high) {
116
+ let from = Math.max(0, low);
117
+ while (!settled(part, from))
118
+ from -= 1;
119
+ let to = Math.min(part.length, high);
120
+ while (!settled(part, to))
121
+ to += 1;
122
+ const edges = [...GRAPHEMES.segment(part.slice(from, to))].map(({ index }) => from + index);
123
+ edges.push(to);
124
+ return edges;
125
+ }
126
+ export function snippet(part, terms, reach) {
127
+ const located = locate(part, terms);
128
+ if (located === null)
129
+ return null;
130
+ const edges = edgesAround(part, located.start - 2 * reach, located.end + 2 * reach);
131
+ const last = (limit) => edges.filter((edge) => edge <= limit).at(-1) ?? edges[0];
132
+ const first = (limit) => edges.find((edge) => edge >= limit) ?? edges[edges.length - 1];
133
+ const from = last(located.start);
134
+ const to = Math.max(first(Math.min(located.end, from + reach)), first(from + 1));
135
+ const start = first(Math.max(0, from - reach));
136
+ const end = last(Math.min(part.length, to + reach));
137
+ return { text: part.slice(start, end), at: [from - start, to - start] };
138
+ }
139
+ export function matched(part, terms) {
140
+ const found = new Set();
141
+ for (const match of part.matchAll(TOKEN)) {
142
+ const token = folded(match[0]);
143
+ for (const term of terms)
144
+ if (agrees(token, term))
145
+ found.add(term);
146
+ if (found.size === terms.length)
147
+ break;
148
+ }
149
+ return [...found];
150
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime",
3
- "version": "0.1.0-c1db74d14e5fa",
3
+ "version": "0.1.0-c1ffd2bc60355",
4
4
  "description": "The headless core of MD App",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "access": "public"
10
10
  },
11
11
  "engines": {
12
- "node": ">=24.21.0"
12
+ "node": ">=24.22.1"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
@@ -32,6 +32,10 @@
32
32
  "types": "./dist/memory.d.ts",
33
33
  "default": "./dist/memory.js"
34
34
  },
35
+ "./tables": {
36
+ "types": "./dist/tables.d.ts",
37
+ "default": "./dist/tables.js"
38
+ },
35
39
  "./react": {
36
40
  "types": "./dist/react.d.ts",
37
41
  "default": "./dist/react.js"
@@ -40,6 +44,10 @@
40
44
  "types": "./dist/chat.d.ts",
41
45
  "default": "./dist/chat.js"
42
46
  },
47
+ "./digest": {
48
+ "types": "./dist/digest.d.ts",
49
+ "default": "./dist/digest.js"
50
+ },
43
51
  "./package.json": "./package.json"
44
52
  },
45
53
  "files": [
@@ -49,14 +57,12 @@
49
57
  "LICENSE"
50
58
  ],
51
59
  "dependencies": {
52
- "@agentshouse/mdmodel": "0.1.0-cad192ab63d5f",
60
+ "@agentshouse/mdmodel": "0.1.0-c2522b181299a",
53
61
  "@assistant-ui/react-markdown": "0.14.20",
54
- "@tanstack/db": "0.9.2",
55
62
  "lucide-react": "1.47.0",
56
63
  "mdast-util-from-markdown": "2.0.3",
57
64
  "mdast-util-gfm": "3.1.0",
58
65
  "micromark-extension-gfm": "3.0.0",
59
- "minisearch": "7.2.0",
60
66
  "radix-ui": "1.8.0",
61
67
  "remark-gfm": "4.0.1"
62
68
  },
@@ -1,14 +0,0 @@
1
- export type RuntimeDemand = {
2
- readonly whole: boolean;
3
- readonly rooms: readonly string[];
4
- readonly handles: readonly string[];
5
- readonly conversations: boolean;
6
- };
7
- export declare const WHOLE_DEMAND: RuntimeDemand;
8
- export declare function demanded(demand: RuntimeDemand, room: {
9
- readonly locator: string;
10
- readonly handle: string;
11
- }): boolean;
12
- export declare function wider(next: RuntimeDemand, current: RuntimeDemand): boolean;
13
- export declare function narrower(next: RuntimeDemand, current: RuntimeDemand): boolean;
14
- //# sourceMappingURL=acquisition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acquisition.d.ts","sourceRoot":"","sources":["../src/acquisition.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAK1B,CAAC;AAEF,wBAAgB,QAAQ,CACtB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,OAAO,CAIT;AAYD,wBAAgB,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAE1E;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAE7E"}
@@ -1,24 +0,0 @@
1
- export const WHOLE_DEMAND = {
2
- whole: true,
3
- rooms: [],
4
- handles: [],
5
- conversations: true,
6
- };
7
- export function demanded(demand, room) {
8
- return (demand.whole || demand.rooms.includes(room.locator) || demand.handles.includes(room.handle));
9
- }
10
- function adds(next, current) {
11
- if (current.whole)
12
- return false;
13
- if (next.whole)
14
- return true;
15
- return ((next.conversations && !current.conversations) ||
16
- next.rooms.some((room) => !current.rooms.includes(room)) ||
17
- next.handles.some((handle) => !current.handles.includes(handle)));
18
- }
19
- export function wider(next, current) {
20
- return adds(next, current);
21
- }
22
- export function narrower(next, current) {
23
- return adds(current, next);
24
- }
@@ -1,25 +0,0 @@
1
- import type { ChangeSet } from './change-set.js';
2
- import { type KeyedResult, type QueryMessage } from './observation.js';
3
- import type { PendingResult, Plan, QueryCoverage, QueryRows } from './query.js';
4
- import type { SearchedDocument } from './search.js';
5
- export type Cover = {
6
- coverage: QueryCoverage;
7
- } | PendingResult;
8
- export type ReadSide = {
9
- apply(set: ChangeSet): void;
10
- recover(): void;
11
- query<T>(plan: Plan, at: () => T): Promise<{
12
- rows: QueryRows;
13
- at: T;
14
- }>;
15
- watch(plan: Plan, identity: string, cover: () => Cover, deliver: (message: QueryMessage) => void): () => void;
16
- room(room: string): readonly string[];
17
- document(room: string, path: string): SearchedDocument | null;
18
- close(): void;
19
- };
20
- export declare function reconciled(previous: KeyedResult, next: KeyedResult): {
21
- keyed: KeyedResult;
22
- message: QueryMessage;
23
- } | null;
24
- export declare function createReadSide(): ReadSide;
25
- //# sourceMappingURL=read-side.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAOV,aAAa,EACb,IAAI,EAEJ,aAAa,EAGb,SAAS,EAIV,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA4CpD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,aAAa,CAAC;AAuBhE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,EAAE,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IACvE,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,KAAK,EAClB,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GACvC,MAAM,IAAI,CAAC;IACd,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAqWF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,GAChB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAAG,IAAI,CAuCtD;AAgBD,wBAAgB,cAAc,IAAI,QAAQ,CA+QzC"}