@nextclaw/ui 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/assets/{ChannelsList-DF2U-LY1.js → ChannelsList-DBcoVJRW.js} +1 -1
- package/dist/assets/ChatPage-CD3cxyyM.js +37 -0
- package/dist/assets/{DocBrowser-B9ws5JL7.js → DocBrowser-DDX2HMXW.js} +1 -1
- package/dist/assets/{LogoBadge-DvGAzkZ3.js → LogoBadge-J53F_3JA.js} +1 -1
- package/dist/assets/{MarketplacePage-DG5mHWJ8.js → MarketplacePage-0BZ4bza0.js} +2 -2
- package/dist/assets/{ModelConfig-BL_HsOsm.js → ModelConfig-Wzq9wGHV.js} +1 -1
- package/dist/assets/{ProvidersList-CH5z00YT.js → ProvidersList-kwzRS8_M.js} +1 -1
- package/dist/assets/RuntimeConfig-N771_AM6.js +1 -0
- package/dist/assets/{SearchConfig-BhaI0fUf.js → SearchConfig-DVt5QVa_.js} +1 -1
- package/dist/assets/{SecretsConfig-CFoimOh9.js → SecretsConfig-CkwauPa8.js} +2 -2
- package/dist/assets/SessionsConfig-C3mnHzkZ.js +2 -0
- package/dist/assets/{session-run-status-TkIuGbVw.js → chat-message-pxr79GDs.js} +3 -3
- package/dist/assets/{index-X5J6Mm--.js → index-BIvFMkN4.js} +1 -1
- package/dist/assets/index-CzkY1reu.js +8 -0
- package/dist/assets/{index-uMsNsQX6.js → index-GdpEEKnz.js} +1 -1
- package/dist/assets/index-RZ0kHHRI.css +1 -0
- package/dist/assets/{label-D8ly4a2P.js → label-CmksBHgc.js} +1 -1
- package/dist/assets/{page-layout-BSYfvwbp.js → page-layout-Db0GbnhS.js} +1 -1
- package/dist/assets/security-config-CjLFME5Q.js +1 -0
- package/dist/assets/skeleton-CkpQeVWN.js +1 -0
- package/dist/assets/{switch-Ce_g9lpN.js → switch-C24d-UJU.js} +1 -1
- package/dist/assets/tabs-custom-D89bh-fc.js +1 -0
- package/dist/assets/{useConfirmDialog-A8Ek8Wu7.js → useConfirmDialog-BeP35LcG.js} +2 -2
- package/dist/assets/{vendor-B7ozqnFC.js → vendor-psXJBy9u.js} +65 -70
- package/dist/index.html +3 -3
- package/package.json +5 -2
- package/src/api/config.ts +38 -0
- package/src/api/types.ts +19 -0
- package/src/components/chat/ChatPage.tsx +10 -324
- package/src/components/chat/adapters/chat-message.adapter.test.ts +1 -0
- package/src/components/chat/chat-chain.test.ts +22 -0
- package/src/components/chat/chat-chain.ts +23 -0
- package/src/components/chat/chat-page-shell.tsx +103 -0
- package/src/components/chat/containers/chat-message-list.container.tsx +5 -1
- package/src/components/chat/legacy/LegacyChatPage.tsx +228 -0
- package/src/components/chat/ncp/NcpChatPage.tsx +349 -0
- package/src/components/chat/ncp/ncp-chat-input.manager.ts +173 -0
- package/src/components/chat/ncp/ncp-chat-page-data.ts +134 -0
- package/src/components/chat/ncp/ncp-chat-thread.manager.ts +89 -0
- package/src/components/chat/ncp/ncp-chat.presenter.ts +33 -0
- package/src/components/chat/ncp/ncp-session-adapter.test.ts +49 -0
- package/src/components/chat/ncp/ncp-session-adapter.ts +194 -0
- package/src/components/chat/presenter/chat-presenter-context.tsx +43 -4
- package/src/hooks/useConfig.ts +42 -0
- package/src/lib/i18n.ts +1 -1
- package/tailwind.config.js +8 -3
- package/tsconfig.json +4 -1
- package/dist/assets/ChatPage-BX39y0U5.js +0 -36
- package/dist/assets/RuntimeConfig-BplBgkwo.js +0 -1
- package/dist/assets/SessionsConfig-BHTAYn9T.js +0 -2
- package/dist/assets/index-BLeJkJ0o.css +0 -1
- package/dist/assets/index-DK4TS5ev.js +0 -8
- package/dist/assets/security-config-DlKEYHNN.js +0 -1
- package/dist/assets/skeleton-CWbsNx2h.js +0 -1
- package/dist/assets/tabs-custom-Cf5azvT5.js +0 -1
|
@@ -1,11 +1,50 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SetStateAction } from 'react';
|
|
4
|
+
import type { ChatRunStatusManager } from '@/components/chat/managers/chat-run-status.manager';
|
|
5
|
+
import type { ChatSessionListManager } from '@/components/chat/managers/chat-session-list.manager';
|
|
6
|
+
import type { ChatStreamActionsManager } from '@/components/chat/managers/chat-stream-actions.manager';
|
|
7
|
+
import type { ChatUiManager } from '@/components/chat/managers/chat-ui.manager';
|
|
8
|
+
import type { ChatThreadSnapshot } from '@/components/chat/stores/chat-thread.store';
|
|
9
|
+
import type { ThinkingLevel } from '@/api/types';
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
export type ChatInputManagerLike = {
|
|
12
|
+
syncSnapshot: (patch: Record<string, unknown>) => void;
|
|
13
|
+
setDraft: (next: SetStateAction<string>) => void;
|
|
14
|
+
setPendingSessionType: (next: SetStateAction<string>) => void;
|
|
15
|
+
send: () => Promise<void>;
|
|
16
|
+
stop: () => Promise<void>;
|
|
17
|
+
goToProviders: () => void;
|
|
18
|
+
setSelectedModel: (next: SetStateAction<string>) => void;
|
|
19
|
+
setSelectedThinkingLevel: (next: SetStateAction<ThinkingLevel | null>) => void;
|
|
20
|
+
setSelectedSkills: (next: SetStateAction<string[]>) => void;
|
|
21
|
+
selectSessionType: (value: string) => void;
|
|
22
|
+
selectModel: (value: string) => void;
|
|
23
|
+
selectThinkingLevel: (value: ThinkingLevel) => void;
|
|
24
|
+
selectSkills: (next: string[]) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ChatThreadManagerLike = {
|
|
28
|
+
bindActions: (patch: { refetchSessions?: () => Promise<unknown> }) => void;
|
|
29
|
+
syncSnapshot: (patch: Partial<ChatThreadSnapshot>) => void;
|
|
30
|
+
deleteSession: () => void;
|
|
31
|
+
createSession: () => void;
|
|
32
|
+
goToProviders: () => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ChatPresenterLike = {
|
|
36
|
+
chatUiManager: ChatUiManager;
|
|
37
|
+
chatStreamActionsManager: ChatStreamActionsManager;
|
|
38
|
+
chatInputManager: ChatInputManagerLike;
|
|
39
|
+
chatSessionListManager: ChatSessionListManager;
|
|
40
|
+
chatRunStatusManager: ChatRunStatusManager;
|
|
41
|
+
chatThreadManager: ChatThreadManagerLike;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ChatPresenterContext = createContext<ChatPresenterLike | null>(null);
|
|
6
45
|
|
|
7
46
|
type ChatPresenterProviderProps = {
|
|
8
|
-
presenter:
|
|
47
|
+
presenter: ChatPresenterLike;
|
|
9
48
|
children: ReactNode;
|
|
10
49
|
};
|
|
11
50
|
|
|
@@ -13,7 +52,7 @@ export function ChatPresenterProvider({ presenter, children }: ChatPresenterProv
|
|
|
13
52
|
return <ChatPresenterContext.Provider value={presenter}>{children}</ChatPresenterContext.Provider>;
|
|
14
53
|
}
|
|
15
54
|
|
|
16
|
-
export function usePresenter():
|
|
55
|
+
export function usePresenter(): ChatPresenterLike {
|
|
17
56
|
const presenter = useContext(ChatPresenterContext);
|
|
18
57
|
if (!presenter) {
|
|
19
58
|
throw new Error('usePresenter must be used inside ChatPresenterProvider');
|
package/src/hooks/useConfig.ts
CHANGED
|
@@ -19,8 +19,11 @@ import {
|
|
|
19
19
|
executeConfigAction,
|
|
20
20
|
fetchSessions,
|
|
21
21
|
fetchSessionHistory,
|
|
22
|
+
fetchNcpSessions,
|
|
23
|
+
fetchNcpSessionMessages,
|
|
22
24
|
updateSession,
|
|
23
25
|
deleteSession,
|
|
26
|
+
deleteNcpSession,
|
|
24
27
|
sendChatTurn,
|
|
25
28
|
fetchChatRun,
|
|
26
29
|
fetchChatRuns,
|
|
@@ -252,6 +255,29 @@ export function useSessionHistory(key: string | null, limit = 200) {
|
|
|
252
255
|
});
|
|
253
256
|
}
|
|
254
257
|
|
|
258
|
+
export function useNcpSessions(params?: { limit?: number }) {
|
|
259
|
+
return useQuery({
|
|
260
|
+
queryKey: ['ncp-sessions', params?.limit ?? null],
|
|
261
|
+
queryFn: () => fetchNcpSessions(params),
|
|
262
|
+
staleTime: 5_000,
|
|
263
|
+
retry: false,
|
|
264
|
+
refetchInterval: (query) => {
|
|
265
|
+
const hasRunningSession = Boolean(query.state.data?.sessions.some((session) => session.status === 'running'));
|
|
266
|
+
return hasRunningSession ? 800 : false;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function useNcpSessionMessages(sessionId: string | null, limit = 200) {
|
|
272
|
+
return useQuery({
|
|
273
|
+
queryKey: ['ncp-session-messages', sessionId, limit],
|
|
274
|
+
queryFn: () => fetchNcpSessionMessages(sessionId as string, limit),
|
|
275
|
+
enabled: Boolean(sessionId),
|
|
276
|
+
staleTime: 5_000,
|
|
277
|
+
retry: false
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
255
281
|
export function useUpdateSession() {
|
|
256
282
|
const queryClient = useQueryClient();
|
|
257
283
|
|
|
@@ -285,6 +311,22 @@ export function useDeleteSession() {
|
|
|
285
311
|
});
|
|
286
312
|
}
|
|
287
313
|
|
|
314
|
+
export function useDeleteNcpSession() {
|
|
315
|
+
const queryClient = useQueryClient();
|
|
316
|
+
|
|
317
|
+
return useMutation({
|
|
318
|
+
mutationFn: ({ sessionId }: { sessionId: string }) => deleteNcpSession(sessionId),
|
|
319
|
+
onSuccess: () => {
|
|
320
|
+
queryClient.invalidateQueries({ queryKey: ['ncp-sessions'] });
|
|
321
|
+
queryClient.invalidateQueries({ queryKey: ['ncp-session-messages'] });
|
|
322
|
+
toast.success(t('configSavedApplied'));
|
|
323
|
+
},
|
|
324
|
+
onError: (error: Error) => {
|
|
325
|
+
toast.error(t('configSaveFailed') + ': ' + error.message);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
288
330
|
export function useSendChatTurn() {
|
|
289
331
|
return useMutation({
|
|
290
332
|
mutationFn: ({ data }: { data: Parameters<typeof sendChatTurn>[0] }) =>
|
package/src/lib/i18n.ts
CHANGED
|
@@ -670,7 +670,7 @@ export const LABELS: Record<string, { zh: string; en: string }> = {
|
|
|
670
670
|
chatToolWorkflowDetails: { zh: '展开查看参数和结果', en: 'Expand to view params and results' },
|
|
671
671
|
chatToolOutput: { zh: '查看输出', en: 'View Output' },
|
|
672
672
|
chatToolNoOutput: { zh: '无输出(执行完成)', en: 'No output (completed)' },
|
|
673
|
-
chatReasoning: { zh: '
|
|
673
|
+
chatReasoning: { zh: '推理过程', en: 'Reasoning' },
|
|
674
674
|
chatUnknownPart: { zh: '未知消息片段', en: 'Unknown message part' },
|
|
675
675
|
chatCodeCopy: { zh: '复制代码', en: 'Copy' },
|
|
676
676
|
chatCodeCopied: { zh: '已复制', en: 'Copied' },
|
package/tailwind.config.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import tailwindcssAnimate from 'tailwindcss-animate';
|
|
2
|
+
|
|
1
3
|
/** @type {import('tailwindcss').Config} */
|
|
2
4
|
export default {
|
|
3
5
|
darkMode: ['class'],
|
|
4
|
-
content: [
|
|
6
|
+
content: [
|
|
7
|
+
'./index.html',
|
|
8
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
9
|
+
'../nextclaw-agent-chat-ui/src/**/*.{js,ts,jsx,tsx}',
|
|
10
|
+
],
|
|
5
11
|
theme: {
|
|
6
12
|
extend: {
|
|
7
13
|
colors: {
|
|
@@ -146,6 +152,5 @@ export default {
|
|
|
146
152
|
},
|
|
147
153
|
},
|
|
148
154
|
},
|
|
149
|
-
|
|
150
|
-
plugins: [require('tailwindcss-animate')],
|
|
155
|
+
plugins: [tailwindcssAnimate],
|
|
151
156
|
};
|
package/tsconfig.json
CHANGED
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
"paths": {
|
|
14
14
|
"@/*": ["./src/*"],
|
|
15
15
|
"@nextclaw/agent-chat": ["../nextclaw-agent-chat/src/index.ts"],
|
|
16
|
-
"@nextclaw/agent-chat-ui": ["../nextclaw-agent-chat-ui/src/index.ts"]
|
|
16
|
+
"@nextclaw/agent-chat-ui": ["../nextclaw-agent-chat-ui/src/index.ts"],
|
|
17
|
+
"@nextclaw/ncp": ["../ncp-packages/nextclaw-ncp/src/index.ts"],
|
|
18
|
+
"@nextclaw/ncp-http-agent-client": ["../ncp-packages/nextclaw-ncp-http-agent-client/src/index.ts"],
|
|
19
|
+
"@nextclaw/ncp-react": ["../ncp-packages/nextclaw-ncp-react/src/index.ts"]
|
|
17
20
|
}
|
|
18
21
|
},
|
|
19
22
|
"include": ["src"]
|