vue-agent-start 0.1.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.
Files changed (169) hide show
  1. package/package.json +30 -0
  2. package/pnpm-workspace.yaml +3 -0
  3. package/src/agent-flow/adapter/backend.ts +99 -0
  4. package/src/agent-flow/components/ChatIframePanel.vue +773 -0
  5. package/src/agent-flow/components/DatasetItemCard.vue +313 -0
  6. package/src/agent-flow/components/MemoryWindow.vue +104 -0
  7. package/src/agent-flow/components/PromptEditor.vue +804 -0
  8. package/src/agent-flow/components/PromptEditorTagPanel.vue +460 -0
  9. package/src/agent-flow/components/SvgIcon.vue +32 -0
  10. package/src/agent-flow/components/ToolItemCard.vue +169 -0
  11. package/src/agent-flow/components/VariableCard.vue +161 -0
  12. package/src/agent-flow/components/VariableSelector.vue +162 -0
  13. package/src/agent-flow/components/chat-iframe-types.ts +35 -0
  14. package/src/agent-flow/components/stubs/DatasetChooser.vue +70 -0
  15. package/src/agent-flow/components/stubs/Embedding.vue +22 -0
  16. package/src/agent-flow/components/stubs/ModelSelect.vue +24 -0
  17. package/src/agent-flow/components/stubs/RestfulSelectCard.vue +24 -0
  18. package/src/agent-flow/components/stubs/ToolChooser.vue +96 -0
  19. package/src/agent-flow/components/stubs/TriggersItemCard.vue +126 -0
  20. package/src/agent-flow/components/stubs/VariableModal.vue +115 -0
  21. package/src/agent-flow/index.ts +73 -0
  22. package/src/agent-flow/stores/workflow.ts +72 -0
  23. package/src/agent-flow/utils/langUtils.ts +173 -0
  24. package/src/agent-flow/workflow/Ability.vue +65 -0
  25. package/src/agent-flow/workflow/AuthorizationItem.vue +101 -0
  26. package/src/agent-flow/workflow/ConversationVar.vue +42 -0
  27. package/src/agent-flow/workflow/CustomEdge.vue +94 -0
  28. package/src/agent-flow/workflow/EnvironmentVar.vue +40 -0
  29. package/src/agent-flow/workflow/FlowDesigner.vue +2802 -0
  30. package/src/agent-flow/workflow/Icon.vue +179 -0
  31. package/src/agent-flow/workflow/NodeConfig.vue +509 -0
  32. package/src/agent-flow/workflow/NodeConfigCard.vue +460 -0
  33. package/src/agent-flow/workflow/NodeHandle.vue +147 -0
  34. package/src/agent-flow/workflow/NodeHeaderToolbar.vue +77 -0
  35. package/src/agent-flow/workflow/NodeHoverToolbar.vue +176 -0
  36. package/src/agent-flow/workflow/OutputItemCard.vue +668 -0
  37. package/src/agent-flow/workflow/ParamTableItem.vue +200 -0
  38. package/src/agent-flow/workflow/StructTable.vue +202 -0
  39. package/src/agent-flow/workflow/VarInsertField.vue +517 -0
  40. package/src/agent-flow/workflow/VarSelectField.vue +223 -0
  41. package/src/agent-flow/workflow/VariableSelectorItem.vue +48 -0
  42. package/src/agent-flow/workflow/WfField.vue +206 -0
  43. package/src/agent-flow/workflow/_config-base.css +470 -0
  44. package/src/agent-flow/workflow/composables/useNode.js +55 -0
  45. package/src/agent-flow/workflow/index.vue +53 -0
  46. package/src/agent-flow/workflow/nodeCard/AgentNodeCard.vue +180 -0
  47. package/src/agent-flow/workflow/nodeCard/AnswerNodeCard.vue +65 -0
  48. package/src/agent-flow/workflow/nodeCard/ClassifierCard.vue +152 -0
  49. package/src/agent-flow/workflow/nodeCard/CodeNodeCard.vue +139 -0
  50. package/src/agent-flow/workflow/nodeCard/ConditionNodeCard.vue +323 -0
  51. package/src/agent-flow/workflow/nodeCard/DocumentExtractorCard.vue +83 -0
  52. package/src/agent-flow/workflow/nodeCard/EndNodeCard.vue +123 -0
  53. package/src/agent-flow/workflow/nodeCard/HttpNodeCard.vue +451 -0
  54. package/src/agent-flow/workflow/nodeCard/HumanInputCard.vue +152 -0
  55. package/src/agent-flow/workflow/nodeCard/IterationCard.vue +66 -0
  56. package/src/agent-flow/workflow/nodeCard/KnowledgeRetrievalCard.vue +48 -0
  57. package/src/agent-flow/workflow/nodeCard/LLMNodeCard.vue +206 -0
  58. package/src/agent-flow/workflow/nodeCard/ListOperatorCard.vue +188 -0
  59. package/src/agent-flow/workflow/nodeCard/ParameterExtractorCard.vue +352 -0
  60. package/src/agent-flow/workflow/nodeCard/ServiceApiNodeCard.vue +188 -0
  61. package/src/agent-flow/workflow/nodeCard/StartNodeCard.vue +216 -0
  62. package/src/agent-flow/workflow/nodeCard/VariableAssignerCard.vue +125 -0
  63. package/src/agent-flow/workflow/nodeCard/VariableNodeCard.vue +121 -0
  64. package/src/agent-flow/workflow/nodes/AgentNode.vue +122 -0
  65. package/src/agent-flow/workflow/nodes/AnswerNode.vue +99 -0
  66. package/src/agent-flow/workflow/nodes/ClassifierNode.vue +199 -0
  67. package/src/agent-flow/workflow/nodes/CodeNode.vue +152 -0
  68. package/src/agent-flow/workflow/nodes/ConditionNode.vue +232 -0
  69. package/src/agent-flow/workflow/nodes/DocumentExtractorNode.vue +96 -0
  70. package/src/agent-flow/workflow/nodes/EndNode.vue +119 -0
  71. package/src/agent-flow/workflow/nodes/FileUploadNode.vue +97 -0
  72. package/src/agent-flow/workflow/nodes/HttpNode.vue +204 -0
  73. package/src/agent-flow/workflow/nodes/HumanInputNode.vue +110 -0
  74. package/src/agent-flow/workflow/nodes/IterationNode.vue +98 -0
  75. package/src/agent-flow/workflow/nodes/KnowledgeRetrievalNode.vue +253 -0
  76. package/src/agent-flow/workflow/nodes/LLMNode.vue +134 -0
  77. package/src/agent-flow/workflow/nodes/ListOperatorNode.vue +111 -0
  78. package/src/agent-flow/workflow/nodes/LoopNode.vue +94 -0
  79. package/src/agent-flow/workflow/nodes/ParameterExtractorNode.vue +147 -0
  80. package/src/agent-flow/workflow/nodes/ServiceApiNode.vue +161 -0
  81. package/src/agent-flow/workflow/nodes/StartNode.vue +199 -0
  82. package/src/agent-flow/workflow/nodes/TemplateNode.vue +103 -0
  83. package/src/agent-flow/workflow/nodes/UserInputNode.vue +92 -0
  84. package/src/agent-flow/workflow/nodes/VariableAssignerNode.vue +145 -0
  85. package/src/agent-flow/workflow/nodes/VariableNode.vue +130 -0
  86. package/src/agent-flow/workflow/nodes/_node-base.css +338 -0
  87. package/src/agent-flow/workflow/utils/node_card_form.ts +335 -0
  88. package/src/agent-flow/workflow/utils/node_config.ts +63 -0
  89. package/src/agent-flow/workflow/utils/workflow_utils.ts +151 -0
  90. package/src/agent-studio/adapters/springAgentStart.ts +390 -0
  91. package/src/agent-studio/api/index.ts +1 -0
  92. package/src/agent-studio/api/types.ts +173 -0
  93. package/src/agent-studio/components/AgentApiDocs.vue +500 -0
  94. package/src/agent-studio/components/AgentAppsPage.vue +1601 -0
  95. package/src/agent-studio/components/AgentCardGrid.vue +259 -0
  96. package/src/agent-studio/components/AgentChatPage.vue +553 -0
  97. package/src/agent-studio/components/AgentDebugPanel.vue +350 -0
  98. package/src/agent-studio/components/AgentLogsPanel.vue +391 -0
  99. package/src/agent-studio/components/AgentMonitorPanel.vue +204 -0
  100. package/src/agent-studio/components/AgentOrchestrate.vue +505 -0
  101. package/src/agent-studio/components/AgentPromptEditor.vue +237 -0
  102. package/src/agent-studio/components/AgentStudioShell.vue +227 -0
  103. package/src/agent-studio/components/AgentToolsPanel.vue +394 -0
  104. package/src/agent-studio/components/AgentVariablesPanel.vue +205 -0
  105. package/src/agent-studio/components/ApiKeyManager.vue +251 -0
  106. package/src/agent-studio/components/AppDesignDrawer.vue +3391 -0
  107. package/src/agent-studio/components/CreateAppModal.vue +737 -0
  108. package/src/agent-studio/components/SparkChart.vue +200 -0
  109. package/src/agent-studio/components/VariableEditorModal.vue +499 -0
  110. package/src/agent-studio/composables/useAgentStudio.ts +347 -0
  111. package/src/agent-studio/index.ts +60 -0
  112. package/src/agent-studio/panels/DrawerFlowDesigner.vue +203 -0
  113. package/src/agent-studio/panels/LogAnnotationPanel.vue +490 -0
  114. package/src/agent-studio/panels/MonitorPanel.vue +535 -0
  115. package/src/agent-studio/types.ts +242 -0
  116. package/src/index.ts +155 -0
  117. package/src/knowledge-hub/adapters/springAgentStart.ts +472 -0
  118. package/src/knowledge-hub/components/AddDocumentsWizard.vue +1452 -0
  119. package/src/knowledge-hub/components/CreateDatasetWizard.vue +1723 -0
  120. package/src/knowledge-hub/components/DatasetCardGrid.vue +467 -0
  121. package/src/knowledge-hub/components/DatasetDetailDrawer.vue +888 -0
  122. package/src/knowledge-hub/components/DatasetPicker.vue +65 -0
  123. package/src/knowledge-hub/components/DatasetPickerModal.vue +526 -0
  124. package/src/knowledge-hub/components/DatasetSettingsPanel.vue +908 -0
  125. package/src/knowledge-hub/components/DatasetSidebar.vue +781 -0
  126. package/src/knowledge-hub/components/DocumentChunksView.vue +802 -0
  127. package/src/knowledge-hub/components/DocumentTable.vue +552 -0
  128. package/src/knowledge-hub/components/HitTestingPanel.vue +74 -0
  129. package/src/knowledge-hub/components/KnowledgeApp.vue +66 -0
  130. package/src/knowledge-hub/components/KnowledgeHubApp.vue +504 -0
  131. package/src/knowledge-hub/components/RecallTestingPanelV2.vue +515 -0
  132. package/src/knowledge-hub/components/RetrievalConfigPopover.vue +270 -0
  133. package/src/knowledge-hub/components/RetrievalMethodPicker.vue +547 -0
  134. package/src/knowledge-hub/components/RetrievedList.vue +24 -0
  135. package/src/knowledge-hub/components/internal/KhDialog.vue +195 -0
  136. package/src/knowledge-hub/composables/useKnowledge.ts +89 -0
  137. package/src/knowledge-hub/i18n/index.ts +2 -0
  138. package/src/knowledge-hub/i18n/messages.ts +422 -0
  139. package/src/knowledge-hub/i18n/useKhI18n.ts +107 -0
  140. package/src/knowledge-hub/index.ts +46 -0
  141. package/src/knowledge-hub/styles/index.css +4 -0
  142. package/src/knowledge-hub/styles/tokens.css +138 -0
  143. package/src/knowledge-hub/types/api.ts +213 -0
  144. package/src/knowledge-hub/types/dataset.ts +88 -0
  145. package/src/knowledge-hub/types/document.ts +45 -0
  146. package/src/knowledge-hub/types/index.ts +9 -0
  147. package/src/knowledge-hub/types/retrieval.ts +46 -0
  148. package/src/provider-hub/components/CredentialForm.vue +103 -0
  149. package/src/provider-hub/components/DefaultModelsPanel.vue +270 -0
  150. package/src/provider-hub/components/GroupedModelSelect.vue +445 -0
  151. package/src/provider-hub/components/ModelCardGrid.vue +332 -0
  152. package/src/provider-hub/components/ModelParameterDrawer.vue +739 -0
  153. package/src/provider-hub/components/ModelPickerPopover.vue +1282 -0
  154. package/src/provider-hub/components/ProviderApp.vue +159 -0
  155. package/src/provider-hub/components/ProviderCredentialModal.vue +321 -0
  156. package/src/provider-hub/components/ProviderGallery.vue +131 -0
  157. package/src/provider-hub/components/ProviderHubShell.vue +1992 -0
  158. package/src/provider-hub/components/ProviderIcon.vue +130 -0
  159. package/src/provider-hub/composables/useProviderHub.ts +358 -0
  160. package/src/provider-hub/index.ts +43 -0
  161. package/src/provider-hub/svg/MiniMax.svg +1 -0
  162. package/src/provider-hub/svg/Volcengine.svg +1 -0
  163. package/src/provider-hub/svg/Zhipu.svg +1 -0
  164. package/src/provider-hub/svg/deepseek.svg +1 -0
  165. package/src/provider-hub/svg/moonshot.svg +1 -0
  166. package/src/provider-hub/svg/openai.svg +1 -0
  167. package/src/provider-hub/svg/qwen.svg +1 -0
  168. package/src/provider-hub/svg/siliconflow.svg +1 -0
  169. package/src/provider-hub/types.ts +256 -0
@@ -0,0 +1,65 @@
1
+ <script setup lang="ts">
2
+ import { onMounted, ref, watch } from 'vue';
3
+
4
+ import { useKnowledge } from '../composables/useKnowledge';
5
+ import type { Dataset } from '../types';
6
+
7
+ interface Props {
8
+ modelValue?: string[];
9
+ multiple?: boolean;
10
+ tenantId?: string;
11
+ placeholder?: string;
12
+ }
13
+
14
+ const props = withDefaults(defineProps<Props>(), {
15
+ modelValue: () => [],
16
+ multiple: true,
17
+ placeholder: '选择知识库',
18
+ });
19
+
20
+ const emit = defineEmits<{
21
+ (e: 'update:modelValue', v: string[]): void;
22
+ }>();
23
+
24
+ const options = ref<Dataset[]>([]);
25
+ const selected = ref<string[]>(props.modelValue);
26
+
27
+ watch(
28
+ () => props.modelValue,
29
+ (v) => (selected.value = v),
30
+ );
31
+ watch(selected, (v) => emit('update:modelValue', v));
32
+
33
+ onMounted(async () => {
34
+ const { listDatasets } = useKnowledge();
35
+ try {
36
+ options.value = await listDatasets(props.tenantId);
37
+ } catch {
38
+ options.value = [];
39
+ }
40
+ });
41
+ </script>
42
+
43
+ <template>
44
+ <!--
45
+ Note: this component intentionally does NOT depend on ant-design-vue — it
46
+ uses a native multi-select so any Vue 3 app can host it. Style it via the
47
+ class hooks below.
48
+ -->
49
+ <select
50
+ v-model="selected"
51
+ :multiple="multiple"
52
+ class="knowledge-hub-picker w-full rounded border px-2 py-1"
53
+ >
54
+ <option v-for="d in options" :key="d.id" :value="d.id">
55
+ {{ d.name }}
56
+ <span v-if="d.documentCount">· {{ d.documentCount }} 文档</span>
57
+ </option>
58
+ </select>
59
+ </template>
60
+
61
+ <style scoped>
62
+ .knowledge-hub-picker {
63
+ min-height: 32px;
64
+ }
65
+ </style>
@@ -0,0 +1,526 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * DatasetPickerModal — Dify-style "选择引用知识库" modal.
4
+ *
5
+ * One shared picker for every place that lets the user attach knowledge bases
6
+ * to something (AppDesignDrawer 知识库 card, workflow KNOWLEDGE_RETRIEVAL node
7
+ * config, etc.). It fetches the catalog itself via {@link useKnowledge}, but
8
+ * a caller with a pre-loaded list can bypass the fetch by passing `datasets`.
9
+ *
10
+ * Usage (v-model:open):
11
+ *
12
+ * <DatasetPickerModal
13
+ * v-model:open="open"
14
+ * :initial-selected-ids="ids"
15
+ * :tenant-id="tenantId"
16
+ * @submit="onDatasetsChosen"
17
+ * />
18
+ *
19
+ * The `submit` event carries the FULL {@link DatasetSummary} objects for the
20
+ * caller to render — most callers want name + indexingTechnique badges without
21
+ * having to look them up again.
22
+ */
23
+ import { computed, onMounted, ref, watch } from 'vue';
24
+
25
+ import { useKnowledge } from '../composables/useKnowledge';
26
+ import type { DatasetSummary, RetrievalConfig } from '../types';
27
+
28
+ interface Props {
29
+ /** v-model:open — controls modal visibility. */
30
+ open: boolean;
31
+ /** Pre-selected dataset ids. */
32
+ initialSelectedIds?: string[];
33
+ /** Optional pre-loaded catalog to skip the fetch. */
34
+ datasets?: DatasetSummary[];
35
+ /** Multi-tenant filter passed to the /datasets list endpoint. */
36
+ tenantId?: string;
37
+ /** Header text — override for custom flows. */
38
+ title?: string;
39
+ /** When true, only one dataset can be selected. */
40
+ single?: boolean;
41
+ }
42
+
43
+ const props = withDefaults(defineProps<Props>(), {
44
+ initialSelectedIds: () => [],
45
+ datasets: undefined,
46
+ tenantId: undefined,
47
+ title: '选择引用知识库',
48
+ single: false,
49
+ });
50
+
51
+ const emit = defineEmits<{
52
+ (e: 'update:open', v: boolean): void;
53
+ /** User confirmed — carries full dataset objects for the caller to render. */
54
+ (e: 'submit', datasets: DatasetSummary[]): void;
55
+ (e: 'cancel'): void;
56
+ }>();
57
+
58
+ // ---------------------------------------------------------------------------
59
+ // Catalog loading
60
+ // ---------------------------------------------------------------------------
61
+ const catalog = ref<DatasetSummary[]>([]);
62
+ const loading = ref(false);
63
+ const loadError = ref<string | null>(null);
64
+
65
+ async function loadCatalog() {
66
+ if (props.datasets) {
67
+ catalog.value = [...props.datasets];
68
+ return;
69
+ }
70
+ loading.value = true;
71
+ loadError.value = null;
72
+ try {
73
+ const { listDatasets } = useKnowledge();
74
+ catalog.value = await listDatasets(props.tenantId);
75
+ } catch (e) {
76
+ loadError.value = e instanceof Error ? e.message : String(e);
77
+ catalog.value = [];
78
+ } finally {
79
+ loading.value = false;
80
+ }
81
+ }
82
+
83
+ onMounted(() => {
84
+ if (props.open) loadCatalog();
85
+ });
86
+
87
+ watch(
88
+ () => props.open,
89
+ (open) => {
90
+ if (open) {
91
+ selected.value = new Set(props.initialSelectedIds);
92
+ search.value = '';
93
+ loadCatalog();
94
+ }
95
+ },
96
+ );
97
+
98
+ watch(
99
+ () => props.datasets,
100
+ (v) => {
101
+ if (v) catalog.value = [...v];
102
+ },
103
+ );
104
+
105
+ // ---------------------------------------------------------------------------
106
+ // Search + selection
107
+ // ---------------------------------------------------------------------------
108
+ const search = ref('');
109
+ const selected = ref<Set<string>>(new Set(props.initialSelectedIds));
110
+
111
+ const filtered = computed(() => {
112
+ const q = search.value.trim().toLowerCase();
113
+ if (!q) return catalog.value;
114
+ return catalog.value.filter(
115
+ (d) =>
116
+ (d.name ?? '').toLowerCase().includes(q) ||
117
+ (d.description ?? '').toLowerCase().includes(q),
118
+ );
119
+ });
120
+
121
+ function toggle(id: string) {
122
+ if (props.single) {
123
+ selected.value = new Set(selected.value.has(id) ? [] : [id]);
124
+ return;
125
+ }
126
+ const next = new Set(selected.value);
127
+ if (next.has(id)) next.delete(id);
128
+ else next.add(id);
129
+ selected.value = next;
130
+ }
131
+
132
+ function isSelected(id: string): boolean {
133
+ return selected.value.has(id);
134
+ }
135
+
136
+ // ---------------------------------------------------------------------------
137
+ // Retrieval-method badge (parsed from dataset.retrievalConfigJson) — matches
138
+ // the "混合检索 / 向量检索 / 全文检索" labels shown next to each row in Dify.
139
+ // ---------------------------------------------------------------------------
140
+ function methodLabel(d: DatasetSummary): null | string {
141
+ const raw = d.retrievalConfigJson;
142
+ if (!raw) return null;
143
+ try {
144
+ const cfg = JSON.parse(raw) as RetrievalConfig;
145
+ switch (cfg.method) {
146
+ case 'VECTOR':
147
+ return '向量检索';
148
+ case 'FULL_TEXT':
149
+ return '全文检索';
150
+ case 'HYBRID':
151
+ return '混合检索';
152
+ default:
153
+ return null;
154
+ }
155
+ } catch {
156
+ return null;
157
+ }
158
+ }
159
+
160
+ function techniqueLabel(d: DatasetSummary): null | string {
161
+ if (!d.indexingTechnique) return null;
162
+ return d.indexingTechnique === 'ECONOMY' ? '经济' : '高质量';
163
+ }
164
+
165
+ // ---------------------------------------------------------------------------
166
+ // Emit helpers
167
+ // ---------------------------------------------------------------------------
168
+ function close() {
169
+ emit('update:open', false);
170
+ }
171
+ function onCancel() {
172
+ emit('cancel');
173
+ close();
174
+ }
175
+ function onSubmit() {
176
+ const byId = new Map(catalog.value.map((d) => [d.id, d]));
177
+ const out: DatasetSummary[] = [];
178
+ for (const id of selected.value) {
179
+ const d = byId.get(id);
180
+ if (d) out.push(d);
181
+ }
182
+ emit('submit', out);
183
+ close();
184
+ }
185
+
186
+ function onMaskClick(e: MouseEvent) {
187
+ if (e.target === e.currentTarget) onCancel();
188
+ }
189
+ </script>
190
+
191
+ <template>
192
+ <Teleport to="body" :disabled="!open">
193
+ <div v-if="open" class="kh-dpm-mask" @click="onMaskClick">
194
+ <div class="kh-dpm-panel" role="dialog" aria-modal="true">
195
+ <div class="kh-dpm-header">
196
+ <span class="kh-dpm-title">{{ title }}</span>
197
+ <button class="kh-dpm-close" aria-label="关闭" @click="onCancel">
198
+
199
+ </button>
200
+ </div>
201
+
202
+ <div class="kh-dpm-search">
203
+ <span class="kh-dpm-search-icon" aria-hidden="true">🔍</span>
204
+ <input
205
+ v-model="search"
206
+ class="kh-dpm-search-input"
207
+ placeholder="搜索知识库..."
208
+ />
209
+ </div>
210
+
211
+ <div class="kh-dpm-list">
212
+ <div v-if="loading" class="kh-dpm-state">加载中…</div>
213
+ <div v-else-if="loadError" class="kh-dpm-state kh-dpm-state-error">
214
+ 加载失败:{{ loadError }}
215
+ </div>
216
+ <div v-else-if="filtered.length === 0" class="kh-dpm-state">
217
+ {{ catalog.length === 0 ? '暂无可选知识库' : '未匹配到任何知识库' }}
218
+ </div>
219
+ <button
220
+ v-for="d in filtered"
221
+ v-else
222
+ :key="d.id"
223
+ :class="['kh-dpm-item', { 'kh-dpm-item-on': isSelected(d.id) }]"
224
+ :aria-pressed="isSelected(d.id)"
225
+ @click="toggle(d.id)"
226
+ >
227
+ <span class="kh-dpm-item-icon" aria-hidden="true">📚</span>
228
+ <span class="kh-dpm-item-body">
229
+ <span class="kh-dpm-item-name" :title="d.name">
230
+ {{ d.name }}
231
+ </span>
232
+ <span v-if="d.description" class="kh-dpm-item-desc">
233
+ {{ d.description }}
234
+ </span>
235
+ </span>
236
+ <span class="kh-dpm-item-tags">
237
+ <span v-if="techniqueLabel(d)" class="kh-dpm-tag">
238
+ {{ techniqueLabel(d) }}
239
+ </span>
240
+ <span v-if="methodLabel(d)" class="kh-dpm-tag kh-dpm-tag-muted">
241
+ {{ methodLabel(d) }}
242
+ </span>
243
+ <span v-if="d.documentCount != null" class="kh-dpm-tag kh-dpm-tag-muted">
244
+ {{ d.documentCount }} 文档
245
+ </span>
246
+ </span>
247
+ <span class="kh-dpm-check" aria-hidden="true">
248
+ <span v-if="isSelected(d.id)">✓</span>
249
+ </span>
250
+ </button>
251
+ </div>
252
+
253
+ <div class="kh-dpm-footer">
254
+ <span class="kh-dpm-count">
255
+ {{ selected.size }} 个知识库被选中
256
+ </span>
257
+ <div class="kh-dpm-actions">
258
+ <button class="kh-dpm-btn kh-dpm-btn-ghost" @click="onCancel">
259
+ 取消
260
+ </button>
261
+ <button
262
+ class="kh-dpm-btn kh-dpm-btn-primary"
263
+ :disabled="selected.size === 0"
264
+ @click="onSubmit"
265
+ >
266
+ 添加
267
+ </button>
268
+ </div>
269
+ </div>
270
+ </div>
271
+ </div>
272
+ </Teleport>
273
+ </template>
274
+
275
+ <style scoped>
276
+ .kh-dpm-mask {
277
+ position: fixed;
278
+ inset: 0;
279
+ z-index: 1200;
280
+ background: rgba(15, 23, 42, 0.45);
281
+ display: flex;
282
+ align-items: center;
283
+ justify-content: center;
284
+ animation: kh-dpm-fade 0.14s ease-out;
285
+ }
286
+ @keyframes kh-dpm-fade {
287
+ from {
288
+ opacity: 0;
289
+ }
290
+ to {
291
+ opacity: 1;
292
+ }
293
+ }
294
+ .kh-dpm-panel {
295
+ width: 480px;
296
+ max-width: calc(100vw - 32px);
297
+ max-height: calc(100vh - 80px);
298
+ display: flex;
299
+ flex-direction: column;
300
+ background: #fff;
301
+ border-radius: 14px;
302
+ box-shadow:
303
+ 0 20px 60px rgba(15, 23, 42, 0.24),
304
+ 0 4px 12px rgba(15, 23, 42, 0.08);
305
+ overflow: hidden;
306
+ animation: kh-dpm-in 0.16s ease-out;
307
+ }
308
+ @keyframes kh-dpm-in {
309
+ from {
310
+ opacity: 0;
311
+ transform: translateY(-6px);
312
+ }
313
+ to {
314
+ opacity: 1;
315
+ transform: translateY(0);
316
+ }
317
+ }
318
+ .kh-dpm-header {
319
+ padding: 14px 18px;
320
+ display: flex;
321
+ align-items: center;
322
+ justify-content: space-between;
323
+ border-bottom: 1px solid #f1f5f9;
324
+ }
325
+ .kh-dpm-title {
326
+ font-size: 15px;
327
+ font-weight: 600;
328
+ color: #0f172a;
329
+ }
330
+ .kh-dpm-close {
331
+ width: 24px;
332
+ height: 24px;
333
+ padding: 0;
334
+ border: none;
335
+ background: transparent;
336
+ color: #94a3b8;
337
+ font-size: 14px;
338
+ cursor: pointer;
339
+ border-radius: 4px;
340
+ }
341
+ .kh-dpm-close:hover {
342
+ background: #f1f5f9;
343
+ color: #475569;
344
+ }
345
+
346
+ .kh-dpm-search {
347
+ position: relative;
348
+ padding: 12px 18px 8px;
349
+ }
350
+ .kh-dpm-search-icon {
351
+ position: absolute;
352
+ left: 28px;
353
+ top: 50%;
354
+ transform: translateY(-40%);
355
+ font-size: 12px;
356
+ color: #94a3b8;
357
+ pointer-events: none;
358
+ }
359
+ .kh-dpm-search-input {
360
+ width: 100%;
361
+ padding: 8px 12px 8px 30px;
362
+ font-size: 13px;
363
+ color: #0f172a;
364
+ background: #f8fafc;
365
+ border: 1px solid #e5e7eb;
366
+ border-radius: 8px;
367
+ }
368
+ .kh-dpm-search-input:focus {
369
+ outline: none;
370
+ background: #fff;
371
+ border-color: #6366f1;
372
+ box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
373
+ }
374
+
375
+ .kh-dpm-list {
376
+ flex: 1;
377
+ min-height: 200px;
378
+ max-height: 420px;
379
+ overflow-y: auto;
380
+ padding: 4px 12px 12px;
381
+ display: flex;
382
+ flex-direction: column;
383
+ gap: 6px;
384
+ }
385
+ .kh-dpm-state {
386
+ padding: 40px 12px;
387
+ text-align: center;
388
+ font-size: 12px;
389
+ color: #94a3b8;
390
+ }
391
+ .kh-dpm-state-error {
392
+ color: #dc2626;
393
+ }
394
+ .kh-dpm-item {
395
+ display: flex;
396
+ align-items: center;
397
+ gap: 10px;
398
+ padding: 10px 12px;
399
+ background: #fff;
400
+ border: 1px solid #e5e7eb;
401
+ border-radius: 8px;
402
+ cursor: pointer;
403
+ text-align: left;
404
+ transition:
405
+ border-color 0.15s,
406
+ background 0.15s;
407
+ }
408
+ .kh-dpm-item:hover {
409
+ border-color: #c7d2fe;
410
+ background: #f8fafc;
411
+ }
412
+ .kh-dpm-item-on {
413
+ border-color: #6366f1;
414
+ background: #eef2ff;
415
+ }
416
+ .kh-dpm-item-icon {
417
+ width: 28px;
418
+ height: 28px;
419
+ display: inline-flex;
420
+ align-items: center;
421
+ justify-content: center;
422
+ background: #eef2ff;
423
+ color: #4338ca;
424
+ border-radius: 6px;
425
+ font-size: 14px;
426
+ flex-shrink: 0;
427
+ }
428
+ .kh-dpm-item-body {
429
+ flex: 1;
430
+ min-width: 0;
431
+ display: flex;
432
+ flex-direction: column;
433
+ gap: 2px;
434
+ }
435
+ .kh-dpm-item-name {
436
+ font-size: 13px;
437
+ font-weight: 500;
438
+ color: #0f172a;
439
+ white-space: nowrap;
440
+ overflow: hidden;
441
+ text-overflow: ellipsis;
442
+ }
443
+ .kh-dpm-item-desc {
444
+ font-size: 11px;
445
+ color: #64748b;
446
+ white-space: nowrap;
447
+ overflow: hidden;
448
+ text-overflow: ellipsis;
449
+ }
450
+ .kh-dpm-item-tags {
451
+ display: inline-flex;
452
+ align-items: center;
453
+ gap: 4px;
454
+ flex-shrink: 0;
455
+ }
456
+ .kh-dpm-tag {
457
+ padding: 1px 6px;
458
+ font-size: 10px;
459
+ color: #4338ca;
460
+ background: #e0e7ff;
461
+ border-radius: 4px;
462
+ white-space: nowrap;
463
+ }
464
+ .kh-dpm-tag-muted {
465
+ color: #64748b;
466
+ background: #f1f5f9;
467
+ }
468
+ .kh-dpm-check {
469
+ width: 18px;
470
+ height: 18px;
471
+ display: inline-flex;
472
+ align-items: center;
473
+ justify-content: center;
474
+ border: 1.5px solid #cbd5e1;
475
+ border-radius: 4px;
476
+ color: #fff;
477
+ font-size: 11px;
478
+ flex-shrink: 0;
479
+ }
480
+ .kh-dpm-item-on .kh-dpm-check {
481
+ border-color: #6366f1;
482
+ background: #6366f1;
483
+ }
484
+
485
+ .kh-dpm-footer {
486
+ padding: 12px 18px;
487
+ display: flex;
488
+ align-items: center;
489
+ justify-content: space-between;
490
+ gap: 12px;
491
+ border-top: 1px solid #f1f5f9;
492
+ background: #fff;
493
+ }
494
+ .kh-dpm-count {
495
+ font-size: 12px;
496
+ color: #64748b;
497
+ }
498
+ .kh-dpm-actions {
499
+ display: flex;
500
+ gap: 8px;
501
+ }
502
+ .kh-dpm-btn {
503
+ padding: 5px 14px;
504
+ font-size: 13px;
505
+ border: none;
506
+ border-radius: 6px;
507
+ cursor: pointer;
508
+ transition: opacity 0.15s;
509
+ }
510
+ .kh-dpm-btn-ghost {
511
+ color: #64748b;
512
+ background: #fff;
513
+ border: 1px solid #e5e7eb;
514
+ }
515
+ .kh-dpm-btn-ghost:hover {
516
+ background: #f8fafc;
517
+ }
518
+ .kh-dpm-btn-primary {
519
+ color: #fff;
520
+ background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
521
+ }
522
+ .kh-dpm-btn-primary:disabled {
523
+ background: #cbd5e1;
524
+ cursor: not-allowed;
525
+ }
526
+ </style>