@ateam-ai-mobile/core 0.1.33 → 0.1.35
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/dist/index.d.mts +90 -20
- package/dist/index.d.ts +90 -20
- package/dist/index.js +176 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/blockText.ts +253 -0
- package/src/chat/store.ts +1 -70
- package/src/index.ts +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ateam-ai-mobile/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "Headless ADAS SDK core — auth bridge, API client, chat/job streaming, MCP calls, theme tokens. No UI, no Expo dependencies.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the phone's chat bubble is handed for a reply: the blocks of a conversation turn as ONE flat string, and that string
|
|
3
|
+
* split back into what the bubble draws. Pure and import-free, so a test runs it in node (it used to sit in store.ts).
|
|
4
|
+
*
|
|
5
|
+
* Nothing a reply holds is dropped. This file used to throw away every json and code block that sat beside a text block (a copy of
|
|
6
|
+
* the web chat's March rule), so a script, a command or a diagram under the answer never reached the person. Which raw data is
|
|
7
|
+
* shown CLOSED is Core's call, made once, at read (backend utils/blockDisplay.js marks it `meta.display: "folded"`); this file only
|
|
8
|
+
* carries that mark to the bubble: a marked block's text is wrapped in the DETAILS sentinels, and the bubble draws that segment as
|
|
9
|
+
* a closed "Details" row. It never decides what folds.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sentinel delimiters used to embed structured table data inside a flat message string. UI layers split on these and render the
|
|
14
|
+
* contents with a native table component instead of markdown tables, which look terrible on narrow phone screens.
|
|
15
|
+
*
|
|
16
|
+
* Unicode Private Use Area chars so they never collide with anything the model could legitimately emit.
|
|
17
|
+
*/
|
|
18
|
+
export const TABLE_BLOCK_OPEN = '\uE100';
|
|
19
|
+
export const TABLE_BLOCK_CLOSE = '\uE101';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The same, for a block Core marked folded: its text (already rendered to markdown) travels between these, percent-encoded so it
|
|
23
|
+
* can never hold a newline or a sentinel, and the bubble draws it closed under "Details".
|
|
24
|
+
*/
|
|
25
|
+
export const DETAILS_BLOCK_OPEN = '\uE102';
|
|
26
|
+
export const DETAILS_BLOCK_CLOSE = '\uE103';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The same, for a `diagram` block: a straight list of numbered steps with arrows and a colour per status word. Its payload is the
|
|
30
|
+
* clean `DiagramView` (below) as percent-encoded JSON, and the bubble draws it with a native component.
|
|
31
|
+
*/
|
|
32
|
+
export const DIAGRAM_BLOCK_OPEN = '\uE104';
|
|
33
|
+
export const DIAGRAM_BLOCK_CLOSE = '\uE105';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A block's own text can hold one of the six sentinels (a glyph from an icon font, a paste). One inside a text would cut the
|
|
37
|
+
* message in the wrong place (a stray DETAILS mark would swallow the words before it into a closed row), so they are taken out of
|
|
38
|
+
* the text of a block. A table, a folded block and a diagram carry their payload percent-encoded, which cannot hold one.
|
|
39
|
+
*/
|
|
40
|
+
const SENTINEL_CHARS = /[\uE100-\uE105]/g;
|
|
41
|
+
const clean = (text: string): string => text.replace(SENTINEL_CHARS, '');
|
|
42
|
+
|
|
43
|
+
/** A block of a conversation turn, as /api/conversation serves it. */
|
|
44
|
+
export interface ConversationBlock {
|
|
45
|
+
kind: string;
|
|
46
|
+
content?: any;
|
|
47
|
+
language?: string;
|
|
48
|
+
meta?: { display?: string };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Render a `{ columns: [...], rows: [...] }` payload as a sentinel-wrapped JSON marker. Returns null if the shape doesn't match.
|
|
53
|
+
*/
|
|
54
|
+
function renderTableShape(content: any): string | null {
|
|
55
|
+
if (!content || typeof content !== 'object') return null;
|
|
56
|
+
const cols = Array.isArray(content.columns) ? content.columns : null;
|
|
57
|
+
const rows = Array.isArray(content.rows) ? content.rows : null;
|
|
58
|
+
if (!cols || !rows) return null;
|
|
59
|
+
// encodeURIComponent so the JSON can never contain newlines or sentinel chars.
|
|
60
|
+
const payload = encodeURIComponent(JSON.stringify({ columns: cols, rows }));
|
|
61
|
+
return `${TABLE_BLOCK_OPEN}${payload}${TABLE_BLOCK_CLOSE}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The status words a diagram step or badge may carry; none is neutral. The same four as Core's `DIAGRAM_STATUSES` (backend
|
|
66
|
+
* utils/blockShape.js) and the web's (apps/frontend chat/blocks/diagramView.js): a test on each side holds the list. Colours are
|
|
67
|
+
* this app's own; Core never sends one.
|
|
68
|
+
*/
|
|
69
|
+
export const DIAGRAM_STATUSES = ['ok', 'bad', 'warn', 'info'] as const;
|
|
70
|
+
export type DiagramStatus = (typeof DIAGRAM_STATUSES)[number];
|
|
71
|
+
|
|
72
|
+
export interface DiagramView {
|
|
73
|
+
title: string;
|
|
74
|
+
steps: Array<{ title: string; text: string; status: DiagramStatus | ''; badges: Array<{ text: string; status: DiagramStatus | '' }> }>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const str = (v: any): string => (typeof v === 'string' ? v : typeof v === 'number' || typeof v === 'boolean' ? String(v) : '');
|
|
78
|
+
const statusOf = (v: any): DiagramStatus | '' => ((DIAGRAM_STATUSES as readonly string[]).includes(v) ? v : '');
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The diagram a block holds, ready to draw, every field text; null when there is nothing to draw (fewer than 2 steps). Core sends it
|
|
82
|
+
* clean (`diagramOf`); this is the phone's own net, so a field of the wrong type can never reach a native <Text>.
|
|
83
|
+
*/
|
|
84
|
+
export function diagramView(content: any): DiagramView | null {
|
|
85
|
+
if (!content || typeof content !== 'object' || !Array.isArray(content.steps)) return null;
|
|
86
|
+
const steps: DiagramView['steps'] = [];
|
|
87
|
+
for (const s of content.steps) {
|
|
88
|
+
if (!s || typeof s !== 'object') continue;
|
|
89
|
+
const title = str(s.title);
|
|
90
|
+
const text = str(s.text);
|
|
91
|
+
if (!title && !text) continue;
|
|
92
|
+
const badges: DiagramView['steps'][number]['badges'] = [];
|
|
93
|
+
for (const b of Array.isArray(s.badges) ? s.badges : []) {
|
|
94
|
+
const bt = str(b && typeof b === 'object' ? b.text : b);
|
|
95
|
+
if (bt) badges.push({ text: bt, status: statusOf(b && b.status) });
|
|
96
|
+
}
|
|
97
|
+
steps.push({ title: title || text, text: title ? text : '', status: statusOf(s.status), badges });
|
|
98
|
+
}
|
|
99
|
+
return steps.length < 2 ? null : { title: str(content.title), steps };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A diagram as readable text, the same numbered list Core gives other channels (backend `diagramToText`). */
|
|
103
|
+
export function diagramAsText(d: DiagramView): string {
|
|
104
|
+
const lines = d.title ? [d.title] : [];
|
|
105
|
+
d.steps.forEach((s, i) => {
|
|
106
|
+
const badges = s.badges.length ? ` [${s.badges.map(b => b.text).join(', ')}]` : '';
|
|
107
|
+
lines.push(`${i + 1}. ${s.title}${s.text ? ` — ${s.text}` : ''}${badges}`);
|
|
108
|
+
});
|
|
109
|
+
return lines.join('\n');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** A markdown fence around `code`, long enough that a run of backticks inside the code cannot close it early. */
|
|
113
|
+
function fence(code: string, language: string): string {
|
|
114
|
+
const longest = (code.match(/`+/g) || []).reduce((n, run) => Math.max(n, run.length), 0);
|
|
115
|
+
const ticks = '`'.repeat(Math.max(3, longest + 1));
|
|
116
|
+
return `${ticks}${language}\n${code}\n${ticks}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The text of one block, before any "folded" wrapping. Empty when the block holds nothing to draw. */
|
|
120
|
+
function blockText(b: ConversationBlock): string {
|
|
121
|
+
if (b.kind === 'text' || b.kind === 'markdown' || b.kind === 'description') {
|
|
122
|
+
return typeof b.content === 'string' ? clean(b.content) : '';
|
|
123
|
+
}
|
|
124
|
+
if (b.kind === 'code') {
|
|
125
|
+
// Core sends { kind: 'code', content: { content: '...', language: '...' } }; a flat string with a `language` also reads.
|
|
126
|
+
const nested = b.content && typeof b.content === 'object';
|
|
127
|
+
const code = nested ? b.content.content : b.content;
|
|
128
|
+
if (typeof code !== 'string' || !code.trim()) return '';
|
|
129
|
+
const lang = clean(String((nested ? b.content.language : b.language) || '').trim());
|
|
130
|
+
return fence(clean(code), lang && lang.toLowerCase() !== 'auto' ? lang : '');
|
|
131
|
+
}
|
|
132
|
+
if (b.kind === 'table' && b.content && typeof b.content === 'object') {
|
|
133
|
+
const md = renderTableShape(b.content);
|
|
134
|
+
if (md) return md;
|
|
135
|
+
// Fall through to generic JSON rendering if shape is unexpected.
|
|
136
|
+
}
|
|
137
|
+
if (b.kind === 'diagram') {
|
|
138
|
+
const view = diagramView(b.content);
|
|
139
|
+
if (view) return `${DIAGRAM_BLOCK_OPEN}${encodeURIComponent(JSON.stringify(view))}${DIAGRAM_BLOCK_CLOSE}`;
|
|
140
|
+
// Not a diagram the phone can draw: fall through to the generic text below, never a lost block.
|
|
141
|
+
}
|
|
142
|
+
if (b.kind === 'json') {
|
|
143
|
+
// Polisher sometimes wraps tables as kind:'json' when the content has columns/rows — render those as table blocks too.
|
|
144
|
+
const md = renderTableShape(b.content);
|
|
145
|
+
if (md) return md;
|
|
146
|
+
const pretty = JSON.stringify(b.content, null, 2); // undefined when there is nothing to write
|
|
147
|
+
return typeof pretty === 'string' ? fence(clean(pretty), 'json') : '';
|
|
148
|
+
}
|
|
149
|
+
if (b.kind === 'html') {
|
|
150
|
+
return typeof b.content === 'string' ? clean(b.content) : '';
|
|
151
|
+
}
|
|
152
|
+
if (typeof b.content === 'string') return clean(b.content);
|
|
153
|
+
return b.content === undefined ? '' : clean(JSON.stringify(b.content) ?? '');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Extract display text from a conversation turn's blocks. Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
158
|
+
* Every block that holds something is in the result, in order; a block Core marked `meta.display: "folded"` is wrapped in the
|
|
159
|
+
* DETAILS sentinels so the bubble draws it closed.
|
|
160
|
+
*/
|
|
161
|
+
export function blocksToText(blocks?: ConversationBlock[]): string {
|
|
162
|
+
if (!blocks || blocks.length === 0) return '';
|
|
163
|
+
return blocks.map(b => {
|
|
164
|
+
if (!b || typeof b !== 'object') return '';
|
|
165
|
+
const text = blockText(b);
|
|
166
|
+
if (!text) return '';
|
|
167
|
+
// A table or a diagram is drawn as itself whatever the mark says (Core never marks one; either inside a closed row would show as characters).
|
|
168
|
+
if (text.startsWith(TABLE_BLOCK_OPEN) || text.startsWith(DIAGRAM_BLOCK_OPEN)) return text;
|
|
169
|
+
return b.meta?.display === 'folded'
|
|
170
|
+
? `${DETAILS_BLOCK_OPEN}${encodeURIComponent(text)}${DETAILS_BLOCK_CLOSE}`
|
|
171
|
+
: text;
|
|
172
|
+
}).filter(Boolean).join('\n\n');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** One piece of a flat message string, as the bubble draws it: markdown, a table payload, a diagram payload, or a closed "Details" payload. */
|
|
176
|
+
export interface BlockSegment {
|
|
177
|
+
kind: 'md' | 'table' | 'details' | 'diagram';
|
|
178
|
+
/** md: the markdown. table / details / diagram: the still percent-encoded payload between the sentinels. */
|
|
179
|
+
content: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const PAIRS: Array<{ kind: 'table' | 'details' | 'diagram'; open: string; close: string }> = [
|
|
183
|
+
{ kind: 'table', open: TABLE_BLOCK_OPEN, close: TABLE_BLOCK_CLOSE },
|
|
184
|
+
{ kind: 'details', open: DETAILS_BLOCK_OPEN, close: DETAILS_BLOCK_CLOSE },
|
|
185
|
+
{ kind: 'diagram', open: DIAGRAM_BLOCK_OPEN, close: DIAGRAM_BLOCK_CLOSE },
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Split a flat message string on the table, details and diagram sentinels, in order. A string with none is one markdown segment. An
|
|
190
|
+
* unterminated marker is kept as markdown from the marker on, so nothing is lost.
|
|
191
|
+
*/
|
|
192
|
+
export function splitBlockSegments(content: string): BlockSegment[] {
|
|
193
|
+
const segments: BlockSegment[] = [];
|
|
194
|
+
if (!content) return segments;
|
|
195
|
+
let cursor = 0;
|
|
196
|
+
while (cursor < content.length) {
|
|
197
|
+
let found: { index: number; pair: (typeof PAIRS)[number] } | null = null;
|
|
198
|
+
for (const pair of PAIRS) {
|
|
199
|
+
const index = content.indexOf(pair.open, cursor);
|
|
200
|
+
if (index !== -1 && (!found || index < found.index)) found = { index, pair };
|
|
201
|
+
}
|
|
202
|
+
if (!found) {
|
|
203
|
+
segments.push({ kind: 'md', content: content.slice(cursor) });
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if (found.index > cursor) {
|
|
207
|
+
segments.push({ kind: 'md', content: content.slice(cursor, found.index) });
|
|
208
|
+
}
|
|
209
|
+
const close = content.indexOf(found.pair.close, found.index + found.pair.open.length);
|
|
210
|
+
if (close === -1) {
|
|
211
|
+
// Unterminated marker — keep the rest as markdown so we don't lose data.
|
|
212
|
+
segments.push({ kind: 'md', content: content.slice(found.index) });
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
segments.push({ kind: found.pair.kind, content: content.slice(found.index + found.pair.open.length, close) });
|
|
216
|
+
cursor = close + found.pair.close.length;
|
|
217
|
+
}
|
|
218
|
+
return segments;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** A table payload as readable text: its columns, then one line per row, cells separated by " | ". */
|
|
222
|
+
function tableAsText(payload: string): string {
|
|
223
|
+
try {
|
|
224
|
+
const data = JSON.parse(decodeURIComponent(payload));
|
|
225
|
+
const cols: any[] = Array.isArray(data?.columns) ? data.columns : [];
|
|
226
|
+
const rows: any[] = Array.isArray(data?.rows) ? data.rows : [];
|
|
227
|
+
const cell = (v: any) => (v == null ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v));
|
|
228
|
+
const line = (cells: any) => (Array.isArray(cells) ? cells : [cells]).map(cell).join(' | ');
|
|
229
|
+
return [line(cols), ...rows.map(line)].join('\n');
|
|
230
|
+
} catch {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The flat content of a message as the person would read it: a table is its columns and rows as lines, and a "Details" payload is
|
|
237
|
+
* its text. What long-press copy and a screen reader are given; the raw string holds percent-encoded payloads between private-use
|
|
238
|
+
* characters, which nobody should hear or paste.
|
|
239
|
+
*/
|
|
240
|
+
export function plainTextOf(content: string): string {
|
|
241
|
+
if (!content) return '';
|
|
242
|
+
return splitBlockSegments(content).map(seg => {
|
|
243
|
+
if (seg.kind === 'md') return seg.content;
|
|
244
|
+
if (seg.kind === 'table') return tableAsText(seg.content);
|
|
245
|
+
if (seg.kind === 'diagram') {
|
|
246
|
+
try {
|
|
247
|
+
const view = diagramView(JSON.parse(decodeURIComponent(seg.content)));
|
|
248
|
+
return view ? diagramAsText(view) : '';
|
|
249
|
+
} catch { return ''; }
|
|
250
|
+
}
|
|
251
|
+
try { return decodeURIComponent(seg.content); } catch { return seg.content; }
|
|
252
|
+
}).join('');
|
|
253
|
+
}
|
package/src/chat/store.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { pluginCommandEmitter } from '../utils/emitter';
|
|
|
17
17
|
import { focusPlugin } from '../utils/hostIntents';
|
|
18
18
|
import type { OutgoingAttachment } from '../storage/types';
|
|
19
19
|
import { prepareAttachments } from './attachments';
|
|
20
|
+
import { blocksToText } from './blockText';
|
|
20
21
|
import type { Message, MessageAttachment, JobProgress, UIAction } from './types';
|
|
21
22
|
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
@@ -152,76 +153,6 @@ function isTerminalSnapshot(snap: any): boolean {
|
|
|
152
153
|
return snap?.done === true || isTerminalStatus(snap?.status);
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
/**
|
|
156
|
-
* Sentinel delimiters used to embed structured table data inside a flat
|
|
157
|
-
* message string. UI layers split on these and render the contents with a
|
|
158
|
-
* native table component instead of markdown tables — markdown tables look
|
|
159
|
-
* terrible on narrow phone screens.
|
|
160
|
-
*
|
|
161
|
-
* Unicode Private Use Area chars (U+E100/U+E101) so they never collide with
|
|
162
|
-
* anything the model could legitimately emit.
|
|
163
|
-
*/
|
|
164
|
-
export const TABLE_BLOCK_OPEN = '\uE100';
|
|
165
|
-
export const TABLE_BLOCK_CLOSE = '\uE101';
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Render a `{ columns: [...], rows: [...] }` payload as a sentinel-wrapped
|
|
169
|
-
* JSON marker. Returns null if the shape doesn't match.
|
|
170
|
-
*/
|
|
171
|
-
function renderTableShape(content: any): string | null {
|
|
172
|
-
if (!content || typeof content !== 'object') return null;
|
|
173
|
-
const cols = Array.isArray(content.columns) ? content.columns : null;
|
|
174
|
-
const rows = Array.isArray(content.rows) ? content.rows : null;
|
|
175
|
-
if (!cols || !rows) return null;
|
|
176
|
-
// encodeURIComponent so the JSON can never contain newlines or sentinel chars.
|
|
177
|
-
const payload = encodeURIComponent(JSON.stringify({ columns: cols, rows }));
|
|
178
|
-
return `${TABLE_BLOCK_OPEN}${payload}${TABLE_BLOCK_CLOSE}`;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Extract display text from a conversation turn's assistant blocks.
|
|
183
|
-
* Handles multiple block kinds (text, code, json, markdown, table, html).
|
|
184
|
-
*/
|
|
185
|
-
export function blocksToText(blocks?: Array<{ kind: string; content: any }>): string {
|
|
186
|
-
if (!blocks || blocks.length === 0) return '';
|
|
187
|
-
// Mirror the web renderer: when a human-readable text/markdown block exists in
|
|
188
|
-
// the same turn, drop internal-state json/code blocks (planning state,
|
|
189
|
-
// askUser payloads) — otherwise they render as a raw ```json blob AFTER the
|
|
190
|
-
// real answer. Standalone json/code (no text block, e.g. a table-only turn)
|
|
191
|
-
// still renders as before.
|
|
192
|
-
const hasTextBlock = blocks.some(
|
|
193
|
-
b => b.kind === 'text' || b.kind === 'markdown' || b.kind === 'description',
|
|
194
|
-
);
|
|
195
|
-
return blocks.map(b => {
|
|
196
|
-
if ((b.kind === 'json' || b.kind === 'code') && hasTextBlock) return '';
|
|
197
|
-
if (b.kind === 'text' || b.kind === 'markdown' || b.kind === 'description') {
|
|
198
|
-
return typeof b.content === 'string' ? b.content : '';
|
|
199
|
-
}
|
|
200
|
-
if (b.kind === 'code') {
|
|
201
|
-
const code = typeof b.content === 'object' ? b.content.content : b.content;
|
|
202
|
-
return `\`\`\`\n${code}\n\`\`\``;
|
|
203
|
-
}
|
|
204
|
-
if (b.kind === 'table' && b.content && typeof b.content === 'object') {
|
|
205
|
-
const md = renderTableShape(b.content);
|
|
206
|
-
if (md) return md;
|
|
207
|
-
// Fall through to generic JSON rendering if shape is unexpected.
|
|
208
|
-
}
|
|
209
|
-
if (b.kind === 'json') {
|
|
210
|
-
// Skip pendingQuestion state objects — internal sys.askUser data
|
|
211
|
-
if (b.content && typeof b.content === 'object' && 'pendingQuestion' in b.content) return '';
|
|
212
|
-
// Polisher sometimes wraps tables as kind:'json' when the content has
|
|
213
|
-
// columns/rows — render those as table blocks too.
|
|
214
|
-
const md = renderTableShape(b.content);
|
|
215
|
-
if (md) return md;
|
|
216
|
-
return '```json\n' + JSON.stringify(b.content, null, 2) + '\n```';
|
|
217
|
-
}
|
|
218
|
-
if (b.kind === 'html') {
|
|
219
|
-
return typeof b.content === 'string' ? b.content : '';
|
|
220
|
-
}
|
|
221
|
-
return typeof b.content === 'string' ? b.content : JSON.stringify(b.content);
|
|
222
|
-
}).filter(Boolean).join('\n\n');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
156
|
/** Extract image/file attachments from conversation blocks */
|
|
226
157
|
function blocksToAttachments(blocks?: Array<{ kind: string; hash?: string; url?: string; mimeType?: string; name?: string }>): MessageAttachment[] | undefined {
|
|
227
158
|
if (!blocks || blocks.length === 0) return undefined;
|
package/src/index.ts
CHANGED
|
@@ -146,10 +146,22 @@ export {
|
|
|
146
146
|
setClientDeclarationProvider,
|
|
147
147
|
useChatStore,
|
|
148
148
|
closeChatStream,
|
|
149
|
+
} from './chat/store';
|
|
150
|
+
export {
|
|
149
151
|
blocksToText,
|
|
152
|
+
splitBlockSegments,
|
|
153
|
+
plainTextOf,
|
|
150
154
|
TABLE_BLOCK_OPEN,
|
|
151
155
|
TABLE_BLOCK_CLOSE,
|
|
152
|
-
|
|
156
|
+
DETAILS_BLOCK_OPEN,
|
|
157
|
+
DETAILS_BLOCK_CLOSE,
|
|
158
|
+
DIAGRAM_BLOCK_OPEN,
|
|
159
|
+
DIAGRAM_BLOCK_CLOSE,
|
|
160
|
+
DIAGRAM_STATUSES,
|
|
161
|
+
diagramView,
|
|
162
|
+
diagramAsText,
|
|
163
|
+
} from './chat/blockText';
|
|
164
|
+
export type { ConversationBlock, BlockSegment, DiagramView, DiagramStatus } from './chat/blockText';
|
|
153
165
|
export type {
|
|
154
166
|
Message,
|
|
155
167
|
MessageAttachment,
|