@tano.page/workbench 0.14.0 → 0.16.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 (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -0,0 +1,452 @@
1
+ <script setup lang="ts">
2
+ import { computed, nextTick, ref, watch } from 'vue';
3
+ import { Puzzle, Search, X } from 'lucide-vue-next';
4
+ import { t } from '../../i18n/i18n';
5
+ import type { PluginUiDialogRequest, PluginUiToastItem } from '../../stores/workspace-plugins-state';
6
+
7
+ const props = defineProps<{
8
+ dialog: PluginUiDialogRequest | null;
9
+ toasts: readonly PluginUiToastItem[];
10
+ }>();
11
+ const emit = defineEmits<{
12
+ resolve: [id: string, value: string | boolean | null];
13
+ dismissToast: [id: string];
14
+ }>();
15
+
16
+ const query = ref('');
17
+ const selectedIndex = ref(0);
18
+ const promptValue = ref('');
19
+ const inputRef = ref<HTMLInputElement>();
20
+
21
+ const filteredItems = computed(() => {
22
+ if (props.dialog?.kind !== 'pick') return [];
23
+ const q = query.value.trim().toLowerCase();
24
+ if (!q) return props.dialog.options.items;
25
+ return props.dialog.options.items.filter(
26
+ (item) =>
27
+ item.label.toLowerCase().includes(q) ||
28
+ item.description?.toLowerCase().includes(q) ||
29
+ item.detail?.toLowerCase().includes(q),
30
+ );
31
+ });
32
+
33
+ watch(
34
+ () => props.dialog?.id,
35
+ async () => {
36
+ query.value = '';
37
+ selectedIndex.value = 0;
38
+ promptValue.value = props.dialog?.kind === 'prompt' ? (props.dialog.options.defaultValue ?? '') : '';
39
+ if (props.dialog) {
40
+ await nextTick();
41
+ inputRef.value?.focus();
42
+ }
43
+ },
44
+ { immediate: true },
45
+ );
46
+
47
+ watch(filteredItems, (items) => {
48
+ if (selectedIndex.value >= items.length) selectedIndex.value = 0;
49
+ });
50
+
51
+ function cancel() {
52
+ if (!props.dialog) return;
53
+ emit('resolve', props.dialog.id, props.dialog.kind === 'confirm' ? false : null);
54
+ }
55
+
56
+ function confirmPrompt() {
57
+ if (props.dialog?.kind !== 'prompt') return;
58
+ emit('resolve', props.dialog.id, promptValue.value);
59
+ }
60
+
61
+ function choosePick(id: string) {
62
+ if (props.dialog?.kind !== 'pick') return;
63
+ emit('resolve', props.dialog.id, id);
64
+ }
65
+
66
+ function handleKeydown(event: KeyboardEvent) {
67
+ if (!props.dialog) return;
68
+ if (event.key === 'Escape') {
69
+ event.preventDefault();
70
+ event.stopPropagation();
71
+ cancel();
72
+ return;
73
+ }
74
+ if (props.dialog.kind === 'pick') {
75
+ const items = filteredItems.value;
76
+ if (!items.length) return;
77
+ if (event.key === 'ArrowDown') {
78
+ event.preventDefault();
79
+ selectedIndex.value = (selectedIndex.value + 1) % items.length;
80
+ } else if (event.key === 'ArrowUp') {
81
+ event.preventDefault();
82
+ selectedIndex.value = (selectedIndex.value - 1 + items.length) % items.length;
83
+ } else if (event.key === 'Enter') {
84
+ event.preventDefault();
85
+ const target = items[selectedIndex.value];
86
+ if (target) choosePick(target.id);
87
+ }
88
+ }
89
+ }
90
+ </script>
91
+
92
+ <template>
93
+ <div
94
+ v-if="dialog"
95
+ class="plugin-ui-backdrop"
96
+ role="presentation"
97
+ @mousedown.self="cancel"
98
+ @keydown="handleKeydown"
99
+ >
100
+ <section
101
+ class="plugin-ui-dialog"
102
+ role="dialog"
103
+ aria-modal="true"
104
+ :aria-label="dialog.options.title"
105
+ >
106
+ <header class="plugin-ui-header">
107
+ <div class="plugin-ui-source">
108
+ <Puzzle :size="13" aria-hidden="true" />
109
+ <span>{{ t('插件:{0}', [dialog.pluginName]) }}</span>
110
+ </div>
111
+ <button type="button" class="plugin-ui-close" :aria-label="t('取消')" @click="cancel">
112
+ <X :size="15" />
113
+ </button>
114
+ </header>
115
+ <h3 class="plugin-ui-title">{{ dialog.options.title }}</h3>
116
+
117
+ <template v-if="dialog.kind === 'pick'">
118
+ <div class="plugin-ui-search">
119
+ <Search :size="14" aria-hidden="true" />
120
+ <input
121
+ ref="inputRef"
122
+ v-model="query"
123
+ type="text"
124
+ :placeholder="dialog.options.placeholder || t('输入关键词筛选…')"
125
+ :aria-label="dialog.options.placeholder || dialog.options.title"
126
+ autocomplete="off"
127
+ />
128
+ </div>
129
+ <ul v-if="filteredItems.length" class="plugin-ui-list" role="listbox">
130
+ <li
131
+ v-for="(item, index) in filteredItems"
132
+ :key="item.id"
133
+ role="option"
134
+ :aria-selected="index === selectedIndex"
135
+ >
136
+ <button
137
+ type="button"
138
+ class="plugin-ui-option"
139
+ :class="{ active: index === selectedIndex }"
140
+ @mouseenter="selectedIndex = index"
141
+ @click="choosePick(item.id)"
142
+ >
143
+ <div class="plugin-ui-option-head">
144
+ <strong>{{ item.label }}</strong>
145
+ <span v-if="item.description" class="plugin-ui-option-desc">{{ item.description }}</span>
146
+ </div>
147
+ <p v-if="item.detail" class="plugin-ui-option-detail">{{ item.detail }}</p>
148
+ </button>
149
+ </li>
150
+ </ul>
151
+ <p v-else class="plugin-ui-empty">{{ t('没有匹配的选项') }}</p>
152
+ </template>
153
+
154
+ <form v-else-if="dialog.kind === 'prompt'" class="plugin-ui-form" @submit.prevent="confirmPrompt">
155
+ <p v-if="dialog.options.message" class="plugin-ui-message">{{ dialog.options.message }}</p>
156
+ <input
157
+ ref="inputRef"
158
+ v-model="promptValue"
159
+ type="text"
160
+ class="plugin-ui-input"
161
+ :placeholder="dialog.options.placeholder"
162
+ :aria-label="dialog.options.title"
163
+ autocomplete="off"
164
+ />
165
+ <div class="plugin-ui-actions">
166
+ <button type="button" class="plugin-ui-btn" @click="cancel">{{ t('取消') }}</button>
167
+ <button type="submit" class="plugin-ui-btn primary">
168
+ {{ dialog.options.confirmLabel || t('确定') }}
169
+ </button>
170
+ </div>
171
+ </form>
172
+
173
+ <div v-else class="plugin-ui-form">
174
+ <p v-if="dialog.options.message" class="plugin-ui-message">{{ dialog.options.message }}</p>
175
+ <div class="plugin-ui-actions">
176
+ <button type="button" class="plugin-ui-btn" @click="cancel">
177
+ {{ dialog.options.cancelLabel || t('取消') }}
178
+ </button>
179
+ <button
180
+ type="button"
181
+ class="plugin-ui-btn"
182
+ :class="dialog.options.danger ? 'danger' : 'primary'"
183
+ @click="emit('resolve', dialog.id, true)"
184
+ >
185
+ {{ dialog.options.confirmLabel || t('确认') }}
186
+ </button>
187
+ </div>
188
+ </div>
189
+ </section>
190
+ </div>
191
+
192
+ <div v-if="toasts.length" class="plugin-toast-stack" role="status" aria-live="polite">
193
+ <div
194
+ v-for="toast in toasts"
195
+ :key="toast.id"
196
+ class="plugin-toast"
197
+ :class="`tone-${toast.tone}`"
198
+ >
199
+ <div class="plugin-toast-body">
200
+ <strong>{{ toast.pluginName }}</strong>
201
+ <span>{{ toast.message }}</span>
202
+ </div>
203
+ <button
204
+ type="button"
205
+ class="plugin-toast-close"
206
+ :aria-label="t('关闭提示')"
207
+ @click="emit('dismissToast', toast.id)"
208
+ >
209
+ <X :size="13" />
210
+ </button>
211
+ </div>
212
+ </div>
213
+ </template>
214
+
215
+ <style scoped>
216
+ .plugin-ui-backdrop {
217
+ position: fixed;
218
+ inset: 0;
219
+ z-index: 120;
220
+ display: flex;
221
+ align-items: flex-start;
222
+ justify-content: center;
223
+ padding: min(14vh, 108px) 16px 24px;
224
+ background: rgb(0 0 0 / 32%);
225
+ }
226
+ .plugin-ui-dialog {
227
+ width: min(480px, 100%);
228
+ max-height: 72vh;
229
+ display: flex;
230
+ flex-direction: column;
231
+ gap: 10px;
232
+ padding: 16px;
233
+ border: 1px solid var(--line);
234
+ border-radius: var(--radius-dialog, 12px);
235
+ background: var(--paper);
236
+ color: var(--text);
237
+ box-shadow: var(--dialog-shadow, 0 20px 56px rgb(0 0 0 / 26%));
238
+ }
239
+ .plugin-ui-header {
240
+ display: flex;
241
+ align-items: center;
242
+ justify-content: space-between;
243
+ gap: 8px;
244
+ }
245
+ .plugin-ui-source {
246
+ display: inline-flex;
247
+ align-items: center;
248
+ gap: 5px;
249
+ font-size: 11px;
250
+ color: var(--muted);
251
+ }
252
+ .plugin-ui-close {
253
+ display: inline-flex;
254
+ align-items: center;
255
+ justify-content: center;
256
+ width: 24px;
257
+ height: 24px;
258
+ border-radius: 6px;
259
+ color: var(--muted);
260
+ }
261
+ .plugin-ui-close:hover {
262
+ background: var(--hover);
263
+ color: var(--text);
264
+ }
265
+ .plugin-ui-title {
266
+ margin: 0;
267
+ font-size: 15px;
268
+ font-weight: 600;
269
+ line-height: 1.4;
270
+ }
271
+ .plugin-ui-message {
272
+ margin: 0;
273
+ font-size: 13px;
274
+ line-height: 1.6;
275
+ color: var(--muted);
276
+ white-space: pre-wrap;
277
+ overflow-wrap: anywhere;
278
+ }
279
+ .plugin-ui-search {
280
+ display: flex;
281
+ align-items: center;
282
+ gap: 8px;
283
+ padding: 0 10px;
284
+ height: 36px;
285
+ border: 1px solid var(--control-border, var(--line));
286
+ border-radius: var(--radius-control, 8px);
287
+ background: var(--surface, var(--paper));
288
+ color: var(--muted);
289
+ }
290
+ .plugin-ui-search input {
291
+ flex: 1;
292
+ min-width: 0;
293
+ border: 0;
294
+ background: transparent;
295
+ color: var(--text);
296
+ font-size: 13px;
297
+ outline: none;
298
+ }
299
+ .plugin-ui-list {
300
+ list-style: none;
301
+ margin: 0;
302
+ padding: 0;
303
+ overflow-y: auto;
304
+ max-height: 300px;
305
+ display: flex;
306
+ flex-direction: column;
307
+ gap: 2px;
308
+ }
309
+ .plugin-ui-option {
310
+ width: 100%;
311
+ text-align: left;
312
+ padding: 8px 10px;
313
+ border-radius: 7px;
314
+ display: flex;
315
+ flex-direction: column;
316
+ gap: 3px;
317
+ color: var(--text);
318
+ }
319
+ .plugin-ui-option:hover,
320
+ .plugin-ui-option.active {
321
+ background: var(--selected, var(--hover));
322
+ }
323
+ .plugin-ui-option-head {
324
+ display: flex;
325
+ align-items: baseline;
326
+ justify-content: space-between;
327
+ gap: 8px;
328
+ }
329
+ .plugin-ui-option-head strong {
330
+ font-size: 13px;
331
+ font-weight: 500;
332
+ }
333
+ .plugin-ui-option-desc,
334
+ .plugin-ui-option-detail {
335
+ margin: 0;
336
+ font-size: 12px;
337
+ color: var(--muted);
338
+ overflow-wrap: anywhere;
339
+ }
340
+ .plugin-ui-empty {
341
+ margin: 6px 0;
342
+ font-size: 12px;
343
+ color: var(--muted);
344
+ text-align: center;
345
+ }
346
+ .plugin-ui-form {
347
+ display: flex;
348
+ flex-direction: column;
349
+ gap: 12px;
350
+ }
351
+ .plugin-ui-input {
352
+ width: 100%;
353
+ box-sizing: border-box;
354
+ height: 36px;
355
+ padding: 0 10px;
356
+ border: 1px solid var(--control-border, var(--line));
357
+ border-radius: var(--radius-control, 8px);
358
+ background: var(--surface, var(--paper));
359
+ color: var(--text);
360
+ font-size: 13px;
361
+ }
362
+ .plugin-ui-input:focus {
363
+ outline: 2px solid var(--green);
364
+ outline-offset: -1px;
365
+ }
366
+ .plugin-ui-actions {
367
+ display: flex;
368
+ justify-content: flex-end;
369
+ gap: 8px;
370
+ }
371
+ .plugin-ui-btn {
372
+ height: 32px;
373
+ padding: 0 14px;
374
+ border: 1px solid var(--line);
375
+ border-radius: var(--radius-control, 7px);
376
+ background: var(--surface, var(--paper));
377
+ color: var(--text);
378
+ font-size: 13px;
379
+ }
380
+ .plugin-ui-btn:hover {
381
+ background: var(--hover);
382
+ }
383
+ .plugin-ui-btn.primary {
384
+ border-color: var(--green);
385
+ background: var(--green);
386
+ color: #fff;
387
+ }
388
+ .plugin-ui-btn.danger {
389
+ border-color: var(--danger, #c4483d);
390
+ background: var(--danger, #c4483d);
391
+ color: #fff;
392
+ }
393
+ .plugin-toast-stack {
394
+ position: fixed;
395
+ right: 18px;
396
+ bottom: 34px;
397
+ z-index: 115;
398
+ display: flex;
399
+ flex-direction: column;
400
+ gap: 8px;
401
+ max-width: min(360px, calc(100vw - 32px));
402
+ pointer-events: none;
403
+ }
404
+ .plugin-toast {
405
+ pointer-events: auto;
406
+ display: flex;
407
+ align-items: flex-start;
408
+ gap: 10px;
409
+ padding: 10px 12px;
410
+ border: 1px solid var(--line);
411
+ border-left: 3px solid var(--muted);
412
+ border-radius: 9px;
413
+ background: var(--paper);
414
+ color: var(--text);
415
+ box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
416
+ font-size: 12px;
417
+ }
418
+ .plugin-toast.tone-success {
419
+ border-left-color: var(--brand-green, var(--green));
420
+ }
421
+ .plugin-toast.tone-warning {
422
+ border-left-color: #d9822b;
423
+ }
424
+ .plugin-toast.tone-error {
425
+ border-left-color: var(--danger, #c4483d);
426
+ }
427
+ .plugin-toast-body {
428
+ flex: 1;
429
+ min-width: 0;
430
+ display: flex;
431
+ flex-direction: column;
432
+ gap: 2px;
433
+ }
434
+ .plugin-toast-body strong {
435
+ font-size: 11px;
436
+ color: var(--muted);
437
+ font-weight: 500;
438
+ }
439
+ .plugin-toast-body span {
440
+ line-height: 1.5;
441
+ overflow-wrap: anywhere;
442
+ }
443
+ .plugin-toast-close {
444
+ color: var(--muted);
445
+ padding: 2px;
446
+ border-radius: 4px;
447
+ }
448
+ .plugin-toast-close:hover {
449
+ background: var(--hover);
450
+ color: var(--text);
451
+ }
452
+ </style>
@@ -0,0 +1,61 @@
1
+ <script setup lang="ts">
2
+ import type { Workspace } from '@tano/protocol';
3
+ import { t } from '../../i18n/i18n';
4
+ import type { WorkbenchActions, WorkbenchExtensions } from '../../runtime';
5
+ import { PluginInstaller } from '../../shell/workbench-async-components';
6
+
7
+ defineProps<{
8
+ workspace: Workspace;
9
+ objectReferencesEnabled: boolean;
10
+ developerMode: boolean;
11
+ extensions: WorkbenchExtensions;
12
+ extensionActions: WorkbenchActions;
13
+ }>();
14
+
15
+ const emit = defineEmits<{
16
+ 'enable-developer-mode': [];
17
+ 'create-object': [type: string];
18
+ }>();
19
+ </script>
20
+
21
+ <template>
22
+ <main class="plugins-tab-page">
23
+ <div class="plugins-tab-content">
24
+ <p v-if="!objectReferencesEnabled" class="tool-level-notice">
25
+ {{ t('「工作区对象与引用」已关闭,插件对象和关系暂时只读。可在工作区设置中重新启用。') }}
26
+ </p>
27
+ <p v-else-if="workspace.readOnly" class="tool-level-notice">
28
+ {{ t('此工作区为只读,无法修改对象和关系。') }}
29
+ </p>
30
+ <PluginInstaller
31
+ :developer-mode="developerMode"
32
+ @enable-developer-mode="emit('enable-developer-mode')"
33
+ @create-object="emit('create-object', $event)"
34
+ >
35
+ <template v-if="extensions.regions['plugin-customize']" #customize="{ developerMode: devMode }">
36
+ <component
37
+ :is="extensions.regions['plugin-customize']"
38
+ :actions="extensionActions"
39
+ :developer-mode="devMode"
40
+ />
41
+ </template>
42
+ <template v-if="extensions.regions['plugin-forge']" #forge="{ canPublish, openPublishing, developerMode: devMode }">
43
+ <component
44
+ :is="extensions.regions['plugin-forge']"
45
+ :actions="extensionActions"
46
+ :can-publish="canPublish"
47
+ :developer-mode="devMode"
48
+ @open-publishing="openPublishing"
49
+ />
50
+ </template>
51
+ <template v-if="extensions.regions['plugin-publishing']" #publishing="{ developerMode: devMode }">
52
+ <component
53
+ :is="extensions.regions['plugin-publishing']"
54
+ :actions="extensionActions"
55
+ :developer-mode="devMode"
56
+ />
57
+ </template>
58
+ </PluginInstaller>
59
+ </div>
60
+ </main>
61
+ </template>
@@ -581,3 +581,8 @@
581
581
  .plugin-policy { display: grid; gap: 12px; }
582
582
  .plugin-policy label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
583
583
  .plugin-policy select, .plugin-policy input, .plugin-policy textarea { padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
584
+ .workspace-plugin-policy { margin: 16px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
585
+ .workspace-plugin-policy label { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
586
+ .workspace-plugin-policy select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--text); font: inherit; font-size: 12.5px; }
587
+ .dev-optin-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
588
+ .dev-optin-link:hover { color: var(--text); background: var(--hover); }
@@ -1,86 +1,9 @@
1
- import { canonicalPluginJson, pluginRecord } from '@tano/protocol';
2
- import type { PluginPage, PluginPageOptions, PluginTextEdit, PluginEvent } from './plugin-sdk';
3
- import { assistantHash } from '../assistant/hash';
4
-
5
- export function pluginQueryOptions(value: unknown, allowed: readonly string[]) {
6
- const options = value === undefined ? {} : value;
7
- if (!pluginRecord(options) || Object.keys(options).some(key => ![...allowed, 'limit', 'cursor', 'direction'].includes(key))) throw new Error('查询参数无效');
8
- if (options.limit !== undefined && (!Number.isInteger(options.limit) || Number(options.limit) < 1 || Number(options.limit) > 100)) throw new Error('每页数量必须为 1 至 100');
9
- if (options.cursor !== undefined && (typeof options.cursor !== 'string' || options.cursor.length > 100)) throw new Error('分页游标无效');
10
- if (options.direction !== undefined && !['asc', 'desc'].includes(String(options.direction))) throw new Error('查询排序方向无效');
11
- return options;
12
- }
13
- export function queryText(value: unknown, limit = 200): string | undefined {
14
- if (value === undefined) return undefined;
15
- if (typeof value !== 'string' || value.length > limit) throw new Error('查询文本无效');
16
- return value;
17
- }
18
- export function queryBoolean(value: unknown): boolean | undefined {
19
- if (value !== undefined && typeof value !== 'boolean') throw new Error('查询条件必须为布尔值');
20
- return value as boolean | undefined;
21
- }
22
- export const compareQueryText = (a: string, b: string) => a < b ? -1 : a > b ? 1 : 0;
23
-
24
- /** Cursors never contain workspace data and are bound to an execution instance and query revision. */
25
- export class PluginQueryPager {
26
- private cursors = new Map<string, { scope: string; signature: string; offset: number; expires: number }>();
27
- clear() { this.cursors.clear(); }
28
- async page<T, R = T>(scope: string, method: string, options: PluginPageOptions, revision: unknown, rows: T[],
29
- project: (row: T) => Promise<R | undefined> = async row => row as unknown as R,
30
- assertCurrent: () => void = () => {}, scanLimit = Number.POSITIVE_INFINITY): Promise<PluginPage<R>> {
31
- const { cursor, ...query } = options;
32
- const signature = await assistantHash(canonicalPluginJson([method, query, revision]));
33
- assertCurrent();
34
- for (const [key, value] of this.cursors) if (value.expires < Date.now()) this.cursors.delete(key);
35
- const previous = cursor ? this.cursors.get(cursor) : undefined;
36
- if (cursor && (!previous || previous.scope !== scope || previous.signature !== signature)) throw new Error('查询结果已变化或分页已过期,请从第一页重新查询');
37
- let offset = previous?.offset ?? 0, scanned = 0, bytes = 0;
38
- const items: R[] = [], limit = options.limit ?? 50;
39
- while (offset < rows.length && items.length < limit && scanned < scanLimit) {
40
- assertCurrent();
41
- const item = await project(rows[offset]!);
42
- assertCurrent();
43
- if (item !== undefined) {
44
- const size = new TextEncoder().encode(JSON.stringify(item)).length;
45
- if (size > 256 * 1024) throw new Error('单条查询结果超过 256 KB,请缩小对象内容');
46
- if (bytes + size > 256 * 1024) break;
47
- items.push(item); bytes += size;
48
- }
49
- offset++; scanned++;
50
- }
51
- const result: PluginPage<R> = { items };
52
- if (scanLimit === Number.POSITIVE_INFINITY) result.total = rows.length;
53
- if (offset < rows.length) {
54
- result.nextCursor = crypto.randomUUID();
55
- this.cursors.set(result.nextCursor, { scope, signature, offset, expires: Date.now() + 60_000 });
56
- if (this.cursors.size > 128) this.cursors.delete(this.cursors.keys().next().value!);
57
- }
58
- return result;
59
- }
60
- }
61
-
62
- export function applyPluginTextEdits(content: string, value: unknown): string {
63
- if (!Array.isArray(value) || !value.length || value.length > 100) throw new Error('编辑事务需要 1 至 100 个修改');
64
- const edits: PluginTextEdit[] = value.map(edit => {
65
- if (!pluginRecord(edit) || Object.keys(edit).some(key => !['from', 'to', 'insert'].includes(key)) ||
66
- !Number.isInteger(edit.from) || !Number.isInteger(edit.to) || Number(edit.from) < 0 || Number(edit.to) < Number(edit.from) ||
67
- Number(edit.to) > content.length || typeof edit.insert !== 'string') throw new Error('编辑范围无效');
68
- const splitsSurrogate = (offset: number) => /[\uD800-\uDBFF]/.test(content[offset - 1] ?? '') && /[\uDC00-\uDFFF]/.test(content[offset] ?? '');
69
- if (splitsSurrogate(Number(edit.from)) || splitsSurrogate(Number(edit.to))) throw new Error('编辑范围不能拆分 Unicode 字符');
70
- return edit as unknown as PluginTextEdit;
71
- }).sort((a, b) => a.from - b.from || a.to - b.to);
72
- for (let i = 1; i < edits.length; i++) if (edits[i]!.from < edits[i - 1]!.to || edits[i]!.from === edits[i - 1]!.from) throw new Error('编辑范围不能重叠');
73
- let next = content;
74
- for (const edit of edits.reverse()) next = next.slice(0, edit.from) + edit.insert + next.slice(edit.to);
75
- if (next.length > 512000) throw new Error('编辑后的文档超过大小限制');
76
- return next;
77
- }
78
-
79
- /** Deltas expose identities only; permission checks occur again before delivery in the host. */
80
- export function pluginChanges(type: Exclude<PluginEvent['type'], 'workspace.changed'>, before: Map<string, string>, after: Map<string, string>): PluginEvent | undefined {
81
- const changes: { id: string; kind: 'created' | 'updated' | 'deleted' }[] = [];
82
- for (const [id, stamp] of after) if (before.get(id) !== stamp) changes.push({ id, kind: before.has(id) ? 'updated' : 'created' });
83
- for (const id of before.keys()) if (!after.has(id)) changes.push({ id, kind: 'deleted' });
84
- if (!changes.length) return;
85
- return changes.length > 100 ? { type, changes: [], reset: true } : { type, changes };
86
- }
1
+ export {
2
+ applyPluginTextEdits,
3
+ compareQueryText,
4
+ pluginChanges,
5
+ PluginQueryPager,
6
+ pluginQueryOptions,
7
+ queryBoolean,
8
+ queryText,
9
+ } from '@tano/protocol/plugin-data';