@nextclaw/ui 0.12.9 → 0.12.10
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/CHANGELOG.md +61 -0
- package/dist/assets/ChannelsList-M9FTK1Ak.js +8 -0
- package/dist/assets/DocBrowser-CH7-GxlL.js +1 -0
- package/dist/assets/{DocBrowser-6ReNjvzF.js → DocBrowser-DMfr0Oow.js} +1 -1
- package/dist/assets/{DocBrowserContext-B6SpA7Qs.js → DocBrowserContext-BXydqby-.js} +1 -1
- package/dist/assets/{LogoBadge-ByNLYg65.js → LogoBadge-hO7tY7hE.js} +1 -1
- package/dist/assets/ModelConfig-CNIgLf0e.js +1 -0
- package/dist/assets/{ProviderScopedModelInput-Da7khnBA.js → ProviderScopedModelInput-B3HWP4oz.js} +1 -1
- package/dist/assets/ProvidersList-CHjMnRhX.js +1 -0
- package/dist/assets/RuntimeConfig-psp8nMSG.js +1 -0
- package/dist/assets/SearchConfig-CSoKip1f.js +1 -0
- package/dist/assets/{SecretsConfig-D281Rotl.js → SecretsConfig-MEt6MjuD.js} +2 -2
- package/dist/assets/SessionsConfig-DifCiXwR.js +2 -0
- package/dist/assets/{app-query-client-VnFElj4E.js → app-query-client-9jNewezV.js} +1 -1
- package/dist/assets/{book-open-BdcxxoQu.js → book-open-DzdUViDm.js} +1 -1
- package/dist/assets/chat-page-CLp0UV0Y.js +58 -0
- package/dist/assets/chat-session-display-DsYHx0RZ.js +1 -0
- package/dist/assets/{chunk-JZWAC4HX-DK5HPmIK.js → chunk-JZWAC4HX-C5dEc8hV.js} +1 -1
- package/dist/assets/{client-_i4MU2bB.js → client-C-8fH7-c.js} +1 -1
- package/dist/assets/{config-DtIQwrHF.js → config-CBScxsdV.js} +1 -1
- package/dist/assets/config-split-page-BUout_Ak.js +1 -0
- package/dist/assets/{createLucideIcon-BSeTgkZW.js → createLucideIcon-dy5ie7Ox.js} +1 -1
- package/dist/assets/desktop-update-config-2BS6BMkW.js +1 -0
- package/dist/assets/{dist-ccBFUi-o.js → dist-BruyLa92.js} +1 -1
- package/dist/assets/{dist-6TrrnPCR.js → dist-Cy7_j6hA.js} +1 -1
- package/dist/assets/{download-BhDxnyvU.js → download-BD0ETkB-.js} +1 -1
- package/dist/assets/{external-link-BgErLCNT.js → external-link-kZSAO8nT.js} +1 -1
- package/dist/assets/{hash-Bl7dr_UG.js → hash-BHJC2Ovu.js} +1 -1
- package/dist/assets/{i18n-eDHeDY0n.js → i18n-CpTZLchQ.js} +1 -1
- package/dist/assets/index-mW8W2FUu.css +1 -0
- package/dist/assets/index-zDZfXoI4.js +6 -0
- package/dist/assets/{infiniteQueryBehavior-ZDS92Qpp.js → infiniteQueryBehavior-CyER9hv0.js} +1 -1
- package/dist/assets/loader-circle-Bc2gCU33.js +1 -0
- package/dist/assets/{logos-x89HbrZ4.js → logos-B7gRObP8.js} +1 -1
- package/dist/assets/marketplace-page-3qVMnF3d.js +1 -0
- package/dist/assets/marketplace-page-BhFIeQzI.js +49 -0
- package/dist/assets/mcp-marketplace-page-DYfteJ1D.js +40 -0
- package/dist/assets/{page-layout-vZnghcFy.js → page-layout-0UcO9H9Z.js} +1 -1
- package/dist/assets/play-CKDjSQFL.js +1 -0
- package/dist/assets/plus-CG0QrVY_.js +1 -0
- package/dist/assets/{refresh-ccw-DT98i__E.js → refresh-ccw-COVhNHtN.js} +1 -1
- package/dist/assets/{refresh-cw-C47QSEwg.js → refresh-cw-Bcv40SXy.js} +1 -1
- package/dist/assets/remote-access-page-CWHG-sug.js +1 -0
- package/dist/assets/{rotate-cw-JtFzpNn6.js → rotate-cw-oHMKJMC8.js} +1 -1
- package/dist/assets/{save-3S6-H3Xw.js → save-EqJPOF0G.js} +1 -1
- package/dist/assets/search-BCAlB8nz.js +1 -0
- package/dist/assets/security-config-Slh0Mayz.js +1 -0
- package/dist/assets/select-CVz0t7MF.js +41 -0
- package/dist/assets/setting-row-CbVHAuQt.js +1 -0
- package/dist/assets/skeleton-D5rdKvzy.js +1 -0
- package/dist/assets/{status-dot-vbanNPFU.js → status-dot-DpPtVzQT.js} +1 -1
- package/dist/assets/{switch-BsLtHOH-.js → switch-CM29eCAR.js} +1 -1
- package/dist/assets/{tabs-custom-D3HYMt6k.js → tabs-custom-YcZUWn3o.js} +1 -1
- package/dist/assets/tag-chip-DMXdnLcj.js +1 -0
- package/dist/assets/{trash-2-G48scll7.js → trash-2-mJT6oWa2.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-DkNhD-42.js → use-infinite-scroll-loader-DJ1L81Dz.js} +1 -1
- package/dist/assets/{useConfirmDialog-BkvTN-vd.js → useConfirmDialog-BsVuqu1x.js} +1 -1
- package/dist/assets/{useMutation-CBWjE2uj.js → useMutation-CNcz2fgt.js} +1 -1
- package/dist/assets/x-Czwxm82I.js +1 -0
- package/dist/index.html +22 -22
- package/dist/runtime-icons/claude.ico +0 -0
- package/dist/runtime-icons/codex-openai.svg +6 -0
- package/dist/runtime-icons/hermes-agent.png +0 -0
- package/package.json +6 -6
- package/public/runtime-icons/claude.ico +0 -0
- package/public/runtime-icons/codex-openai.svg +6 -0
- package/public/runtime-icons/hermes-agent.png +0 -0
- package/src/account/components/account-panel.tsx +217 -97
- package/src/account/managers/account.manager.ts +3 -2
- package/src/api/chat-session-type.types.ts +7 -0
- package/src/api/runtime-control.types.ts +8 -0
- package/src/api/types.ts +8 -0
- package/src/app.tsx +221 -57
- package/src/components/agents/agent-dialogs.tsx +499 -0
- package/src/components/agents/agents-page.test.tsx +238 -0
- package/src/components/agents/agents-page.tsx +435 -0
- package/src/components/chat/ChatSidebar.tsx +11 -35
- package/src/components/chat/chat-conversation-panel.test.tsx +20 -0
- package/src/components/chat/chat-conversation-panel.tsx +83 -13
- package/src/components/chat/chat-page-shell.tsx +19 -13
- package/src/components/chat/chat-session-type-option-item.test.tsx +46 -0
- package/src/components/chat/chat-session-type-option-item.tsx +68 -0
- package/src/components/chat/chat-session-workspace-file-preview.test.tsx +87 -0
- package/src/components/chat/chat-session-workspace-file-preview.tsx +14 -43
- package/src/components/chat/chat-session-workspace-panel-nav.tsx +8 -2
- package/src/components/chat/chat-sidebar-project-groups.tsx +11 -36
- package/src/components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts +77 -0
- package/src/components/chat/ncp/ncp-chat-page.tsx +2 -0
- package/src/components/chat/ncp/ncp-session-adapter.test.ts +1 -0
- package/src/components/chat/ncp/ncp-session-adapter.ts +3 -0
- package/src/components/chat/ncp/page/ncp-chat-derived-state.ts +10 -4
- package/src/components/chat/stores/chat-input.store.ts +2 -1
- package/src/components/chat/stores/chat-thread.store.ts +3 -1
- package/src/components/chat/useChatSessionTypeState.ts +10 -1
- package/src/components/chat/workspace/chat-session-workspace-file-breadcrumbs.tsx +86 -0
- package/src/components/common/BrandHeader.tsx +3 -1
- package/src/components/common/session-context-icon.tsx +15 -2
- package/src/components/common/{TagInput.tsx → tag-input.tsx} +25 -17
- package/src/components/config/ChannelForm.test.tsx +89 -3
- package/src/components/config/ChannelForm.tsx +157 -188
- package/src/components/config/ChannelsList.test.tsx +163 -119
- package/src/components/config/ChannelsList.tsx +90 -101
- package/src/components/config/ProviderForm.tsx +108 -146
- package/src/components/config/ProvidersList.tsx +100 -123
- package/src/components/config/SearchConfig.tsx +423 -393
- package/src/components/config/channel-form-fields-section.tsx +70 -37
- package/src/components/config/config-split-page.tsx +109 -0
- package/src/components/config/provider-enabled-field.tsx +17 -10
- package/src/components/config/runtime-control-card.test.tsx +56 -0
- package/src/components/config/runtime-control-card.tsx +25 -0
- package/src/components/config/runtime-presence-card.tsx +93 -79
- package/src/components/layout/AppLayout.tsx +25 -37
- package/src/components/layout/app-layout.test.tsx +46 -14
- package/src/components/layout/runtime-status-entry.test.tsx +157 -0
- package/src/components/layout/runtime-status-entry.tsx +143 -0
- package/src/components/marketplace/marketplace-detail-doc.ts +93 -0
- package/src/components/marketplace/marketplace-list-card.tsx +288 -0
- package/src/components/marketplace/marketplace-page-data.ts +129 -0
- package/src/components/marketplace/marketplace-page.test.tsx +339 -0
- package/src/components/marketplace/marketplace-page.tsx +596 -0
- package/src/components/marketplace/mcp/mcp-marketplace-card.tsx +128 -0
- package/src/components/marketplace/mcp/mcp-marketplace-dialogs.tsx +191 -0
- package/src/components/marketplace/mcp/mcp-marketplace-doc.ts +152 -0
- package/src/components/marketplace/mcp/mcp-marketplace-page.test.tsx +223 -0
- package/src/components/marketplace/mcp/mcp-marketplace-page.tsx +414 -0
- package/src/components/remote/remote-access-page.test.tsx +105 -0
- package/src/components/remote/remote-access-page.tsx +248 -0
- package/src/components/ui/notice-card.tsx +129 -0
- package/src/components/ui/setting-row.tsx +51 -0
- package/src/components/ui/tag-chip.tsx +39 -0
- package/src/components/ui/textarea.tsx +19 -0
- package/src/hooks/useConfig.ts +2 -1
- package/src/index.css +24 -0
- package/src/lib/app-resource-uri.test.ts +20 -0
- package/src/lib/app-resource-uri.ts +29 -0
- package/src/lib/i18n.remote.ts +1 -1
- package/src/lib/i18n.runtime-control.ts +31 -0
- package/src/lib/i18n.ts +5 -8
- package/src/lib/session-context.utils.test.ts +71 -0
- package/src/lib/session-context.utils.ts +28 -3
- package/src/lib/session-project/workspace-file-breadcrumb.test.ts +83 -0
- package/src/lib/session-project/workspace-file-breadcrumb.ts +188 -0
- package/dist/assets/ChannelsList-Ita2Zm1_.js +0 -8
- package/dist/assets/DocBrowser-BNwbPHf4.js +0 -1
- package/dist/assets/MarketplacePage-CjX2MWww.js +0 -1
- package/dist/assets/MarketplacePage-D0sDlYX4.js +0 -49
- package/dist/assets/McpMarketplacePage-BGKJm1sJ.js +0 -40
- package/dist/assets/ModelConfig-BzZenCH-.js +0 -1
- package/dist/assets/ProvidersList-BbVzRxjY.js +0 -1
- package/dist/assets/RemoteAccessPage-BaDH_X1Q.js +0 -1
- package/dist/assets/RuntimeConfig-F_XKGgLm.js +0 -1
- package/dist/assets/SearchConfig-BGkzXQP-.js +0 -1
- package/dist/assets/SessionsConfig-ChHQ7M5c.js +0 -2
- package/dist/assets/chat-page-Doe0yTtB.js +0 -58
- package/dist/assets/chat-session-display-cw78aiI_.js +0 -1
- package/dist/assets/config-layout-CHs0mAaR.js +0 -1
- package/dist/assets/desktop-update-config-Dpcf4BKG.js +0 -1
- package/dist/assets/index-CF9xve0E.js +0 -6
- package/dist/assets/index-FgA52VBt.css +0 -1
- package/dist/assets/loader-circle-ACM1s51e.js +0 -1
- package/dist/assets/play-CFUwCA2E.js +0 -1
- package/dist/assets/plus-rYsv72JG.js +0 -1
- package/dist/assets/popover-Bg1VoTZ6.js +0 -1
- package/dist/assets/search-3kFR_zh9.js +0 -1
- package/dist/assets/security-config-BWaiARNk.js +0 -1
- package/dist/assets/select-DJ2MUjBB.js +0 -41
- package/dist/assets/skeleton-ByQepn0M.js +0 -1
- package/dist/assets/x-ByDbItbq.js +0 -1
- package/src/components/agents/AgentDialogs.tsx +0 -400
- package/src/components/agents/AgentsPage.test.tsx +0 -217
- package/src/components/agents/AgentsPage.tsx +0 -352
- package/src/components/config/config-layout.ts +0 -10
- package/src/components/marketplace/MarketplacePage.test.tsx +0 -322
- package/src/components/marketplace/MarketplacePage.tsx +0 -827
- package/src/components/marketplace/mcp/McpMarketplacePage.test.tsx +0 -208
- package/src/components/marketplace/mcp/McpMarketplacePage.tsx +0 -580
- package/src/components/remote/RemoteAccessPage.test.tsx +0 -103
- package/src/components/remote/RemoteAccessPage.tsx +0 -144
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import type { AgentProfileView } from "@/api/types";
|
|
3
|
+
import {
|
|
4
|
+
normalizeSessionType,
|
|
5
|
+
resolveSessionTypeLabel,
|
|
6
|
+
type ChatSessionTypeOption,
|
|
7
|
+
} from "@/components/chat/useChatSessionTypeState";
|
|
8
|
+
import { ProviderScopedModelInput } from "@/components/common/ProviderScopedModelInput";
|
|
9
|
+
import { Button } from "@/components/ui/button";
|
|
10
|
+
import { NoticeCard } from "@/components/ui/notice-card";
|
|
11
|
+
import {
|
|
12
|
+
Select,
|
|
13
|
+
SelectContent,
|
|
14
|
+
SelectItem,
|
|
15
|
+
SelectTrigger,
|
|
16
|
+
SelectValue,
|
|
17
|
+
} from "@/components/ui/select";
|
|
18
|
+
import {
|
|
19
|
+
Dialog,
|
|
20
|
+
DialogContent,
|
|
21
|
+
DialogDescription,
|
|
22
|
+
DialogFooter,
|
|
23
|
+
DialogHeader,
|
|
24
|
+
DialogTitle,
|
|
25
|
+
} from "@/components/ui/dialog";
|
|
26
|
+
import { Input } from "@/components/ui/input";
|
|
27
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
28
|
+
import { t } from "@/lib/i18n";
|
|
29
|
+
import type { ProviderModelCatalogItem } from "@/lib/provider-models";
|
|
30
|
+
import { Pencil, Plus } from "lucide-react";
|
|
31
|
+
|
|
32
|
+
export type AgentCreateFormState = {
|
|
33
|
+
id: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
description: string;
|
|
36
|
+
avatar: string;
|
|
37
|
+
home: string;
|
|
38
|
+
model: string;
|
|
39
|
+
runtime: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type AgentEditFormState = {
|
|
43
|
+
displayName: string;
|
|
44
|
+
description: string;
|
|
45
|
+
avatar: string;
|
|
46
|
+
model: string;
|
|
47
|
+
runtime: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const EMPTY_AGENT_CREATE_FORM: AgentCreateFormState = {
|
|
51
|
+
id: "",
|
|
52
|
+
displayName: "",
|
|
53
|
+
description: "",
|
|
54
|
+
avatar: "",
|
|
55
|
+
model: "",
|
|
56
|
+
home: "",
|
|
57
|
+
runtime: "",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const EMPTY_AGENT_EDIT_FORM: AgentEditFormState = {
|
|
61
|
+
displayName: "",
|
|
62
|
+
description: "",
|
|
63
|
+
avatar: "",
|
|
64
|
+
model: "",
|
|
65
|
+
runtime: "",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export function toAgentEditFormState(
|
|
69
|
+
agent: AgentProfileView,
|
|
70
|
+
): AgentEditFormState {
|
|
71
|
+
return {
|
|
72
|
+
displayName: agent.displayName ?? "",
|
|
73
|
+
description: agent.description ?? "",
|
|
74
|
+
avatar: agent.avatar ?? "",
|
|
75
|
+
model: agent.model ?? "",
|
|
76
|
+
runtime: agent.runtime ?? agent.engine ?? "",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function buildRuntimeSelectOptions(params: {
|
|
81
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
82
|
+
currentRuntime: string;
|
|
83
|
+
}): ChatSessionTypeOption[] {
|
|
84
|
+
const { runtimeOptions, currentRuntime: rawCurrentRuntime } = params;
|
|
85
|
+
const currentRuntime = rawCurrentRuntime.trim();
|
|
86
|
+
if (!currentRuntime) {
|
|
87
|
+
return runtimeOptions;
|
|
88
|
+
}
|
|
89
|
+
const normalizedCurrentRuntime = normalizeSessionType(currentRuntime);
|
|
90
|
+
if (
|
|
91
|
+
runtimeOptions.some((option) => option.value === normalizedCurrentRuntime)
|
|
92
|
+
) {
|
|
93
|
+
return runtimeOptions;
|
|
94
|
+
}
|
|
95
|
+
return [
|
|
96
|
+
...runtimeOptions,
|
|
97
|
+
{
|
|
98
|
+
value: normalizedCurrentRuntime,
|
|
99
|
+
label: resolveSessionTypeLabel(normalizedCurrentRuntime),
|
|
100
|
+
icon: null,
|
|
101
|
+
ready: false,
|
|
102
|
+
reason: "unavailable",
|
|
103
|
+
reasonMessage: null,
|
|
104
|
+
supportedModels: undefined,
|
|
105
|
+
recommendedModel: null,
|
|
106
|
+
cta: null,
|
|
107
|
+
},
|
|
108
|
+
].sort((left, right) => {
|
|
109
|
+
if (left.value === "native") {
|
|
110
|
+
return -1;
|
|
111
|
+
}
|
|
112
|
+
if (right.value === "native") {
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
return left.value.localeCompare(right.value);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type AgentRuntimeSelectFieldProps = {
|
|
120
|
+
value: string;
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
123
|
+
defaultRuntime: string;
|
|
124
|
+
onChange: (value: string) => void;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function AgentRuntimeSelectField({
|
|
128
|
+
value,
|
|
129
|
+
disabled = false,
|
|
130
|
+
runtimeOptions,
|
|
131
|
+
defaultRuntime,
|
|
132
|
+
onChange,
|
|
133
|
+
}: AgentRuntimeSelectFieldProps) {
|
|
134
|
+
const normalizedValue = value.trim() ? normalizeSessionType(value) : "";
|
|
135
|
+
const selectOptions = buildRuntimeSelectOptions({
|
|
136
|
+
runtimeOptions,
|
|
137
|
+
currentRuntime: value,
|
|
138
|
+
});
|
|
139
|
+
const selectedRuntimeOption =
|
|
140
|
+
selectOptions.find((option) => option.value === normalizedValue) ?? null;
|
|
141
|
+
const helperText =
|
|
142
|
+
selectedRuntimeOption?.reasonMessage?.trim() ||
|
|
143
|
+
(selectedRuntimeOption?.ready === false
|
|
144
|
+
? t("agentsRuntimeUnavailableHelp")
|
|
145
|
+
: "");
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div className="space-y-2">
|
|
149
|
+
<Select
|
|
150
|
+
value={normalizedValue || defaultRuntime}
|
|
151
|
+
onValueChange={(nextValue) =>
|
|
152
|
+
onChange(nextValue === defaultRuntime ? "" : nextValue)
|
|
153
|
+
}
|
|
154
|
+
disabled={disabled}
|
|
155
|
+
>
|
|
156
|
+
<SelectTrigger
|
|
157
|
+
aria-label={t("agentsCardRuntimeLabel")}
|
|
158
|
+
className="rounded-xl"
|
|
159
|
+
>
|
|
160
|
+
<SelectValue placeholder={t("agentsRuntimeSelectPlaceholder")} />
|
|
161
|
+
</SelectTrigger>
|
|
162
|
+
<SelectContent className="rounded-xl">
|
|
163
|
+
{selectOptions.map((option) => (
|
|
164
|
+
<SelectItem
|
|
165
|
+
key={option.value}
|
|
166
|
+
value={option.value}
|
|
167
|
+
disabled={
|
|
168
|
+
option.ready === false && option.value !== normalizedValue
|
|
169
|
+
}
|
|
170
|
+
className="rounded-lg"
|
|
171
|
+
>
|
|
172
|
+
{option.label}
|
|
173
|
+
</SelectItem>
|
|
174
|
+
))}
|
|
175
|
+
</SelectContent>
|
|
176
|
+
</Select>
|
|
177
|
+
{helperText ? (
|
|
178
|
+
<p className="text-xs text-gray-500">{helperText}</p>
|
|
179
|
+
) : null}
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
type AgentCreateDialogProps = {
|
|
185
|
+
open: boolean;
|
|
186
|
+
pending: boolean;
|
|
187
|
+
providerCatalog: ProviderModelCatalogItem[];
|
|
188
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
189
|
+
defaultRuntime: string;
|
|
190
|
+
onOpenChange: (open: boolean) => void;
|
|
191
|
+
onSubmit: (form: AgentCreateFormState) => Promise<void> | void;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export function AgentCreateDialog({
|
|
195
|
+
open,
|
|
196
|
+
pending,
|
|
197
|
+
providerCatalog,
|
|
198
|
+
runtimeOptions,
|
|
199
|
+
defaultRuntime,
|
|
200
|
+
onOpenChange,
|
|
201
|
+
onSubmit,
|
|
202
|
+
}: AgentCreateDialogProps) {
|
|
203
|
+
return (
|
|
204
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
205
|
+
{open || pending ? (
|
|
206
|
+
<AgentCreateDialogContent
|
|
207
|
+
key={open ? "create-open" : "create-closed"}
|
|
208
|
+
pending={pending}
|
|
209
|
+
providerCatalog={providerCatalog}
|
|
210
|
+
runtimeOptions={runtimeOptions}
|
|
211
|
+
defaultRuntime={defaultRuntime}
|
|
212
|
+
onOpenChange={onOpenChange}
|
|
213
|
+
onSubmit={onSubmit}
|
|
214
|
+
/>
|
|
215
|
+
) : null}
|
|
216
|
+
</Dialog>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
type AgentEditDialogProps = {
|
|
221
|
+
agent: AgentProfileView | null;
|
|
222
|
+
pending: boolean;
|
|
223
|
+
providerCatalog: ProviderModelCatalogItem[];
|
|
224
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
225
|
+
defaultRuntime: string;
|
|
226
|
+
onOpenChange: (open: boolean) => void;
|
|
227
|
+
onSubmit: (agentId: string, form: AgentEditFormState) => Promise<void> | void;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export function AgentEditDialog({
|
|
231
|
+
agent,
|
|
232
|
+
pending,
|
|
233
|
+
providerCatalog,
|
|
234
|
+
runtimeOptions,
|
|
235
|
+
defaultRuntime,
|
|
236
|
+
onOpenChange,
|
|
237
|
+
onSubmit,
|
|
238
|
+
}: AgentEditDialogProps) {
|
|
239
|
+
return (
|
|
240
|
+
<Dialog open={agent !== null} onOpenChange={onOpenChange}>
|
|
241
|
+
{agent ? (
|
|
242
|
+
<AgentEditDialogContent
|
|
243
|
+
key={agent.id}
|
|
244
|
+
agent={agent}
|
|
245
|
+
pending={pending}
|
|
246
|
+
providerCatalog={providerCatalog}
|
|
247
|
+
runtimeOptions={runtimeOptions}
|
|
248
|
+
defaultRuntime={defaultRuntime}
|
|
249
|
+
onOpenChange={onOpenChange}
|
|
250
|
+
onSubmit={onSubmit}
|
|
251
|
+
/>
|
|
252
|
+
) : null}
|
|
253
|
+
</Dialog>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function AgentCreateDialogContent(props: {
|
|
258
|
+
pending: boolean;
|
|
259
|
+
providerCatalog: ProviderModelCatalogItem[];
|
|
260
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
261
|
+
defaultRuntime: string;
|
|
262
|
+
onOpenChange: (open: boolean) => void;
|
|
263
|
+
onSubmit: (form: AgentCreateFormState) => Promise<void> | void;
|
|
264
|
+
}) {
|
|
265
|
+
const {
|
|
266
|
+
pending,
|
|
267
|
+
providerCatalog,
|
|
268
|
+
runtimeOptions,
|
|
269
|
+
defaultRuntime,
|
|
270
|
+
onOpenChange,
|
|
271
|
+
onSubmit,
|
|
272
|
+
} = props;
|
|
273
|
+
const [form, setForm] = useState<AgentCreateFormState>(
|
|
274
|
+
EMPTY_AGENT_CREATE_FORM,
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<DialogContent className="flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl">
|
|
279
|
+
<div className="shrink-0 border-b border-[#f0e2c8] px-6 py-6">
|
|
280
|
+
<DialogHeader className="text-left">
|
|
281
|
+
<DialogTitle>{t("agentsCreateDialogTitle")}</DialogTitle>
|
|
282
|
+
<DialogDescription>
|
|
283
|
+
{t("agentsCreateDialogDescription")}
|
|
284
|
+
</DialogDescription>
|
|
285
|
+
</DialogHeader>
|
|
286
|
+
</div>
|
|
287
|
+
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6">
|
|
288
|
+
<div className="space-y-4">
|
|
289
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
290
|
+
<Input
|
|
291
|
+
value={form.id}
|
|
292
|
+
onChange={(event) =>
|
|
293
|
+
setForm((prev) => ({ ...prev, id: event.target.value }))
|
|
294
|
+
}
|
|
295
|
+
placeholder={t("agentsFormIdPlaceholder")}
|
|
296
|
+
/>
|
|
297
|
+
<Input
|
|
298
|
+
value={form.displayName}
|
|
299
|
+
onChange={(event) =>
|
|
300
|
+
setForm((prev) => ({
|
|
301
|
+
...prev,
|
|
302
|
+
displayName: event.target.value,
|
|
303
|
+
}))
|
|
304
|
+
}
|
|
305
|
+
placeholder={t("agentsFormNamePlaceholder")}
|
|
306
|
+
/>
|
|
307
|
+
<Textarea
|
|
308
|
+
value={form.description}
|
|
309
|
+
onChange={(event) =>
|
|
310
|
+
setForm((prev) => ({
|
|
311
|
+
...prev,
|
|
312
|
+
description: event.target.value,
|
|
313
|
+
}))
|
|
314
|
+
}
|
|
315
|
+
placeholder={t("agentsFormDescriptionPlaceholder")}
|
|
316
|
+
rows={4}
|
|
317
|
+
className="md:col-span-2"
|
|
318
|
+
/>
|
|
319
|
+
<Input
|
|
320
|
+
value={form.avatar}
|
|
321
|
+
onChange={(event) =>
|
|
322
|
+
setForm((prev) => ({ ...prev, avatar: event.target.value }))
|
|
323
|
+
}
|
|
324
|
+
placeholder={t("agentsFormAvatarPlaceholder")}
|
|
325
|
+
/>
|
|
326
|
+
<Input
|
|
327
|
+
value={form.home}
|
|
328
|
+
onChange={(event) =>
|
|
329
|
+
setForm((prev) => ({ ...prev, home: event.target.value }))
|
|
330
|
+
}
|
|
331
|
+
placeholder={t("agentsFormHomePlaceholder")}
|
|
332
|
+
/>
|
|
333
|
+
<ProviderScopedModelInput
|
|
334
|
+
value={form.model}
|
|
335
|
+
onChange={(value) =>
|
|
336
|
+
setForm((prev) => ({ ...prev, model: value }))
|
|
337
|
+
}
|
|
338
|
+
providerCatalog={providerCatalog}
|
|
339
|
+
disabled={pending}
|
|
340
|
+
className="md:col-span-2"
|
|
341
|
+
/>
|
|
342
|
+
<AgentRuntimeSelectField
|
|
343
|
+
value={form.runtime}
|
|
344
|
+
onChange={(value) =>
|
|
345
|
+
setForm((prev) => ({ ...prev, runtime: value }))
|
|
346
|
+
}
|
|
347
|
+
runtimeOptions={runtimeOptions}
|
|
348
|
+
defaultRuntime={defaultRuntime}
|
|
349
|
+
disabled={pending}
|
|
350
|
+
/>
|
|
351
|
+
</div>
|
|
352
|
+
<NoticeCard
|
|
353
|
+
tone="warning"
|
|
354
|
+
title={t("agentsCreateDialogHint")}
|
|
355
|
+
className="text-xs leading-6"
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
<DialogFooter className="shrink-0 border-t border-[#f1e7d4] px-6 py-5">
|
|
360
|
+
<Button
|
|
361
|
+
type="button"
|
|
362
|
+
variant="ghost"
|
|
363
|
+
onClick={() => onOpenChange(false)}
|
|
364
|
+
disabled={pending}
|
|
365
|
+
>
|
|
366
|
+
{t("cancel")}
|
|
367
|
+
</Button>
|
|
368
|
+
<Button
|
|
369
|
+
type="button"
|
|
370
|
+
variant="primary"
|
|
371
|
+
className="rounded-2xl px-5"
|
|
372
|
+
onClick={() => void onSubmit(form)}
|
|
373
|
+
disabled={pending || form.id.trim().length === 0}
|
|
374
|
+
>
|
|
375
|
+
<Plus className="mr-2 h-4 w-4" />
|
|
376
|
+
{t("agentsCreateAction")}
|
|
377
|
+
</Button>
|
|
378
|
+
</DialogFooter>
|
|
379
|
+
</DialogContent>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function AgentEditDialogContent(props: {
|
|
384
|
+
agent: AgentProfileView;
|
|
385
|
+
pending: boolean;
|
|
386
|
+
providerCatalog: ProviderModelCatalogItem[];
|
|
387
|
+
runtimeOptions: ChatSessionTypeOption[];
|
|
388
|
+
defaultRuntime: string;
|
|
389
|
+
onOpenChange: (open: boolean) => void;
|
|
390
|
+
onSubmit: (agentId: string, form: AgentEditFormState) => Promise<void> | void;
|
|
391
|
+
}) {
|
|
392
|
+
const {
|
|
393
|
+
agent,
|
|
394
|
+
pending,
|
|
395
|
+
providerCatalog,
|
|
396
|
+
runtimeOptions,
|
|
397
|
+
defaultRuntime,
|
|
398
|
+
onOpenChange,
|
|
399
|
+
onSubmit,
|
|
400
|
+
} = props;
|
|
401
|
+
const [form, setForm] = useState<AgentEditFormState>(
|
|
402
|
+
toAgentEditFormState(agent),
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
return (
|
|
406
|
+
<DialogContent className="flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl">
|
|
407
|
+
<div className="shrink-0 border-b border-[#f0e2c8] px-6 py-6">
|
|
408
|
+
<DialogHeader className="text-left">
|
|
409
|
+
<DialogTitle>{t("agentsEditDialogTitle")}</DialogTitle>
|
|
410
|
+
<DialogDescription>
|
|
411
|
+
{t("agentsEditDialogDescription")}
|
|
412
|
+
</DialogDescription>
|
|
413
|
+
</DialogHeader>
|
|
414
|
+
</div>
|
|
415
|
+
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6">
|
|
416
|
+
<div className="space-y-4">
|
|
417
|
+
<NoticeCard
|
|
418
|
+
tone="warning"
|
|
419
|
+
title={t("agentsEditHomeReadonly")}
|
|
420
|
+
description={t("agentsEditHomeReadonlyHint")}
|
|
421
|
+
>
|
|
422
|
+
<div className="break-all text-sm text-amber-950">
|
|
423
|
+
{agent.workspace ?? "-"}
|
|
424
|
+
</div>
|
|
425
|
+
</NoticeCard>
|
|
426
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
427
|
+
<Input
|
|
428
|
+
value={form.displayName}
|
|
429
|
+
onChange={(event) =>
|
|
430
|
+
setForm((prev) => ({
|
|
431
|
+
...prev,
|
|
432
|
+
displayName: event.target.value,
|
|
433
|
+
}))
|
|
434
|
+
}
|
|
435
|
+
placeholder={t("agentsFormNamePlaceholder")}
|
|
436
|
+
/>
|
|
437
|
+
<Textarea
|
|
438
|
+
value={form.description}
|
|
439
|
+
onChange={(event) =>
|
|
440
|
+
setForm((prev) => ({
|
|
441
|
+
...prev,
|
|
442
|
+
description: event.target.value,
|
|
443
|
+
}))
|
|
444
|
+
}
|
|
445
|
+
placeholder={t("agentsFormDescriptionPlaceholder")}
|
|
446
|
+
rows={4}
|
|
447
|
+
className="md:col-span-2"
|
|
448
|
+
/>
|
|
449
|
+
<Input
|
|
450
|
+
value={form.avatar}
|
|
451
|
+
onChange={(event) =>
|
|
452
|
+
setForm((prev) => ({ ...prev, avatar: event.target.value }))
|
|
453
|
+
}
|
|
454
|
+
placeholder={t("agentsFormAvatarPlaceholder")}
|
|
455
|
+
/>
|
|
456
|
+
<ProviderScopedModelInput
|
|
457
|
+
value={form.model}
|
|
458
|
+
onChange={(value) =>
|
|
459
|
+
setForm((prev) => ({ ...prev, model: value }))
|
|
460
|
+
}
|
|
461
|
+
providerCatalog={providerCatalog}
|
|
462
|
+
disabled={pending}
|
|
463
|
+
className="md:col-span-2"
|
|
464
|
+
/>
|
|
465
|
+
<AgentRuntimeSelectField
|
|
466
|
+
value={form.runtime}
|
|
467
|
+
onChange={(value) =>
|
|
468
|
+
setForm((prev) => ({ ...prev, runtime: value }))
|
|
469
|
+
}
|
|
470
|
+
runtimeOptions={runtimeOptions}
|
|
471
|
+
defaultRuntime={defaultRuntime}
|
|
472
|
+
disabled={pending}
|
|
473
|
+
/>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
</div>
|
|
477
|
+
<DialogFooter className="shrink-0 border-t border-[#f1e7d4] px-6 py-5">
|
|
478
|
+
<Button
|
|
479
|
+
type="button"
|
|
480
|
+
variant="ghost"
|
|
481
|
+
onClick={() => onOpenChange(false)}
|
|
482
|
+
disabled={pending}
|
|
483
|
+
>
|
|
484
|
+
{t("cancel")}
|
|
485
|
+
</Button>
|
|
486
|
+
<Button
|
|
487
|
+
type="button"
|
|
488
|
+
variant="primary"
|
|
489
|
+
className="rounded-2xl px-5"
|
|
490
|
+
onClick={() => onSubmit(agent.id, form)}
|
|
491
|
+
disabled={pending}
|
|
492
|
+
>
|
|
493
|
+
<Pencil className="mr-2 h-4 w-4" />
|
|
494
|
+
{t("agentsEditSaveAction")}
|
|
495
|
+
</Button>
|
|
496
|
+
</DialogFooter>
|
|
497
|
+
</DialogContent>
|
|
498
|
+
);
|
|
499
|
+
}
|