@agentshouse/mdruntime 0.1.0-cc7bd7a53214e → 0.1.0-ccbe92df1c4f6

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 (261) hide show
  1. package/AGENTS.md +302 -200
  2. package/README.md +22 -11
  3. package/dist/adapter.d.ts +172 -49
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js +1 -9
  6. package/dist/attached-model.d.ts +14 -0
  7. package/dist/attached-model.d.ts.map +1 -0
  8. package/dist/attached-model.js +57 -0
  9. package/dist/attempt.d.ts +16 -0
  10. package/dist/attempt.d.ts.map +1 -0
  11. package/dist/attempt.js +70 -0
  12. package/dist/binary.d.ts +18 -0
  13. package/dist/binary.d.ts.map +1 -0
  14. package/dist/binary.js +8 -0
  15. package/dist/bootstrap.d.ts +39 -6
  16. package/dist/bootstrap.d.ts.map +1 -1
  17. package/dist/bootstrap.js +188 -45
  18. package/dist/chain.d.ts +11 -0
  19. package/dist/chain.d.ts.map +1 -0
  20. package/dist/chain.js +64 -0
  21. package/dist/change-set.d.ts +9 -14
  22. package/dist/change-set.d.ts.map +1 -1
  23. package/dist/change-set.js +11 -56
  24. package/dist/change.d.ts +45 -0
  25. package/dist/change.d.ts.map +1 -1
  26. package/dist/change.js +34 -0
  27. package/dist/chat/acts.d.ts +33 -0
  28. package/dist/chat/acts.d.ts.map +1 -0
  29. package/dist/chat/acts.js +36 -0
  30. package/dist/chat/context.d.ts +3 -0
  31. package/dist/chat/context.d.ts.map +1 -0
  32. package/dist/chat/context.js +10 -0
  33. package/dist/chat/earlier.d.ts +10 -0
  34. package/dist/chat/earlier.d.ts.map +1 -0
  35. package/dist/chat/earlier.js +54 -0
  36. package/dist/chat/house.d.ts +25 -0
  37. package/dist/chat/house.d.ts.map +1 -0
  38. package/dist/chat/house.js +38 -0
  39. package/dist/chat/input.d.ts +11 -0
  40. package/dist/chat/input.d.ts.map +1 -0
  41. package/dist/chat/input.js +92 -0
  42. package/dist/chat/kit.d.ts +61 -0
  43. package/dist/chat/kit.d.ts.map +1 -0
  44. package/dist/chat/kit.js +123 -0
  45. package/dist/chat/lasting.d.ts +6 -0
  46. package/dist/chat/lasting.d.ts.map +1 -0
  47. package/dist/chat/lasting.js +19 -0
  48. package/dist/chat/list.d.ts +28 -0
  49. package/dist/chat/list.d.ts.map +1 -0
  50. package/dist/chat/list.js +103 -0
  51. package/dist/chat/markdown.d.ts +20 -0
  52. package/dist/chat/markdown.d.ts.map +1 -0
  53. package/dist/chat/markdown.js +229 -0
  54. package/dist/chat/message.d.ts +7 -0
  55. package/dist/chat/message.d.ts.map +1 -0
  56. package/dist/chat/message.js +254 -0
  57. package/dist/chat/messages.d.ts +35 -0
  58. package/dist/chat/messages.d.ts.map +1 -0
  59. package/dist/chat/messages.js +210 -0
  60. package/dist/chat/name.d.ts +7 -0
  61. package/dist/chat/name.d.ts.map +1 -0
  62. package/dist/chat/name.js +37 -0
  63. package/dist/chat/opened.d.ts +12 -0
  64. package/dist/chat/opened.d.ts.map +1 -0
  65. package/dist/chat/opened.js +19 -0
  66. package/dist/chat/overlay.d.ts +32 -0
  67. package/dist/chat/overlay.d.ts.map +1 -0
  68. package/dist/chat/overlay.js +103 -0
  69. package/dist/chat/parts.d.ts +58 -0
  70. package/dist/chat/parts.d.ts.map +1 -0
  71. package/dist/chat/parts.js +120 -0
  72. package/dist/chat/pieces.d.ts +62 -0
  73. package/dist/chat/pieces.d.ts.map +1 -0
  74. package/dist/chat/pieces.js +1110 -0
  75. package/dist/chat/process.d.ts +20 -0
  76. package/dist/chat/process.d.ts.map +1 -0
  77. package/dist/chat/process.js +32 -0
  78. package/dist/chat/provider.d.ts +70 -0
  79. package/dist/chat/provider.d.ts.map +1 -0
  80. package/dist/chat/provider.js +635 -0
  81. package/dist/chat/question.d.ts +9 -0
  82. package/dist/chat/question.d.ts.map +1 -0
  83. package/dist/chat/question.js +69 -0
  84. package/dist/chat/questions.d.ts +31 -0
  85. package/dist/chat/questions.d.ts.map +1 -0
  86. package/dist/chat/questions.js +111 -0
  87. package/dist/chat/read.d.ts +5 -0
  88. package/dist/chat/read.d.ts.map +1 -0
  89. package/dist/chat/read.js +13 -0
  90. package/dist/chat/ready.d.ts +37 -0
  91. package/dist/chat/ready.d.ts.map +1 -0
  92. package/dist/chat/ready.js +93 -0
  93. package/dist/chat/room-file.d.ts +8 -0
  94. package/dist/chat/room-file.d.ts.map +1 -0
  95. package/dist/chat/room-file.js +72 -0
  96. package/dist/chat/steady.d.ts +3 -0
  97. package/dist/chat/steady.d.ts.map +1 -0
  98. package/dist/chat/steady.js +26 -0
  99. package/dist/chat/style.d.ts +4 -0
  100. package/dist/chat/style.d.ts.map +1 -0
  101. package/dist/chat/style.js +307 -0
  102. package/dist/chat.d.ts +15 -0
  103. package/dist/chat.d.ts.map +1 -0
  104. package/dist/chat.js +8 -0
  105. package/dist/client.d.ts +35 -14
  106. package/dist/client.d.ts.map +1 -1
  107. package/dist/client.js +108 -26
  108. package/dist/collection.d.ts +9 -13
  109. package/dist/collection.d.ts.map +1 -1
  110. package/dist/collection.js +47 -56
  111. package/dist/compile.d.ts +16 -0
  112. package/dist/compile.d.ts.map +1 -0
  113. package/dist/compile.js +721 -0
  114. package/dist/connection.d.ts +61 -24
  115. package/dist/connection.d.ts.map +1 -1
  116. package/dist/connection.js +3786 -906
  117. package/dist/conversation.d.ts +56 -16
  118. package/dist/conversation.d.ts.map +1 -1
  119. package/dist/conversation.js +736 -242
  120. package/dist/digest.d.ts +7 -0
  121. package/dist/digest.d.ts.map +1 -0
  122. package/dist/digest.js +113 -0
  123. package/dist/durability.d.ts +5 -1
  124. package/dist/durability.d.ts.map +1 -1
  125. package/dist/durability.js +5 -0
  126. package/dist/entry.d.ts +19 -0
  127. package/dist/entry.d.ts.map +1 -0
  128. package/dist/entry.js +151 -0
  129. package/dist/expectation.d.ts +21 -0
  130. package/dist/expectation.d.ts.map +1 -0
  131. package/dist/expectation.js +70 -0
  132. package/dist/failure.d.ts +13 -0
  133. package/dist/failure.d.ts.map +1 -0
  134. package/dist/failure.js +19 -0
  135. package/dist/fence.d.ts +6 -0
  136. package/dist/fence.d.ts.map +1 -0
  137. package/dist/fence.js +10 -0
  138. package/dist/file.d.ts +2 -10
  139. package/dist/file.d.ts.map +1 -1
  140. package/dist/file.js +3 -120
  141. package/dist/fulltext.d.ts +27 -0
  142. package/dist/fulltext.d.ts.map +1 -0
  143. package/dist/fulltext.js +368 -0
  144. package/dist/host.d.ts +15 -2
  145. package/dist/host.d.ts.map +1 -1
  146. package/dist/host.js +113 -30
  147. package/dist/identity.d.ts +4 -0
  148. package/dist/identity.d.ts.map +1 -1
  149. package/dist/identity.js +16 -1
  150. package/dist/index.d.ts +20 -9
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.js +8 -0
  153. package/dist/live.d.ts +22 -0
  154. package/dist/live.d.ts.map +1 -0
  155. package/dist/live.js +123 -0
  156. package/dist/memory.d.ts +21 -7
  157. package/dist/memory.d.ts.map +1 -1
  158. package/dist/memory.js +171 -47
  159. package/dist/messages.d.ts +28 -0
  160. package/dist/messages.d.ts.map +1 -0
  161. package/dist/messages.js +90 -0
  162. package/dist/model.d.ts +17 -14
  163. package/dist/model.d.ts.map +1 -1
  164. package/dist/model.js +16 -4
  165. package/dist/name.d.ts +4 -0
  166. package/dist/name.d.ts.map +1 -0
  167. package/dist/name.js +122 -0
  168. package/dist/observation.d.ts +19 -2
  169. package/dist/observation.d.ts.map +1 -1
  170. package/dist/observation.js +113 -12
  171. package/dist/open.d.ts +2 -0
  172. package/dist/open.d.ts.map +1 -0
  173. package/dist/open.js +1 -0
  174. package/dist/opened.d.ts +22 -0
  175. package/dist/opened.d.ts.map +1 -0
  176. package/dist/opened.js +107 -0
  177. package/dist/outcome.d.ts +62 -3
  178. package/dist/outcome.d.ts.map +1 -1
  179. package/dist/outcome.js +67 -1
  180. package/dist/overlay.d.ts +15 -5
  181. package/dist/overlay.d.ts.map +1 -1
  182. package/dist/overlay.js +136 -180
  183. package/dist/paths.d.ts +0 -1
  184. package/dist/paths.d.ts.map +1 -1
  185. package/dist/paths.js +0 -16
  186. package/dist/query.d.ts +65 -5
  187. package/dist/query.d.ts.map +1 -1
  188. package/dist/query.js +122 -40
  189. package/dist/reach.d.ts +11 -4
  190. package/dist/reach.d.ts.map +1 -1
  191. package/dist/reach.js +202 -73
  192. package/dist/react.d.ts +43 -0
  193. package/dist/react.d.ts.map +1 -0
  194. package/dist/react.js +54 -0
  195. package/dist/readiness.d.ts +63 -0
  196. package/dist/readiness.d.ts.map +1 -0
  197. package/dist/readiness.js +33 -0
  198. package/dist/reads.d.ts +11 -0
  199. package/dist/reads.d.ts.map +1 -0
  200. package/dist/reads.js +100 -0
  201. package/dist/recovery.d.ts +25 -0
  202. package/dist/recovery.d.ts.map +1 -0
  203. package/dist/recovery.js +198 -0
  204. package/dist/refresh.d.ts +19 -7
  205. package/dist/refresh.d.ts.map +1 -1
  206. package/dist/refresh.js +129 -53
  207. package/dist/replica.d.ts +60 -33
  208. package/dist/replica.d.ts.map +1 -1
  209. package/dist/replica.js +319 -154
  210. package/dist/room-draft.d.ts +40 -9
  211. package/dist/room-draft.d.ts.map +1 -1
  212. package/dist/room-draft.js +153 -37
  213. package/dist/rows.d.ts +30 -34
  214. package/dist/rows.d.ts.map +1 -1
  215. package/dist/rows.js +168 -82
  216. package/dist/save.d.ts +72 -6
  217. package/dist/save.d.ts.map +1 -1
  218. package/dist/save.js +889 -178
  219. package/dist/search.d.ts +41 -29
  220. package/dist/search.d.ts.map +1 -1
  221. package/dist/search.js +37 -105
  222. package/dist/seed.d.ts +16 -0
  223. package/dist/seed.d.ts.map +1 -0
  224. package/dist/seed.js +75 -0
  225. package/dist/shared.d.ts +16 -0
  226. package/dist/shared.d.ts.map +1 -0
  227. package/dist/shared.js +431 -0
  228. package/dist/status.d.ts +6 -2
  229. package/dist/status.d.ts.map +1 -1
  230. package/dist/status.js +0 -8
  231. package/dist/store.d.ts +124 -58
  232. package/dist/store.d.ts.map +1 -1
  233. package/dist/store.js +359 -344
  234. package/dist/stored.d.ts +145 -0
  235. package/dist/stored.d.ts.map +1 -0
  236. package/dist/stored.js +567 -0
  237. package/dist/tables.d.ts +344 -0
  238. package/dist/tables.d.ts.map +1 -0
  239. package/dist/tables.js +580 -0
  240. package/dist/turn.d.ts +9 -0
  241. package/dist/turn.d.ts.map +1 -0
  242. package/dist/turn.js +75 -0
  243. package/dist/validation.d.ts +30 -0
  244. package/dist/validation.d.ts.map +1 -0
  245. package/dist/validation.js +162 -0
  246. package/dist/windows.d.ts +22 -0
  247. package/dist/windows.d.ts.map +1 -0
  248. package/dist/windows.js +89 -0
  249. package/dist/wire.d.ts +170 -45
  250. package/dist/wire.d.ts.map +1 -1
  251. package/dist/wire.js +69 -46
  252. package/dist/words.d.ts +19 -0
  253. package/dist/words.d.ts.map +1 -0
  254. package/dist/words.js +150 -0
  255. package/package.json +39 -9
  256. package/dist/attachment.d.ts +0 -3
  257. package/dist/attachment.d.ts.map +0 -1
  258. package/dist/attachment.js +0 -8
  259. package/dist/read-side.d.ts +0 -18
  260. package/dist/read-side.d.ts.map +0 -1
  261. package/dist/read-side.js +0 -377
package/dist/wire.js CHANGED
@@ -1,64 +1,78 @@
1
- export const RUNTIME_WIRE_PROTOCOL = 8;
2
- export const PROTOCOL_MISMATCH = {
3
- reason: 'client-host-protocol-mismatch',
4
- reauthorizationOffered: false,
5
- refusal: null,
6
- };
1
+ import { UNCERTAIN } from './outcome.js';
7
2
  const MEMBERS = {
8
- rooms: 'within',
9
- query: 'within',
10
- search: 'within',
11
- types: 'within',
12
- save: 'within',
13
- history: 'within',
14
- call: 'actions',
15
- reached: 'within',
16
- log: 'whole',
17
- persistence: 'runtime',
18
- reauthorize: 'runtime',
19
- 'roomDraft.list': 'within',
20
- 'roomDraft.read': 'within',
21
- 'roomDraft.write': 'within',
22
- 'roomDraft.discard': 'within',
23
- 'presentation.read': 'app',
24
- 'presentation.write': 'app',
25
- 'conversation.list': 'within',
26
- 'conversation.read': 'within',
27
- 'conversation.create': 'within',
28
- 'conversation.send': 'within',
29
- 'conversation.answer': 'within',
30
- 'conversation.interrupt': 'within',
31
- 'conversation.kill': 'within',
32
- 'conversation.cancel': 'within',
33
- 'conversation.delete': 'within',
34
- 'chatDraft.write': 'within',
35
- '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' },
36
41
  };
37
42
  const TOPICS = {
38
43
  rooms: 'within',
44
+ readiness: 'within',
39
45
  'connection-refusal': 'runtime',
40
46
  'storage-loss': 'runtime',
41
47
  'deployment-facts': 'runtime',
42
48
  'sync-status': 'within',
43
49
  'service-mode': 'runtime',
50
+ member: 'runtime',
44
51
  query: 'within',
45
52
  queue: 'within',
46
53
  'room-drafts': 'within',
47
54
  presentation: 'app',
48
55
  conversation: 'within',
56
+ conversations: 'within',
57
+ agents: 'within',
49
58
  };
50
- export const WIRE_REACH = { members: MEMBERS, topics: TOPICS };
51
- export const AUTHORIZATION_ENDED = 'the host authorization ended';
52
- export const PORT_CLOSED = 'the port closed';
53
- export function envelope(message) {
54
- return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };
55
- }
56
- export function carried(data) {
57
- if (typeof data !== 'object' || data === null || !('mdRuntime' in data))
59
+ export const WIRE = { members: MEMBERS, topics: TOPICS };
60
+ export function unanswered(call) {
61
+ const { effect } = MEMBERS[call.member];
62
+ if (effect === 'read')
58
63
  return null;
59
- const record = data;
60
- return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };
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
+ };
61
73
  }
74
+ export const AUTHORIZATION_ENDED = 'the host authorization ended';
75
+ export const PORT_CLOSED = 'the port closed';
62
76
  function body(message) {
63
77
  if (typeof message !== 'object' || message === null)
64
78
  return null;
@@ -116,8 +130,17 @@ export function answer(message) {
116
130
  return { kind: 'result', id: shape.id, value: record.value };
117
131
  if (shape.kind === 'event')
118
132
  return { kind: 'event', id: shape.id, value: record.value };
119
- if (shape.kind === 'failure' && typeof record.message === 'string') {
120
- return { kind: 'failure', id: shape.id, message: record.message };
133
+ if (shape.kind === 'failure' &&
134
+ typeof record.message === 'string' &&
135
+ typeof record.code === 'string' &&
136
+ typeof record.retryable === 'boolean') {
137
+ return {
138
+ kind: 'failure',
139
+ id: shape.id,
140
+ message: record.message,
141
+ code: record.code,
142
+ retryable: record.retryable,
143
+ };
121
144
  }
122
145
  return null;
123
146
  }
@@ -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-cc7bd7a53214e",
3
+ "version": "0.1.0-ccbe92df1c4f6",
4
4
  "description": "The headless core of MD App",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,24 +9,44 @@
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
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
17
+ "default": "./dist/index.js"
18
18
  },
19
19
  "./host": {
20
20
  "types": "./dist/host.d.ts",
21
- "import": "./dist/host.js"
21
+ "default": "./dist/host.js"
22
22
  },
23
23
  "./client": {
24
24
  "types": "./dist/client.d.ts",
25
- "import": "./dist/client.js"
25
+ "default": "./dist/client.js"
26
+ },
27
+ "./entry": {
28
+ "types": "./dist/entry.d.ts",
29
+ "default": "./dist/entry.js"
26
30
  },
27
31
  "./memory": {
28
32
  "types": "./dist/memory.d.ts",
29
- "import": "./dist/memory.js"
33
+ "default": "./dist/memory.js"
34
+ },
35
+ "./tables": {
36
+ "types": "./dist/tables.d.ts",
37
+ "default": "./dist/tables.js"
38
+ },
39
+ "./react": {
40
+ "types": "./dist/react.d.ts",
41
+ "default": "./dist/react.js"
42
+ },
43
+ "./chat": {
44
+ "types": "./dist/chat.d.ts",
45
+ "default": "./dist/chat.js"
46
+ },
47
+ "./digest": {
48
+ "types": "./dist/digest.d.ts",
49
+ "default": "./dist/digest.js"
30
50
  },
31
51
  "./package.json": "./package.json"
32
52
  },
@@ -37,8 +57,18 @@
37
57
  "LICENSE"
38
58
  ],
39
59
  "dependencies": {
40
- "@agentshouse/mdmodel": "0.1.0-c6b0c6dc1a195",
41
- "@tanstack/db": "0.9.2",
42
- "minisearch": "7.2.0"
60
+ "@agentshouse/mdmodel": "0.1.0-c37720432b75a",
61
+ "@assistant-ui/react-markdown": "0.14.20",
62
+ "lucide-react": "1.47.0",
63
+ "mdast-util-from-markdown": "2.0.3",
64
+ "mdast-util-gfm": "3.1.0",
65
+ "micromark-extension-gfm": "3.0.0",
66
+ "radix-ui": "1.8.0",
67
+ "remark-gfm": "4.0.1"
68
+ },
69
+ "peerDependencies": {
70
+ "@assistant-ui/react": "^0.15.22",
71
+ "react": ">=18",
72
+ "react-dom": ">=18"
43
73
  }
44
74
  }
@@ -1,3 +0,0 @@
1
- import type { RoomAttachment } from './adapter.js';
2
- export declare function declaredAttachments(pages: readonly (readonly RoomAttachment[])[]): readonly RoomAttachment[];
3
- //# sourceMappingURL=attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,GAC5C,SAAS,cAAc,EAAE,CAQ3B"}
@@ -1,8 +0,0 @@
1
- export function declaredAttachments(pages) {
2
- const byReference = new Map();
3
- for (const page of pages) {
4
- for (const attachment of page)
5
- byReference.set(attachment.reference, attachment);
6
- }
7
- return [...byReference.values()].sort((left, right) => left.reference < right.reference ? -1 : left.reference > right.reference ? 1 : 0);
8
- }
@@ -1,18 +0,0 @@
1
- import type { ChangeSet } from './change-set.js';
2
- import { type KeyedResult, type QueryChange } from './observation.js';
3
- import type { Plan, QueryResult } from './query.js';
4
- import type { SearchedDocument } from './search.js';
5
- export type ReadSide = {
6
- apply(set: ChangeSet): void;
7
- query(plan: Plan): Promise<QueryResult>;
8
- watch(plan: Plan, identity: string, deliver: (message: KeyedResult | QueryChange) => void): () => void;
9
- documents(): readonly SearchedDocument[];
10
- document(room: string, path: string): SearchedDocument | null;
11
- close(): void;
12
- };
13
- export declare function reconciled(previous: KeyedResult, next: KeyedResult): {
14
- keyed: KeyedResult;
15
- change: QueryChange;
16
- } | null;
17
- export declare function createReadSide(): ReadSide;
18
- //# 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":"AA2BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAOV,IAAI,EAIJ,WAAW,EAIZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAqDpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,KAAK,IAAI,GACpD,MAAM,IAAI,CAAC;IACd,SAAS,IAAI,SAAS,gBAAgB,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AA8RF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,GAChB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG,IAAI,CA4BpD;AAED,wBAAgB,cAAc,IAAI,QAAQ,CA4HzC"}