@agentshouse/mdruntime 0.1.0-c5f333dfa0583 → 0.1.0-c5fe3b2cddda7

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/README.md +10 -8
  2. package/dist/adapter.d.ts +39 -40
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +2 -1
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +28 -4
  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 +16 -8
  11. package/dist/bootstrap.d.ts.map +1 -1
  12. package/dist/bootstrap.js +142 -94
  13. package/dist/change-set.d.ts +1 -7
  14. package/dist/change-set.d.ts.map +1 -1
  15. package/dist/change-set.js +1 -4
  16. package/dist/client.d.ts +6 -7
  17. package/dist/client.d.ts.map +1 -1
  18. package/dist/client.js +54 -7
  19. package/dist/collection.d.ts +5 -3
  20. package/dist/collection.d.ts.map +1 -1
  21. package/dist/collection.js +24 -19
  22. package/dist/compile.d.ts +6 -1
  23. package/dist/compile.d.ts.map +1 -1
  24. package/dist/compile.js +94 -33
  25. package/dist/connection.d.ts +8 -7
  26. package/dist/connection.d.ts.map +1 -1
  27. package/dist/connection.js +1160 -1151
  28. package/dist/conversation.d.ts +7 -5
  29. package/dist/conversation.d.ts.map +1 -1
  30. package/dist/conversation.js +171 -55
  31. package/dist/durability.d.ts +1 -5
  32. package/dist/durability.d.ts.map +1 -1
  33. package/dist/durability.js +5 -0
  34. package/dist/entry.d.ts +1 -0
  35. package/dist/entry.d.ts.map +1 -1
  36. package/dist/entry.js +1 -1
  37. package/dist/file.d.ts +2 -11
  38. package/dist/file.d.ts.map +1 -1
  39. package/dist/file.js +6 -4
  40. package/dist/fulltext.d.ts +27 -0
  41. package/dist/fulltext.d.ts.map +1 -0
  42. package/dist/fulltext.js +370 -0
  43. package/dist/host.d.ts +3 -4
  44. package/dist/host.d.ts.map +1 -1
  45. package/dist/host.js +42 -18
  46. package/dist/identity.d.ts +0 -1
  47. package/dist/identity.d.ts.map +1 -1
  48. package/dist/identity.js +0 -3
  49. package/dist/index.d.ts +10 -10
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +4 -3
  52. package/dist/live.d.ts.map +1 -1
  53. package/dist/live.js +2 -1
  54. package/dist/media.d.ts +8 -0
  55. package/dist/media.d.ts.map +1 -0
  56. package/dist/media.js +218 -0
  57. package/dist/memory.d.ts +3 -2
  58. package/dist/memory.d.ts.map +1 -1
  59. package/dist/memory.js +93 -38
  60. package/dist/messages.d.ts +28 -0
  61. package/dist/messages.d.ts.map +1 -0
  62. package/dist/messages.js +90 -0
  63. package/dist/model.d.ts +6 -1
  64. package/dist/model.d.ts.map +1 -1
  65. package/dist/model.js +7 -10
  66. package/dist/observation.d.ts +1 -0
  67. package/dist/observation.d.ts.map +1 -1
  68. package/dist/observation.js +1 -1
  69. package/dist/outcome.d.ts +13 -6
  70. package/dist/outcome.d.ts.map +1 -1
  71. package/dist/outcome.js +16 -5
  72. package/dist/overlay.js +1 -1
  73. package/dist/paths.d.ts +1 -0
  74. package/dist/paths.d.ts.map +1 -1
  75. package/dist/paths.js +4 -0
  76. package/dist/query.d.ts +10 -1
  77. package/dist/query.d.ts.map +1 -1
  78. package/dist/query.js +12 -1
  79. package/dist/reach.d.ts +8 -3
  80. package/dist/reach.d.ts.map +1 -1
  81. package/dist/reach.js +69 -46
  82. package/dist/readiness.d.ts +14 -15
  83. package/dist/readiness.d.ts.map +1 -1
  84. package/dist/readiness.js +2 -8
  85. package/dist/recovery.d.ts +1 -0
  86. package/dist/recovery.d.ts.map +1 -1
  87. package/dist/recovery.js +26 -0
  88. package/dist/refresh.d.ts +9 -4
  89. package/dist/refresh.d.ts.map +1 -1
  90. package/dist/refresh.js +64 -30
  91. package/dist/replica.d.ts +5 -5
  92. package/dist/replica.d.ts.map +1 -1
  93. package/dist/replica.js +4 -7
  94. package/dist/room-draft.d.ts +18 -2
  95. package/dist/room-draft.d.ts.map +1 -1
  96. package/dist/room-draft.js +73 -6
  97. package/dist/rows.d.ts +15 -6
  98. package/dist/rows.d.ts.map +1 -1
  99. package/dist/rows.js +102 -74
  100. package/dist/save.d.ts +2 -0
  101. package/dist/save.d.ts.map +1 -1
  102. package/dist/save.js +13 -7
  103. package/dist/search.d.ts +11 -43
  104. package/dist/search.d.ts.map +1 -1
  105. package/dist/search.js +0 -296
  106. package/dist/shared.d.ts +0 -1
  107. package/dist/shared.d.ts.map +1 -1
  108. package/dist/shared.js +0 -10
  109. package/dist/status.d.ts +4 -3
  110. package/dist/status.d.ts.map +1 -1
  111. package/dist/status.js +3 -1
  112. package/dist/store.d.ts +23 -58
  113. package/dist/store.d.ts.map +1 -1
  114. package/dist/store.js +37 -272
  115. package/dist/stored.d.ts +10 -23
  116. package/dist/stored.d.ts.map +1 -1
  117. package/dist/stored.js +217 -218
  118. package/dist/tables.d.ts +51 -46
  119. package/dist/tables.d.ts.map +1 -1
  120. package/dist/tables.js +94 -53
  121. package/dist/transfer.d.ts +0 -5
  122. package/dist/transfer.d.ts.map +1 -1
  123. package/dist/validation.d.ts +3 -4
  124. package/dist/validation.d.ts.map +1 -1
  125. package/dist/validation.js +35 -96
  126. package/dist/wire.d.ts +5 -5
  127. package/dist/wire.d.ts.map +1 -1
  128. package/dist/wire.js +2 -2
  129. package/dist/words.d.ts +19 -0
  130. package/dist/words.d.ts.map +1 -0
  131. package/dist/words.js +156 -0
  132. package/package.json +11 -19
  133. package/AGENTS.md +0 -312
  134. package/dist/chat/acts.d.ts +0 -33
  135. package/dist/chat/acts.d.ts.map +0 -1
  136. package/dist/chat/acts.js +0 -36
  137. package/dist/chat/context.d.ts +0 -3
  138. package/dist/chat/context.d.ts.map +0 -1
  139. package/dist/chat/context.js +0 -10
  140. package/dist/chat/earlier.d.ts +0 -10
  141. package/dist/chat/earlier.d.ts.map +0 -1
  142. package/dist/chat/earlier.js +0 -54
  143. package/dist/chat/house.d.ts +0 -25
  144. package/dist/chat/house.d.ts.map +0 -1
  145. package/dist/chat/house.js +0 -38
  146. package/dist/chat/input.d.ts +0 -11
  147. package/dist/chat/input.d.ts.map +0 -1
  148. package/dist/chat/input.js +0 -92
  149. package/dist/chat/kit.d.ts +0 -61
  150. package/dist/chat/kit.d.ts.map +0 -1
  151. package/dist/chat/kit.js +0 -123
  152. package/dist/chat/lasting.d.ts +0 -6
  153. package/dist/chat/lasting.d.ts.map +0 -1
  154. package/dist/chat/lasting.js +0 -19
  155. package/dist/chat/list.d.ts +0 -28
  156. package/dist/chat/list.d.ts.map +0 -1
  157. package/dist/chat/list.js +0 -103
  158. package/dist/chat/markdown.d.ts +0 -21
  159. package/dist/chat/markdown.d.ts.map +0 -1
  160. package/dist/chat/markdown.js +0 -246
  161. package/dist/chat/message.d.ts +0 -7
  162. package/dist/chat/message.d.ts.map +0 -1
  163. package/dist/chat/message.js +0 -254
  164. package/dist/chat/messages.d.ts +0 -35
  165. package/dist/chat/messages.d.ts.map +0 -1
  166. package/dist/chat/messages.js +0 -210
  167. package/dist/chat/name.d.ts +0 -7
  168. package/dist/chat/name.d.ts.map +0 -1
  169. package/dist/chat/name.js +0 -37
  170. package/dist/chat/opened.d.ts +0 -12
  171. package/dist/chat/opened.d.ts.map +0 -1
  172. package/dist/chat/opened.js +0 -19
  173. package/dist/chat/overlay.d.ts +0 -32
  174. package/dist/chat/overlay.d.ts.map +0 -1
  175. package/dist/chat/overlay.js +0 -103
  176. package/dist/chat/parts.d.ts +0 -58
  177. package/dist/chat/parts.d.ts.map +0 -1
  178. package/dist/chat/parts.js +0 -120
  179. package/dist/chat/pieces.d.ts +0 -62
  180. package/dist/chat/pieces.d.ts.map +0 -1
  181. package/dist/chat/pieces.js +0 -1110
  182. package/dist/chat/process.d.ts +0 -20
  183. package/dist/chat/process.d.ts.map +0 -1
  184. package/dist/chat/process.js +0 -32
  185. package/dist/chat/provider.d.ts +0 -70
  186. package/dist/chat/provider.d.ts.map +0 -1
  187. package/dist/chat/provider.js +0 -635
  188. package/dist/chat/question.d.ts +0 -9
  189. package/dist/chat/question.d.ts.map +0 -1
  190. package/dist/chat/question.js +0 -69
  191. package/dist/chat/questions.d.ts +0 -31
  192. package/dist/chat/questions.d.ts.map +0 -1
  193. package/dist/chat/questions.js +0 -111
  194. package/dist/chat/read.d.ts +0 -5
  195. package/dist/chat/read.d.ts.map +0 -1
  196. package/dist/chat/read.js +0 -13
  197. package/dist/chat/ready.d.ts +0 -37
  198. package/dist/chat/ready.d.ts.map +0 -1
  199. package/dist/chat/ready.js +0 -93
  200. package/dist/chat/room-file.d.ts +0 -8
  201. package/dist/chat/room-file.d.ts.map +0 -1
  202. package/dist/chat/room-file.js +0 -72
  203. package/dist/chat/steady.d.ts +0 -3
  204. package/dist/chat/steady.d.ts.map +0 -1
  205. package/dist/chat/steady.js +0 -26
  206. package/dist/chat/style.d.ts +0 -4
  207. package/dist/chat/style.d.ts.map +0 -1
  208. package/dist/chat/style.js +0 -307
  209. package/dist/chat.d.ts +0 -15
  210. package/dist/chat.d.ts.map +0 -1
  211. package/dist/chat.js +0 -8
  212. package/dist/reads.d.ts +0 -11
  213. package/dist/reads.d.ts.map +0 -1
  214. package/dist/reads.js +0 -98
@@ -1,246 +0,0 @@
1
- import { createElement, Fragment, useEffect, useMemo, useRef, useState, } from 'react';
2
- import { flushSync } from 'react-dom';
3
- import { drawn, longOf, parseMarkdown, pieceAt, remaining, } from './pieces.js';
4
- function unfiled(options) {
5
- const { definitions, ids, onLink } = options;
6
- return onLink === undefined ? { definitions, ids } : { definitions, ids, onLink };
7
- }
8
- export function slugOf(text) {
9
- return text
10
- .trim()
11
- .toLowerCase()
12
- .replace(/[^\p{L}\p{M}\p{N}\s_-]/gu, '')
13
- .replace(/\s/g, '-');
14
- }
15
- export function anchorOf(fragment) {
16
- return `md-${slugOf(fragment)}`;
17
- }
18
- function headingId(slugs, text) {
19
- const slug = slugOf(text);
20
- const seen = slugs.get(slug) ?? 0;
21
- slugs.set(slug, seen + 1);
22
- return anchorOf(seen === 0 ? slug : `${slug}-${seen}`);
23
- }
24
- function whole(file, text) {
25
- return (file !== undefined &&
26
- ([...text.matchAll(file.pattern)].some((one) => one[0] === text) || file.names?.(text) === true));
27
- }
28
- function referenced(file, text, key) {
29
- const parts = [];
30
- let from = 0;
31
- for (const found of text.matchAll(file.pattern)) {
32
- const at = found.index;
33
- if (at > from)
34
- parts.push(text.slice(from, at));
35
- parts.push(createElement(Fragment, { key: at }, file.draw(found[0], found[0], false)));
36
- from = at + found[0].length;
37
- }
38
- if (from === 0)
39
- return text;
40
- if (from < text.length)
41
- parts.push(text.slice(from));
42
- return createElement(Fragment, { key }, ...parts);
43
- }
44
- function safeHref(url) {
45
- const href = url.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, '');
46
- if (href === '' || /^[\\/]{2}/.test(href))
47
- return null;
48
- if (/^(?:https?:|mailto:)/i.test(href))
49
- return href;
50
- if (/^[a-z][a-z0-9+.-]*:/i.test(href))
51
- return null;
52
- return href;
53
- }
54
- function external(href) {
55
- return /^(?:https?:|mailto:)/i.test(href);
56
- }
57
- function textOf(node) {
58
- if ('value' in node && typeof node.value === 'string')
59
- return node.value;
60
- if ('children' in node)
61
- return node.children.map(textOf).join('');
62
- return '';
63
- }
64
- function headingIds(nodes, slugs, ids) {
65
- for (const node of nodes) {
66
- if (node.type === 'heading')
67
- ids.set(node, headingId(slugs, textOf(node)));
68
- else if (node.type === 'blockquote' || node.type === 'list' || node.type === 'listItem') {
69
- headingIds(node.children, slugs, ids);
70
- }
71
- }
72
- }
73
- const revealers = new Set();
74
- export function revealed(anchor) {
75
- const heading = document.getElementById(anchor);
76
- if (heading !== null)
77
- return heading;
78
- for (const reveal of revealers)
79
- if (reveal(anchor))
80
- return document.getElementById(anchor);
81
- return null;
82
- }
83
- function fragmentOf(href) {
84
- try {
85
- return decodeURIComponent(href.slice(1));
86
- }
87
- catch {
88
- return href.slice(1);
89
- }
90
- }
91
- function link(url, node, key, options) {
92
- if (whole(options.file, url)) {
93
- return createElement(Fragment, { key }, options.file.draw(url, textOf(node) || url, false));
94
- }
95
- const inside = node.children.map((child, at) => render(child, at, unfiled(options)));
96
- const href = safeHref(url);
97
- if (href === null)
98
- return createElement(Fragment, { key }, ...inside);
99
- const onLink = options.onLink;
100
- if (external(href) || onLink === undefined) {
101
- const onClick = href.startsWith('#') ? () => revealed(fragmentOf(href)) : undefined;
102
- return createElement('a', { key, href, rel: 'noreferrer', onClick }, ...inside);
103
- }
104
- return createElement('a', {
105
- key,
106
- href,
107
- onClick: (event) => {
108
- event.preventDefault();
109
- onLink(href);
110
- },
111
- }, ...inside);
112
- }
113
- function render(node, key, options, header = false) {
114
- const children = () => 'children' in node
115
- ? node.children.map((child, at) => render(child, at, options))
116
- : [];
117
- switch (node.type) {
118
- case 'root':
119
- return createElement(Fragment, { key }, ...children());
120
- case 'paragraph':
121
- return createElement('p', { key }, ...children());
122
- case 'heading':
123
- return createElement(`h${node.depth}`, { key, id: options.ids.get(node) }, ...children());
124
- case 'text':
125
- return options.file === undefined ? node.value : referenced(options.file, node.value, key);
126
- case 'emphasis':
127
- return createElement('em', { key }, ...children());
128
- case 'strong':
129
- return createElement('strong', { key }, ...children());
130
- case 'delete':
131
- return createElement('del', { key }, ...children());
132
- case 'inlineCode':
133
- return createElement('code', { key }, node.value);
134
- case 'code':
135
- return createElement('pre', { key }, createElement('code', null, node.value));
136
- case 'blockquote':
137
- return createElement('blockquote', { key }, ...children());
138
- case 'list':
139
- return node.ordered === true
140
- ? createElement('ol', { key, start: node.start ?? undefined }, ...children())
141
- : createElement('ul', { key }, ...children());
142
- case 'listItem': {
143
- const items = node.children.flatMap((child, at) => child.type === 'paragraph' && node.spread !== true
144
- ? child.children.map((inline, place) => render(inline, at * 1000 + place, options))
145
- : [render(child, at, options)]);
146
- return createElement('li', { key }, node.checked == null
147
- ? null
148
- : createElement('input', { type: 'checkbox', checked: node.checked, disabled: true }), ...items);
149
- }
150
- case 'thematicBreak':
151
- return createElement('hr', { key });
152
- case 'break':
153
- return createElement('br', { key });
154
- case 'link':
155
- return link(node.url, node, key, options);
156
- case 'linkReference':
157
- return link(options.definitions.get(node.identifier) ?? '', node, key, options);
158
- case 'image':
159
- return whole(options.file, node.url)
160
- ? createElement(Fragment, { key }, options.file.draw(node.url, node.alt || node.url, true))
161
- : (node.alt ?? '');
162
- case 'html':
163
- return node.value;
164
- case 'table':
165
- return createElement('table', { key }, createElement('thead', null, ...node.children.slice(0, 1).map((row, at) => render(row, at, options, true))), createElement('tbody', null, ...node.children.slice(1).map((row, at) => render(row, at, options))));
166
- case 'tableRow':
167
- return createElement('tr', { key }, ...node.children.map((cell, at) => createElement(header ? 'th' : 'td', { key: at }, ...cell.children.map((inline, place) => render(inline, place, options)))));
168
- case 'footnoteReference':
169
- return createElement('sup', { key }, node.label ?? node.identifier);
170
- case 'definition':
171
- case 'yaml':
172
- return null;
173
- default:
174
- return textOf(node);
175
- }
176
- }
177
- const INLINE = new Set([
178
- 'paragraph',
179
- 'heading',
180
- 'emphasis',
181
- 'strong',
182
- 'delete',
183
- 'link',
184
- 'linkReference',
185
- 'tableCell',
186
- ]);
187
- function spokenOf(node) {
188
- if (node.type === 'yaml')
189
- return '';
190
- if (node.type === 'image')
191
- return node.alt ?? '';
192
- if ('value' in node && typeof node.value === 'string')
193
- return node.value;
194
- if (!('children' in node))
195
- return node.type === 'break' ? ' ' : '';
196
- return node.children.map(spokenOf).join(INLINE.has(node.type) ? '' : ' ');
197
- }
198
- export function plainText(text) {
199
- return spokenOf(parseMarkdown(text)).replace(/\s+/g, ' ').trim();
200
- }
201
- export function Markdown({ text, className, ...options }) {
202
- const long = useMemo(() => longOf(text), [text]);
203
- const [shown, setShown] = useState(1);
204
- const more = useRef(null);
205
- const nodes = drawn(long, shown);
206
- const showing = Math.min(shown, long.pieces.length);
207
- const rest = remaining(long, showing);
208
- useEffect(() => {
209
- const sentinel = more.current;
210
- if (sentinel === null)
211
- return;
212
- const watcher = new IntersectionObserver((seen) => {
213
- if (seen.some((one) => one.isIntersecting))
214
- setShown(showing + 1);
215
- }, { rootMargin: '0px 0px 100% 0px' });
216
- watcher.observe(sentinel);
217
- return () => watcher.disconnect();
218
- }, [showing, long]);
219
- useEffect(() => {
220
- if (!rest)
221
- return;
222
- const reveal = (anchor) => {
223
- const slugs = new Map();
224
- for (let index = 0;; index += 1) {
225
- const piece = pieceAt(long, index);
226
- if (piece === null)
227
- return false;
228
- const ids = new Map();
229
- headingIds(piece.nodes, slugs, ids);
230
- if ([...ids.values()].includes(anchor)) {
231
- if (index >= showing)
232
- flushSync(() => setShown(index + 1));
233
- return true;
234
- }
235
- }
236
- };
237
- revealers.add(reveal);
238
- return () => {
239
- revealers.delete(reveal);
240
- };
241
- }, [showing, long, rest]);
242
- const ids = new Map();
243
- headingIds(nodes, new Map(), ids);
244
- const rendering = { ...options, definitions: long.urls, ids };
245
- return createElement('div', { className }, ...nodes.map((node, at) => render(node, at, rendering)), rest ? createElement('div', { key: 'more', ref: more }) : null);
246
- }
@@ -1,7 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- export declare const Linked: import("react").Context<((href: string) => void) | null>;
3
- export declare function UserMessage(): ReactElement;
4
- export declare function HouseMessage(): ReactElement;
5
- export declare function Undelivered(): ReactElement;
6
- export declare function AssistantMessage(): ReactElement;
7
- //# sourceMappingURL=message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAuCf,eAAO,MAAM,MAAM,kCAAyB,MAAM,KAAK,IAAI,SAAe,CAAC;AAiR3E,wBAAgB,WAAW,IAAI,YAAY,CAkB1C;AAuCD,wBAAgB,YAAY,IAAI,YAAY,CAW3C;AAkCD,wBAAgB,WAAW,IAAI,YAAY,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CAiG/C"}
@@ -1,254 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createContext, useContext, } from 'react';
3
- import { ActionBarPrimitive, AuiIf, ErrorPrimitive, MessagePrimitive, groupPartByType, useAuiState, } from '@assistant-ui/react';
4
- import { MarkdownTextPrimitive } from '@assistant-ui/react-markdown';
5
- import { Collapsible } from 'radix-ui';
6
- import remarkGfm from 'remark-gfm';
7
- import Bot from 'lucide-react/dist/esm/icons/bot.mjs';
8
- import Brain from 'lucide-react/dist/esm/icons/brain.mjs';
9
- import CalendarClock from 'lucide-react/dist/esm/icons/calendar-clock.mjs';
10
- import Check from 'lucide-react/dist/esm/icons/check.mjs';
11
- import ChevronRight from 'lucide-react/dist/esm/icons/chevron-right.mjs';
12
- import Copy from 'lucide-react/dist/esm/icons/copy.mjs';
13
- import Cpu from 'lucide-react/dist/esm/icons/cpu.mjs';
14
- import ImageGlyph from 'lucide-react/dist/esm/icons/image.mjs';
15
- import Layers from 'lucide-react/dist/esm/icons/layers.mjs';
16
- import ListChecks from 'lucide-react/dist/esm/icons/list-checks.mjs';
17
- import ListTodo from 'lucide-react/dist/esm/icons/list-todo.mjs';
18
- import RotateCw from 'lucide-react/dist/esm/icons/rotate-cw.mjs';
19
- import Send from 'lucide-react/dist/esm/icons/send.mjs';
20
- import SlidersHorizontal from 'lucide-react/dist/esm/icons/sliders-horizontal.mjs';
21
- import Terminal from 'lucide-react/dist/esm/icons/terminal.mjs';
22
- import { SESSION_STARTED } from '../conversation.js';
23
- import { buttonClass, Working } from './kit.js';
24
- import { StillRunning } from './lasting.js';
25
- import { stamp } from './name.js';
26
- import { useOpened } from './opened.js';
27
- import { useChat } from './provider.js';
28
- import { isRoomPath, RoomFile } from './room-file.js';
29
- import { list, record, text } from './read.js';
30
- export const Linked = createContext(null);
31
- const groupBy = groupPartByType({
32
- reasoning: ['group-thought', 'group-reasoning'],
33
- 'tool-call': ['group-thought'],
34
- });
35
- const GFM = [remarkGfm];
36
- const SENT = {
37
- send_routine_request: 'Sent a request',
38
- cancel_routine_request: 'Cancelled a request',
39
- };
40
- const MARKED = {
41
- mode: { title: 'Mode', Icon: SlidersHorizontal },
42
- compaction: { title: 'Context compacted', Icon: Layers },
43
- retry: { title: 'Retrying', Icon: RotateCw },
44
- model: { title: 'Model', Icon: Cpu },
45
- };
46
- const STEP = { completed: '✓', in_progress: '→' };
47
- function counted(count) {
48
- return count === 1 ? '1 command' : `${count} commands`;
49
- }
50
- function jobShown(said) {
51
- const icon = _jsx(CalendarClock, { "aria-hidden": "true" });
52
- const shown = { icon, input: '', output: '' };
53
- const label = said('label');
54
- const state = said('state');
55
- if (said('job') === 'started') {
56
- return { ...shown, title: 'Background job started', detail: label };
57
- }
58
- if (said('job') === 'scheduled') {
59
- const detail = said('next') === '' ? label : `${label} · ${state}`;
60
- return { ...shown, title: 'Schedule set', detail };
61
- }
62
- const detail = state === '' ? label : `${label} · ${state}`;
63
- return { ...shown, title: 'Background job ended', detail };
64
- }
65
- function shownOf({ toolName, args, result }) {
66
- const said = (key) => text(args, key) ?? '';
67
- const plain = { detail: '', input: '', output: '' };
68
- switch (toolName) {
69
- case 'subagent':
70
- return {
71
- icon: _jsx(Bot, { "aria-hidden": "true" }),
72
- title: 'Sub-agent',
73
- detail: said('description'),
74
- input: said('description'),
75
- output: typeof result === 'string' ? result : '',
76
- };
77
- case 'message':
78
- return {
79
- ...plain,
80
- icon: _jsx(Send, { "aria-hidden": "true" }),
81
- title: SENT[said('command')] ?? said('command'),
82
- detail: said('target'),
83
- };
84
- case 'plan': {
85
- const steps = list(args, 'steps').map(record);
86
- return {
87
- ...plain,
88
- icon: _jsx(ListTodo, { "aria-hidden": "true" }),
89
- title: 'Plan',
90
- detail: text(steps.find((one) => one.status === 'in_progress') ?? {}, 'content') ?? '',
91
- input: steps
92
- .map((one) => `${STEP[text(one, 'status') ?? ''] ?? '○'} ${text(one, 'content') ?? ''}`)
93
- .join('\n'),
94
- };
95
- }
96
- case 'marker': {
97
- const marked = MARKED[said('marker')];
98
- if (marked === undefined)
99
- return jobShown(said);
100
- return {
101
- ...plain,
102
- icon: _jsx(marked.Icon, { "aria-hidden": "true" }),
103
- title: marked.title,
104
- detail: said('text'),
105
- };
106
- }
107
- default:
108
- return {
109
- ...plain,
110
- icon: _jsx(Terminal, { "aria-hidden": "true" }),
111
- title: counted(Number(args.count)),
112
- };
113
- }
114
- }
115
- function workedOf(calls) {
116
- const commands = calls.reduce((sum, one) => (one.toolName === 'commands' ? sum + Number(one.args.count) : sum), 0);
117
- return commands === 0 ? 'Worked' : `Worked · ${counted(commands)}`;
118
- }
119
- function Toggle({ icon, label, detail = '', active, children, }) {
120
- return (_jsxs(Collapsible.Root, { children: [_jsxs(Collapsible.Trigger, { className: "ahc-row ahc-toggle", children: [icon, _jsx("span", { className: active ? 'ahc-clipped ahc-shimmer' : 'ahc-clipped', children: label }), detail === '' ? null : _jsx("span", { className: "ahc-clipped", children: detail }), _jsx("span", { className: "ahc-chevron", children: _jsx(ChevronRight, { "aria-hidden": "true" }) })] }), _jsx(Collapsible.Content, { children: children })] }));
121
- }
122
- function ToolCall({ call, active }) {
123
- const shown = shownOf(call);
124
- if (shown.input === '' && shown.output === '') {
125
- return (_jsxs("div", { className: "ahc-toolline ahc-quiet", children: [shown.icon, _jsx("span", { className: active ? 'ahc-shimmer' : undefined, children: shown.title }), shown.detail === '' ? null : _jsx("span", { className: "ahc-clipped", children: shown.detail })] }));
126
- }
127
- return (_jsx(Toggle, { icon: shown.icon, label: shown.title, detail: shown.detail, active: active, children: _jsxs("div", { className: "ahc-quiet ahc-wells", children: [shown.input === '' ? null : _jsx("div", { className: "ahc-well", children: shown.input }), shown.output === '' ? null : _jsx("div", { className: "ahc-well", children: shown.output })] }) }));
128
- }
129
- function Thought({ indices, active, children, }) {
130
- const parts = useAuiState((s) => s.message.parts);
131
- const held = indices.flatMap((at) => parts[at] ?? []);
132
- const calls = held.flatMap((part) => (part.type === 'tool-call' ? [part] : []));
133
- if (calls.length === 0 || held.length === 1)
134
- return _jsx(_Fragment, { children: children });
135
- const last = held.at(-1);
136
- const now = last?.type === 'tool-call'
137
- ? shownOf(last)
138
- : { icon: _jsx(Brain, { "aria-hidden": "true" }), title: 'Thinking', detail: '' };
139
- return (_jsx(Toggle, { icon: active ? now.icon : _jsx(ListChecks, { "aria-hidden": "true" }), label: active ? now.title : workedOf(calls), detail: active ? now.detail : '', active: active, children: children }));
140
- }
141
- const SCHEME = /^[a-z][a-z0-9+.-]*:/i;
142
- const ROOM_LINK = /\[([^\]]*)\]\((\/rooms\/[^)\s]+)\)/gu;
143
- function nameOf(href) {
144
- return href.slice(href.lastIndexOf('/') + 1);
145
- }
146
- function Linking({ href, ...rest }) {
147
- const onLink = useContext(Linked);
148
- if (SCHEME.test(href) || onLink === null)
149
- return _jsx("a", { ...rest, href: href, rel: "noreferrer" });
150
- return (_jsx("a", { ...rest, href: href, onClick: (event) => {
151
- event.preventDefault();
152
- onLink(href);
153
- } }));
154
- }
155
- function Anchor({ node: _node, href = '', ...rest }) {
156
- const link = _jsx(Linking, { ...rest, href: href });
157
- return isRoomPath(href) ? _jsx(RoomFile, { href: href, name: nameOf(href), otherwise: link }) : link;
158
- }
159
- const LINKED = { a: Anchor };
160
- const THOUGHT = { className: 'ahc-thought' };
161
- function Said({ thought = false }) {
162
- return (_jsx(MarkdownTextPrimitive, { className: "ahc-text ahc-markdown", containerProps: thought ? THOUGHT : undefined, remarkPlugins: GFM, components: LINKED, smooth: false }));
163
- }
164
- function Transcribed({ text: said }) {
165
- return (_jsxs("span", { className: "ahc-transcript ahc-quiet", children: [_jsx("span", { className: "ahc-meta", children: "Transcript: " }), said] }));
166
- }
167
- function UserText({ text: said }) {
168
- const transcripts = useAuiState((s) => s.message.metadata.custom.transcripts);
169
- const pieces = [];
170
- const shown = new Set();
171
- let from = 0;
172
- for (const found of said.matchAll(ROOM_LINK)) {
173
- const [whole, , href] = found;
174
- pieces.push(said.slice(from, found.index));
175
- pieces.push(_jsx(RoomFile, { href: href, name: nameOf(href), otherwise: whole }, found.index));
176
- const transcript = transcripts?.find((one) => one.path === href);
177
- if (transcript !== undefined && !shown.has(href)) {
178
- shown.add(href);
179
- pieces.push(_jsx(Transcribed, { text: transcript.text }, `${found.index}:transcript`));
180
- }
181
- from = found.index + whole.length;
182
- }
183
- pieces.push(said.slice(from));
184
- return _jsx("span", { className: "ahc-said", children: pieces });
185
- }
186
- export function UserMessage() {
187
- const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text' && one.text !== ''));
188
- const undelivered = useAuiState((s) => s.message.metadata.custom.undelivered === true);
189
- const unknown = useAuiState((s) => s.message.metadata.custom.unknown === true);
190
- const id = useAuiState((s) => s.message.id);
191
- return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "You", className: "ahc-you", children: [said ? (_jsx("div", { className: "ahc-bubble", children: _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }) })) : null, undelivered ? _jsx(Undelivered, {}) : null, unknown ? _jsx(DeliveryUnknown, { message: id }) : null] }));
192
- }
193
- function From({ source }) {
194
- if (source.kind === 'mail') {
195
- return (_jsxs("div", { className: "ahc-house__from", children: [_jsx("span", { className: "ahc-house__title", children: "House \u00B7 Mail" }), _jsx("span", { className: "ahc-meta", children: `From ${source.agent} of ${source.owner}` })] }));
196
- }
197
- const { requester, room } = source;
198
- return (_jsxs("div", { className: "ahc-house__from", children: [_jsx("span", { className: "ahc-house__title", children: `House · ${source.routine} v${source.version}` }), _jsx("span", { className: "ahc-meta", children: requester.room ? `From ${requester.name}` : `From ${requester.name} in ${room.name}` })] }));
199
- }
200
- function Decided({ source, waiting, }) {
201
- if (source.kind !== 'request')
202
- return null;
203
- if (waiting)
204
- return _jsx("span", { className: "ahc-meta", children: "Waits for your approval" });
205
- if (source.approved === null)
206
- return null;
207
- return (_jsxs("span", { className: "ahc-meta", children: ["Approved ", _jsx("time", { dateTime: source.approved, children: stamp(source.approved) })] }));
208
- }
209
- export function HouseMessage() {
210
- const custom = useAuiState((s) => s.message.metadata.custom);
211
- const source = (custom.source ?? null);
212
- return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "House", className: "ahc-house", children: [source === null ? null : _jsx(From, { source: source }), _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }), source === null ? null : _jsx(Decided, { source: source, waiting: custom.waiting === true }), custom.undelivered === true ? _jsx(Undelivered, {}) : null] }));
213
- }
214
- function DeliveryUnknown({ message }) {
215
- const chat = useChat();
216
- return (_jsxs("span", { className: "ahc-meta", children: ["Delivery unknown", _jsx("button", { type: "button", className: buttonClass('outline', true, false), disabled: chat.acting.busy, onClick: () => void chat.retry(message), children: "Retry" })] }));
217
- }
218
- function Renew() {
219
- const chat = useOpened();
220
- if (chat.deleted)
221
- return null;
222
- return (_jsx("button", { type: "button", className: buttonClass('outline', true, false), disabled: chat.acting.busy, onClick: () => void chat.renew(), children: "Start new chat" }));
223
- }
224
- export function Undelivered() {
225
- return _jsx("span", { className: "ahc-meta", children: "Telegram didn't receive this" });
226
- }
227
- export function AssistantMessage() {
228
- const running = useAuiState((s) => s.message.status?.type === 'running');
229
- const started = useAuiState((s) => s.message.metadata.isOptimistic !== true);
230
- const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text'));
231
- const last = useAuiState((s) => s.message.isLast);
232
- const custom = useAuiState((s) => s.message.metadata.custom);
233
- const lasting = Array.isArray(custom.lasting) ? custom.lasting : [];
234
- return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": running ? 'Turn, running' : 'Turn', className: "ahc-turn", children: [_jsx(MessagePrimitive.GroupedParts, { groupBy: groupBy, indicator: "empty", children: ({ part, children }) => {
235
- switch (part.type) {
236
- case 'group-thought':
237
- return (_jsx(Thought, { indices: part.indices, active: part.status.type === 'running', children: children }));
238
- case 'group-reasoning':
239
- return (_jsx(Toggle, { icon: _jsx(Brain, { "aria-hidden": "true" }), label: "Thinking", active: part.status.type === 'running', children: children }));
240
- case 'text':
241
- return _jsx(Said, {});
242
- case 'reasoning':
243
- return _jsx(Said, { thought: true });
244
- case 'tool-call':
245
- return _jsx(ToolCall, { call: part, active: part.status.type === 'running' });
246
- case 'file':
247
- return (_jsx(RoomFile, { href: part.data, name: part.filename ?? nameOf(part.data), otherwise: _jsxs("div", { className: "ahc-toolline ahc-quiet", children: [_jsx(ImageGlyph, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-clipped", children: part.filename })] }) }));
248
- case 'indicator':
249
- return _jsx(Working, { step: started ? SESSION_STARTED : undefined });
250
- default:
251
- return null;
252
- }
253
- } }), _jsx(MessagePrimitive.Error, { children: _jsxs(ErrorPrimitive.Root, { className: "ahc-failure", children: [_jsx(ErrorPrimitive.Message, {}), _jsx(AuiIf, { condition: (s) => s.thread.capabilities.reload && s.message.metadata.custom.again === true, children: _jsx(ActionBarPrimitive.Reload, { className: buttonClass('outline', true, false), children: "Try again" }) }), custom.renew === true ? _jsx(Renew, {}) : null] }) }), custom.undelivered === true ? _jsx(Undelivered, {}) : null, said ? (_jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", autohideFloat: "always", className: last ? 'ahc-actions' : 'ahc-actions ahc-actions--floating', children: _jsxs(ActionBarPrimitive.Copy, { className: `${buttonClass('quiet', true, true)} ahc-secondary`, "aria-label": "Copy", children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(Check, { "aria-hidden": "true" }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(Copy, { "aria-hidden": "true" }) })] }) })) : null, lasting.length === 0 ? null : _jsx(StillRunning, { lasting: lasting })] }));
254
- }
@@ -1,35 +0,0 @@
1
- import type { ThreadMessageLike } from '@assistant-ui/react';
2
- import type { TurnContext } from '../adapter.js';
3
- import type { ConversationView } from '../conversation.js';
4
- import { type ChatRequest, type HouseSource } from './house.js';
5
- import { type Part } from './parts.js';
6
- type Entry = ConversationView['messages'][number];
7
- export type Transcript = {
8
- readonly path: string;
9
- readonly text: string;
10
- };
11
- export type Said = {
12
- readonly turn: string;
13
- readonly user: boolean;
14
- readonly house: boolean;
15
- readonly source: HouseSource | null;
16
- readonly waiting: boolean;
17
- readonly text: string;
18
- readonly transcripts: readonly Transcript[];
19
- readonly parts: readonly Part[];
20
- readonly context: TurnContext | null;
21
- readonly failure: string | null;
22
- readonly resumeRefused: boolean;
23
- readonly undelivered: boolean;
24
- };
25
- export declare function saidOf(entry: Entry): Said;
26
- export declare function awaitsTurn(view: ConversationView | null): boolean;
27
- export declare function requestIn(view: ConversationView | null): {
28
- readonly request: ChatRequest;
29
- readonly waiting: boolean;
30
- } | null;
31
- export declare function askedBefore(view: ConversationView | null, id: string | null): string | null;
32
- export declare function chatMessages(view: ConversationView | null): ThreadMessageLike[];
33
- export declare function contextOf(view: ConversationView | null): TurnContext | null;
34
- export {};
35
- //# sourceMappingURL=messages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/chat/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAY,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAA0D,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAO/F,KAAK,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAaF,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAyBzC;AAiGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAKjE;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAC5B;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAOrE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAO3F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,EAAE,CAiE/E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAS3E"}