@agent-native/core 0.193.0 → 0.193.1-nightly-20260926220417
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/corpus/README.md +1 -1
- package/corpus/templates/assets/changelog/2026-09-26-builder-is-the-primary-first-run-setup.md +6 -0
- package/corpus/templates/chat/app/components/chat/ChatRouteContent.tsx +93 -0
- package/corpus/templates/chat/app/i18n/en-US.ts +2 -0
- package/corpus/templates/chat/changelog/2026-09-26-builder-setup-retry.md +6 -0
- package/corpus/templates/clips/changelog/2026-09-26-builder-is-the-primary-first-run-setup.md +6 -0
- package/corpus/templates/design/changelog/2026-09-26-builder-is-the-primary-first-run-setup.md +6 -0
- package/corpus/templates/slides/changelog/2026-09-26-builder-is-the-primary-first-run-setup.md +6 -0
- package/dist/client/agent-chat/index.d.ts +1 -1
- package/dist/client/agent-chat/index.js +1 -1
- package/dist/client/chat/agentkit-protocol.js +18 -1
- package/dist/client/chat/run-recovery.d.ts +1 -0
- package/dist/client/chat/run-recovery.js +1 -1
- package/dist/client/onboarding/FirstRunOnboarding.js +59 -22
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/localization/core-messages/ar-SA.js +1 -0
- package/dist/localization/core-messages/de-DE.js +1 -0
- package/dist/localization/core-messages/en-US.d.ts +1 -0
- package/dist/localization/core-messages/en-US.js +1 -0
- package/dist/localization/core-messages/es-ES.js +1 -0
- package/dist/localization/core-messages/fr-FR.js +1 -0
- package/dist/localization/core-messages/hi-IN.js +1 -0
- package/dist/localization/core-messages/ja-JP.js +1 -0
- package/dist/localization/core-messages/ko-KR.js +1 -0
- package/dist/localization/core-messages/pt-BR.js +1 -0
- package/dist/localization/core-messages/zh-CN.js +1 -0
- package/dist/localization/core-messages/zh-TW.js +1 -0
- package/dist/localization/core-messages.d.ts +1 -0
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/sharing/actions/list-resource-shares.d.ts +1 -1
- package/dist/templates/chat/app/components/chat/ChatRouteContent.tsx +93 -0
- package/dist/templates/chat/app/i18n/ar-SA.ts +1 -0
- package/dist/templates/chat/app/i18n/de-DE.ts +2 -0
- package/dist/templates/chat/app/i18n/en-US.ts +2 -0
- package/dist/templates/chat/app/i18n/es-ES.ts +2 -0
- package/dist/templates/chat/app/i18n/fr-FR.ts +2 -0
- package/dist/templates/chat/app/i18n/hi-IN.ts +2 -0
- package/dist/templates/chat/app/i18n/ja-JP.ts +2 -0
- package/dist/templates/chat/app/i18n/ko-KR.ts +2 -0
- package/dist/templates/chat/app/i18n/pt-BR.ts +2 -0
- package/dist/templates/chat/app/i18n/zh-CN.ts +1 -0
- package/dist/templates/chat/app/i18n/zh-TW.ts +1 -0
- package/dist/templates/chat/changelog/2026-09-26-builder-setup-retry.md +6 -0
- package/package.json +1 -1
- package/src/templates/chat/app/components/chat/ChatRouteContent.tsx +93 -0
- package/src/templates/chat/app/i18n/ar-SA.ts +1 -0
- package/src/templates/chat/app/i18n/de-DE.ts +2 -0
- package/src/templates/chat/app/i18n/en-US.ts +2 -0
- package/src/templates/chat/app/i18n/es-ES.ts +2 -0
- package/src/templates/chat/app/i18n/fr-FR.ts +2 -0
- package/src/templates/chat/app/i18n/hi-IN.ts +2 -0
- package/src/templates/chat/app/i18n/ja-JP.ts +2 -0
- package/src/templates/chat/app/i18n/ko-KR.ts +2 -0
- package/src/templates/chat/app/i18n/pt-BR.ts +2 -0
- package/src/templates/chat/app/i18n/zh-CN.ts +1 -0
- package/src/templates/chat/app/i18n/zh-TW.ts +1 -0
- package/src/templates/chat/changelog/2026-09-26-builder-setup-retry.md +6 -0
|
@@ -70,6 +70,7 @@ const messages = {
|
|
|
70
70
|
"onboarding.roleOther": "其他",
|
|
71
71
|
"onboarding.roleOtherInputLabel": "描述你的角色",
|
|
72
72
|
"onboarding.skipForNow": "暫時略過",
|
|
73
|
+
"onboarding.useOwnApiKeys": "使用我自己的 API 金鑰",
|
|
73
74
|
"onboarding.saveRoleError": "無法儲存你的角色。",
|
|
74
75
|
"onboarding.builderCreateAccount": "建立 Builder.io 帳戶",
|
|
75
76
|
"onboarding.builderSignInWithAccount": "使用 Builder.io 帳戶登入",
|
|
@@ -72,6 +72,7 @@ export declare const englishAgentChatMessages: {
|
|
|
72
72
|
readonly "onboarding.roleOther": "Other";
|
|
73
73
|
readonly "onboarding.roleOtherInputLabel": "Describe your role";
|
|
74
74
|
readonly "onboarding.skipForNow": "Skip for now";
|
|
75
|
+
readonly "onboarding.useOwnApiKeys": "Use my own API keys";
|
|
75
76
|
readonly "onboarding.saveRoleError": "Could not save your role.";
|
|
76
77
|
readonly "onboarding.builderCreateAccount": "Create Builder.io account";
|
|
77
78
|
readonly "onboarding.builderSignInWithAccount": "Sign in with Builder.io account";
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* DELETE /_agent-native/notifications/:id — delete
|
|
12
12
|
*/
|
|
13
13
|
export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
|
|
14
|
-
error?: undefined;
|
|
15
14
|
count: number;
|
|
16
15
|
updated?: undefined;
|
|
16
|
+
error?: undefined;
|
|
17
17
|
ok?: undefined;
|
|
18
18
|
} | {
|
|
19
|
-
error?: undefined;
|
|
20
19
|
count?: undefined;
|
|
21
20
|
updated: number;
|
|
21
|
+
error?: undefined;
|
|
22
22
|
ok?: undefined;
|
|
23
23
|
} | {
|
|
24
24
|
count?: undefined;
|
|
@@ -26,8 +26,8 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
|
|
|
26
26
|
error: string;
|
|
27
27
|
ok?: undefined;
|
|
28
28
|
} | {
|
|
29
|
-
error?: undefined;
|
|
30
29
|
count?: undefined;
|
|
31
30
|
updated?: undefined;
|
|
32
31
|
ok: boolean;
|
|
32
|
+
error?: undefined;
|
|
33
33
|
}>>;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -57,37 +57,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
|
|
|
57
57
|
/** POST /_agent-native/secrets/:key — write a secret. */
|
|
58
58
|
export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
59
59
|
error: string;
|
|
60
|
-
status?: undefined;
|
|
61
60
|
ok?: undefined;
|
|
61
|
+
status?: undefined;
|
|
62
62
|
} | {
|
|
63
|
+
error?: undefined;
|
|
63
64
|
ok: boolean;
|
|
64
65
|
status: string;
|
|
65
|
-
error?: undefined;
|
|
66
66
|
} | {
|
|
67
|
+
ok?: undefined;
|
|
67
68
|
error: string;
|
|
68
69
|
removed?: undefined;
|
|
69
|
-
ok?: undefined;
|
|
70
70
|
} | {
|
|
71
|
+
error?: undefined;
|
|
71
72
|
ok: boolean;
|
|
72
73
|
removed: boolean;
|
|
73
|
-
error?: undefined;
|
|
74
74
|
}>>;
|
|
75
75
|
/**
|
|
76
76
|
* POST /_agent-native/secrets/:key/test — validate an optional candidate value
|
|
77
77
|
* or the current stored value without changing anything.
|
|
78
78
|
*/
|
|
79
79
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
80
|
+
ok?: undefined;
|
|
80
81
|
error: string;
|
|
81
82
|
note?: undefined;
|
|
82
|
-
ok?: undefined;
|
|
83
83
|
} | {
|
|
84
|
+
error?: undefined;
|
|
84
85
|
ok: boolean;
|
|
85
86
|
note?: undefined;
|
|
86
|
-
error?: undefined;
|
|
87
87
|
} | {
|
|
88
|
+
error?: undefined;
|
|
88
89
|
ok: boolean;
|
|
89
90
|
note: string;
|
|
90
|
-
error?: undefined;
|
|
91
91
|
} | {
|
|
92
92
|
note?: undefined;
|
|
93
93
|
ok: boolean;
|
|
@@ -119,11 +119,11 @@ export interface AdHocSecretPayload {
|
|
|
119
119
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
120
120
|
error: string;
|
|
121
121
|
} | {
|
|
122
|
+
error?: undefined;
|
|
122
123
|
ok: boolean;
|
|
123
124
|
key: string;
|
|
124
|
-
error?: undefined;
|
|
125
125
|
} | {
|
|
126
|
+
error?: undefined;
|
|
126
127
|
ok: boolean;
|
|
127
128
|
removed: boolean;
|
|
128
|
-
error?: undefined;
|
|
129
129
|
}>>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* static suggestion list in `model-config.ts`.
|
|
6
6
|
*/
|
|
7
7
|
export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
8
|
-
error: string;
|
|
9
8
|
ok?: undefined;
|
|
9
|
+
error: string;
|
|
10
10
|
models?: undefined;
|
|
11
11
|
} | {
|
|
12
12
|
error?: undefined;
|
|
@@ -2,6 +2,7 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
2
2
|
resourceType: string;
|
|
3
3
|
resourceId: string;
|
|
4
4
|
}, {
|
|
5
|
+
role?: undefined;
|
|
5
6
|
ownerEmail: any;
|
|
6
7
|
visibility: any;
|
|
7
8
|
shares: any[];
|
|
@@ -11,7 +12,6 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
11
12
|
supportsGroupShares?: boolean;
|
|
12
13
|
};
|
|
13
14
|
orgId?: undefined;
|
|
14
|
-
role?: undefined;
|
|
15
15
|
agentReadable?: undefined;
|
|
16
16
|
} | {
|
|
17
17
|
ownerEmail: string;
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
AgentMessage,
|
|
4
4
|
} from "@agent-native/agentkit";
|
|
5
5
|
import {
|
|
6
|
+
AgentMessageView,
|
|
7
|
+
AgentRunFailure,
|
|
6
8
|
AgentConnectionRequestCard,
|
|
7
9
|
AgentKitChat,
|
|
8
10
|
} from "@agent-native/agentkit/react/components";
|
|
@@ -10,9 +12,14 @@ import {
|
|
|
10
12
|
useAgentKit,
|
|
11
13
|
useAgentKitControl,
|
|
12
14
|
useAgentThread,
|
|
15
|
+
type AgentRunFailureRenderProps,
|
|
13
16
|
type AgentKitRenderProps,
|
|
14
17
|
} from "@agent-native/agentkit/react/context";
|
|
15
18
|
import { AgentKitRoot } from "@agent-native/agentkit/react/root";
|
|
19
|
+
import {
|
|
20
|
+
BuilderSetupCard,
|
|
21
|
+
isMissingLlmProviderRunError,
|
|
22
|
+
} from "@agent-native/core/client/agent-chat";
|
|
16
23
|
import { CoreComposerRuntimeProvider } from "@agent-native/core/client/agentkit-chat/composer";
|
|
17
24
|
import {
|
|
18
25
|
McpAgentKitConnectionRequestCard,
|
|
@@ -120,7 +127,9 @@ function ChatThreadRouteContent({
|
|
|
120
127
|
labels={{ composerPlaceholder: t("chat.composerPlaceholder") }}
|
|
121
128
|
slots={{
|
|
122
129
|
emptyState: ChatEmptyState,
|
|
130
|
+
message: ChatMessage,
|
|
123
131
|
messageSupplement: ChatMcpConnectionSuggestion,
|
|
132
|
+
runFailure: ChatRunFailure,
|
|
124
133
|
connectionRequest: ChatMcpConnectionRequest,
|
|
125
134
|
footer: ChatAgentFooter,
|
|
126
135
|
}}
|
|
@@ -153,6 +162,90 @@ function ChatThreadRouteContent({
|
|
|
153
162
|
);
|
|
154
163
|
}
|
|
155
164
|
|
|
165
|
+
function ChatMessage({ value, threadId }: AgentKitRenderProps<AgentMessage>) {
|
|
166
|
+
const metadata = value.metadata as
|
|
167
|
+
| { custom?: { agentNativeRecoveryAction?: unknown } }
|
|
168
|
+
| undefined;
|
|
169
|
+
const recoveryAction = metadata?.custom?.agentNativeRecoveryAction;
|
|
170
|
+
if (
|
|
171
|
+
value.role === "user" &&
|
|
172
|
+
(recoveryAction === "continue" || recoveryAction === "retry")
|
|
173
|
+
) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return <AgentMessageView value={value} threadId={threadId} />;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function ChatRunFailure({
|
|
180
|
+
error,
|
|
181
|
+
runId,
|
|
182
|
+
threadId,
|
|
183
|
+
}: AgentRunFailureRenderProps) {
|
|
184
|
+
const thread = useAgentThread(threadId);
|
|
185
|
+
const { controller } = useAgentKit();
|
|
186
|
+
const t = useT();
|
|
187
|
+
const recoveryMetadata = (message: (typeof thread.messages)[number]) =>
|
|
188
|
+
(
|
|
189
|
+
message.metadata as
|
|
190
|
+
| {
|
|
191
|
+
custom?: {
|
|
192
|
+
agentNativeRecoveryAction?: unknown;
|
|
193
|
+
agentNativeRecoveryOfRunId?: unknown;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
| undefined
|
|
197
|
+
)?.custom;
|
|
198
|
+
const userRequests = thread.messages.filter((message) => {
|
|
199
|
+
if (message.role !== "user") return false;
|
|
200
|
+
const action = recoveryMetadata(message)?.agentNativeRecoveryAction;
|
|
201
|
+
return action !== "continue" && action !== "retry";
|
|
202
|
+
});
|
|
203
|
+
const originalRequest = userRequests[0];
|
|
204
|
+
const hasRetryForThisRun = thread.messages.some(
|
|
205
|
+
(message) =>
|
|
206
|
+
recoveryMetadata(message)?.agentNativeRecoveryAction === "retry" &&
|
|
207
|
+
recoveryMetadata(message)?.agentNativeRecoveryOfRunId === runId,
|
|
208
|
+
);
|
|
209
|
+
const retryFirstMessage = useCallback(() => {
|
|
210
|
+
const prompt =
|
|
211
|
+
originalRequest?.parts
|
|
212
|
+
.filter((part) => part.type === "text")
|
|
213
|
+
.map((part) => part.text)
|
|
214
|
+
.join("\n") ?? "";
|
|
215
|
+
const attachments =
|
|
216
|
+
originalRequest?.parts.filter((part) => part.type === "file") ?? [];
|
|
217
|
+
void controller.sendMessage({
|
|
218
|
+
threadId,
|
|
219
|
+
text: prompt || t("chat.retryPreviousRequest"),
|
|
220
|
+
...(attachments.length ? { attachments } : {}),
|
|
221
|
+
metadata: {
|
|
222
|
+
custom: {
|
|
223
|
+
agentNativeRecoveryAction: "retry",
|
|
224
|
+
agentNativeRecoveryOfRunId: runId,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}, [controller, originalRequest, runId, t, threadId]);
|
|
229
|
+
const isFirstMessage = userRequests.length === 1 && !hasRetryForThisRun;
|
|
230
|
+
if (
|
|
231
|
+
isFirstMessage &&
|
|
232
|
+
isMissingLlmProviderRunError({
|
|
233
|
+
message: error.message,
|
|
234
|
+
details: typeof error.details === "string" ? error.details : undefined,
|
|
235
|
+
errorCode: error.code,
|
|
236
|
+
})
|
|
237
|
+
) {
|
|
238
|
+
return (
|
|
239
|
+
<BuilderSetupCard
|
|
240
|
+
fullWidth
|
|
241
|
+
layout="sidebar"
|
|
242
|
+
onRetry={retryFirstMessage}
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return <AgentRunFailure error={error} runId={runId} threadId={threadId} />;
|
|
247
|
+
}
|
|
248
|
+
|
|
156
249
|
function ChatLifecycleTracking({ threadId }: { threadId: string }) {
|
|
157
250
|
const thread = useAgentThread(threadId);
|
|
158
251
|
const lifecycleRef = useRef({
|
|
@@ -32,6 +32,7 @@ const messages = {
|
|
|
32
32
|
pinChat: "تثبيت المحادثة",
|
|
33
33
|
pinned: "المثبتة",
|
|
34
34
|
recents: "الأخيرة",
|
|
35
|
+
retryPreviousRequest: "أعِد محاولة طلبي السابق الآن بعد توصيل مزود النموذج.",
|
|
35
36
|
renameChat: "إعادة تسمية المحادثة",
|
|
36
37
|
renameFailed: "فشلت إعادة التسمية",
|
|
37
38
|
renameThread: "إعادة تسمية السلسلة",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Chat anheften",
|
|
35
35
|
pinned: "Angepinnt",
|
|
36
36
|
recents: "Kürzlich",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Wiederhole meine vorherige Anfrage, jetzt wo der KI-Anbieter verbunden ist.",
|
|
37
39
|
renameChat: "Chat umbenennen",
|
|
38
40
|
renameFailed: "Umbenennen fehlgeschlagen",
|
|
39
41
|
renameThread: "Thread umbenennen",
|
|
@@ -33,6 +33,8 @@ const messages = {
|
|
|
33
33
|
pinChat: "Pin Chat",
|
|
34
34
|
pinned: "Pinned",
|
|
35
35
|
recents: "Recents",
|
|
36
|
+
retryPreviousRequest:
|
|
37
|
+
"Retry my previous request now that the model provider is connected.",
|
|
36
38
|
renameChat: "Rename Chat",
|
|
37
39
|
renameFailed: "Rename Failed",
|
|
38
40
|
renameThread: "Rename Thread",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Fijar chat",
|
|
35
35
|
pinned: "Fijados",
|
|
36
36
|
recents: "Recientes",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Reintenta mi solicitud anterior ahora que el proveedor del modelo está conectado.",
|
|
37
39
|
renameChat: "Renombrar chat",
|
|
38
40
|
renameFailed: "No se pudo renombrar",
|
|
39
41
|
renameThread: "Renombrar hilo",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Épingler le chat",
|
|
35
35
|
pinned: "Épinglés",
|
|
36
36
|
recents: "Récents",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Réessaie ma demande précédente maintenant que le fournisseur du modèle est connecté.",
|
|
37
39
|
renameChat: "Renommer le chat",
|
|
38
40
|
renameFailed: "Échec du renommage",
|
|
39
41
|
renameThread: "Renommer le fil",
|
|
@@ -32,6 +32,8 @@ const messages = {
|
|
|
32
32
|
pinChat: "चैट पिन करें",
|
|
33
33
|
pinned: "पिन की गई",
|
|
34
34
|
recents: "हाल की",
|
|
35
|
+
retryPreviousRequest:
|
|
36
|
+
"मेरा पिछला अनुरोध फिर से आज़माएँ, अब जबकि मॉडल प्रदाता कनेक्ट हो गया है।",
|
|
35
37
|
renameChat: "चैट का नाम बदलें",
|
|
36
38
|
renameFailed: "नाम बदलना विफल",
|
|
37
39
|
renameThread: "थ्रेड का नाम बदलें",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Fixar chat",
|
|
35
35
|
pinned: "Fixados",
|
|
36
36
|
recents: "Recentes",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Tente novamente minha solicitação anterior agora que o provedor do modelo está conectado.",
|
|
37
39
|
renameChat: "Renomear chat",
|
|
38
40
|
renameFailed: "Falha ao renomear",
|
|
39
41
|
renameThread: "Renomear conversa",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.193.
|
|
3
|
+
"version": "0.193.1-nightly-20260926220417",
|
|
4
4
|
"description": "The agentic application framework for building autonomous agents with intuitive UIs",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
AgentMessage,
|
|
4
4
|
} from "@agent-native/agentkit";
|
|
5
5
|
import {
|
|
6
|
+
AgentMessageView,
|
|
7
|
+
AgentRunFailure,
|
|
6
8
|
AgentConnectionRequestCard,
|
|
7
9
|
AgentKitChat,
|
|
8
10
|
} from "@agent-native/agentkit/react/components";
|
|
@@ -10,9 +12,14 @@ import {
|
|
|
10
12
|
useAgentKit,
|
|
11
13
|
useAgentKitControl,
|
|
12
14
|
useAgentThread,
|
|
15
|
+
type AgentRunFailureRenderProps,
|
|
13
16
|
type AgentKitRenderProps,
|
|
14
17
|
} from "@agent-native/agentkit/react/context";
|
|
15
18
|
import { AgentKitRoot } from "@agent-native/agentkit/react/root";
|
|
19
|
+
import {
|
|
20
|
+
BuilderSetupCard,
|
|
21
|
+
isMissingLlmProviderRunError,
|
|
22
|
+
} from "@agent-native/core/client/agent-chat";
|
|
16
23
|
import { CoreComposerRuntimeProvider } from "@agent-native/core/client/agentkit-chat/composer";
|
|
17
24
|
import {
|
|
18
25
|
McpAgentKitConnectionRequestCard,
|
|
@@ -120,7 +127,9 @@ function ChatThreadRouteContent({
|
|
|
120
127
|
labels={{ composerPlaceholder: t("chat.composerPlaceholder") }}
|
|
121
128
|
slots={{
|
|
122
129
|
emptyState: ChatEmptyState,
|
|
130
|
+
message: ChatMessage,
|
|
123
131
|
messageSupplement: ChatMcpConnectionSuggestion,
|
|
132
|
+
runFailure: ChatRunFailure,
|
|
124
133
|
connectionRequest: ChatMcpConnectionRequest,
|
|
125
134
|
footer: ChatAgentFooter,
|
|
126
135
|
}}
|
|
@@ -153,6 +162,90 @@ function ChatThreadRouteContent({
|
|
|
153
162
|
);
|
|
154
163
|
}
|
|
155
164
|
|
|
165
|
+
function ChatMessage({ value, threadId }: AgentKitRenderProps<AgentMessage>) {
|
|
166
|
+
const metadata = value.metadata as
|
|
167
|
+
| { custom?: { agentNativeRecoveryAction?: unknown } }
|
|
168
|
+
| undefined;
|
|
169
|
+
const recoveryAction = metadata?.custom?.agentNativeRecoveryAction;
|
|
170
|
+
if (
|
|
171
|
+
value.role === "user" &&
|
|
172
|
+
(recoveryAction === "continue" || recoveryAction === "retry")
|
|
173
|
+
) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return <AgentMessageView value={value} threadId={threadId} />;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function ChatRunFailure({
|
|
180
|
+
error,
|
|
181
|
+
runId,
|
|
182
|
+
threadId,
|
|
183
|
+
}: AgentRunFailureRenderProps) {
|
|
184
|
+
const thread = useAgentThread(threadId);
|
|
185
|
+
const { controller } = useAgentKit();
|
|
186
|
+
const t = useT();
|
|
187
|
+
const recoveryMetadata = (message: (typeof thread.messages)[number]) =>
|
|
188
|
+
(
|
|
189
|
+
message.metadata as
|
|
190
|
+
| {
|
|
191
|
+
custom?: {
|
|
192
|
+
agentNativeRecoveryAction?: unknown;
|
|
193
|
+
agentNativeRecoveryOfRunId?: unknown;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
| undefined
|
|
197
|
+
)?.custom;
|
|
198
|
+
const userRequests = thread.messages.filter((message) => {
|
|
199
|
+
if (message.role !== "user") return false;
|
|
200
|
+
const action = recoveryMetadata(message)?.agentNativeRecoveryAction;
|
|
201
|
+
return action !== "continue" && action !== "retry";
|
|
202
|
+
});
|
|
203
|
+
const originalRequest = userRequests[0];
|
|
204
|
+
const hasRetryForThisRun = thread.messages.some(
|
|
205
|
+
(message) =>
|
|
206
|
+
recoveryMetadata(message)?.agentNativeRecoveryAction === "retry" &&
|
|
207
|
+
recoveryMetadata(message)?.agentNativeRecoveryOfRunId === runId,
|
|
208
|
+
);
|
|
209
|
+
const retryFirstMessage = useCallback(() => {
|
|
210
|
+
const prompt =
|
|
211
|
+
originalRequest?.parts
|
|
212
|
+
.filter((part) => part.type === "text")
|
|
213
|
+
.map((part) => part.text)
|
|
214
|
+
.join("\n") ?? "";
|
|
215
|
+
const attachments =
|
|
216
|
+
originalRequest?.parts.filter((part) => part.type === "file") ?? [];
|
|
217
|
+
void controller.sendMessage({
|
|
218
|
+
threadId,
|
|
219
|
+
text: prompt || t("chat.retryPreviousRequest"),
|
|
220
|
+
...(attachments.length ? { attachments } : {}),
|
|
221
|
+
metadata: {
|
|
222
|
+
custom: {
|
|
223
|
+
agentNativeRecoveryAction: "retry",
|
|
224
|
+
agentNativeRecoveryOfRunId: runId,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}, [controller, originalRequest, runId, t, threadId]);
|
|
229
|
+
const isFirstMessage = userRequests.length === 1 && !hasRetryForThisRun;
|
|
230
|
+
if (
|
|
231
|
+
isFirstMessage &&
|
|
232
|
+
isMissingLlmProviderRunError({
|
|
233
|
+
message: error.message,
|
|
234
|
+
details: typeof error.details === "string" ? error.details : undefined,
|
|
235
|
+
errorCode: error.code,
|
|
236
|
+
})
|
|
237
|
+
) {
|
|
238
|
+
return (
|
|
239
|
+
<BuilderSetupCard
|
|
240
|
+
fullWidth
|
|
241
|
+
layout="sidebar"
|
|
242
|
+
onRetry={retryFirstMessage}
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return <AgentRunFailure error={error} runId={runId} threadId={threadId} />;
|
|
247
|
+
}
|
|
248
|
+
|
|
156
249
|
function ChatLifecycleTracking({ threadId }: { threadId: string }) {
|
|
157
250
|
const thread = useAgentThread(threadId);
|
|
158
251
|
const lifecycleRef = useRef({
|
|
@@ -32,6 +32,7 @@ const messages = {
|
|
|
32
32
|
pinChat: "تثبيت المحادثة",
|
|
33
33
|
pinned: "المثبتة",
|
|
34
34
|
recents: "الأخيرة",
|
|
35
|
+
retryPreviousRequest: "أعِد محاولة طلبي السابق الآن بعد توصيل مزود النموذج.",
|
|
35
36
|
renameChat: "إعادة تسمية المحادثة",
|
|
36
37
|
renameFailed: "فشلت إعادة التسمية",
|
|
37
38
|
renameThread: "إعادة تسمية السلسلة",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Chat anheften",
|
|
35
35
|
pinned: "Angepinnt",
|
|
36
36
|
recents: "Kürzlich",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Wiederhole meine vorherige Anfrage, jetzt wo der KI-Anbieter verbunden ist.",
|
|
37
39
|
renameChat: "Chat umbenennen",
|
|
38
40
|
renameFailed: "Umbenennen fehlgeschlagen",
|
|
39
41
|
renameThread: "Thread umbenennen",
|
|
@@ -33,6 +33,8 @@ const messages = {
|
|
|
33
33
|
pinChat: "Pin Chat",
|
|
34
34
|
pinned: "Pinned",
|
|
35
35
|
recents: "Recents",
|
|
36
|
+
retryPreviousRequest:
|
|
37
|
+
"Retry my previous request now that the model provider is connected.",
|
|
36
38
|
renameChat: "Rename Chat",
|
|
37
39
|
renameFailed: "Rename Failed",
|
|
38
40
|
renameThread: "Rename Thread",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Fijar chat",
|
|
35
35
|
pinned: "Fijados",
|
|
36
36
|
recents: "Recientes",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Reintenta mi solicitud anterior ahora que el proveedor del modelo está conectado.",
|
|
37
39
|
renameChat: "Renombrar chat",
|
|
38
40
|
renameFailed: "No se pudo renombrar",
|
|
39
41
|
renameThread: "Renombrar hilo",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Épingler le chat",
|
|
35
35
|
pinned: "Épinglés",
|
|
36
36
|
recents: "Récents",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Réessaie ma demande précédente maintenant que le fournisseur du modèle est connecté.",
|
|
37
39
|
renameChat: "Renommer le chat",
|
|
38
40
|
renameFailed: "Échec du renommage",
|
|
39
41
|
renameThread: "Renommer le fil",
|
|
@@ -32,6 +32,8 @@ const messages = {
|
|
|
32
32
|
pinChat: "चैट पिन करें",
|
|
33
33
|
pinned: "पिन की गई",
|
|
34
34
|
recents: "हाल की",
|
|
35
|
+
retryPreviousRequest:
|
|
36
|
+
"मेरा पिछला अनुरोध फिर से आज़माएँ, अब जबकि मॉडल प्रदाता कनेक्ट हो गया है।",
|
|
35
37
|
renameChat: "चैट का नाम बदलें",
|
|
36
38
|
renameFailed: "नाम बदलना विफल",
|
|
37
39
|
renameThread: "थ्रेड का नाम बदलें",
|
|
@@ -34,6 +34,8 @@ const messages = {
|
|
|
34
34
|
pinChat: "Fixar chat",
|
|
35
35
|
pinned: "Fixados",
|
|
36
36
|
recents: "Recentes",
|
|
37
|
+
retryPreviousRequest:
|
|
38
|
+
"Tente novamente minha solicitação anterior agora que o provedor do modelo está conectado.",
|
|
37
39
|
renameChat: "Renomear chat",
|
|
38
40
|
renameFailed: "Falha ao renomear",
|
|
39
41
|
renameThread: "Renomear conversa",
|