@base44/superagent-native 0.0.1 → 0.0.2
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/LICENSE +21 -0
- package/README.md +12 -20
- package/lib/commonjs/AgentSettingsPanel.js +32 -15
- package/lib/commonjs/AgentSettingsPanel.js.map +1 -1
- package/lib/commonjs/AttachmentPickerStatusModal.js +2 -2
- package/lib/commonjs/AttachmentPickerStatusModal.js.map +1 -1
- package/lib/commonjs/ConversationChat.js +27 -11
- package/lib/commonjs/ConversationChat.js.map +1 -1
- package/lib/commonjs/ConversationComposer.js +10 -6
- package/lib/commonjs/ConversationComposer.js.map +1 -1
- package/lib/commonjs/ConversationScreen.js +2 -0
- package/lib/commonjs/ConversationScreen.js.map +1 -1
- package/lib/commonjs/MarkdownText.js +1 -1
- package/lib/commonjs/MarkdownText.js.map +1 -1
- package/lib/commonjs/MessageActionBar.js +10 -3
- package/lib/commonjs/MessageActionBar.js.map +1 -1
- package/lib/commonjs/SuperagentHomeScreen.js +17 -3
- package/lib/commonjs/SuperagentHomeScreen.js.map +1 -1
- package/lib/commonjs/ToolApprovalCard.js +1 -1
- package/lib/commonjs/ToolApprovalCard.js.map +1 -1
- package/lib/commonjs/ToolCallSummary.js +5 -1
- package/lib/commonjs/ToolCallSummary.js.map +1 -1
- package/lib/commonjs/attachmentUpload.js +2 -1
- package/lib/commonjs/attachmentUpload.js.map +1 -1
- package/lib/commonjs/conversationRuntime.js +37 -2
- package/lib/commonjs/conversationRuntime.js.map +1 -1
- package/lib/commonjs/fileTreeUtils.js +7 -0
- package/lib/commonjs/fileTreeUtils.js.map +1 -1
- package/lib/commonjs/screenParts.js +3 -3
- package/lib/commonjs/styles.js +43 -43
- package/lib/commonjs/useSuperagentConversation.js +117 -34
- package/lib/commonjs/useSuperagentConversation.js.map +1 -1
- package/lib/commonjs/useSuperagentRuntime.js +79 -24
- package/lib/commonjs/useSuperagentRuntime.js.map +1 -1
- package/lib/module/AgentSettingsPanel.js +32 -15
- package/lib/module/AgentSettingsPanel.js.map +1 -1
- package/lib/module/AttachmentPickerStatusModal.js +2 -2
- package/lib/module/AttachmentPickerStatusModal.js.map +1 -1
- package/lib/module/ConversationChat.js +27 -11
- package/lib/module/ConversationChat.js.map +1 -1
- package/lib/module/ConversationComposer.js +10 -6
- package/lib/module/ConversationComposer.js.map +1 -1
- package/lib/module/ConversationScreen.js +2 -0
- package/lib/module/ConversationScreen.js.map +1 -1
- package/lib/module/MarkdownText.js +1 -1
- package/lib/module/MarkdownText.js.map +1 -1
- package/lib/module/MessageActionBar.js +10 -3
- package/lib/module/MessageActionBar.js.map +1 -1
- package/lib/module/SuperagentHomeScreen.js +18 -4
- package/lib/module/SuperagentHomeScreen.js.map +1 -1
- package/lib/module/ToolApprovalCard.js +1 -1
- package/lib/module/ToolApprovalCard.js.map +1 -1
- package/lib/module/ToolCallSummary.js +5 -1
- package/lib/module/ToolCallSummary.js.map +1 -1
- package/lib/module/attachmentUpload.js +2 -1
- package/lib/module/attachmentUpload.js.map +1 -1
- package/lib/module/conversationRuntime.js +36 -2
- package/lib/module/conversationRuntime.js.map +1 -1
- package/lib/module/fileTreeUtils.js +6 -0
- package/lib/module/fileTreeUtils.js.map +1 -1
- package/lib/module/screenParts.js +3 -3
- package/lib/module/styles.js +43 -43
- package/lib/module/useSuperagentConversation.js +118 -35
- package/lib/module/useSuperagentConversation.js.map +1 -1
- package/lib/module/useSuperagentRuntime.js +80 -25
- package/lib/module/useSuperagentRuntime.js.map +1 -1
- package/lib/typescript/commonjs/AgentSettingsPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationChat.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationComposer.d.ts.map +1 -1
- package/lib/typescript/commonjs/ConversationScreen.d.ts +1 -1
- package/lib/typescript/commonjs/ConversationScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/conversationRuntime.d.ts +3 -2
- package/lib/typescript/commonjs/conversationRuntime.d.ts.map +1 -1
- package/lib/typescript/commonjs/fileTreeUtils.d.ts +1 -0
- package/lib/typescript/commonjs/fileTreeUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +1 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/useSuperagentConversation.d.ts.map +1 -1
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts +3 -1
- package/lib/typescript/commonjs/useSuperagentRuntime.d.ts.map +1 -1
- package/lib/typescript/module/AgentSettingsPanel.d.ts.map +1 -1
- package/lib/typescript/module/ConversationChat.d.ts.map +1 -1
- package/lib/typescript/module/ConversationComposer.d.ts.map +1 -1
- package/lib/typescript/module/ConversationScreen.d.ts +1 -1
- package/lib/typescript/module/ConversationScreen.d.ts.map +1 -1
- package/lib/typescript/module/SuperagentHomeScreen.d.ts.map +1 -1
- package/lib/typescript/module/conversationRuntime.d.ts +3 -2
- package/lib/typescript/module/conversationRuntime.d.ts.map +1 -1
- package/lib/typescript/module/fileTreeUtils.d.ts +1 -0
- package/lib/typescript/module/fileTreeUtils.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +1 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/useSuperagentConversation.d.ts.map +1 -1
- package/lib/typescript/module/useSuperagentRuntime.d.ts +3 -1
- package/lib/typescript/module/useSuperagentRuntime.d.ts.map +1 -1
- package/package.json +13 -11
- package/src/AgentSettingsPanel.tsx +28 -9
- package/src/AttachmentPickerStatusModal.tsx +2 -2
- package/src/ConversationChat.tsx +37 -9
- package/src/ConversationComposer.tsx +11 -6
- package/src/ConversationScreen.tsx +2 -0
- package/src/MarkdownText.tsx +1 -1
- package/src/MessageActionBar.tsx +9 -3
- package/src/SuperagentHomeScreen.tsx +18 -3
- package/src/ToolApprovalCard.tsx +1 -1
- package/src/ToolCallSummary.tsx +4 -1
- package/src/attachmentUpload.ts +2 -1
- package/src/conversationRuntime.ts +48 -4
- package/src/fileTreeUtils.ts +13 -0
- package/src/screenParts.tsx +3 -3
- package/src/styles.ts +43 -43
- package/src/types.ts +1 -0
- package/src/useSuperagentConversation.ts +116 -31
- package/src/useSuperagentRuntime.ts +80 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AUTO_GREET_MESSAGE","nextMessageId","normalizeMessages","messages","map","message","content","normalizeContent","createdAt","getMessageCursor","mergeMessage","nextMessage","normalized","created_at","Date","now","id","existingIndex","findIndex","index","
|
|
1
|
+
{"version":3,"names":["AUTO_GREET_MESSAGE","nextMessageId","normalizeMessages","messages","map","message","content","normalizeContent","createdAt","getMessageCursor","mergeMessage","nextMessage","normalized","created_at","Date","now","id","existingIndex","findIndex","index","role","length","isVisibleMessage","hidden","createUserMessage","options","fileUrls","filter","Boolean","replyTo","toISOString","file_urls","additional_message_params","reply_to","message_id","messageId","createErrorMessage","error","Error","isQueuedResponse","response","queued","countAssistantResponses","trim","hasNewAssistantResponse","assistantCountBefore","mergeConversationSnapshot","current","incoming","currentById","Map","incomingIds","Set","incomingUserContents","merged","local","get","undefined","pendingLocal","has","refreshConversation","apiClient","conversationId","setMessages","refreshed","getConversation","normalizedMessages","sendWithFallback","agentId","onSendMessage","setIsSending","responseMessages","Array","isArray","some","errorMessage","pollConversation","onComplete","onAgentMessageDone","attempts","interval","setInterval","shouldStop","foundAssistantResponse","refreshedMessages","clearInterval","normalizeDate","metadata","created_date","value","date","Number","isNaN","getTime","JSON","stringify","String"],"sourceRoot":"../../src","sources":["conversationRuntime.ts"],"mappings":";;AAEA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,gBAAa;AAG/D,OAAO,SAASC,iBAAiBA,CAACC,QAA6B,EAAE;EAC/D,OAAOA,QAAQ,CAACC,GAAG,CAAEC,OAAO,KAAM;IAChC,GAAGA,OAAO;IACVC,OAAO,EAAEC,gBAAgB,CAACF,OAAO,CAACC,OAAO,CAAC;IAC1CE,SAAS,EA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ules/', '.agents/skills/', '.agents/mcps/', '.agents/hooks/', '.agents/cron/', '.agents/memory/', 'incoming_files/'];
|
|
5
|
+
export function sanitizeSandboxFilePath(path) {
|
|
6
|
+
// Strip absolute / `..` / `.` segments and null bytes so a picked file name can't
|
|
7
|
+
// write outside the sandbox via path traversal (defense in depth, not a substitute
|
|
8
|
+
// for the backend's own validation).
|
|
9
|
+
return path.replace(/\\/g, '/').replace(/\0/g, '').split('/').map(segment => segment.trim()).filter(segment => segment && segment !== '.' && segment !== '..').join('/');
|
|
10
|
+
}
|
|
5
11
|
export function normalizeFilePaths(paths = []) {
|
|
6
12
|
return paths.filter(path => typeof path === 'string' && path.trim().length > 0).map(path => path.replace(/^\/+/, '')).filter(path => !path.includes('\0')).filter(path => !HIDDEN_FILE_NAMES.has(getFileName(path)));
|
|
7
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HIDDEN_FILE_NAMES","Set","DEFAULT_SANDBOX_FILE_PATHS","
|
|
1
|
+
{"version":3,"names":["HIDDEN_FILE_NAMES","Set","DEFAULT_SANDBOX_FILE_PATHS","sanitizeSandboxFilePath","path","replace","split","map","segment","trim","filter","join","normalizeFilePaths","paths","length","includes","has","getFileName","buildFileTree","root","fileCount","folderCount","parts","Boolean","current","index","part","isFile","endsWith","toNodes","value","Object","entries","name","children","type","sort","first","second","localeCompare","tree","flattenFileTree","nodes","parentPath","node","push","getFileCategory","filePath","extension","getFileExtension","isEditableFile","category","pop","getFolderPath","fileName","toLowerCase","dotIndex","lastIndexOf","slice","getImageMimeType"],"sourceRoot":"../../src","sources":["fileTreeUtils.ts"],"mappings":";;AAEA,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;AAE7F,OAAO,MAAMC,0BAA0B,GAAG,CACxC,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAA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,KAAK,KAAK;MACR,OAAO,WAAW;IACpB,KAAK,KAAK;MACR,OAAO,cAAc;IACvB,KAAK,KAAK;IACV,KAAK,MAAM;MACT,OAAO,YAAY;IACrB,KAAK,KAAK;MACR,OAAO,eAAe;IACxB,KAAK,MAAM;MACT,OAAO,YAAY;IACrB;MACE,OAAO,WAAW;EACtB;AACF","ignoreList":[]}
|
|
@@ -47,7 +47,7 @@ export function AgentCard({
|
|
|
47
47
|
children: preview || agent.description || 'Open your latest Superagent conversation.'
|
|
48
48
|
})]
|
|
49
49
|
}), /*#__PURE__*/_jsx(ChevronRight, {
|
|
50
|
-
color: "#
|
|
50
|
+
color: "#A1A1AA",
|
|
51
51
|
size: 24,
|
|
52
52
|
strokeWidth: 2.5
|
|
53
53
|
})]
|
|
@@ -133,7 +133,7 @@ export function AgentRow({
|
|
|
133
133
|
children: preview || agent.description || 'Ready for the next instruction.'
|
|
134
134
|
})]
|
|
135
135
|
}), /*#__PURE__*/_jsx(ChevronRight, {
|
|
136
|
-
color: "#
|
|
136
|
+
color: "#A1A1AA",
|
|
137
137
|
size: 21,
|
|
138
138
|
strokeWidth: 2.5
|
|
139
139
|
})]
|
|
@@ -163,7 +163,7 @@ export function CreateAgentButton({
|
|
|
163
163
|
pressed
|
|
164
164
|
}) => [styles.secondaryButton, pressed && styles.pressed],
|
|
165
165
|
children: [/*#__PURE__*/_jsx(Plus, {
|
|
166
|
-
color: "#
|
|
166
|
+
color: "#18181B",
|
|
167
167
|
size: 18,
|
|
168
168
|
strokeWidth: 2.6
|
|
169
169
|
}), /*#__PURE__*/_jsx(Text, {
|
package/lib/module/styles.js
CHANGED
|
@@ -4,7 +4,7 @@ import { StyleSheet } from 'react-native';
|
|
|
4
4
|
export const styles = StyleSheet.create({
|
|
5
5
|
safeArea: {
|
|
6
6
|
flex: 1,
|
|
7
|
-
backgroundColor: '#
|
|
7
|
+
backgroundColor: '#F7F7F8'
|
|
8
8
|
},
|
|
9
9
|
container: {
|
|
10
10
|
paddingBottom: 34,
|
|
@@ -13,7 +13,7 @@ export const styles = StyleSheet.create({
|
|
|
13
13
|
},
|
|
14
14
|
homeTopBar: {
|
|
15
15
|
alignItems: 'center',
|
|
16
|
-
borderBottomColor: '#
|
|
16
|
+
borderBottomColor: '#E4E4E7',
|
|
17
17
|
borderBottomWidth: 1,
|
|
18
18
|
flexDirection: 'row',
|
|
19
19
|
minHeight: 62,
|
|
@@ -35,7 +35,7 @@ export const styles = StyleSheet.create({
|
|
|
35
35
|
minWidth: 0
|
|
36
36
|
},
|
|
37
37
|
topBarTitle: {
|
|
38
|
-
color: '#
|
|
38
|
+
color: '#18181B',
|
|
39
39
|
fontSize: 17,
|
|
40
40
|
fontWeight: '900',
|
|
41
41
|
letterSpacing: 0,
|
|
@@ -58,20 +58,20 @@ export const styles = StyleSheet.create({
|
|
|
58
58
|
marginLeft: 12
|
|
59
59
|
},
|
|
60
60
|
eyebrow: {
|
|
61
|
-
color: '#
|
|
61
|
+
color: '#71717A',
|
|
62
62
|
fontSize: 12,
|
|
63
63
|
fontWeight: '800',
|
|
64
64
|
marginTop: 2
|
|
65
65
|
},
|
|
66
66
|
title: {
|
|
67
|
-
color: '#
|
|
67
|
+
color: '#18181B',
|
|
68
68
|
fontSize: 24,
|
|
69
69
|
fontWeight: '900',
|
|
70
70
|
letterSpacing: 0,
|
|
71
71
|
lineHeight: 29
|
|
72
72
|
},
|
|
73
73
|
subtitle: {
|
|
74
|
-
color: '#
|
|
74
|
+
color: '#52525B',
|
|
75
75
|
fontSize: 14,
|
|
76
76
|
fontWeight: '600',
|
|
77
77
|
lineHeight: 20,
|
|
@@ -79,8 +79,8 @@ export const styles = StyleSheet.create({
|
|
|
79
79
|
},
|
|
80
80
|
headerAvatar: {
|
|
81
81
|
alignItems: 'center',
|
|
82
|
-
backgroundColor: '#
|
|
83
|
-
borderColor: '#
|
|
82
|
+
backgroundColor: '#FFFFFF',
|
|
83
|
+
borderColor: '#E4E4E7',
|
|
84
84
|
borderRadius: 22,
|
|
85
85
|
borderWidth: 1,
|
|
86
86
|
height: 44,
|
|
@@ -89,15 +89,15 @@ export const styles = StyleSheet.create({
|
|
|
89
89
|
},
|
|
90
90
|
loadingPanel: {
|
|
91
91
|
alignItems: 'center',
|
|
92
|
-
backgroundColor: '#
|
|
93
|
-
borderColor: '#
|
|
92
|
+
backgroundColor: '#FFFFFF',
|
|
93
|
+
borderColor: '#E4E4E7',
|
|
94
94
|
borderRadius: 18,
|
|
95
95
|
borderWidth: 1,
|
|
96
96
|
padding: 32
|
|
97
97
|
},
|
|
98
98
|
heroPanel: {
|
|
99
|
-
backgroundColor: '#
|
|
100
|
-
borderColor: '#
|
|
99
|
+
backgroundColor: '#FFFFFF',
|
|
100
|
+
borderColor: '#E4E4E7',
|
|
101
101
|
borderRadius: 22,
|
|
102
102
|
borderWidth: 1,
|
|
103
103
|
overflow: 'hidden',
|
|
@@ -110,7 +110,7 @@ export const styles = StyleSheet.create({
|
|
|
110
110
|
marginBottom: 16
|
|
111
111
|
},
|
|
112
112
|
heroLabel: {
|
|
113
|
-
color: '#
|
|
113
|
+
color: '#71717A',
|
|
114
114
|
fontSize: 11,
|
|
115
115
|
fontWeight: '900',
|
|
116
116
|
textTransform: 'uppercase'
|
|
@@ -122,8 +122,8 @@ export const styles = StyleSheet.create({
|
|
|
122
122
|
},
|
|
123
123
|
avatar: {
|
|
124
124
|
alignItems: 'center',
|
|
125
|
-
backgroundColor: '#
|
|
126
|
-
borderColor: '#
|
|
125
|
+
backgroundColor: '#F4F4F5',
|
|
126
|
+
borderColor: '#E4E4E7',
|
|
127
127
|
borderRadius: 24,
|
|
128
128
|
borderWidth: 1,
|
|
129
129
|
height: 52,
|
|
@@ -131,7 +131,7 @@ export const styles = StyleSheet.create({
|
|
|
131
131
|
width: 52
|
|
132
132
|
},
|
|
133
133
|
avatarText: {
|
|
134
|
-
color: '#
|
|
134
|
+
color: '#18181B',
|
|
135
135
|
fontSize: 18,
|
|
136
136
|
fontWeight: '900'
|
|
137
137
|
},
|
|
@@ -141,20 +141,20 @@ export const styles = StyleSheet.create({
|
|
|
141
141
|
minWidth: 0
|
|
142
142
|
},
|
|
143
143
|
agentName: {
|
|
144
|
-
color: '#
|
|
144
|
+
color: '#18181B',
|
|
145
145
|
fontSize: 21,
|
|
146
146
|
fontWeight: '900',
|
|
147
147
|
lineHeight: 25
|
|
148
148
|
},
|
|
149
149
|
agentDescription: {
|
|
150
|
-
color: '#
|
|
150
|
+
color: '#52525B',
|
|
151
151
|
fontSize: 14,
|
|
152
152
|
fontWeight: '600',
|
|
153
153
|
lineHeight: 20,
|
|
154
154
|
marginTop: 7
|
|
155
155
|
},
|
|
156
156
|
chevron: {
|
|
157
|
-
color: '#
|
|
157
|
+
color: '#A1A1AA',
|
|
158
158
|
fontSize: 20,
|
|
159
159
|
fontWeight: '900'
|
|
160
160
|
},
|
|
@@ -165,8 +165,8 @@ export const styles = StyleSheet.create({
|
|
|
165
165
|
marginTop: 14
|
|
166
166
|
},
|
|
167
167
|
agentMetaPill: {
|
|
168
|
-
backgroundColor: '#
|
|
169
|
-
borderColor: '#
|
|
168
|
+
backgroundColor: '#F4F4F5',
|
|
169
|
+
borderColor: '#E4E4E7',
|
|
170
170
|
borderRadius: 13,
|
|
171
171
|
borderWidth: 1,
|
|
172
172
|
marginRight: 7,
|
|
@@ -175,26 +175,26 @@ export const styles = StyleSheet.create({
|
|
|
175
175
|
paddingVertical: 6
|
|
176
176
|
},
|
|
177
177
|
agentMetaText: {
|
|
178
|
-
color: '#
|
|
178
|
+
color: '#3F3F46',
|
|
179
179
|
fontSize: 12,
|
|
180
180
|
fontWeight: '800'
|
|
181
181
|
},
|
|
182
182
|
emptyPanel: {
|
|
183
|
-
backgroundColor: '#
|
|
184
|
-
borderColor: '#
|
|
183
|
+
backgroundColor: '#FFFFFF',
|
|
184
|
+
borderColor: '#E4E4E7',
|
|
185
185
|
borderRadius: 22,
|
|
186
186
|
borderWidth: 1,
|
|
187
187
|
padding: 16
|
|
188
188
|
},
|
|
189
189
|
emptyTitle: {
|
|
190
|
-
color: '#
|
|
190
|
+
color: '#18181B',
|
|
191
191
|
fontSize: 23,
|
|
192
192
|
fontWeight: '900',
|
|
193
193
|
lineHeight: 28,
|
|
194
194
|
marginTop: 15
|
|
195
195
|
},
|
|
196
196
|
emptyBody: {
|
|
197
|
-
color: '#
|
|
197
|
+
color: '#52525B',
|
|
198
198
|
fontSize: 14,
|
|
199
199
|
fontWeight: '600',
|
|
200
200
|
lineHeight: 21,
|
|
@@ -206,8 +206,8 @@ export const styles = StyleSheet.create({
|
|
|
206
206
|
marginTop: 14
|
|
207
207
|
},
|
|
208
208
|
emptyChip: {
|
|
209
|
-
backgroundColor: '#
|
|
210
|
-
borderColor: '#
|
|
209
|
+
backgroundColor: '#F4F4F5',
|
|
210
|
+
borderColor: '#E4E4E7',
|
|
211
211
|
borderRadius: 15,
|
|
212
212
|
borderWidth: 1,
|
|
213
213
|
marginRight: 7,
|
|
@@ -216,13 +216,13 @@ export const styles = StyleSheet.create({
|
|
|
216
216
|
paddingVertical: 7
|
|
217
217
|
},
|
|
218
218
|
emptyChipText: {
|
|
219
|
-
color: '#
|
|
219
|
+
color: '#3F3F46',
|
|
220
220
|
fontSize: 12,
|
|
221
221
|
fontWeight: '800'
|
|
222
222
|
},
|
|
223
223
|
primaryButton: {
|
|
224
224
|
alignItems: 'center',
|
|
225
|
-
backgroundColor: '#
|
|
225
|
+
backgroundColor: '#18181B',
|
|
226
226
|
borderRadius: 17,
|
|
227
227
|
justifyContent: 'center',
|
|
228
228
|
marginTop: 20,
|
|
@@ -230,14 +230,14 @@ export const styles = StyleSheet.create({
|
|
|
230
230
|
paddingHorizontal: 18
|
|
231
231
|
},
|
|
232
232
|
primaryButtonText: {
|
|
233
|
-
color: '#
|
|
233
|
+
color: '#FFFFFF',
|
|
234
234
|
fontSize: 16,
|
|
235
235
|
fontWeight: '900'
|
|
236
236
|
},
|
|
237
237
|
secondaryButton: {
|
|
238
238
|
alignItems: 'center',
|
|
239
|
-
backgroundColor: '#
|
|
240
|
-
borderColor: '#
|
|
239
|
+
backgroundColor: '#FFFFFF',
|
|
240
|
+
borderColor: '#E4E4E7',
|
|
241
241
|
borderRadius: 16,
|
|
242
242
|
borderWidth: 1,
|
|
243
243
|
flexDirection: 'row',
|
|
@@ -247,7 +247,7 @@ export const styles = StyleSheet.create({
|
|
|
247
247
|
paddingHorizontal: 16
|
|
248
248
|
},
|
|
249
249
|
secondaryButtonText: {
|
|
250
|
-
color: '#
|
|
250
|
+
color: '#18181B',
|
|
251
251
|
fontSize: 14,
|
|
252
252
|
fontWeight: '900',
|
|
253
253
|
marginLeft: 7
|
|
@@ -262,19 +262,19 @@ export const styles = StyleSheet.create({
|
|
|
262
262
|
marginBottom: 10
|
|
263
263
|
},
|
|
264
264
|
sectionTitle: {
|
|
265
|
-
color: '#
|
|
265
|
+
color: '#18181B',
|
|
266
266
|
fontSize: 17,
|
|
267
267
|
fontWeight: '900'
|
|
268
268
|
},
|
|
269
269
|
sectionCount: {
|
|
270
|
-
color: '#
|
|
270
|
+
color: '#A1A1AA',
|
|
271
271
|
fontSize: 12,
|
|
272
272
|
fontWeight: '900'
|
|
273
273
|
},
|
|
274
274
|
agentRow: {
|
|
275
275
|
alignItems: 'center',
|
|
276
|
-
backgroundColor: '#
|
|
277
|
-
borderColor: '#
|
|
276
|
+
backgroundColor: '#FFFFFF',
|
|
277
|
+
borderColor: '#E4E4E7',
|
|
278
278
|
borderRadius: 17,
|
|
279
279
|
borderWidth: 1,
|
|
280
280
|
flexDirection: 'row',
|
|
@@ -290,12 +290,12 @@ export const styles = StyleSheet.create({
|
|
|
290
290
|
minWidth: 0
|
|
291
291
|
},
|
|
292
292
|
agentRowName: {
|
|
293
|
-
color: '#
|
|
293
|
+
color: '#18181B',
|
|
294
294
|
fontSize: 15,
|
|
295
295
|
fontWeight: '900'
|
|
296
296
|
},
|
|
297
297
|
agentRowDescription: {
|
|
298
|
-
color: '#
|
|
298
|
+
color: '#71717A',
|
|
299
299
|
fontSize: 12,
|
|
300
300
|
fontWeight: '600',
|
|
301
301
|
lineHeight: 17,
|
|
@@ -303,8 +303,8 @@ export const styles = StyleSheet.create({
|
|
|
303
303
|
},
|
|
304
304
|
compactAvatar: {
|
|
305
305
|
alignItems: 'center',
|
|
306
|
-
backgroundColor: '#
|
|
307
|
-
borderColor: '#
|
|
306
|
+
backgroundColor: '#F4F4F5',
|
|
307
|
+
borderColor: '#E4E4E7',
|
|
308
308
|
borderRadius: 15,
|
|
309
309
|
borderWidth: 1,
|
|
310
310
|
height: 38,
|
|
@@ -326,7 +326,7 @@ export const styles = StyleSheet.create({
|
|
|
326
326
|
fontWeight: '700'
|
|
327
327
|
},
|
|
328
328
|
helperText: {
|
|
329
|
-
color: '#
|
|
329
|
+
color: '#A1A1AA',
|
|
330
330
|
fontSize: 12,
|
|
331
331
|
fontWeight: '700',
|
|
332
332
|
lineHeight: 18,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { AUTO_GREET_MESSAGE, MESSAGES_PAGE_SIZE } from "./constants.js";
|
|
5
|
-
import { countAssistantResponses, createErrorMessage, createUserMessage, getMessageCursor, hasNewAssistantResponse, isQueuedResponse, isVisibleMessage, mergeMessage, normalizeMessages, pollConversation, refreshConversation, sendWithFallback } from "./conversationRuntime.js";
|
|
5
|
+
import { countAssistantResponses, createErrorMessage, createUserMessage, getMessageCursor, hasNewAssistantResponse, isQueuedResponse, isVisibleMessage, mergeConversationSnapshot, mergeMessage, normalizeMessages, pollConversation, refreshConversation, sendWithFallback } from "./conversationRuntime.js";
|
|
6
6
|
export function useSuperagentConversation({
|
|
7
7
|
agentId,
|
|
8
8
|
apiClient,
|
|
@@ -21,6 +21,36 @@ export function useSuperagentConversation({
|
|
|
21
21
|
const [initError, setInitError] = useState(null);
|
|
22
22
|
const [hasMoreMessages, setHasMoreMessages] = useState(false);
|
|
23
23
|
const sendGenerationRef = useRef(0);
|
|
24
|
+
const pollIntervalRef = useRef(null);
|
|
25
|
+
const loadingPreviousRef = useRef(false);
|
|
26
|
+
const settleTimeoutRef = useRef(null);
|
|
27
|
+
const messagesRef = useRef(messages);
|
|
28
|
+
const onAgentMessageDoneRef = useRef(onAgentMessageDone);
|
|
29
|
+
const onConversationSettledRef = useRef(onConversationSettled);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
messagesRef.current = messages;
|
|
32
|
+
}, [messages]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
onAgentMessageDoneRef.current = onAgentMessageDone;
|
|
35
|
+
onConversationSettledRef.current = onConversationSettled;
|
|
36
|
+
}, [onAgentMessageDone, onConversationSettled]);
|
|
37
|
+
|
|
38
|
+
// Cancel any in-flight poll/settle timers — called on each new send and on unmount.
|
|
39
|
+
const clearPendingSettlers = useCallback(() => {
|
|
40
|
+
if (pollIntervalRef.current) {
|
|
41
|
+
clearInterval(pollIntervalRef.current);
|
|
42
|
+
pollIntervalRef.current = null;
|
|
43
|
+
}
|
|
44
|
+
if (settleTimeoutRef.current) {
|
|
45
|
+
clearTimeout(settleTimeoutRef.current);
|
|
46
|
+
settleTimeoutRef.current = null;
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
// Clear any active poll interval / settle timeout when the hook unmounts.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
return () => clearPendingSettlers();
|
|
53
|
+
}, [clearPendingSettlers]);
|
|
24
54
|
useEffect(() => {
|
|
25
55
|
if (!apiClient) setMessages(fallbackMessages);
|
|
26
56
|
}, [apiClient, fallbackMessages]);
|
|
@@ -65,45 +95,64 @@ export function useSuperagentConversation({
|
|
|
65
95
|
if (!realtimeClient || !conversationId) return undefined;
|
|
66
96
|
return realtimeClient.subscribeToConversation(conversationId, {
|
|
67
97
|
onMessage(message) {
|
|
98
|
+
// Don't clear the sending/stop state on intermediate assistant messages
|
|
99
|
+
// (tool-call steps or streamed content arrive before the turn is done).
|
|
100
|
+
// The turn ends on `agent_done` (onAgentDone) or the 5s settle fallback.
|
|
68
101
|
setMessages(current => mergeMessage(current, message));
|
|
69
|
-
if (message.role === 'assistant' && (message.content || message.toolCalls?.length || message.tool_calls?.length)) {
|
|
70
|
-
setIsSending(false);
|
|
71
|
-
}
|
|
72
102
|
},
|
|
73
103
|
onConversation(conversation) {
|
|
74
104
|
if (conversation.id !== conversationId) return;
|
|
75
|
-
|
|
105
|
+
const incoming = normalizeMessages(conversation.messages ?? []);
|
|
106
|
+
setMessages(current => mergeConversationSnapshot(current, incoming));
|
|
76
107
|
},
|
|
77
108
|
onAgentDone() {
|
|
109
|
+
// Agent finished via realtime — cancel the 5s settle fallback so
|
|
110
|
+
// onConversationSettled doesn't also fire when the timer elapses.
|
|
111
|
+
if (settleTimeoutRef.current) {
|
|
112
|
+
clearTimeout(settleTimeoutRef.current);
|
|
113
|
+
settleTimeoutRef.current = null;
|
|
114
|
+
}
|
|
78
115
|
setIsSending(false);
|
|
79
|
-
|
|
116
|
+
setQueuedMessages([]);
|
|
117
|
+
onAgentMessageDoneRef.current?.();
|
|
80
118
|
if (apiClient) {
|
|
81
|
-
refreshConversation(apiClient, conversationId, setMessages).then(() =>
|
|
119
|
+
refreshConversation(apiClient, conversationId, setMessages).then(() => onConversationSettledRef.current?.()).catch(() => {});
|
|
82
120
|
} else {
|
|
83
|
-
|
|
121
|
+
onConversationSettledRef.current?.();
|
|
84
122
|
}
|
|
85
123
|
},
|
|
86
124
|
onReconnect() {
|
|
125
|
+
// A reconnect means the transient socket error cleared — drop the
|
|
126
|
+
// "something went wrong" state so it doesn't linger as a failed load.
|
|
127
|
+
setInitError(null);
|
|
87
128
|
if (apiClient) refreshConversation(apiClient, conversationId, setMessages).catch(() => {});
|
|
88
129
|
},
|
|
89
130
|
onError(error) {
|
|
90
131
|
setInitError(error instanceof Error ? error.message : 'Realtime connection failed');
|
|
91
132
|
}
|
|
92
133
|
});
|
|
93
|
-
}, [apiClient, conversationId,
|
|
134
|
+
}, [apiClient, conversationId, realtimeClient]);
|
|
94
135
|
const visibleMessages = useMemo(() => messages.filter((message, index) => isVisibleMessage(message, index)), [messages]);
|
|
95
136
|
const sendMessage = useCallback(async (content, options = {}) => {
|
|
96
137
|
const trimmedContent = content.trim();
|
|
97
138
|
const fileUrls = options.fileUrls?.filter(Boolean) ?? [];
|
|
98
139
|
if (!trimmedContent && fileUrls.length === 0) return;
|
|
99
|
-
|
|
140
|
+
|
|
141
|
+
// A new send supersedes any pending poll/settle timers from the previous one.
|
|
142
|
+
clearPendingSettlers();
|
|
143
|
+
const assistantCountBefore = countAssistantResponses(messagesRef.current);
|
|
100
144
|
const userMessage = createUserMessage(trimmedContent, {
|
|
101
145
|
fileUrls,
|
|
102
146
|
replyTo: options.replyTo
|
|
103
147
|
});
|
|
104
148
|
setMessages(current => [...current, userMessage]);
|
|
105
149
|
if (!apiClient || !conversationId) {
|
|
106
|
-
if (!onSendMessage)
|
|
150
|
+
if (!onSendMessage) {
|
|
151
|
+
// No send path yet (no fallback handler, or the conversation is still
|
|
152
|
+
// loading) — drop the optimistic bubble so the turn doesn't look sent.
|
|
153
|
+
setMessages(current => current.filter(message => message.id !== userMessage.id));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
107
156
|
const sendGeneration = sendGenerationRef.current + 1;
|
|
108
157
|
sendGenerationRef.current = sendGeneration;
|
|
109
158
|
const setSendingForCurrentSend = value => {
|
|
@@ -111,7 +160,7 @@ export function useSuperagentConversation({
|
|
|
111
160
|
};
|
|
112
161
|
setIsSending(true);
|
|
113
162
|
const hasAssistantResponse = await sendWithFallback(agentId, trimmedContent, fileUrls, options.replyTo, onSendMessage, setMessages, setSendingForCurrentSend);
|
|
114
|
-
if (hasAssistantResponse)
|
|
163
|
+
if (hasAssistantResponse) onAgentMessageDoneRef.current?.();
|
|
115
164
|
return;
|
|
116
165
|
}
|
|
117
166
|
const sendGeneration = sendGenerationRef.current + 1;
|
|
@@ -121,6 +170,25 @@ export function useSuperagentConversation({
|
|
|
121
170
|
};
|
|
122
171
|
setIsSending(true);
|
|
123
172
|
try {
|
|
173
|
+
// Wait for the turn to complete: poll without realtime, otherwise a 5s
|
|
174
|
+
// fallback in case agent_done never arrives.
|
|
175
|
+
const armSettleFallback = () => {
|
|
176
|
+
if (!realtimeClient) {
|
|
177
|
+
pollIntervalRef.current = pollConversation(apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore, () => {
|
|
178
|
+
setQueuedMessages([]);
|
|
179
|
+
onConversationSettledRef.current?.();
|
|
180
|
+
}, () => onAgentMessageDoneRef.current?.());
|
|
181
|
+
} else {
|
|
182
|
+
settleTimeoutRef.current = setTimeout(() => {
|
|
183
|
+
settleTimeoutRef.current = null;
|
|
184
|
+
refreshConversation(apiClient, conversationId, setMessages).catch(() => {});
|
|
185
|
+
setSendingForCurrentSend(false);
|
|
186
|
+
setQueuedMessages([]);
|
|
187
|
+
onAgentMessageDoneRef.current?.();
|
|
188
|
+
onConversationSettledRef.current?.();
|
|
189
|
+
}, 5000);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
124
192
|
const response = await apiClient.addMessage(conversationId, userMessage);
|
|
125
193
|
if (isQueuedResponse(response)) {
|
|
126
194
|
setQueuedMessages(current => [...current, {
|
|
@@ -128,21 +196,17 @@ export function useSuperagentConversation({
|
|
|
128
196
|
content: userMessage.content,
|
|
129
197
|
position: current.length
|
|
130
198
|
}]);
|
|
199
|
+
// A queued send still needs a settle path, or isSending / the queued strip stick.
|
|
200
|
+
armSettleFallback();
|
|
131
201
|
} else {
|
|
132
202
|
const refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
|
|
133
|
-
if (!realtimeClient) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else {
|
|
139
|
-
pollConversation(apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore, onConversationSettled, onAgentMessageDone);
|
|
140
|
-
}
|
|
203
|
+
if (!realtimeClient && hasNewAssistantResponse(refreshedMessages, assistantCountBefore)) {
|
|
204
|
+
setSendingForCurrentSend(false);
|
|
205
|
+
setQueuedMessages([]);
|
|
206
|
+
onAgentMessageDoneRef.current?.();
|
|
207
|
+
onConversationSettledRef.current?.();
|
|
141
208
|
} else {
|
|
142
|
-
|
|
143
|
-
setSendingForCurrentSend(false);
|
|
144
|
-
onConversationSettled?.();
|
|
145
|
-
}, 5000);
|
|
209
|
+
armSettleFallback();
|
|
146
210
|
}
|
|
147
211
|
}
|
|
148
212
|
} catch (error) {
|
|
@@ -150,7 +214,7 @@ export function useSuperagentConversation({
|
|
|
150
214
|
setMessages(current => [...current, errorMessage]);
|
|
151
215
|
setSendingForCurrentSend(false);
|
|
152
216
|
}
|
|
153
|
-
}, [agentId, apiClient,
|
|
217
|
+
}, [agentId, apiClient, clearPendingSettlers, conversationId, onSendMessage, realtimeClient]);
|
|
154
218
|
const deleteMessage = useCallback(async messageId => {
|
|
155
219
|
if (!messageId || messageId === 'welcome') return false;
|
|
156
220
|
if (!apiClient || !conversationId) {
|
|
@@ -159,15 +223,22 @@ export function useSuperagentConversation({
|
|
|
159
223
|
}
|
|
160
224
|
try {
|
|
161
225
|
await apiClient.deleteMessage(conversationId, messageId);
|
|
226
|
+
// Remove locally before refreshing: mergeConversationSnapshot keeps rows
|
|
227
|
+
// missing from the server snapshot, so without this the just-deleted
|
|
228
|
+
// message would be resurrected.
|
|
229
|
+
setMessages(current => current.filter(message => message.id !== messageId));
|
|
162
230
|
await refreshConversation(apiClient, conversationId, setMessages);
|
|
163
231
|
return true;
|
|
164
|
-
} catch
|
|
165
|
-
|
|
232
|
+
} catch {
|
|
233
|
+
// A failed delete is not a load failure — don't drive the "something went
|
|
234
|
+
// wrong" panel (it would persist). Signal failure via the return value so
|
|
235
|
+
// the caller can surface it.
|
|
166
236
|
return false;
|
|
167
237
|
}
|
|
168
238
|
}, [apiClient, conversationId]);
|
|
169
239
|
const stop = useCallback(async () => {
|
|
170
240
|
sendGenerationRef.current += 1;
|
|
241
|
+
clearPendingSettlers();
|
|
171
242
|
if (!apiClient || !conversationId) {
|
|
172
243
|
setIsSending(false);
|
|
173
244
|
return;
|
|
@@ -176,21 +247,33 @@ export function useSuperagentConversation({
|
|
|
176
247
|
setQueuedMessages([]);
|
|
177
248
|
await apiClient.stopConversation(conversationId);
|
|
178
249
|
await refreshConversation(apiClient, conversationId, setMessages);
|
|
179
|
-
}, [apiClient, conversationId]);
|
|
250
|
+
}, [apiClient, clearPendingSettlers, conversationId]);
|
|
180
251
|
const loadPrevious = useCallback(async () => {
|
|
252
|
+
if (loadingPreviousRef.current) return;
|
|
181
253
|
const before = getMessageCursor(messages[0]);
|
|
182
254
|
if (!apiClient || !conversationId || !before) return;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
255
|
+
loadingPreviousRef.current = true;
|
|
256
|
+
try {
|
|
257
|
+
const page = await apiClient.getMessages(conversationId, {
|
|
258
|
+
limit: MESSAGES_PAGE_SIZE,
|
|
259
|
+
before
|
|
260
|
+
});
|
|
261
|
+
setMessages(current => [...normalizeMessages(page.messages), ...current]);
|
|
262
|
+
setHasMoreMessages(Boolean(page.has_more ?? page.hasMore));
|
|
263
|
+
} catch {
|
|
264
|
+
// Pagination failed — swallow so it isn't an unhandled rejection from the
|
|
265
|
+
// button, and leave hasMoreMessages as-is so the user can retry.
|
|
266
|
+
} finally {
|
|
267
|
+
loadingPreviousRef.current = false;
|
|
268
|
+
}
|
|
189
269
|
}, [apiClient, conversationId, messages]);
|
|
190
270
|
const submitToolCallInput = useCallback(async (toolCallId, approve, extraUserInput, originRequestId) => {
|
|
191
271
|
if (!apiClient || !conversationId) return null;
|
|
192
272
|
const updated = await apiClient.submitToolCallInput(conversationId, toolCallId, approve, extraUserInput, originRequestId);
|
|
193
|
-
if (updated.messages)
|
|
273
|
+
if (updated.messages) {
|
|
274
|
+
const incoming = normalizeMessages(updated.messages);
|
|
275
|
+
setMessages(current => mergeConversationSnapshot(current, incoming));
|
|
276
|
+
}
|
|
194
277
|
onConversationSettled?.();
|
|
195
278
|
return updated;
|
|
196
279
|
}, [apiClient, conversationId, onConversationSettled]);
|