@docyrus/rn-assistant 0.1.2 → 0.2.0
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/commonjs/components/assistant-screen/assistant-screen.js +27 -8
- package/dist/commonjs/components/assistant-screen/assistant-screen.js.map +1 -1
- package/dist/commonjs/components/message-parts/code-block.js +279 -0
- package/dist/commonjs/components/message-parts/code-block.js.map +1 -0
- package/dist/commonjs/components/message-parts/message-parts.js +144 -85
- package/dist/commonjs/components/message-parts/message-parts.js.map +1 -1
- package/dist/commonjs/components/sessions-list/sessions-list.js +3 -19
- package/dist/commonjs/components/sessions-list/sessions-list.js.map +1 -1
- package/dist/commonjs/hooks/use-assistant.js +90 -16
- package/dist/commonjs/hooks/use-assistant.js.map +1 -1
- package/dist/module/components/assistant-screen/assistant-screen.js +29 -10
- package/dist/module/components/assistant-screen/assistant-screen.js.map +1 -1
- package/dist/module/components/message-parts/code-block.js +274 -0
- package/dist/module/components/message-parts/code-block.js.map +1 -0
- package/dist/module/components/message-parts/message-parts.js +145 -86
- package/dist/module/components/message-parts/message-parts.js.map +1 -1
- package/dist/module/components/sessions-list/sessions-list.js +3 -19
- package/dist/module/components/sessions-list/sessions-list.js.map +1 -1
- package/dist/module/hooks/use-assistant.js +90 -16
- package/dist/module/hooks/use-assistant.js.map +1 -1
- package/dist/typescript/commonjs/src/components/assistant-screen/assistant-screen.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/message-parts/code-block.d.ts +9 -0
- package/dist/typescript/commonjs/src/components/message-parts/code-block.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/message-parts/message-parts.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/sessions-list/sessions-list.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/hooks/use-assistant.d.ts +2 -0
- package/dist/typescript/commonjs/src/hooks/use-assistant.d.ts.map +1 -1
- package/dist/typescript/module/src/components/assistant-screen/assistant-screen.d.ts.map +1 -1
- package/dist/typescript/module/src/components/message-parts/code-block.d.ts +9 -0
- package/dist/typescript/module/src/components/message-parts/code-block.d.ts.map +1 -0
- package/dist/typescript/module/src/components/message-parts/message-parts.d.ts.map +1 -1
- package/dist/typescript/module/src/components/sessions-list/sessions-list.d.ts.map +1 -1
- package/dist/typescript/module/src/hooks/use-assistant.d.ts +2 -0
- package/dist/typescript/module/src/hooks/use-assistant.d.ts.map +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
|
+
import { View, Text, TouchableOpacity, StyleSheet, ScrollView } from 'react-native';
|
|
5
|
+
import * as Clipboard from 'expo-clipboard';
|
|
6
|
+
import { Check, Copy } from 'lucide-react-native';
|
|
7
|
+
import { useDocyrusRNAssistantTheme } from "../../theme/index.js";
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* ============================================================================
|
|
11
|
+
* Syntax highlighting tokens
|
|
12
|
+
* ============================================================================
|
|
13
|
+
*/
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
const KEYWORDS_STR = 'abstract as async await break case catch class const continue debugger default delete do else ' + 'enum export extends false finally for from function if implements import in instanceof interface ' + 'let new null of package private protected public return static super switch this throw true try ' + 'type typeof undefined var void while with yield ' + 'def lambda pass raise global nonlocal assert elif except exec print and or not is None True False self cls ' + 'fn pub mod use struct impl trait mut ref match loop move unsafe where crate ' + 'func go chan defer range select map make ' + 'SELECT FROM WHERE INSERT UPDATE DELETE CREATE TABLE JOIN LEFT RIGHT INNER ON AND OR NOT ' + 'ORDER BY GROUP HAVING LIMIT SET INTO VALUES ALTER DROP INDEX VIEW AS DISTINCT COUNT SUM AVG MIN MAX BETWEEN LIKE IN IS NULL EXISTS';
|
|
17
|
+
const KEYWORDS = new Set(KEYWORDS_STR.split(' '));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Simple regex-based tokenizer for syntax highlighting.
|
|
21
|
+
* Not a full parser — handles common patterns for most languages.
|
|
22
|
+
*/
|
|
23
|
+
function tokenize(code) {
|
|
24
|
+
const tokens = [];
|
|
25
|
+
let remaining = code;
|
|
26
|
+
while (remaining.length > 0) {
|
|
27
|
+
let matched = false;
|
|
28
|
+
|
|
29
|
+
// Single-line comment
|
|
30
|
+
const commentMatch = remaining.match(/^(\/\/.*|#.*)/);
|
|
31
|
+
if (commentMatch) {
|
|
32
|
+
tokens.push({
|
|
33
|
+
text: commentMatch[0],
|
|
34
|
+
type: 'comment'
|
|
35
|
+
});
|
|
36
|
+
remaining = remaining.slice(commentMatch[0].length);
|
|
37
|
+
matched = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Multi-line comment
|
|
41
|
+
if (!matched) {
|
|
42
|
+
const blockCommentMatch = remaining.match(/^\/\*[\s\S]*?\*\//);
|
|
43
|
+
if (blockCommentMatch) {
|
|
44
|
+
tokens.push({
|
|
45
|
+
text: blockCommentMatch[0],
|
|
46
|
+
type: 'comment'
|
|
47
|
+
});
|
|
48
|
+
remaining = remaining.slice(blockCommentMatch[0].length);
|
|
49
|
+
matched = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Strings (double, single, backtick)
|
|
54
|
+
if (!matched) {
|
|
55
|
+
const stringMatch = remaining.match(/^("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`)/);
|
|
56
|
+
if (stringMatch) {
|
|
57
|
+
tokens.push({
|
|
58
|
+
text: stringMatch[0],
|
|
59
|
+
type: 'string'
|
|
60
|
+
});
|
|
61
|
+
remaining = remaining.slice(stringMatch[0].length);
|
|
62
|
+
matched = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Numbers
|
|
67
|
+
if (!matched) {
|
|
68
|
+
const numberMatch = remaining.match(/^(0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|\d+\.?\d*(?:[eE][+-]?\d+)?)/);
|
|
69
|
+
if (numberMatch) {
|
|
70
|
+
tokens.push({
|
|
71
|
+
text: numberMatch[0],
|
|
72
|
+
type: 'number'
|
|
73
|
+
});
|
|
74
|
+
remaining = remaining.slice(numberMatch[0].length);
|
|
75
|
+
matched = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Function call (word followed by parenthesis)
|
|
80
|
+
if (!matched) {
|
|
81
|
+
const funcMatch = remaining.match(/^([a-zA-Z_$][\w$]*)\s*(?=\()/);
|
|
82
|
+
if (funcMatch && funcMatch[1]) {
|
|
83
|
+
const word = funcMatch[1];
|
|
84
|
+
if (KEYWORDS.has(word)) {
|
|
85
|
+
tokens.push({
|
|
86
|
+
text: word,
|
|
87
|
+
type: 'keyword'
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
tokens.push({
|
|
91
|
+
text: word,
|
|
92
|
+
type: 'function'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
remaining = remaining.slice(word.length);
|
|
96
|
+
matched = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Keywords and identifiers
|
|
101
|
+
if (!matched) {
|
|
102
|
+
const wordMatch = remaining.match(/^[a-zA-Z_$][\w$]*/);
|
|
103
|
+
if (wordMatch) {
|
|
104
|
+
const word = wordMatch[0];
|
|
105
|
+
tokens.push({
|
|
106
|
+
text: word,
|
|
107
|
+
type: KEYWORDS.has(word) ? 'keyword' : 'plain'
|
|
108
|
+
});
|
|
109
|
+
remaining = remaining.slice(word.length);
|
|
110
|
+
matched = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Operators
|
|
115
|
+
if (!matched) {
|
|
116
|
+
const opMatch = remaining.match(/^(=>|===|!==|==|!=|<=|>=|&&|\|\||[+\-*/%=<>!&|^~?:])/);
|
|
117
|
+
if (opMatch) {
|
|
118
|
+
tokens.push({
|
|
119
|
+
text: opMatch[0],
|
|
120
|
+
type: 'operator'
|
|
121
|
+
});
|
|
122
|
+
remaining = remaining.slice(opMatch[0].length);
|
|
123
|
+
matched = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Punctuation
|
|
128
|
+
if (!matched) {
|
|
129
|
+
const punctMatch = remaining.match(/^[{}()[\];,.:]/);
|
|
130
|
+
if (punctMatch) {
|
|
131
|
+
tokens.push({
|
|
132
|
+
text: punctMatch[0],
|
|
133
|
+
type: 'punctuation'
|
|
134
|
+
});
|
|
135
|
+
remaining = remaining.slice(punctMatch[0].length);
|
|
136
|
+
matched = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Whitespace and anything else
|
|
141
|
+
if (!matched) {
|
|
142
|
+
tokens.push({
|
|
143
|
+
text: remaining.charAt(0),
|
|
144
|
+
type: 'plain'
|
|
145
|
+
});
|
|
146
|
+
remaining = remaining.slice(1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return tokens;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* ============================================================================
|
|
154
|
+
* CodeBlock Component
|
|
155
|
+
* ============================================================================
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
export function CodeBlock({
|
|
159
|
+
code,
|
|
160
|
+
language
|
|
161
|
+
}) {
|
|
162
|
+
const theme = useDocyrusRNAssistantTheme();
|
|
163
|
+
const [copied, setCopied] = useState(false);
|
|
164
|
+
const bgColor = theme.isDark ? '#1e1e2e' : '#f6f8fa';
|
|
165
|
+
const headerBg = theme.isDark ? '#181825' : '#edf0f3';
|
|
166
|
+
const textColor = theme.isDark ? '#cdd6f4' : '#24292e';
|
|
167
|
+
const tokenColors = useMemo(() => ({
|
|
168
|
+
keyword: theme.isDark ? '#cba6f7' : '#d73a49',
|
|
169
|
+
string: theme.isDark ? '#a6e3a1' : '#032f62',
|
|
170
|
+
comment: theme.isDark ? '#6c7086' : '#6a737d',
|
|
171
|
+
number: theme.isDark ? '#fab387' : '#005cc5',
|
|
172
|
+
function: theme.isDark ? '#89b4fa' : '#6f42c1',
|
|
173
|
+
operator: theme.isDark ? '#89dceb' : '#d73a49',
|
|
174
|
+
punctuation: theme.isDark ? '#9399b2' : '#24292e',
|
|
175
|
+
plain: textColor
|
|
176
|
+
}), [theme.isDark, textColor]);
|
|
177
|
+
const tokens = useMemo(() => tokenize(code), [code]);
|
|
178
|
+
const handleCopy = async () => {
|
|
179
|
+
await Clipboard.setStringAsync(code);
|
|
180
|
+
setCopied(true);
|
|
181
|
+
setTimeout(() => setCopied(false), 2000);
|
|
182
|
+
};
|
|
183
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
184
|
+
style: [styles.container, {
|
|
185
|
+
backgroundColor: bgColor,
|
|
186
|
+
borderRadius: theme.borderRadius.lg
|
|
187
|
+
}],
|
|
188
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
189
|
+
style: [styles.header, {
|
|
190
|
+
backgroundColor: headerBg,
|
|
191
|
+
borderTopLeftRadius: theme.borderRadius.lg,
|
|
192
|
+
borderTopRightRadius: theme.borderRadius.lg
|
|
193
|
+
}],
|
|
194
|
+
children: [language ? /*#__PURE__*/_jsx(Text, {
|
|
195
|
+
style: [styles.languageLabel, {
|
|
196
|
+
color: theme.colors.mutedForeground
|
|
197
|
+
}],
|
|
198
|
+
children: language
|
|
199
|
+
}) : /*#__PURE__*/_jsx(View, {}), /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
200
|
+
onPress: handleCopy,
|
|
201
|
+
style: styles.copyButton,
|
|
202
|
+
activeOpacity: 0.7,
|
|
203
|
+
children: [copied ? /*#__PURE__*/_jsx(Check, {
|
|
204
|
+
size: 15,
|
|
205
|
+
color: theme.colors.success
|
|
206
|
+
}) : /*#__PURE__*/_jsx(Copy, {
|
|
207
|
+
size: 15,
|
|
208
|
+
color: theme.colors.mutedForeground
|
|
209
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
210
|
+
style: [styles.copyText, {
|
|
211
|
+
color: copied ? theme.colors.success : theme.colors.mutedForeground
|
|
212
|
+
}],
|
|
213
|
+
children: copied ? 'Copied' : 'Copy'
|
|
214
|
+
})]
|
|
215
|
+
})]
|
|
216
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
217
|
+
horizontal: true,
|
|
218
|
+
showsHorizontalScrollIndicator: false,
|
|
219
|
+
style: styles.codeScroll,
|
|
220
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
221
|
+
style: [styles.codeText, {
|
|
222
|
+
color: textColor
|
|
223
|
+
}],
|
|
224
|
+
selectable: true,
|
|
225
|
+
children: tokens.map((token, index) => /*#__PURE__*/_jsx(Text, {
|
|
226
|
+
style: {
|
|
227
|
+
color: tokenColors[token.type]
|
|
228
|
+
},
|
|
229
|
+
children: token.text
|
|
230
|
+
}, index))
|
|
231
|
+
})
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const styles = StyleSheet.create({
|
|
236
|
+
container: {
|
|
237
|
+
marginVertical: 8,
|
|
238
|
+
overflow: 'hidden'
|
|
239
|
+
},
|
|
240
|
+
header: {
|
|
241
|
+
flexDirection: 'row',
|
|
242
|
+
alignItems: 'center',
|
|
243
|
+
justifyContent: 'space-between',
|
|
244
|
+
paddingHorizontal: 14,
|
|
245
|
+
paddingVertical: 8
|
|
246
|
+
},
|
|
247
|
+
languageLabel: {
|
|
248
|
+
fontSize: 12,
|
|
249
|
+
fontWeight: '600',
|
|
250
|
+
textTransform: 'lowercase'
|
|
251
|
+
},
|
|
252
|
+
copyButton: {
|
|
253
|
+
flexDirection: 'row',
|
|
254
|
+
alignItems: 'center',
|
|
255
|
+
gap: 4,
|
|
256
|
+
paddingVertical: 2,
|
|
257
|
+
paddingHorizontal: 6
|
|
258
|
+
},
|
|
259
|
+
copyText: {
|
|
260
|
+
fontSize: 12,
|
|
261
|
+
fontWeight: '500'
|
|
262
|
+
},
|
|
263
|
+
codeScroll: {
|
|
264
|
+
paddingHorizontal: 14,
|
|
265
|
+
paddingVertical: 12
|
|
266
|
+
},
|
|
267
|
+
codeText: {
|
|
268
|
+
fontFamily: 'monospace',
|
|
269
|
+
fontSize: 13,
|
|
270
|
+
lineHeight: 20
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
CodeBlock.displayName = 'CodeBlock';
|
|
274
|
+
//# sourceMappingURL=code-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useMemo","View","Text","TouchableOpacity","StyleSheet","ScrollView","Clipboard","Check","Copy","useDocyrusRNAssistantTheme","jsx","_jsx","jsxs","_jsxs","KEYWORDS_STR","KEYWORDS","Set","split","tokenize","code","tokens","remaining","length","matched","commentMatch","match","push","text","type","slice","blockCommentMatch","stringMatch","numberMatch","funcMatch","word","has","wordMatch","opMatch","punctMatch","charAt","CodeBlock","language","theme","copied","setCopied","bgColor","isDark","headerBg","textColor","tokenColors","keyword","string","comment","number","function","operator","punctuation","plain","handleCopy","setStringAsync","setTimeout","style","styles","container","backgroundColor","borderRadius","lg","children","header","borderTopLeftRadius","borderTopRightRadius","languageLabel","color","colors","mutedForeground","onPress","copyButton","activeOpacity","size","success","copyText","horizontal","showsHorizontalScrollIndicator","codeScroll","codeText","selectable","map","token","index","create","marginVertical","overflow","flexDirection","alignItems","justifyContent","paddingHorizontal","paddingVertical","fontSize","fontWeight","textTransform","gap","fontFamily","lineHeight","displayName"],"sourceRoot":"../../../../src","sources":["components/message-parts/code-block.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAEzC,SACEC,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,UAAU,QAC/C,cAAc;AAErB,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAC3C,SAASC,KAAK,EAAEC,IAAI,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AAc,EAAE,CAAC;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDvB,MAAM,EAAE;IACNwB,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,eAAe;IAC/BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDzB,aAAa,EAAE;IACb0B,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,aAAa,EAAE;EACjB,CAAC;EACDvB,UAAU,EAAE;IACVgB,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBO,GAAG,EAAE,CAAC;IACNJ,eAAe,EAAE,CAAC;IAClBD,iBAAiB,EAAE;EACrB,CAAC;EACDf,QAAQ,EAAE;IACRiB,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDf,UAAU,EAAE;IACVY,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDZ,QAAQ,EAAE;IACRiB,UAAU,EAAE,WAAW;IACvBJ,QAAQ,EAAE,EAAE;IACZK,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF9D,SAAS,CAAC+D,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
4
|
import { View, Text, TouchableOpacity } from 'react-native';
|
|
5
5
|
import { Markdown } from '@docren/react-native-markdown';
|
|
6
|
+
import { Brain, ChevronDown, ChevronUp, Circle, Clock, CheckCircle2, XCircle, Wrench } from 'lucide-react-native';
|
|
6
7
|
import { useI18n } from '@docyrus/i18n/rn';
|
|
7
8
|
import { useDocyrusRNAssistantTheme } from "../../theme/index.js";
|
|
8
|
-
import {
|
|
9
|
+
import { CodeBlock } from "./code-block.js";
|
|
9
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
/**
|
|
11
12
|
* Render message parts from AI SDK
|
|
@@ -19,6 +20,14 @@ export function MessageParts({
|
|
|
19
20
|
t
|
|
20
21
|
} = useI18n();
|
|
21
22
|
const [expandedReasoning, setExpandedReasoning] = useState(false);
|
|
23
|
+
const markdownRenderRules = useMemo(() => ({
|
|
24
|
+
code: ({
|
|
25
|
+
node
|
|
26
|
+
}) => /*#__PURE__*/_jsx(CodeBlock, {
|
|
27
|
+
code: node.value || '',
|
|
28
|
+
language: node.lang || undefined
|
|
29
|
+
}, node.key)
|
|
30
|
+
}), []);
|
|
22
31
|
if (!parts || parts.length === 0) {
|
|
23
32
|
return null;
|
|
24
33
|
}
|
|
@@ -35,6 +44,7 @@ export function MessageParts({
|
|
|
35
44
|
return /*#__PURE__*/_jsx(View, {
|
|
36
45
|
children: /*#__PURE__*/_jsx(Markdown, {
|
|
37
46
|
markdown: part.text || '',
|
|
47
|
+
renderRules: markdownRenderRules,
|
|
38
48
|
styles: {
|
|
39
49
|
root: {
|
|
40
50
|
flex: 0
|
|
@@ -50,86 +60,18 @@ export function MessageParts({
|
|
|
50
60
|
}, `text-${partKey}`);
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
// Tool Call
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
style: {
|
|
66
|
-
flexDirection: 'row',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
marginBottom: 8
|
|
69
|
-
},
|
|
70
|
-
children: [/*#__PURE__*/_jsx(DocyrusIcon, {
|
|
71
|
-
icon: "tool",
|
|
72
|
-
size: 16,
|
|
73
|
-
color: theme.colors.primary
|
|
74
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
75
|
-
style: {
|
|
76
|
-
marginLeft: 8,
|
|
77
|
-
fontSize: 14,
|
|
78
|
-
fontWeight: '600',
|
|
79
|
-
color: theme.colors.foreground
|
|
80
|
-
},
|
|
81
|
-
children: part.toolName || t('assistant.tool-call', 'Tool Call')
|
|
82
|
-
})]
|
|
83
|
-
}), part.args && /*#__PURE__*/_jsx(Text, {
|
|
84
|
-
style: {
|
|
85
|
-
fontSize: 12,
|
|
86
|
-
color: theme.colors.mutedForeground,
|
|
87
|
-
fontFamily: 'monospace'
|
|
88
|
-
},
|
|
89
|
-
children: JSON.stringify(part.args, null, 2)
|
|
90
|
-
})]
|
|
91
|
-
}, `tool-call-${partKey}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Tool Result
|
|
95
|
-
if (part.type === 'tool-result') {
|
|
96
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
97
|
-
style: {
|
|
98
|
-
backgroundColor: part.isError ? theme.colors.destructive : theme.colors.card,
|
|
99
|
-
borderLeftWidth: 3,
|
|
100
|
-
borderLeftColor: part.isError ? theme.colors.destructiveForeground : theme.colors.success,
|
|
101
|
-
padding: 12,
|
|
102
|
-
borderRadius: 8,
|
|
103
|
-
marginVertical: 4
|
|
104
|
-
},
|
|
105
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
106
|
-
style: {
|
|
107
|
-
flexDirection: 'row',
|
|
108
|
-
alignItems: 'center',
|
|
109
|
-
marginBottom: 8
|
|
110
|
-
},
|
|
111
|
-
children: [/*#__PURE__*/_jsx(DocyrusIcon, {
|
|
112
|
-
icon: part.isError ? 'alert-circle' : 'check-circle',
|
|
113
|
-
size: 16,
|
|
114
|
-
color: part.isError ? theme.colors.destructiveForeground : theme.colors.success
|
|
115
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
116
|
-
style: {
|
|
117
|
-
marginLeft: 8,
|
|
118
|
-
fontSize: 14,
|
|
119
|
-
fontWeight: '600',
|
|
120
|
-
color: theme.colors.foreground
|
|
121
|
-
},
|
|
122
|
-
children: part.isError ? t('assistant.tool-error', 'Tool Error') : t('assistant.tool-result', 'Tool Result')
|
|
123
|
-
})]
|
|
124
|
-
}), part.result && /*#__PURE__*/_jsx(Text, {
|
|
125
|
-
style: {
|
|
126
|
-
fontSize: 12,
|
|
127
|
-
color: theme.colors.mutedForeground,
|
|
128
|
-
fontFamily: 'monospace'
|
|
129
|
-
},
|
|
130
|
-
children: typeof part.result === 'string' ? part.result : JSON.stringify(part.result, null, 2)
|
|
131
|
-
})]
|
|
132
|
-
}, `tool-result-${partKey}`);
|
|
63
|
+
// Tool Call / Tool Result — compact collapsible header
|
|
64
|
+
const isToolPart = part.type === 'tool-call' || part.type === 'tool-result' || part.type === 'dynamic-tool' || typeof part.type === 'string' && part.type.startsWith('tool-');
|
|
65
|
+
if (isToolPart) {
|
|
66
|
+
const extractedToolName = part.toolName || (part.type === 'dynamic-tool' ? 'Tool' : null) || (typeof part.type === 'string' && part.type.startsWith('tool-') ? part.type.replace(/^tool-/, '') : null) || 'Tool';
|
|
67
|
+
const resolvedState = part.state || (part.type === 'tool-result' ? part.isError ? 'output-error' : 'output-available' : 'output-available');
|
|
68
|
+
return /*#__PURE__*/_jsx(ToolHeader, {
|
|
69
|
+
toolName: part.output?.text || extractedToolName,
|
|
70
|
+
state: resolvedState,
|
|
71
|
+
args: part.args || part.input,
|
|
72
|
+
result: part.output || part.result,
|
|
73
|
+
input: part.input
|
|
74
|
+
}, `${part.type}-${partKey}`);
|
|
133
75
|
}
|
|
134
76
|
|
|
135
77
|
// Reasoning (for o1 models)
|
|
@@ -149,8 +91,7 @@ export function MessageParts({
|
|
|
149
91
|
padding: 12,
|
|
150
92
|
backgroundColor: theme.colors.muted
|
|
151
93
|
},
|
|
152
|
-
children: [/*#__PURE__*/_jsx(
|
|
153
|
-
icon: "brain",
|
|
94
|
+
children: [/*#__PURE__*/_jsx(Brain, {
|
|
154
95
|
size: 16,
|
|
155
96
|
color: theme.colors.primary
|
|
156
97
|
}), /*#__PURE__*/_jsx(Text, {
|
|
@@ -162,8 +103,10 @@ export function MessageParts({
|
|
|
162
103
|
color: theme.colors.foreground
|
|
163
104
|
},
|
|
164
105
|
children: t('assistant.ai-reasoning', 'AI Reasoning')
|
|
165
|
-
}), /*#__PURE__*/_jsx(
|
|
166
|
-
|
|
106
|
+
}), expandedReasoning ? /*#__PURE__*/_jsx(ChevronUp, {
|
|
107
|
+
size: 16,
|
|
108
|
+
color: theme.colors.mutedForeground
|
|
109
|
+
}) : /*#__PURE__*/_jsx(ChevronDown, {
|
|
167
110
|
size: 16,
|
|
168
111
|
color: theme.colors.mutedForeground
|
|
169
112
|
})]
|
|
@@ -202,4 +145,120 @@ export function MessageParts({
|
|
|
202
145
|
});
|
|
203
146
|
}
|
|
204
147
|
MessageParts.displayName = 'MessageParts';
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* ============================================================================
|
|
151
|
+
* ToolHeader — compact collapsible tool call display
|
|
152
|
+
* ============================================================================
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
function ToolHeader({
|
|
156
|
+
toolName,
|
|
157
|
+
state,
|
|
158
|
+
args,
|
|
159
|
+
result,
|
|
160
|
+
input
|
|
161
|
+
}) {
|
|
162
|
+
const theme = useDocyrusRNAssistantTheme();
|
|
163
|
+
const [expanded, setExpanded] = useState(false);
|
|
164
|
+
const displayName = input?.title || toolName || 'Tool';
|
|
165
|
+
const statusConfig = {
|
|
166
|
+
'input-streaming': {
|
|
167
|
+
icon: Circle,
|
|
168
|
+
color: theme.colors.mutedForeground,
|
|
169
|
+
label: 'Pending'
|
|
170
|
+
},
|
|
171
|
+
'input-available': {
|
|
172
|
+
icon: Clock,
|
|
173
|
+
color: theme.colors.mutedForeground,
|
|
174
|
+
label: 'Running',
|
|
175
|
+
animate: true
|
|
176
|
+
},
|
|
177
|
+
'output-available': {
|
|
178
|
+
icon: CheckCircle2,
|
|
179
|
+
color: '#16a34a',
|
|
180
|
+
label: 'Completed'
|
|
181
|
+
},
|
|
182
|
+
'output-error': {
|
|
183
|
+
icon: XCircle,
|
|
184
|
+
color: theme.colors.destructive,
|
|
185
|
+
label: 'Error'
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const config = statusConfig[state];
|
|
189
|
+
const StatusIcon = config.icon;
|
|
190
|
+
const hasDetails = args || result;
|
|
191
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
192
|
+
children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
193
|
+
onPress: hasDetails ? () => setExpanded(!expanded) : undefined,
|
|
194
|
+
activeOpacity: hasDetails ? 0.7 : 1,
|
|
195
|
+
style: {
|
|
196
|
+
flexDirection: 'row',
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
justifyContent: 'space-between',
|
|
199
|
+
paddingVertical: 5,
|
|
200
|
+
paddingHorizontal: 2
|
|
201
|
+
},
|
|
202
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
203
|
+
style: {
|
|
204
|
+
flexDirection: 'row',
|
|
205
|
+
alignItems: 'center',
|
|
206
|
+
gap: 6,
|
|
207
|
+
flex: 1
|
|
208
|
+
},
|
|
209
|
+
children: [/*#__PURE__*/_jsx(Wrench, {
|
|
210
|
+
size: 12,
|
|
211
|
+
color: theme.colors.mutedForeground
|
|
212
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
213
|
+
style: {
|
|
214
|
+
fontSize: 12,
|
|
215
|
+
fontWeight: '300',
|
|
216
|
+
color: theme.colors.mutedForeground
|
|
217
|
+
},
|
|
218
|
+
numberOfLines: 1,
|
|
219
|
+
children: displayName
|
|
220
|
+
}), /*#__PURE__*/_jsx(StatusIcon, {
|
|
221
|
+
size: 12,
|
|
222
|
+
color: config.color,
|
|
223
|
+
style: config.animate ? {
|
|
224
|
+
opacity: 0.6
|
|
225
|
+
} : undefined
|
|
226
|
+
})]
|
|
227
|
+
}), hasDetails ? /*#__PURE__*/_jsx(ChevronDown, {
|
|
228
|
+
size: 10,
|
|
229
|
+
color: theme.colors.mutedForeground,
|
|
230
|
+
style: {
|
|
231
|
+
transform: [{
|
|
232
|
+
rotate: expanded ? '180deg' : '0deg'
|
|
233
|
+
}]
|
|
234
|
+
}
|
|
235
|
+
}) : null]
|
|
236
|
+
}), expanded && hasDetails ? /*#__PURE__*/_jsxs(View, {
|
|
237
|
+
style: {
|
|
238
|
+
paddingHorizontal: 8,
|
|
239
|
+
paddingVertical: 6,
|
|
240
|
+
marginTop: 2,
|
|
241
|
+
backgroundColor: theme.colors.muted,
|
|
242
|
+
borderRadius: 6
|
|
243
|
+
},
|
|
244
|
+
children: [args ? /*#__PURE__*/_jsx(Text, {
|
|
245
|
+
style: {
|
|
246
|
+
fontSize: 11,
|
|
247
|
+
fontFamily: 'monospace',
|
|
248
|
+
color: theme.colors.mutedForeground
|
|
249
|
+
},
|
|
250
|
+
children: typeof args === 'string' ? args : JSON.stringify(args, null, 2)
|
|
251
|
+
}) : null, result ? /*#__PURE__*/_jsx(Text, {
|
|
252
|
+
style: {
|
|
253
|
+
fontSize: 11,
|
|
254
|
+
fontFamily: 'monospace',
|
|
255
|
+
color: theme.colors.mutedForeground,
|
|
256
|
+
marginTop: args ? 6 : 0
|
|
257
|
+
},
|
|
258
|
+
children: typeof result === 'string' ? result : JSON.stringify(result, null, 2)
|
|
259
|
+
}) : null]
|
|
260
|
+
}) : null]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
ToolHeader.displayName = 'ToolHeader';
|
|
205
264
|
//# sourceMappingURL=message-parts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","View","Text","TouchableOpacity","Markdown","useI18n","useDocyrusRNAssistantTheme","
|
|
1
|
+
{"version":3,"names":["useState","useMemo","View","Text","TouchableOpacity","Markdown","Brain","ChevronDown","ChevronUp","Circle","Clock","CheckCircle2","XCircle","Wrench","useI18n","useDocyrusRNAssistantTheme","CodeBlock","jsx","_jsx","jsxs","_jsxs","MessageParts","parts","theme","t","expandedReasoning","setExpandedReasoning","markdownRenderRules","code","node","value","language","lang","undefined","key","length","style","gap","children","map","part","partKey","toolCallId","type","text","slice","toolName","markdown","renderRules","styles","root","flex","list","paragraph","marginVertical","isToolPart","startsWith","extractedToolName","replace","resolvedState","state","isError","ToolHeader","output","args","input","result","backgroundColor","colors","card","borderRadius","overflow","onPress","flexDirection","alignItems","padding","muted","size","color","primary","marginLeft","fontSize","fontWeight","foreground","mutedForeground","lineHeight","fontStyle","content","ignoredTypes","includes","__DEV__","console","warn","displayName","expanded","setExpanded","title","statusConfig","icon","label","animate","destructive","config","StatusIcon","hasDetails","activeOpacity","justifyContent","paddingVertical","paddingHorizontal","numberOfLines","opacity","transform","rotate","marginTop","fontFamily","JSON","stringify"],"sourceRoot":"../../../../src","sources":["components/message-parts/message-parts.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAEzC,SAASC,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AAE3D,SAASC,QAAQ,QAA0B,+BAA+B;AAC1E,SACEC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,YAAY,EACZC,OAAO,EACPC,MAAM,QACD,qBAAqB;AAC5B,SAASC,OAAO,QAAQ,kBAAkB;AAE1C,SAASC,0BAA0B,QAAQ,sBAAa;AACxD,SAASC,SAAS,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAiBzC;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAC;EAAEC;AAAyB,CAAC,EAAE;EACzD,MAAMC,KAAK,GAAGR,0BAA0B,CAAC,CAAC;EAC1C,MAAM;IAAES;EAAE,CAAC,GAAGV,OAAO,CAAC,CAAC;EACvB,MAAM,CAACW,iBAAiB,EAAEC,oBAAoB,CAAC,GAAG1B,QAAQ,CAAC,KAAK,CAAC;EAEjE,MAAM2B,mBAAgC,GAAG1B,OAAO,CAAC,OAAO;IACtD2B,IAAI,EAAEA,CAAC;MAAEC;IAAK,CAAC,kB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