@yuku123/z-agent-frontend-component 0.1.1

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.
Files changed (41) hide show
  1. package/README.md +66 -0
  2. package/dist/z-agent-frontend-component.css +1 -0
  3. package/dist/z-agent-frontend-component.es.js +9956 -0
  4. package/dist/z-agent-frontend-component.umd.js +219 -0
  5. package/package.json +77 -0
  6. package/src/api/apiRouter.js +78 -0
  7. package/src/api/index.js +23 -0
  8. package/src/api/request.js +59 -0
  9. package/src/api/routes.js +140 -0
  10. package/src/dev.jsx +80 -0
  11. package/src/index.js +86 -0
  12. package/src/pages/agent/app/index.jsx +2 -0
  13. package/src/pages/agent/editor/AgentAppEditor.jsx +456 -0
  14. package/src/pages/agent/editor/WorkflowEditor.jsx +495 -0
  15. package/src/pages/agent/editor/nodes/index.ts +225 -0
  16. package/src/pages/agent/index.jsx +1379 -0
  17. package/src/pages/agent/share.jsx +512 -0
  18. package/src/pages/ak/AkUsageDrawer.jsx +208 -0
  19. package/src/pages/ak/index.jsx +496 -0
  20. package/src/pages/llm/index.jsx +736 -0
  21. package/src/pages/llm/model/index.jsx +220 -0
  22. package/src/pages/llm/provider/index.jsx +173 -0
  23. package/src/pages/mcp/index.jsx +359 -0
  24. package/src/pages/oss/BucketList.jsx +320 -0
  25. package/src/pages/oss/ObjectBrowser.jsx +409 -0
  26. package/src/pages/product/execute.jsx +608 -0
  27. package/src/pages/product/index.jsx +628 -0
  28. package/src/pages/product/scene.jsx +746 -0
  29. package/src/pages/script/ApiBridgeEditor.jsx +255 -0
  30. package/src/pages/script/CurlImportModal.jsx +263 -0
  31. package/src/pages/script/FieldMappingEditor.jsx +131 -0
  32. package/src/pages/script/OpenApiImportModal.jsx +212 -0
  33. package/src/pages/script/index.jsx +532 -0
  34. package/src/pages/skill/index.jsx +1595 -0
  35. package/src/pages/trace/DebugPlayground.jsx +357 -0
  36. package/src/pages/trace/components/MetricsDashboard.jsx +164 -0
  37. package/src/pages/trace/components/RagFragments.jsx +134 -0
  38. package/src/pages/trace/components/Timeline.jsx +142 -0
  39. package/src/pages/trace/components/ToolCallTree.jsx +116 -0
  40. package/src/pages/trace/index.jsx +13 -0
  41. package/src/pages/usage/index.jsx +352 -0
@@ -0,0 +1,220 @@
1
+ import {useEffect, useState} from 'react'
2
+ import {
3
+ Button,
4
+ Card,
5
+ Col,
6
+ Form,
7
+ Input,
8
+ InputNumber,
9
+ message,
10
+ Modal,
11
+ Row,
12
+ Select,
13
+ Space,
14
+ Statistic,
15
+ Table,
16
+ Tag
17
+ } from 'antd'
18
+ import {DeleteOutlined, EditOutlined, PlusOutlined} from '@ant-design/icons'
19
+ import request from '../../../api'
20
+
21
+ const {confirm} = Modal
22
+
23
+ const LlmModel = () => {
24
+ const [data, setData] = useState([])
25
+ const [providers, setProviders] = useState([])
26
+ const [loading, setLoading] = useState(false)
27
+ const [modalVisible, setModalVisible] = useState(false)
28
+ const [editing, setEditing] = useState(null)
29
+ const [form] = Form.useForm()
30
+
31
+ const fetchModels = async () => {
32
+ setLoading(true)
33
+ try {
34
+ const res = await request('/llm-center/model/list', {method: 'GET'})
35
+ const list = Array.isArray(res) ? res : (res?.data || [])
36
+ setData(list)
37
+ } catch (e) {
38
+ message.error('加载失败')
39
+ } finally {
40
+ setLoading(false)
41
+ }
42
+ }
43
+
44
+ const fetchProviders = async () => {
45
+ try {
46
+ const res = await request('/llm-center/provider/list', {method: 'GET'})
47
+ const list = Array.isArray(res) ? res : (res?.data || [])
48
+ setProviders(list)
49
+ } catch (e) {
50
+ }
51
+ }
52
+
53
+ useEffect(() => {
54
+ fetchModels()
55
+ fetchProviders()
56
+ }, [])
57
+
58
+ const handleAdd = () => {
59
+ setEditing(null)
60
+ form.resetFields()
61
+ form.setFieldsValue({status: 'ACTIVE', contextWindow: 4096})
62
+ setModalVisible(true)
63
+ }
64
+
65
+ const handleEdit = (record) => {
66
+ setEditing(record)
67
+ form.setFieldsValue(record)
68
+ setModalVisible(true)
69
+ }
70
+
71
+ const handleDelete = async (record) => {
72
+ confirm({
73
+ title: '确认删除',
74
+ content: `删除模型 ${record.modelName} ?`,
75
+ onOk: async () => {
76
+ await request('/llm-center/model/delete', {method: 'POST', data: {id: record.id}})
77
+ message.success('删除成功')
78
+ fetchModels()
79
+ }
80
+ })
81
+ }
82
+
83
+ const handleSubmit = async () => {
84
+ try {
85
+ const values = await form.validateFields()
86
+ await request(editing ? '/llm-center/model/update' : '/llm-center/model/create', {
87
+ method: 'POST',
88
+ data: values
89
+ })
90
+ message.success(editing ? '更新成功' : '创建成功')
91
+ setModalVisible(false)
92
+ fetchModels()
93
+ } catch (e) {
94
+ }
95
+ }
96
+
97
+ const columns = [
98
+ {title: '模型编码', dataIndex: 'modelCode', width: 120},
99
+ {title: '模型名称', dataIndex: 'modelName', width: 150},
100
+ {
101
+ title: '供应商',
102
+ dataIndex: 'providerCode',
103
+ render: v => <Tag>{v}</Tag>
104
+ },
105
+ {title: '上下文窗口', dataIndex: 'contextWindow', render: v => v ? `${v.toLocaleString()} tokens` : '-'},
106
+ {
107
+ title: '输入价格',
108
+ dataIndex: 'inputPrice',
109
+ render: v => v ? `¥${v}/千token` : '-'
110
+ },
111
+ {
112
+ title: '输出价格',
113
+ dataIndex: 'outputPrice',
114
+ render: v => v ? `¥${v}/千token` : '-'
115
+ },
116
+ {
117
+ title: '状态',
118
+ dataIndex: 'status',
119
+ render: v => <Tag color={v === 'ACTIVE' ? 'green' : 'red'}>{v === 'ACTIVE' ? '正常' : '禁用'}</Tag>
120
+ },
121
+ {
122
+ title: '操作',
123
+ width: 150,
124
+ render: (_, record) => (
125
+ <Space>
126
+ <Button size="small" icon={<EditOutlined/>} onClick={() => handleEdit(record)}>编辑</Button>
127
+ <Button size="small" danger icon={<DeleteOutlined/>}
128
+ onClick={() => handleDelete(record)}>删除</Button>
129
+ </Space>
130
+ )
131
+ }
132
+ ]
133
+
134
+ return (
135
+ <div>
136
+ <Row gutter={16} style={{marginBottom: 16}}>
137
+ <Col span={6}>
138
+ <Card><Statistic title="模型总数" value={data.length}/></Card>
139
+ </Col>
140
+ <Col span={6}>
141
+ <Card><Statistic title="活跃模型" value={data.filter(m => m.status === 'ACTIVE').length}/></Card>
142
+ </Col>
143
+ <Col span={6}>
144
+ <Card><Statistic title="总上下文"
145
+ value={data.reduce((sum, m) => sum + (m.contextWindow || 0), 0).toLocaleString()}
146
+ suffix="tokens"/></Card>
147
+ </Col>
148
+ </Row>
149
+
150
+ <div style={{marginBottom: 16}}>
151
+ <Button type="primary" icon={<PlusOutlined/>} onClick={handleAdd}>添加模型</Button>
152
+ </div>
153
+
154
+ <Table columns={columns} dataSource={data} loading={loading} rowKey="id"/>
155
+
156
+ <Modal
157
+ title={editing ? '编辑模型' : '添加模型'}
158
+ open={modalVisible}
159
+ onOk={handleSubmit}
160
+ onCancel={() => setModalVisible(false)}
161
+ width={600}
162
+ >
163
+ <Form form={form} layout="vertical">
164
+ <Row gutter={16}>
165
+ <Col span={12}>
166
+ <Form.Item name="modelCode" label="模型编码" rules={[{required: true}]}>
167
+ <Input placeholder="如: qwen2.5, gpt-4o" disabled={!!editing}/>
168
+ </Form.Item>
169
+ </Col>
170
+ <Col span={12}>
171
+ <Form.Item name="modelName" label="模型名称" rules={[{required: true}]}>
172
+ <Input placeholder="如: Qwen 2.5 72B"/>
173
+ </Form.Item>
174
+ </Col>
175
+ </Row>
176
+ <Form.Item name="providerCode" label="供应商" rules={[{required: true}]}>
177
+ <Select placeholder="选择供应商">
178
+ {providers.map(p => (
179
+ <Select.Option key={p.providerCode}
180
+ value={p.providerCode}>{p.providerName}</Select.Option>
181
+ ))}
182
+ </Select>
183
+ </Form.Item>
184
+ <Row gutter={16}>
185
+ <Col span={12}>
186
+ <Form.Item name="contextWindow" label="上下文窗口 (tokens)">
187
+ <InputNumber style={{width: '100%'}} placeholder="如: 4096"/>
188
+ </Form.Item>
189
+ </Col>
190
+ <Col span={12}>
191
+ <Form.Item name="status" label="状态" initialValue="ACTIVE">
192
+ <Select>
193
+ <Select.Option value="ACTIVE">正常</Select.Option>
194
+ <Select.Option value="INACTIVE">禁用</Select.Option>
195
+ </Select>
196
+ </Form.Item>
197
+ </Col>
198
+ </Row>
199
+ <Row gutter={16}>
200
+ <Col span={12}>
201
+ <Form.Item name="inputPrice" label="输入价格 (元/千token)">
202
+ <InputNumber style={{width: '100%'}} min={0} precision={6} placeholder="如: 0.001"/>
203
+ </Form.Item>
204
+ </Col>
205
+ <Col span={12}>
206
+ <Form.Item name="outputPrice" label="输出价格 (元/千token)">
207
+ <InputNumber style={{width: '100%'}} min={0} precision={6} placeholder="如: 0.002"/>
208
+ </Form.Item>
209
+ </Col>
210
+ </Row>
211
+ <Form.Item name="description" label="描述">
212
+ <Input.TextArea rows={2} placeholder="模型描述..."/>
213
+ </Form.Item>
214
+ </Form>
215
+ </Modal>
216
+ </div>
217
+ )
218
+ }
219
+
220
+ export default LlmModel
@@ -0,0 +1,173 @@
1
+ import {useEffect, useState} from 'react'
2
+ import {Button, Card, Col, Form, Input, message, Modal, Row, Select, Space, Statistic, Table, Tag} from 'antd'
3
+ import {DeleteOutlined, EditOutlined, GlobalOutlined, PlusOutlined} from '@ant-design/icons'
4
+ import request from '../../../api'
5
+
6
+ const {confirm} = Modal
7
+
8
+ const LlmProvider = () => {
9
+ const [data, setData] = useState([])
10
+ const [loading, setSetLoading] = useState(false)
11
+ const [modalVisible, setModalVisible] = useState(false)
12
+ const [editing, setEditing] = useState(null)
13
+ const [form] = Form.useForm()
14
+
15
+ const fetchProviders = async () => {
16
+ setSetLoading(true)
17
+ try {
18
+ const res = await request('/llm-center/provider/list', {method: 'GET'})
19
+ const list = Array.isArray(res) ? res : (res?.data || [])
20
+ setData(list)
21
+ } catch (e) {
22
+ message.error('加载失败')
23
+ } finally {
24
+ setSetLoading(false)
25
+ }
26
+ }
27
+
28
+ useEffect(() => {
29
+ fetchProviders()
30
+ }, [])
31
+
32
+ const handleAdd = () => {
33
+ setEditing(null)
34
+ form.resetFields()
35
+ setModalVisible(true)
36
+ }
37
+
38
+ const handleEdit = (record) => {
39
+ setEditing(record)
40
+ form.setFieldsValue(record)
41
+ setModalVisible(true)
42
+ }
43
+
44
+ const handleDelete = async (record) => {
45
+ confirm({
46
+ title: '确认删除',
47
+ content: `删除供应商 ${record.providerName} ?`,
48
+ onOk: async () => {
49
+ await request('/llm-center/provider/delete', {method: 'POST', data: {id: record.id}})
50
+ message.success('删除成功')
51
+ fetchProviders()
52
+ }
53
+ })
54
+ }
55
+
56
+ const handleSubmit = async () => {
57
+ try {
58
+ const values = await form.validateFields()
59
+ await request(editing ? '/llm-center/provider/update' : '/llm-center/provider/create', {
60
+ method: 'POST',
61
+ data: values
62
+ })
63
+ message.success(editing ? '更新成功' : '创建成功')
64
+ setModalVisible(false)
65
+ fetchProviders()
66
+ } catch (e) {
67
+ }
68
+ }
69
+
70
+ const providerTypeColor = {
71
+ 'ollama': 'blue',
72
+ 'openai': 'green',
73
+ 'azure': 'purple',
74
+ 'anthropic': 'orange'
75
+ }
76
+
77
+ const columns = [
78
+ {
79
+ title: '供应商',
80
+ render: (_, record) => (
81
+ <Space>
82
+ <GlobalOutlined style={{fontSize: 20, color: providerTypeColor[record.providerCode] || 'blue'}}/>
83
+ <div>
84
+ <div><strong>{record.providerName}</strong></div>
85
+ <div style={{fontSize: 12, color: '#999'}}>{record.providerCode}</div>
86
+ </div>
87
+ </Space>
88
+ )
89
+ },
90
+ {
91
+ title: '类型',
92
+ dataIndex: 'providerType',
93
+ render: v => <Tag color={providerTypeColor[v] || 'default'}>{v?.toUpperCase()}</Tag>
94
+ },
95
+ {title: 'Base URL', dataIndex: 'baseUrl', ellipsis: true},
96
+ {title: '模型数量', dataIndex: 'modelCount', render: v => <Tag>{v || 0}</Tag>},
97
+ {
98
+ title: '状态',
99
+ dataIndex: 'status',
100
+ render: v => <Tag color={v === 'ACTIVE' ? 'green' : 'red'}>{v === 'ACTIVE' ? '正常' : '异常'}</Tag>
101
+ },
102
+ {
103
+ title: '操作',
104
+ width: 150,
105
+ render: (_, record) => (
106
+ <Space>
107
+ <Button size="small" icon={<EditOutlined/>} onClick={() => handleEdit(record)}>编辑</Button>
108
+ <Button size="small" danger icon={<DeleteOutlined/>}
109
+ onClick={() => handleDelete(record)}>删除</Button>
110
+ </Space>
111
+ )
112
+ }
113
+ ]
114
+
115
+ return (
116
+ <div>
117
+ <Row gutter={16} style={{marginBottom: 16}}>
118
+ <Col span={6}>
119
+ <Card><Statistic title="供应商数" value={data.length}/></Card>
120
+ </Col>
121
+ <Col span={6}>
122
+ <Card><Statistic title="活跃模型"
123
+ value={data.reduce((sum, p) => sum + (p.modelCount || 0), 0)}/></Card>
124
+ </Col>
125
+ </Row>
126
+
127
+ <div style={{marginBottom: 16}}>
128
+ <Button type="primary" icon={<PlusOutlined/>} onClick={handleAdd}>添加供应商</Button>
129
+ </div>
130
+
131
+ <Table columns={columns} dataSource={data} loading={loading} rowKey="id"/>
132
+
133
+ <Modal
134
+ title={editing ? '编辑供应商' : '添加供应商'}
135
+ open={modalVisible}
136
+ onOk={handleSubmit}
137
+ onCancel={() => setModalVisible(false)}
138
+ width={500}
139
+ >
140
+ <Form form={form} layout="vertical">
141
+ <Form.Item name="providerCode" label="供应商编码" rules={[{required: true}]}>
142
+ <Input placeholder="如: ollama, openai, azure" disabled={!!editing}/>
143
+ </Form.Item>
144
+ <Form.Item name="providerName" label="供应商名称" rules={[{required: true}]}>
145
+ <Input placeholder="如: Ollama, OpenAI"/>
146
+ </Form.Item>
147
+ <Form.Item name="providerType" label="类型" rules={[{required: true}]}>
148
+ <Select>
149
+ <Select.Option value="ollama">Ollama</Select.Option>
150
+ <Select.Option value="openai">OpenAI</Select.Option>
151
+ <Select.Option value="azure">Azure OpenAI</Select.Option>
152
+ <Select.Option value="anthropic">Anthropic</Select.Option>
153
+ </Select>
154
+ </Form.Item>
155
+ <Form.Item name="baseUrl" label="Base URL" rules={[{required: true}]}>
156
+ <Input placeholder="如: http://localhost:11434"/>
157
+ </Form.Item>
158
+ <Form.Item name="apiKey" label="API Key">
159
+ <Input.Password placeholder="可选,部分供应商需要"/>
160
+ </Form.Item>
161
+ <Form.Item name="status" label="状态" initialValue="ACTIVE">
162
+ <Select>
163
+ <Select.Option value="ACTIVE">正常</Select.Option>
164
+ <Select.Option value="INACTIVE">异常</Select.Option>
165
+ </Select>
166
+ </Form.Item>
167
+ </Form>
168
+ </Modal>
169
+ </div>
170
+ )
171
+ }
172
+
173
+ export default LlmProvider