@agentshouse/mdruntime 0.1.0-c97456d63baba → 0.1.0-c9b1e59e5baeb
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.
- package/AGENTS.md +221 -221
- package/README.md +8 -8
- package/dist/adapter.d.ts +35 -6
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +5 -1
- package/dist/change-set.d.ts +5 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -2
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.js +1 -1
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +40 -4
- package/dist/chat/markdown.d.ts +1 -0
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +78 -20
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +9 -2
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +36 -16
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +10 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +1 -0
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +22 -14
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -1
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +1 -1
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.js +1 -1
- package/dist/chat.d.ts +2 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +6 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/collection.d.ts +4 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +128 -63
- package/dist/connection.d.ts +13 -5
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +506 -228
- package/dist/conversation.d.ts +11 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +195 -41
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +3 -2
- package/dist/host.d.ts +9 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +58 -9
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +24 -11
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +8 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +5 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +197 -132
- package/dist/query.d.ts +27 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +36 -7
- package/dist/reach.d.ts +1 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +17 -4
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +3 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +256 -69
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +39 -14
- package/dist/replica.d.ts +11 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +79 -41
- package/dist/room-draft.d.ts +12 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +11 -12
- package/dist/rows.d.ts +3 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +8 -1
- package/dist/save.d.ts +4 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +195 -111
- package/dist/search.d.ts +27 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +89 -7
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +63 -33
- package/dist/store.d.ts +20 -4
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +404 -317
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +26 -7
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +16 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -0
- package/package.json +2 -2
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
package/dist/chat/markdown.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createElement, Fragment } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { gfm } from 'micromark-extension-gfm';
|
|
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';
|
|
5
4
|
function unfiled(options) {
|
|
6
|
-
const { definitions,
|
|
7
|
-
return onLink === undefined ? { definitions,
|
|
5
|
+
const { definitions, ids, onLink } = options;
|
|
6
|
+
return onLink === undefined ? { definitions, ids } : { definitions, ids, onLink };
|
|
8
7
|
}
|
|
9
8
|
export function slugOf(text) {
|
|
10
9
|
return text
|
|
@@ -42,9 +41,6 @@ function referenced(file, text, key) {
|
|
|
42
41
|
parts.push(text.slice(from));
|
|
43
42
|
return createElement(Fragment, { key }, ...parts);
|
|
44
43
|
}
|
|
45
|
-
function parseMarkdown(text) {
|
|
46
|
-
return fromMarkdown(text, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] });
|
|
47
|
-
}
|
|
48
44
|
function safeHref(url) {
|
|
49
45
|
const href = url.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, '');
|
|
50
46
|
if (href === '' || /^[\\/]{2}/.test(href))
|
|
@@ -65,13 +61,32 @@ function textOf(node) {
|
|
|
65
61
|
return node.children.map(textOf).join('');
|
|
66
62
|
return '';
|
|
67
63
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
}
|
|
75
90
|
}
|
|
76
91
|
function link(url, node, key, options) {
|
|
77
92
|
if (whole(options.file, url)) {
|
|
@@ -83,7 +98,8 @@ function link(url, node, key, options) {
|
|
|
83
98
|
return createElement(Fragment, { key }, ...inside);
|
|
84
99
|
const onLink = options.onLink;
|
|
85
100
|
if (external(href) || onLink === undefined) {
|
|
86
|
-
|
|
101
|
+
const onClick = href.startsWith('#') ? () => revealed(fragmentOf(href)) : undefined;
|
|
102
|
+
return createElement('a', { key, href, rel: 'noreferrer', onClick }, ...inside);
|
|
87
103
|
}
|
|
88
104
|
return createElement('a', {
|
|
89
105
|
key,
|
|
@@ -104,7 +120,7 @@ function render(node, key, options, header = false) {
|
|
|
104
120
|
case 'paragraph':
|
|
105
121
|
return createElement('p', { key }, ...children());
|
|
106
122
|
case 'heading':
|
|
107
|
-
return createElement(`h${node.depth}`, { key, id:
|
|
123
|
+
return createElement(`h${node.depth}`, { key, id: options.ids.get(node) }, ...children());
|
|
108
124
|
case 'text':
|
|
109
125
|
return options.file === undefined ? node.value : referenced(options.file, node.value, key);
|
|
110
126
|
case 'emphasis':
|
|
@@ -183,6 +199,48 @@ export function plainText(text) {
|
|
|
183
199
|
return spokenOf(parseMarkdown(text)).replace(/\s+/g, ' ').trim();
|
|
184
200
|
}
|
|
185
201
|
export function Markdown({ text, className, ...options }) {
|
|
186
|
-
const
|
|
187
|
-
|
|
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);
|
|
188
246
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAoCf,eAAO,MAAM,MAAM,kCAAyB,MAAM,KAAK,IAAI,SAAe,CAAC;AA2O3E,wBAAgB,WAAW,IAAI,YAAY,CA+B1C;AAmBD,wBAAgB,WAAW,IAAI,YAAY,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CA0F/C"}
|
package/dist/chat/message.js
CHANGED
|
@@ -23,6 +23,7 @@ import Terminal from 'lucide-react/dist/esm/icons/terminal.mjs';
|
|
|
23
23
|
import { SESSION_STARTED } from '../conversation.js';
|
|
24
24
|
import { buttonClass, Name, Working } from './kit.js';
|
|
25
25
|
import { StillRunning } from './lasting.js';
|
|
26
|
+
import { useChat } from './provider.js';
|
|
26
27
|
import { list, record, text } from './read.js';
|
|
27
28
|
export const Linked = createContext(null);
|
|
28
29
|
const groupBy = groupPartByType({
|
|
@@ -148,7 +149,7 @@ function Anchor({ node: _node, href = '', ...rest }) {
|
|
|
148
149
|
const LINKED = { a: Anchor };
|
|
149
150
|
const THOUGHT = { className: 'ahc-thought' };
|
|
150
151
|
function Said({ thought = false }) {
|
|
151
|
-
return (_jsx(MarkdownTextPrimitive, { className: "ahc-text ahc-markdown", containerProps: thought ? THOUGHT : undefined, remarkPlugins: GFM, components: LINKED }));
|
|
152
|
+
return (_jsx(MarkdownTextPrimitive, { className: "ahc-text ahc-markdown", containerProps: thought ? THOUGHT : undefined, remarkPlugins: GFM, components: LINKED, smooth: false }));
|
|
152
153
|
}
|
|
153
154
|
function UserText() {
|
|
154
155
|
return _jsx(MessagePartPrimitive.Text, { className: "ahc-said" });
|
|
@@ -157,7 +158,13 @@ export function UserMessage() {
|
|
|
157
158
|
const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text' && one.text !== ''));
|
|
158
159
|
const attached = useAuiState((s) => (s.message.attachments?.length ?? 0) > 0);
|
|
159
160
|
const undelivered = useAuiState((s) => s.message.metadata.custom.undelivered === true);
|
|
160
|
-
|
|
161
|
+
const unknown = useAuiState((s) => s.message.metadata.custom.unknown === true);
|
|
162
|
+
const id = useAuiState((s) => s.message.id);
|
|
163
|
+
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, attached ? (_jsx("div", { className: "ahc-chips", children: _jsx(MessagePrimitive.Attachments, { children: ({ attachment }) => (_jsxs("span", { className: "ahc-chip", children: [_jsx(Paperclip, { "aria-hidden": "true" }), _jsx(Name, { text: attachment.name })] })) }) })) : null, undelivered ? _jsx(Undelivered, {}) : null, unknown ? _jsx(DeliveryUnknown, { message: id }) : null] }));
|
|
164
|
+
}
|
|
165
|
+
function DeliveryUnknown({ message }) {
|
|
166
|
+
const chat = useChat();
|
|
167
|
+
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" })] }));
|
|
161
168
|
}
|
|
162
169
|
export function Undelivered() {
|
|
163
170
|
return _jsx("span", { className: "ahc-meta", children: "Telegram didn't receive this" });
|
|
@@ -1 +1 @@
|
|
|
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,EAA0D,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAO/F,KAAK,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,E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,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,CAmD/E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAS3E"}
|
package/dist/chat/messages.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { contextIn, jobOf, partsOf, stillRunning } from './parts.js';
|
|
2
2
|
import { list, record, text } from './read.js';
|
|
3
|
+
const SAID = new WeakMap();
|
|
4
|
+
const CONVERTED = new WeakMap();
|
|
3
5
|
export function saidOf(entry) {
|
|
6
|
+
const held = SAID.get(entry);
|
|
7
|
+
if (held !== undefined)
|
|
8
|
+
return held;
|
|
4
9
|
const message = record(entry.message);
|
|
5
|
-
|
|
10
|
+
const said = {
|
|
6
11
|
turn: text(message, 'turn_id') ?? entry.turn,
|
|
7
12
|
user: text(message, 'role') === 'user',
|
|
8
13
|
text: text(message, 'text') ?? '',
|
|
@@ -12,6 +17,24 @@ export function saidOf(entry) {
|
|
|
12
17
|
undelivered: message.telegram_undelivered === true,
|
|
13
18
|
files: list(message, 'files').flatMap((one) => text(record(one), 'name') ?? []),
|
|
14
19
|
};
|
|
20
|
+
SAID.set(entry, said);
|
|
21
|
+
return said;
|
|
22
|
+
}
|
|
23
|
+
function sameWork(held, now) {
|
|
24
|
+
return (held.length === now.length &&
|
|
25
|
+
held.every((one, at) => one.kind === now[at].kind && one.title === now[at].title && one.next === now[at].next));
|
|
26
|
+
}
|
|
27
|
+
function converted(entry, lasting, again, unknown, convert) {
|
|
28
|
+
const held = CONVERTED.get(entry);
|
|
29
|
+
if (held !== undefined &&
|
|
30
|
+
held.again === again &&
|
|
31
|
+
held.unknown === unknown &&
|
|
32
|
+
sameWork(held.lasting, lasting)) {
|
|
33
|
+
return held.message;
|
|
34
|
+
}
|
|
35
|
+
const message = convert();
|
|
36
|
+
CONVERTED.set(entry, { lasting, again, unknown, message });
|
|
37
|
+
return message;
|
|
15
38
|
}
|
|
16
39
|
function markerArgs(part) {
|
|
17
40
|
if (part.marker !== 'job')
|
|
@@ -93,7 +116,8 @@ export function chatMessages(view) {
|
|
|
93
116
|
const one = saidOf(entry);
|
|
94
117
|
const custom = { undelivered: one.undelivered };
|
|
95
118
|
if (one.user) {
|
|
96
|
-
|
|
119
|
+
const unknown = view.deliveryUnknown.includes(entry.identity);
|
|
120
|
+
return converted(entry, [], false, unknown, () => ({
|
|
97
121
|
id: entry.identity,
|
|
98
122
|
role: 'user',
|
|
99
123
|
content: [{ type: 'text', text: one.text }],
|
|
@@ -104,28 +128,24 @@ export function chatMessages(view) {
|
|
|
104
128
|
status: { type: 'complete' },
|
|
105
129
|
content: [],
|
|
106
130
|
})),
|
|
107
|
-
metadata: { custom },
|
|
108
|
-
};
|
|
131
|
+
metadata: { custom: { ...custom, unknown } },
|
|
132
|
+
}));
|
|
109
133
|
}
|
|
110
134
|
const failed = one.failure === null
|
|
111
135
|
? undefined
|
|
112
136
|
: { type: 'incomplete', reason: 'error', error: one.failure };
|
|
113
|
-
|
|
137
|
+
const working = lasting.get(one.turn) ?? [];
|
|
138
|
+
const again = failed !== undefined &&
|
|
139
|
+
view.turn === null &&
|
|
140
|
+
at === view.messages.length - 1 &&
|
|
141
|
+
askedBefore(view, view.messages[at - 1]?.identity ?? null) !== null;
|
|
142
|
+
return converted(entry, working, again, false, () => ({
|
|
114
143
|
id: entry.identity,
|
|
115
144
|
role: 'assistant',
|
|
116
145
|
content: contentOf(entry.identity, one.parts, false),
|
|
117
146
|
status: failed,
|
|
118
|
-
metadata: {
|
|
119
|
-
|
|
120
|
-
...custom,
|
|
121
|
-
lasting: lasting.get(one.turn) ?? [],
|
|
122
|
-
again: failed !== undefined &&
|
|
123
|
-
view.turn === null &&
|
|
124
|
-
at === view.messages.length - 1 &&
|
|
125
|
-
askedBefore(view, view.messages[at - 1]?.identity ?? null) !== null,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
};
|
|
147
|
+
metadata: { custom: { ...custom, lasting: working, again } },
|
|
148
|
+
}));
|
|
129
149
|
});
|
|
130
150
|
if (view.turn === null)
|
|
131
151
|
return said;
|
package/dist/chat/overlay.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare function overlay(): Overlay;
|
|
|
24
24
|
export declare function sentMessage(key: string, into: readonly string[], said: ChatDraft, turn: string | null): Expectation;
|
|
25
25
|
export declare function optionChosen(conversation: string, option: string, value: string): Expectation;
|
|
26
26
|
export declare function questionAnswered(conversation: string, interaction: string): Expectation;
|
|
27
|
+
export declare function deliveryRetried(conversation: string, message: string): Expectation;
|
|
27
28
|
export declare function conversationListed(entry: ConversationEntry): Expectation;
|
|
28
29
|
export declare function conversationChanged(conversation: string, changes: Partial<Pick<ConversationEntry, 'name' | 'finished'>>, shown: (entry: ConversationEntry) => boolean): Expectation;
|
|
29
30
|
export declare function conversationGone(conversation: string): Expectation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/chat/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG/E,KAAK,OAAO,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAE5C,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC/C,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACxC,GAC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C,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IACvD,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CACvC,CAAC;AAEF,wBAAgB,OAAO,IAAI,OAAO,CAiBjC;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,GAAG,IAAI,GAClB,WAAW,CA2Bb;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAkB7F;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,WAAW,CAWvF;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAUlF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAQxE;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,EAC9D,KAAK,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,GAC3C,WAAW,CAQb;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAQlE"}
|
package/dist/chat/overlay.js
CHANGED
|
@@ -68,6 +68,16 @@ export function questionAnswered(conversation, interaction) {
|
|
|
68
68
|
shown: (held) => held.conversation === conversation && !held.questions.some(ours),
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
+
export function deliveryRetried(conversation, message) {
|
|
72
|
+
return {
|
|
73
|
+
key: `retry ${conversation} ${message}`,
|
|
74
|
+
view: 'conversation',
|
|
75
|
+
draw: (held) => held.conversation !== conversation
|
|
76
|
+
? held
|
|
77
|
+
: { ...held, deliveryUnknown: held.deliveryUnknown.filter((one) => one !== message) },
|
|
78
|
+
shown: (held) => held.conversation === conversation && !held.deliveryUnknown.includes(message),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
71
81
|
export function conversationListed(entry) {
|
|
72
82
|
const ours = (one) => one.conversation === entry.conversation;
|
|
73
83
|
return {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
2
|
+
export type Root = ReturnType<typeof fromMarkdown>;
|
|
3
|
+
export type Block = Root['children'][number];
|
|
4
|
+
export declare function parseMarkdown(text: string): Root;
|
|
5
|
+
export type Step = 'list' | 'item' | 'footnote' | 'table' | 'blockquote' | 'paragraph';
|
|
6
|
+
export interface Piece {
|
|
7
|
+
readonly nodes: readonly Block[];
|
|
8
|
+
readonly path: readonly Step[];
|
|
9
|
+
readonly join: string;
|
|
10
|
+
}
|
|
11
|
+
interface Level {
|
|
12
|
+
readonly kind: 'quote' | 'item' | 'note';
|
|
13
|
+
readonly line: number;
|
|
14
|
+
readonly column: number;
|
|
15
|
+
readonly size: number;
|
|
16
|
+
readonly carry: string;
|
|
17
|
+
readonly spread: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface Next {
|
|
20
|
+
readonly start: number;
|
|
21
|
+
readonly path: readonly Step[];
|
|
22
|
+
readonly join: string;
|
|
23
|
+
readonly carry: string;
|
|
24
|
+
readonly levels: readonly Level[];
|
|
25
|
+
}
|
|
26
|
+
interface Found {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly at: number;
|
|
29
|
+
readonly url: string;
|
|
30
|
+
}
|
|
31
|
+
interface Region {
|
|
32
|
+
readonly from: number;
|
|
33
|
+
readonly looks: readonly number[];
|
|
34
|
+
readonly last: ReadonlyMap<string, number>;
|
|
35
|
+
readonly runs: ReadonlyMap<number, number>;
|
|
36
|
+
}
|
|
37
|
+
interface Discovery {
|
|
38
|
+
readonly found: Found[];
|
|
39
|
+
next: Next | null;
|
|
40
|
+
}
|
|
41
|
+
export interface Long {
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly starts: Int32Array;
|
|
44
|
+
readonly breaks: Int32Array;
|
|
45
|
+
readonly quoteBreaks: Int32Array;
|
|
46
|
+
readonly anchors: readonly number[];
|
|
47
|
+
readonly candidates: ReadonlyMap<string, readonly number[]>;
|
|
48
|
+
readonly pieces: Piece[];
|
|
49
|
+
next: Next | null;
|
|
50
|
+
readonly urls: Map<string, string>;
|
|
51
|
+
readonly spans: Map<string, readonly Found[]>;
|
|
52
|
+
readonly discoveries: Map<number, Discovery>;
|
|
53
|
+
readonly regions: Map<string, Region>;
|
|
54
|
+
readonly spreads: Map<number, boolean | null>;
|
|
55
|
+
}
|
|
56
|
+
export declare function identifierOf(label: string): string;
|
|
57
|
+
export declare function longOf(text: string): Long;
|
|
58
|
+
export declare function pieceAt(long: Long, index: number): Piece | null;
|
|
59
|
+
export declare function drawn(long: Long, count: number): Block[];
|
|
60
|
+
export declare function remaining(long: Long, count: number): boolean;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=pieces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieces.d.ts","sourceRoot":"","sources":["../../src/chat/pieces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACnD,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAI7C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEhD;AAsED,MAAM,MAAM,IAAI,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