@vibe-forge/client 0.2.0-alpha.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/LICENSE +21 -0
- package/cli.cjs +6 -0
- package/index.html +27 -0
- package/package.json +42 -0
- package/src/App.tsx +174 -0
- package/src/api.ts +241 -0
- package/src/components/ArchiveView.scss +168 -0
- package/src/components/ArchiveView.tsx +299 -0
- package/src/components/AutomationView/AutomationView.scss +26 -0
- package/src/components/AutomationView/RuleFormPanel.scss +129 -0
- package/src/components/AutomationView/RuleFormPanel.tsx +257 -0
- package/src/components/AutomationView/RuleSidebar.scss +219 -0
- package/src/components/AutomationView/RuleSidebar.tsx +258 -0
- package/src/components/AutomationView/RunHistoryPanel.scss +286 -0
- package/src/components/AutomationView/RunHistoryPanel.tsx +320 -0
- package/src/components/AutomationView/TaskList.scss +128 -0
- package/src/components/AutomationView/TaskList.tsx +79 -0
- package/src/components/AutomationView/TriggerList.scss +153 -0
- package/src/components/AutomationView/TriggerList.tsx +217 -0
- package/src/components/AutomationView/index.tsx +228 -0
- package/src/components/AutomationView/types.ts +21 -0
- package/src/components/Chat.scss +89 -0
- package/src/components/Chat.tsx +92 -0
- package/src/components/ConfigView.scss +185 -0
- package/src/components/ConfigView.tsx +258 -0
- package/src/components/NavRail.scss +71 -0
- package/src/components/NavRail.tsx +188 -0
- package/src/components/Sidebar.scss +112 -0
- package/src/components/Sidebar.tsx +291 -0
- package/src/components/chat/ChatHeader.scss +401 -0
- package/src/components/chat/ChatHeader.tsx +342 -0
- package/src/components/chat/ChatHistoryView.tsx +122 -0
- package/src/components/chat/ChatSettingsView.tsx +22 -0
- package/src/components/chat/ChatTimelineView.scss +53 -0
- package/src/components/chat/ChatTimelineView.tsx +158 -0
- package/src/components/chat/CodeBlock.scss +87 -0
- package/src/components/chat/CodeBlock.tsx +179 -0
- package/src/components/chat/CompletionMenu.scss +70 -0
- package/src/components/chat/CompletionMenu.tsx +58 -0
- package/src/components/chat/CurrentTodoList.scss +217 -0
- package/src/components/chat/CurrentTodoList.tsx +103 -0
- package/src/components/chat/MarkdownContent.tsx +43 -0
- package/src/components/chat/MessageFooter.tsx +48 -0
- package/src/components/chat/MessageItem.scss +251 -0
- package/src/components/chat/MessageItem.tsx +78 -0
- package/src/components/chat/NewSessionGuide.scss +186 -0
- package/src/components/chat/NewSessionGuide.tsx +167 -0
- package/src/components/chat/Sender.scss +367 -0
- package/src/components/chat/Sender.tsx +541 -0
- package/src/components/chat/SessionTimelinePanel/EventList.scss +58 -0
- package/src/components/chat/SessionTimelinePanel/EventList.tsx +212 -0
- package/src/components/chat/SessionTimelinePanel/gantt.ts +177 -0
- package/src/components/chat/SessionTimelinePanel/git-graph.ts +518 -0
- package/src/components/chat/SessionTimelinePanel/index.scss +28 -0
- package/src/components/chat/SessionTimelinePanel/index.tsx +121 -0
- package/src/components/chat/SessionTimelinePanel/mermaid.ts +4 -0
- package/src/components/chat/SessionTimelinePanel/types.ts +64 -0
- package/src/components/chat/SessionTimelinePanel/utils.ts +20 -0
- package/src/components/chat/ThinkingStatus.scss +70 -0
- package/src/components/chat/ThinkingStatus.tsx +13 -0
- package/src/components/chat/ToolCallBox.scss +137 -0
- package/src/components/chat/ToolCallBox.tsx +55 -0
- package/src/components/chat/ToolGroup.scss +154 -0
- package/src/components/chat/ToolGroup.tsx +102 -0
- package/src/components/chat/ToolRenderer.tsx +45 -0
- package/src/components/chat/messageUtils.ts +171 -0
- package/src/components/chat/safeSerialize.ts +84 -0
- package/src/components/chat/tools/DefaultTool.tsx +63 -0
- package/src/components/chat/tools/adapter-claude/BashTool.scss +71 -0
- package/src/components/chat/tools/adapter-claude/BashTool.tsx +82 -0
- package/src/components/chat/tools/adapter-claude/GlobTool.scss +88 -0
- package/src/components/chat/tools/adapter-claude/GlobTool.tsx +85 -0
- package/src/components/chat/tools/adapter-claude/GrepTool.scss +96 -0
- package/src/components/chat/tools/adapter-claude/GrepTool.tsx +114 -0
- package/src/components/chat/tools/adapter-claude/LSTool.scss +85 -0
- package/src/components/chat/tools/adapter-claude/LSTool.tsx +94 -0
- package/src/components/chat/tools/adapter-claude/ReadTool.scss +57 -0
- package/src/components/chat/tools/adapter-claude/ReadTool.tsx +87 -0
- package/src/components/chat/tools/adapter-claude/TodoTool.scss +78 -0
- package/src/components/chat/tools/adapter-claude/TodoTool.tsx +60 -0
- package/src/components/chat/tools/adapter-claude/WriteTool.scss +92 -0
- package/src/components/chat/tools/adapter-claude/WriteTool.tsx +86 -0
- package/src/components/chat/tools/adapter-claude/components/FileList.scss +65 -0
- package/src/components/chat/tools/adapter-claude/components/FileList.tsx +185 -0
- package/src/components/chat/tools/adapter-claude/index.ts +28 -0
- package/src/components/chat/tools/defineToolRender.ts +28 -0
- package/src/components/chat/tools/task/GetTaskInfoTool.scss +50 -0
- package/src/components/chat/tools/task/GetTaskInfoTool.tsx +88 -0
- package/src/components/chat/tools/task/ListTasksTool.scss +56 -0
- package/src/components/chat/tools/task/ListTasksTool.tsx +83 -0
- package/src/components/chat/tools/task/StartTasksTool.scss +56 -0
- package/src/components/chat/tools/task/StartTasksTool.tsx +96 -0
- package/src/components/chat/tools/task/components/TaskToolCard.scss +127 -0
- package/src/components/chat/tools/task/components/TaskToolCard.tsx +177 -0
- package/src/components/chat/tools/task/index.ts +15 -0
- package/src/components/chat/useChatModels.tsx +206 -0
- package/src/components/chat/useChatSession.ts +370 -0
- package/src/components/config/ConfigAboutSection.scss +111 -0
- package/src/components/config/ConfigAboutSection.tsx +86 -0
- package/src/components/config/ConfigDisplayValue.scss +22 -0
- package/src/components/config/ConfigDisplayValue.tsx +62 -0
- package/src/components/config/ConfigEditors.scss +65 -0
- package/src/components/config/ConfigEditors.tsx +98 -0
- package/src/components/config/ConfigFieldRow.scss +97 -0
- package/src/components/config/ConfigFieldRow.tsx +36 -0
- package/src/components/config/ConfigSectionForm.scss +94 -0
- package/src/components/config/ConfigSectionForm.tsx +436 -0
- package/src/components/config/ConfigSectionPanel.tsx +67 -0
- package/src/components/config/ConfigShortcutInput.scss +11 -0
- package/src/components/config/ConfigShortcutInput.tsx +52 -0
- package/src/components/config/ConfigSourceSwitch.tsx +57 -0
- package/src/components/config/configSchema.ts +319 -0
- package/src/components/config/configUtils.ts +83 -0
- package/src/components/config/index.tsx +5 -0
- package/src/components/config/recordEditors/BooleanRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/BooleanRecordEditor.tsx +75 -0
- package/src/components/config/recordEditors/KeyValueEditor.scss +1 -0
- package/src/components/config/recordEditors/KeyValueEditor.tsx +97 -0
- package/src/components/config/recordEditors/McpServersRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/McpServersRecordEditor.tsx +258 -0
- package/src/components/config/recordEditors/ModelServicesRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/ModelServicesRecordEditor.tsx +233 -0
- package/src/components/config/recordEditors/RecordEditors.scss +117 -0
- package/src/components/config/recordEditors/RecordJsonEditor.scss +1 -0
- package/src/components/config/recordEditors/RecordJsonEditor.tsx +113 -0
- package/src/components/config/recordEditors/index.tsx +5 -0
- package/src/components/knowledge-base/KnowledgeBaseView.scss +19 -0
- package/src/components/knowledge-base/KnowledgeBaseView.tsx +186 -0
- package/src/components/knowledge-base/components/ActionButton.scss +5 -0
- package/src/components/knowledge-base/components/ActionButton.tsx +9 -0
- package/src/components/knowledge-base/components/EmptyState.scss +19 -0
- package/src/components/knowledge-base/components/EmptyState.tsx +42 -0
- package/src/components/knowledge-base/components/EntitiesTab.scss +5 -0
- package/src/components/knowledge-base/components/EntitiesTab.tsx +80 -0
- package/src/components/knowledge-base/components/EntityItem.scss +82 -0
- package/src/components/knowledge-base/components/EntityItem.tsx +79 -0
- package/src/components/knowledge-base/components/EntityList.scss +5 -0
- package/src/components/knowledge-base/components/EntityList.tsx +70 -0
- package/src/components/knowledge-base/components/FilterBar.scss +21 -0
- package/src/components/knowledge-base/components/FilterBar.tsx +51 -0
- package/src/components/knowledge-base/components/FlowsTab.scss +5 -0
- package/src/components/knowledge-base/components/FlowsTab.tsx +80 -0
- package/src/components/knowledge-base/components/KnowledgeBaseHeader.scss +27 -0
- package/src/components/knowledge-base/components/KnowledgeBaseHeader.tsx +29 -0
- package/src/components/knowledge-base/components/KnowledgeList.scss +19 -0
- package/src/components/knowledge-base/components/KnowledgeList.tsx +19 -0
- package/src/components/knowledge-base/components/LoadingState.scss +5 -0
- package/src/components/knowledge-base/components/LoadingState.tsx +11 -0
- package/src/components/knowledge-base/components/MetaList.scss +19 -0
- package/src/components/knowledge-base/components/MetaList.tsx +18 -0
- package/src/components/knowledge-base/components/RulesTab.scss +5 -0
- package/src/components/knowledge-base/components/RulesTab.tsx +49 -0
- package/src/components/knowledge-base/components/SectionHeader.scss +22 -0
- package/src/components/knowledge-base/components/SectionHeader.tsx +21 -0
- package/src/components/knowledge-base/components/SkillsTab.scss +5 -0
- package/src/components/knowledge-base/components/SkillsTab.tsx +49 -0
- package/src/components/knowledge-base/components/SpecItem.scss +138 -0
- package/src/components/knowledge-base/components/SpecItem.tsx +131 -0
- package/src/components/knowledge-base/components/SpecList.scss +5 -0
- package/src/components/knowledge-base/components/SpecList.tsx +70 -0
- package/src/components/knowledge-base/components/TabContent.scss +8 -0
- package/src/components/knowledge-base/components/TabContent.tsx +17 -0
- package/src/components/knowledge-base/components/TabLabel.scss +10 -0
- package/src/components/knowledge-base/components/TabLabel.tsx +15 -0
- package/src/components/knowledge-base/index.tsx +1 -0
- package/src/components/sidebar/SessionItem.scss +256 -0
- package/src/components/sidebar/SessionItem.tsx +265 -0
- package/src/components/sidebar/SessionList.scss +92 -0
- package/src/components/sidebar/SessionList.tsx +166 -0
- package/src/components/sidebar/SidebarHeader.scss +79 -0
- package/src/components/sidebar/SidebarHeader.tsx +128 -0
- package/src/connectionManager.ts +172 -0
- package/src/hooks/useGlobalShortcut.ts +26 -0
- package/src/hooks/useQueryParams.ts +54 -0
- package/src/i18n.ts +22 -0
- package/src/main.tsx +41 -0
- package/src/resources/locales/en.json +765 -0
- package/src/resources/locales/zh.json +766 -0
- package/src/store/index.ts +23 -0
- package/src/styles/global.scss +100 -0
- package/src/utils/shortcutUtils.ts +88 -0
- package/src/vite-env.d.ts +12 -0
- package/src/ws.ts +33 -0
- package/vite.config.ts +26 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import './ListTasksTool.scss'
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
5
|
+
|
|
6
|
+
import { ToolCallBox } from '../../ToolCallBox'
|
|
7
|
+
import { defineToolRender } from '../defineToolRender'
|
|
8
|
+
import { TaskToolCard } from './components/TaskToolCard'
|
|
9
|
+
|
|
10
|
+
interface TaskResult {
|
|
11
|
+
taskId: string
|
|
12
|
+
status?: 'running' | 'completed' | 'failed'
|
|
13
|
+
exitCode?: number | null
|
|
14
|
+
description?: string
|
|
15
|
+
type?: 'default' | 'spec' | 'entity'
|
|
16
|
+
name?: string | null
|
|
17
|
+
adapter?: string | null
|
|
18
|
+
background?: boolean
|
|
19
|
+
logs?: string[] | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ListTasksTool = defineToolRender(({ resultItem }) => {
|
|
23
|
+
const { t } = useTranslation()
|
|
24
|
+
|
|
25
|
+
const taskResults = useMemo(() => {
|
|
26
|
+
if (!resultItem?.content) {
|
|
27
|
+
return []
|
|
28
|
+
}
|
|
29
|
+
const text = resultItem.content[0].text.trim()
|
|
30
|
+
return JSON.parse(text) as TaskResult[]
|
|
31
|
+
}, [resultItem?.content])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className='tool-group list-tasks-tool'>
|
|
35
|
+
<ToolCallBox
|
|
36
|
+
defaultExpanded={true}
|
|
37
|
+
header={
|
|
38
|
+
<div className='list-tasks-tool__header'>
|
|
39
|
+
<span className='material-symbols-rounded list-tasks-tool__icon'>list_alt</span>
|
|
40
|
+
<span className='list-tasks-tool__title'>{t('chat.tools.listTasks')}</span>
|
|
41
|
+
<span className='list-tasks-tool__count'>{taskResults.length}</span>
|
|
42
|
+
</div>
|
|
43
|
+
}
|
|
44
|
+
content={
|
|
45
|
+
<div className='tool-content'>
|
|
46
|
+
<div className='list-tasks-tool__list'>
|
|
47
|
+
{taskResults.map((task) => {
|
|
48
|
+
const { taskId, exitCode, ...cardProps } = task
|
|
49
|
+
const metaChips = [
|
|
50
|
+
cardProps.adapter,
|
|
51
|
+
cardProps.type === 'default' ? undefined : cardProps.type,
|
|
52
|
+
cardProps.name,
|
|
53
|
+
cardProps.status,
|
|
54
|
+
exitCode != null ? t('chat.tools.taskExitCode', { code: exitCode }) : undefined,
|
|
55
|
+
cardProps.background === false
|
|
56
|
+
? t('chat.tools.startTasksForeground')
|
|
57
|
+
: cardProps.background === true
|
|
58
|
+
? t('chat.tools.startTasksBackground')
|
|
59
|
+
: undefined
|
|
60
|
+
]
|
|
61
|
+
return (
|
|
62
|
+
<TaskToolCard
|
|
63
|
+
key={taskId}
|
|
64
|
+
{...cardProps}
|
|
65
|
+
sessionId={taskId}
|
|
66
|
+
titleFallback={t('chat.tools.task')}
|
|
67
|
+
metaChips={metaChips}
|
|
68
|
+
showExecutionIcon={false}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
})}
|
|
72
|
+
{taskResults.length === 0 && (
|
|
73
|
+
<div className='list-tasks-tool__empty'>
|
|
74
|
+
{t('chat.tools.listTasksEmpty')}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.start-tasks-tool {
|
|
2
|
+
border-color: color-mix(
|
|
3
|
+
in srgb,
|
|
4
|
+
var(--border-color) 55%,
|
|
5
|
+
var(--primary-color) 45%
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
& .tool-call-header {
|
|
9
|
+
background: linear-gradient(
|
|
10
|
+
90deg,
|
|
11
|
+
color-mix(in srgb, var(--tag-bg) 80%, var(--primary-color) 20%),
|
|
12
|
+
var(--tag-bg)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__icon {
|
|
23
|
+
font-size: 16px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__title {
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&__count {
|
|
31
|
+
margin-left: 4px;
|
|
32
|
+
padding: 1px 6px;
|
|
33
|
+
border: 1px solid var(--border-color);
|
|
34
|
+
border-radius: 999px;
|
|
35
|
+
font-size: 11px;
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
color: var(--sub-text-color);
|
|
38
|
+
background: color-mix(in srgb, var(--bg-color) 70%, transparent 30%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__list {
|
|
42
|
+
padding: 10px 12px;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: 8px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&__empty {
|
|
49
|
+
padding: 10px 12px;
|
|
50
|
+
border: 1px dashed var(--border-color);
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
font-size: 12px;
|
|
53
|
+
color: var(--sub-text-color);
|
|
54
|
+
background: var(--bg-color);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import './StartTasksTool.scss'
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
5
|
+
|
|
6
|
+
import { ToolCallBox } from '../../ToolCallBox'
|
|
7
|
+
import { defineToolRender } from '../defineToolRender'
|
|
8
|
+
import { TaskToolCard } from './components/TaskToolCard'
|
|
9
|
+
|
|
10
|
+
interface StartTask {
|
|
11
|
+
description?: string
|
|
12
|
+
type?: 'default' | 'spec' | 'entity'
|
|
13
|
+
name?: string
|
|
14
|
+
adapter?: string
|
|
15
|
+
background?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface TaskResult {
|
|
19
|
+
taskId: string
|
|
20
|
+
status?: 'running' | 'completed' | 'failed'
|
|
21
|
+
exitCode?: number | null
|
|
22
|
+
description?: string
|
|
23
|
+
type?: 'default' | 'spec' | 'entity'
|
|
24
|
+
name?: string | null
|
|
25
|
+
adapter?: string | null
|
|
26
|
+
background?: boolean
|
|
27
|
+
logs?: string[] | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const StartTasksTool = defineToolRender(({ item, resultItem }) => {
|
|
31
|
+
const { t } = useTranslation()
|
|
32
|
+
|
|
33
|
+
const input = (item.input != null ? item.input : {}) as { tasks?: StartTask[] }
|
|
34
|
+
const tasks = Array.isArray(input.tasks) ? input.tasks : []
|
|
35
|
+
|
|
36
|
+
const parsedResult = useMemo(() => {
|
|
37
|
+
if (!resultItem?.content) {
|
|
38
|
+
return { taskResults: null }
|
|
39
|
+
}
|
|
40
|
+
const text = resultItem.content[0].text.trim()
|
|
41
|
+
return {
|
|
42
|
+
taskResults: JSON.parse(text) as TaskResult[]
|
|
43
|
+
}
|
|
44
|
+
}, [resultItem?.content])
|
|
45
|
+
|
|
46
|
+
const { taskResults } = parsedResult
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className='tool-group start-tasks-tool'>
|
|
50
|
+
<ToolCallBox
|
|
51
|
+
defaultExpanded={true}
|
|
52
|
+
header={
|
|
53
|
+
<div className='start-tasks-tool__header'>
|
|
54
|
+
<span className='material-symbols-rounded start-tasks-tool__icon'>playlist_add</span>
|
|
55
|
+
<span className='start-tasks-tool__title'>{t('chat.tools.startTasks')}</span>
|
|
56
|
+
<span className='start-tasks-tool__count'>{tasks.length}</span>
|
|
57
|
+
</div>
|
|
58
|
+
}
|
|
59
|
+
content={
|
|
60
|
+
<div className='tool-content'>
|
|
61
|
+
<div className='start-tasks-tool__list'>
|
|
62
|
+
{tasks.map((task, idx) => {
|
|
63
|
+
const { description, type, name, adapter, background } = task
|
|
64
|
+
const { status, taskId, logs = [] } = taskResults?.[idx] ?? {}
|
|
65
|
+
const cardProps = { description, status, logs, adapter, type, name, background }
|
|
66
|
+
const metaChips = [
|
|
67
|
+
adapter,
|
|
68
|
+
type === 'default' ? undefined : type,
|
|
69
|
+
name
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<TaskToolCard
|
|
74
|
+
key={idx}
|
|
75
|
+
{...cardProps}
|
|
76
|
+
sessionId={taskId}
|
|
77
|
+
titleFallback={t('chat.tools.startTasks')}
|
|
78
|
+
metaChips={metaChips}
|
|
79
|
+
showExecutionIcon={true}
|
|
80
|
+
foregroundLabel={t('chat.tools.startTasksForeground')}
|
|
81
|
+
backgroundLabel={t('chat.tools.startTasksBackground')}
|
|
82
|
+
/>
|
|
83
|
+
)
|
|
84
|
+
})}
|
|
85
|
+
{tasks.length === 0 && (
|
|
86
|
+
<div className='start-tasks-tool__empty'>
|
|
87
|
+
{t('chat.tools.startTasksEmpty')}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
})
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
.task-tool-card {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: 24px minmax(0, 1fr);
|
|
4
|
+
gap: 12px;
|
|
5
|
+
padding: 12px;
|
|
6
|
+
border: 1px solid var(--border-color);
|
|
7
|
+
border-radius: 8px;
|
|
8
|
+
background: color-mix(
|
|
9
|
+
in srgb,
|
|
10
|
+
var(--bg-color) 92%,
|
|
11
|
+
var(--primary-color) 8%
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
&__left {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__status-icon {
|
|
22
|
+
font-size: 20px;
|
|
23
|
+
color: var(--sub-text-color);
|
|
24
|
+
transition: color .2s ease;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
color: var(--text-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.running {
|
|
31
|
+
color: var(--primary-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.completed {
|
|
35
|
+
color: var(--success-color);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.failed {
|
|
39
|
+
color: var(--danger-color);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&__execution-icon {
|
|
44
|
+
font-size: 20px;
|
|
45
|
+
color: var(--sub-text-color);
|
|
46
|
+
transition: color .2s ease;
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
color: var(--text-color);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&--background {
|
|
53
|
+
color: var(--sub-text-color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&--foreground {
|
|
57
|
+
color: var(--warning-color);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__main {
|
|
62
|
+
> .code-block-wrapper {
|
|
63
|
+
border-radius: 8px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&__header {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
align-items: flex-start;
|
|
72
|
+
margin-bottom: 6px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&__title {
|
|
76
|
+
font-size: 14px;
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
color: var(--text-color);
|
|
79
|
+
flex: 1;
|
|
80
|
+
margin-right: 12px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&__session-id {
|
|
84
|
+
font-size: 11px;
|
|
85
|
+
color: var(--sub-text-color);
|
|
86
|
+
opacity: .6;
|
|
87
|
+
font-family: monospace;
|
|
88
|
+
user-select: none;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&__session-link {
|
|
93
|
+
background: transparent;
|
|
94
|
+
border: none;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
padding: 0;
|
|
97
|
+
text-align: right;
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
color: var(--text-color);
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__content {
|
|
106
|
+
font-size: 13px;
|
|
107
|
+
line-height: 1.5;
|
|
108
|
+
color: var(--text-color);
|
|
109
|
+
margin-bottom: 8px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&__meta {
|
|
113
|
+
margin: 6px 0;
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-wrap: wrap;
|
|
116
|
+
gap: 6px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&__meta-chip {
|
|
120
|
+
padding: 2px 6px;
|
|
121
|
+
border: 1px solid var(--border-color);
|
|
122
|
+
border-radius: 999px;
|
|
123
|
+
font-size: 11px;
|
|
124
|
+
color: var(--sub-text-color);
|
|
125
|
+
background: var(--bg-color);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import './TaskToolCard.scss'
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
4
|
+
import { useNavigate } from 'react-router-dom'
|
|
5
|
+
|
|
6
|
+
import type { ChatMessage, WSEvent } from '@vibe-forge/core'
|
|
7
|
+
|
|
8
|
+
import { connectionManager } from '#~/connectionManager.js'
|
|
9
|
+
import { CodeBlock } from '../../../CodeBlock'
|
|
10
|
+
|
|
11
|
+
export interface TaskToolCardProps {
|
|
12
|
+
description?: string
|
|
13
|
+
status?: 'running' | 'completed' | 'failed'
|
|
14
|
+
logs?: string[] | null
|
|
15
|
+
adapter?: string | null
|
|
16
|
+
type?: 'default' | 'spec' | 'entity'
|
|
17
|
+
name?: string | null
|
|
18
|
+
background?: boolean
|
|
19
|
+
sessionId?: string | null
|
|
20
|
+
titleFallback?: string
|
|
21
|
+
metaChips?: Array<string | null | undefined>
|
|
22
|
+
showExecutionIcon?: boolean
|
|
23
|
+
foregroundLabel?: string
|
|
24
|
+
backgroundLabel?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseTaskDescription(description?: string): { title: string; content: string } {
|
|
28
|
+
if (!description) {
|
|
29
|
+
return { title: '', content: '' }
|
|
30
|
+
}
|
|
31
|
+
const lines = description.split('\n')
|
|
32
|
+
const title = lines[0] || ''
|
|
33
|
+
const content = lines.slice(1).join('\n').trim()
|
|
34
|
+
return { title, content }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getStatusIcon(status?: string): string {
|
|
38
|
+
switch (status) {
|
|
39
|
+
case 'running':
|
|
40
|
+
return 'play_circle'
|
|
41
|
+
case 'completed':
|
|
42
|
+
return 'check_circle'
|
|
43
|
+
case 'failed':
|
|
44
|
+
return 'error'
|
|
45
|
+
default:
|
|
46
|
+
return 'help_outline'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function TaskToolCard({
|
|
51
|
+
description,
|
|
52
|
+
status,
|
|
53
|
+
logs,
|
|
54
|
+
background,
|
|
55
|
+
sessionId,
|
|
56
|
+
titleFallback,
|
|
57
|
+
metaChips,
|
|
58
|
+
showExecutionIcon,
|
|
59
|
+
foregroundLabel,
|
|
60
|
+
backgroundLabel
|
|
61
|
+
}: TaskToolCardProps) {
|
|
62
|
+
const navigate = useNavigate()
|
|
63
|
+
const [liveLogs, setLiveLogs] = useState<string[]>(logs ?? [])
|
|
64
|
+
const [liveStatus, setLiveStatus] = useState(status)
|
|
65
|
+
const seenMessageIdsRef = useRef<Set<string>>(new Set())
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setLiveLogs(logs ?? [])
|
|
69
|
+
}, [logs])
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setLiveStatus(status)
|
|
73
|
+
}, [status])
|
|
74
|
+
|
|
75
|
+
const { title, content } = parseTaskDescription(description)
|
|
76
|
+
const logText = useMemo(() => (liveLogs?.join('\n') ?? '').trim(), [liveLogs])
|
|
77
|
+
const resolvedTitle = title || titleFallback || ''
|
|
78
|
+
const chips = (metaChips ?? []).filter((item): item is string => Boolean(item))
|
|
79
|
+
const isForeground = background === false
|
|
80
|
+
const executionClass = isForeground
|
|
81
|
+
? 'task-tool-card__execution-icon--foreground'
|
|
82
|
+
: 'task-tool-card__execution-icon--background'
|
|
83
|
+
const executionLabel = isForeground ? foregroundLabel : backgroundLabel
|
|
84
|
+
const displaySessionId = sessionId != null && sessionId !== ''
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!sessionId) return
|
|
88
|
+
const cleanup = connectionManager.connect(sessionId, {
|
|
89
|
+
onMessage(data: WSEvent) {
|
|
90
|
+
if (data.type === 'message') {
|
|
91
|
+
const message = data.message as ChatMessage
|
|
92
|
+
if (message.id && seenMessageIdsRef.current.has(message.id)) {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
if (message.id) {
|
|
96
|
+
seenMessageIdsRef.current.add(message.id)
|
|
97
|
+
}
|
|
98
|
+
const text = extractMessageText(message)
|
|
99
|
+
if (text !== '') {
|
|
100
|
+
setLiveLogs((prev) => [...prev, text])
|
|
101
|
+
}
|
|
102
|
+
} else if (data.type === 'session_updated') {
|
|
103
|
+
if (data.session?.id === sessionId) {
|
|
104
|
+
const updatedStatus = data.session?.status as typeof status | undefined
|
|
105
|
+
if (updatedStatus) {
|
|
106
|
+
setLiveStatus(updatedStatus)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
return () => {
|
|
113
|
+
cleanup?.()
|
|
114
|
+
}
|
|
115
|
+
}, [sessionId])
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div className='task-tool-card'>
|
|
119
|
+
<div className='task-tool-card__left'>
|
|
120
|
+
<span className={`material-symbols-rounded task-tool-card__status-icon ${liveStatus ?? 'help_outline'}`}>
|
|
121
|
+
{getStatusIcon(liveStatus)}
|
|
122
|
+
</span>
|
|
123
|
+
{showExecutionIcon && (
|
|
124
|
+
<span
|
|
125
|
+
className={`material-symbols-rounded task-tool-card__execution-icon ${executionClass}`}
|
|
126
|
+
title={executionLabel}
|
|
127
|
+
>
|
|
128
|
+
{isForeground ? 'desktop_windows' : 'schedule'}
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
<div className='task-tool-card__main'>
|
|
133
|
+
<div className='task-tool-card__header'>
|
|
134
|
+
<div className='task-tool-card__title'>{resolvedTitle}</div>
|
|
135
|
+
{displaySessionId && (
|
|
136
|
+
<button
|
|
137
|
+
type='button'
|
|
138
|
+
className='task-tool-card__session-id task-tool-card__session-link'
|
|
139
|
+
onClick={() => navigate(`/session/${sessionId}`)}
|
|
140
|
+
>
|
|
141
|
+
{sessionId}
|
|
142
|
+
</button>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
{content && (
|
|
146
|
+
<div className='task-tool-card__content'>
|
|
147
|
+
{content}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
{chips.length > 0 && (
|
|
151
|
+
<div className='task-tool-card__meta'>
|
|
152
|
+
{chips.map((item) => (
|
|
153
|
+
<span className='task-tool-card__meta-chip' key={item}>{item}</span>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
156
|
+
)}
|
|
157
|
+
<CodeBlock
|
|
158
|
+
hideHeader
|
|
159
|
+
code={logText}
|
|
160
|
+
lang='md'
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function extractMessageText(message: ChatMessage): string {
|
|
168
|
+
if (typeof message.content === 'string') {
|
|
169
|
+
return message.content
|
|
170
|
+
}
|
|
171
|
+
if (Array.isArray(message.content)) {
|
|
172
|
+
return message.content
|
|
173
|
+
.map((c) => (c.type === 'text' ? c.text : ''))
|
|
174
|
+
.join('')
|
|
175
|
+
}
|
|
176
|
+
return ''
|
|
177
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineToolRenders } from '../defineToolRender'
|
|
2
|
+
import { GetTaskInfoTool } from './GetTaskInfoTool'
|
|
3
|
+
import { ListTasksTool } from './ListTasksTool'
|
|
4
|
+
import { StartTasksTool } from './StartTasksTool'
|
|
5
|
+
|
|
6
|
+
export const taskToolRenders = defineToolRenders({
|
|
7
|
+
StartTasks: StartTasksTool,
|
|
8
|
+
GetTaskInfo: GetTaskInfoTool,
|
|
9
|
+
ListTasks: ListTasksTool
|
|
10
|
+
}, {
|
|
11
|
+
namespace: 'mcp__VibeForge__'
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export { GetTaskInfoTool, ListTasksTool, StartTasksTool }
|
|
15
|
+
export { TaskToolCard } from './components/TaskToolCard'
|