@nextclaw/ui 0.12.9 → 0.12.11
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 +102 -0
- package/dist/assets/ChannelsList-SQ7Oxotv.js +8 -0
- package/dist/assets/DocBrowser-BCO2k6XD.js +1 -0
- package/dist/assets/{DocBrowser-6ReNjvzF.js → DocBrowser-rDOjI3ga.js} +1 -1
- package/dist/assets/{DocBrowserContext-B6SpA7Qs.js → DocBrowserContext-BUq3Wo8O.js} +1 -1
- package/dist/assets/{LogoBadge-ByNLYg65.js → LogoBadge-DP8Ye7wJ.js} +1 -1
- package/dist/assets/ModelConfig-C77Ae9ru.js +1 -0
- package/dist/assets/ProviderScopedModelInput-CEnK61uo.js +1 -0
- package/dist/assets/ProvidersList-BCupBayq.js +1 -0
- package/dist/assets/RuntimeConfig-Ad-CAcmy.js +1 -0
- package/dist/assets/SearchConfig-BfCz4wJ4.js +1 -0
- package/dist/assets/SecretsConfig-DjmBIhyy.js +3 -0
- package/dist/assets/{SessionsConfig-ChHQ7M5c.js → SessionsConfig-CvjxU40H.js} +2 -2
- package/dist/assets/{book-open-BdcxxoQu.js → book-open-BE8M56IM.js} +1 -1
- package/dist/assets/chat-page-JKC6ln-y.js +58 -0
- package/dist/assets/chat-session-display-YcRMrAMa.js +1 -0
- package/dist/assets/{chunk-JZWAC4HX-DK5HPmIK.js → chunk-JZWAC4HX-erTUn3b8.js} +1 -1
- package/dist/assets/client-CszWMVKi.js +7 -0
- package/dist/assets/config-split-page-BAGSzUR3.js +1 -0
- package/dist/assets/{createLucideIcon-BSeTgkZW.js → createLucideIcon-CCiTGX8L.js} +1 -1
- package/dist/assets/desktop-DfkLlkG2.js +1 -0
- package/dist/assets/desktop-update-config-BXeGlqHD.js +1 -0
- package/dist/assets/dialog-BghZFPch.js +5 -0
- package/dist/assets/{dist-6TrrnPCR.js → dist-Dd9cr-kz.js} +1 -1
- package/dist/assets/dist-ZwoAXs46.js +9 -0
- package/dist/assets/{download-BhDxnyvU.js → download-D7LOizcW.js} +1 -1
- package/dist/assets/es2015-CEAreese.js +41 -0
- package/dist/assets/{external-link-BgErLCNT.js → external-link-qsnCMhw1.js} +1 -1
- package/dist/assets/{hash-Bl7dr_UG.js → hash-0zjWsNl-.js} +1 -1
- package/dist/assets/{i18n-eDHeDY0n.js → i18n-DvzXOGQX.js} +1 -1
- package/dist/assets/index-DvVTC9FF.css +1 -0
- package/dist/assets/index-lr6rQUSd.js +2 -0
- package/dist/assets/key-round-BLe9D8ND.js +1 -0
- package/dist/assets/loader-circle-wj7kARHv.js +1 -0
- package/dist/assets/{logos-x89HbrZ4.js → logos-_v5b2SdG.js} +1 -1
- package/dist/assets/marketplace-page-CAAk1Khc.js +1 -0
- package/dist/assets/marketplace-page-CfCiq90S.js +49 -0
- package/dist/assets/mcp-marketplace-page-D0Pp9Hs-.js +40 -0
- package/dist/assets/play-o6NmwGTi.js +1 -0
- package/dist/assets/plus-I9pBS4Fl.js +1 -0
- package/dist/assets/{refresh-cw-C47QSEwg.js → refresh-cw-MNqgR3LZ.js} +1 -1
- package/dist/assets/remote-C9fXm4V5.js +1 -0
- package/dist/assets/{save-3S6-H3Xw.js → save-D4bObrmH.js} +1 -1
- package/dist/assets/search-DxmL3IWE.js +1 -0
- package/dist/assets/security-config-BUm6FFfl.js +1 -0
- package/dist/assets/select-BILPf7zs.js +1 -0
- package/dist/assets/setting-row-BATDgg4r.js +1 -0
- package/dist/assets/skeleton-COKMAnJy.js +1 -0
- package/dist/assets/{switch-BsLtHOH-.js → switch-CBOzecWS.js} +1 -1
- package/dist/assets/{tabs-custom-D3HYMt6k.js → tabs-custom-Bx3cNhD-.js} +1 -1
- package/dist/assets/tag-chip-zUaDE2-H.js +1 -0
- package/dist/assets/{trash-2-G48scll7.js → trash-2-CQUgYyRn.js} +1 -1
- package/dist/assets/use-infinite-scroll-loader-B5V2Klve.js +1 -0
- package/dist/assets/useConfirmDialog-patAnl1g.js +1 -0
- package/dist/assets/{useMutation-CBWjE2uj.js → useMutation-__AYv-Pz.js} +1 -1
- package/dist/assets/x-BHUGQIUv.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/module-structure.config.json +7 -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/api/chat-session-type.types.ts +7 -0
- package/src/api/config.ts +10 -0
- package/src/api/raw-client.test.ts +1 -1
- package/src/api/{raw-client.ts → raw-client.utils.ts} +2 -0
- package/src/api/runtime-control.types.ts +8 -0
- package/src/api/types.ts +48 -0
- package/src/app/components/app-manager-provider.tsx +20 -0
- package/src/app/managers/app.manager.ts +12 -0
- package/src/app.tsx +223 -59
- 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/chat-conversation-panel.test.tsx +30 -0
- package/src/components/chat/chat-conversation-panel.tsx +83 -13
- package/src/components/chat/chat-input/ncp-chat-input-availability.utils.test.ts +92 -0
- package/src/components/chat/chat-input/ncp-chat-input-availability.utils.ts +45 -0
- 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/containers/chat-input-bar.container.tsx +24 -12
- package/src/components/chat/{ChatSidebar.test.tsx → containers/chat-sidebar.test.tsx} +5 -4
- package/src/components/chat/{ChatSidebar.tsx → containers/chat-sidebar.tsx} +24 -72
- package/src/components/chat/hooks/use-chat-sidebar-session-label-editor.ts +49 -0
- package/src/components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts +77 -0
- package/src/components/chat/ncp/ncp-app-client-fetch.ts +3 -0
- package/src/components/chat/ncp/ncp-chat-input.manager.ts +13 -5
- package/src/components/chat/ncp/ncp-chat-page.tsx +23 -2
- 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/ncp/session-conversation/use-ncp-session-conversation.test.tsx +48 -4
- package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.ts +43 -5
- package/src/components/chat/ncp/tests/ncp-chat-input.manager.test.ts +51 -1
- 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/desktop-update-config.test.tsx +10 -4
- package/src/components/config/desktop-update-config.tsx +5 -3
- package/src/components/config/provider-enabled-field.tsx +17 -10
- package/src/components/config/runtime-control-card.test.tsx +136 -158
- package/src/components/config/runtime-control-card.tsx +43 -68
- package/src/components/config/runtime-presence-card.test.tsx +10 -14
- package/src/components/config/runtime-presence-card.tsx +97 -81
- package/src/components/layout/AppLayout.tsx +25 -37
- package/src/components/layout/Sidebar.tsx +4 -4
- package/src/components/layout/app-layout.test.tsx +46 -14
- package/src/components/layout/runtime-status-entry.test.tsx +101 -0
- package/src/components/layout/runtime-status-entry.tsx +95 -0
- package/src/components/layout/sidebar.layout.test.tsx +11 -5
- 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/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/features/account/components/account-panel.tsx +255 -0
- package/src/features/account/index.ts +6 -0
- package/src/{account → features/account}/managers/account.manager.ts +6 -5
- package/src/features/remote/components/remote-access-page.test.tsx +104 -0
- package/src/features/remote/components/remote-access-page.tsx +250 -0
- package/src/{hooks/useRemoteAccess.ts → features/remote/hooks/use-remote-access.ts} +1 -1
- package/src/features/remote/index.ts +27 -0
- package/src/{remote → features/remote}/managers/remote-access.manager.ts +3 -4
- package/src/{remote → features/remote/services}/remote-access-feedback.service.test.ts +1 -1
- package/src/features/system-status/hooks/use-system-status.ts +104 -0
- package/src/features/system-status/index.ts +12 -0
- package/src/features/system-status/managers/system-status.manager.bootstrap-polling.test.ts +126 -0
- package/src/features/system-status/managers/system-status.manager.test.ts +142 -0
- package/src/features/system-status/managers/system-status.manager.ts +511 -0
- package/src/features/system-status/stores/system-status.store.ts +32 -0
- package/src/features/system-status/types/system-status.types.ts +73 -0
- package/src/features/system-status/utils/system-status.utils.test.ts +132 -0
- package/src/features/system-status/utils/system-status.utils.ts +202 -0
- package/src/hooks/use-realtime-query-bridge.ts +34 -18
- 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.chat.ts +8 -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/src/platforms/desktop/index.ts +20 -0
- package/src/{desktop → platforms/desktop}/managers/desktop-presence.manager.ts +2 -2
- package/src/{desktop → platforms/desktop}/managers/desktop-update.manager.ts +2 -2
- package/src/{desktop → platforms/desktop}/stores/desktop-presence.store.ts +1 -1
- package/src/{desktop → platforms/desktop}/stores/desktop-update.store.ts +1 -1
- package/src/stores/ui.store.ts +0 -9
- package/src/transport/{app-client.ts → app-client.service.ts} +9 -9
- package/src/transport/app-client.test.ts +9 -5
- package/src/transport/index.ts +1 -1
- package/src/transport/{local.transport.ts → local-transport.service.ts} +14 -12
- 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/ProviderScopedModelInput-Da7khnBA.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/SecretsConfig-D281Rotl.js +0 -3
- package/dist/assets/app-query-client-VnFElj4E.js +0 -1
- package/dist/assets/chat-page-Doe0yTtB.js +0 -58
- package/dist/assets/chat-session-display-cw78aiI_.js +0 -1
- package/dist/assets/client-_i4MU2bB.js +0 -7
- package/dist/assets/config-DtIQwrHF.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/dist-ccBFUi-o.js +0 -9
- package/dist/assets/index-CF9xve0E.js +0 -6
- package/dist/assets/index-FgA52VBt.css +0 -1
- package/dist/assets/infiniteQueryBehavior-ZDS92Qpp.js +0 -1
- package/dist/assets/loader-circle-ACM1s51e.js +0 -1
- package/dist/assets/page-layout-vZnghcFy.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/refresh-ccw-DT98i__E.js +0 -1
- package/dist/assets/rotate-cw-JtFzpNn6.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/status-dot-vbanNPFU.js +0 -1
- package/dist/assets/use-infinite-scroll-loader-DkNhD-42.js +0 -1
- package/dist/assets/useConfirmDialog-BkvTN-vd.js +0 -1
- package/dist/assets/x-ByDbItbq.js +0 -1
- package/src/account/components/account-panel.tsx +0 -135
- 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
- package/src/hooks/use-runtime-control.ts +0 -24
- package/src/presenter/app-presenter-context.tsx +0 -20
- package/src/presenter/app.presenter.ts +0 -12
- package/src/runtime-control/runtime-control.manager.ts +0 -118
- /package/dist/assets/{config-hints-BhTmc9P1.js → config-hints-DSQQbeOA.js} +0 -0
- /package/src/{account → features/account}/stores/account.store.ts +0 -0
- /package/src/{remote → features/remote/services}/remote-access-feedback.service.ts +0 -0
- /package/src/{remote/remote-access.query.ts → features/remote/services/remote-access-query.service.ts} +0 -0
- /package/src/{remote → features/remote}/stores/remote-access.store.ts +0 -0
- /package/src/{desktop → platforms/desktop/types}/desktop-update.types.ts +0 -0
|
@@ -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
|
+
}
|