@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.
- package/package.json +50 -16
- package/src/App.vue +82 -752
- package/src/appearance/appearance.ts +14 -4
- package/src/appearance/components/ThemePresetPreview.vue +52 -8
- package/src/appearance/interface-font.ts +99 -0
- package/src/appearance/theme.ts +26 -10
- package/src/appearance/use-interface-font.ts +30 -0
- package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
- package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
- package/src/assets/mail-provider-icons/gmail.svg +1 -0
- package/src/assets/mail-provider-icons/icloud.svg +12 -0
- package/src/assets/mail-provider-icons/netease-126.svg +5 -0
- package/src/assets/mail-provider-icons/netease-163.svg +5 -0
- package/src/assets/mail-provider-icons/qq.svg +9 -0
- package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +425 -8
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -532
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/files.ts +5 -13
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/language.ts +10 -37
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -58
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +167 -327
- package/src/assistant/structures.ts +1 -155
- package/src/assistant/tasks.ts +8 -96
- package/src/assistant/tool-rules.ts +1 -7
- package/src/assistant/workspace-bridge.ts +1 -1
- package/src/composables/use-document-actions.ts +38 -20
- package/src/composables/use-file-tree-controller.ts +7 -12
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-history.ts +2 -4
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +40 -1021
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/features.ts +1 -0
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
- package/src/fonts/Inter-Latin.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
- package/src/help/help-milestones.ts +3 -5
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +371 -3
- package/src/i18n/locales/en-US.json +371 -2
- package/src/i18n/locales/es-ES.json +371 -3
- package/src/i18n/locales/ja-JP.json +370 -2
- package/src/i18n/locales/zh-TW.json +370 -2
- package/src/mail/components/MailAccountDialog.vue +450 -0
- package/src/mail/components/MailComposerDialog.vue +326 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +821 -0
- package/src/mail/components/SidebarMail.vue +134 -0
- package/src/mail/mail-avatar.ts +17 -0
- package/src/mail/mail-bridge.ts +68 -0
- package/src/mail/mail-calendar.ts +208 -0
- package/src/mail/mail-markdown.ts +195 -0
- package/src/mail/types.ts +226 -0
- package/src/objects/components/ObjectDetailModal.vue +1001 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +3 -4
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +65 -9
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +264 -748
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/PlanDateField.vue +6 -4
- package/src/plans/components/PlanDetailPanel.vue +227 -32
- package/src/plans/components/PlanEventList.vue +16 -4
- package/src/plans/components/SidebarPlan.vue +22 -15
- package/src/plans/components/TaskRepeatControls.vue +169 -30
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plans/local-reminders.ts +149 -0
- package/src/plans/personal-plans.ts +10 -1
- package/src/plans/plan-date.ts +8 -1
- package/src/plans/plan-migration.ts +95 -0
- package/src/plans/recurrence.ts +95 -0
- package/src/plans/task-repeat.ts +8 -8
- package/src/plans/timeline-layout.ts +92 -0
- package/src/plugins/assistant-bridge.ts +520 -0
- package/src/plugins/attachment-reader.ts +3 -1
- package/src/plugins/cache-storage.ts +42 -2
- package/src/plugins/components/PluginAutomations.vue +3 -3
- package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
- package/src/plugins/components/PluginChangeSummary.vue +16 -3
- package/src/plugins/components/PluginConnections.vue +1 -1
- package/src/plugins/components/PluginCustomView.vue +2 -2
- package/src/plugins/components/PluginDetailPage.vue +136 -57
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +21 -25
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +273 -288
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +37 -34
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +112 -0
- package/src/plugins/components/PluginStatusBar.vue +161 -0
- package/src/plugins/components/PluginSurface.vue +18 -6
- package/src/plugins/components/PluginUiDialog.vue +452 -0
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
- package/src/plugins/excalidraw/manifest.json +12 -1
- package/src/plugins/host.ts +662 -43
- package/src/plugins/native.ts +2 -10
- package/src/plugins/overlay-mapping.ts +125 -0
- package/src/plugins/packages.ts +73 -1
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-permissions.ts +57 -0
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -94
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/policy.ts +53 -3
- package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/presentation-preview/manifest.json +2 -1
- package/src/plugins/queries.ts +1 -73
- package/src/plugins/sandbox.ts +15 -1
- package/src/plugins/use-plugin-actions.ts +67 -20
- package/src/plugins/user-plugins.ts +254 -0
- package/src/plugins/view-header.ts +2 -7
- package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/word-preview/manifest.json +13 -1
- package/src/plugins/workbench.ts +175 -2
- package/src/plugins/worker.js +105 -8
- package/src/plugins/workspace-plugin-runtime.ts +23 -7
- package/src/plugins/workspace-plugins.ts +212 -21
- package/src/runtime.ts +103 -4
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/components/settings-search.ts +2 -3
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +58 -34
- package/src/shell/components/WorkbenchModals.vue +47 -62
- package/src/shell/components/WorkbenchPanes.vue +371 -1342
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +531 -1153
- package/src/shell/workbench-async-components.ts +14 -5
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/mail.ts +414 -0
- package/src/stores/plan-sync.ts +2 -1
- package/src/stores/plans.ts +2 -9
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +2 -114
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +254 -259
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +6 -44
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +184 -1363
- package/src/styles/agent-diff-modals.css +0 -7
- package/src/styles/dark-theme.css +3 -3
- package/src/styles/inspector.css +0 -59
- package/src/styles/layout-themes.css +346 -0
- package/src/styles/mail.css +1568 -0
- package/src/styles/mobile.css +2 -2
- package/src/styles/recent-and-media.css +0 -17
- package/src/styles/theme-contract.css +3 -3
- package/src/styles/workbench-shell.css +110 -17
- package/src/styles/workspace-states.css +9 -33
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -14
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- package/src/assistant/locales/de-DE.json +0 -126
- package/src/assistant/locales/en-US.json +0 -126
- package/src/assistant/locales/es-ES.json +0 -126
- package/src/assistant/locales/ja-JP.json +0 -126
- package/src/assistant/locales/zh-CN.json +0 -126
- package/src/assistant/locales/zh-TW.json +0 -126
- package/src/assistant/task-prompts.json +0 -39
- package/src/documents/components/FormulaMenu.vue +0 -50
- package/src/files/components/FileDatabasePage.vue +0 -152
- package/src/files/components/FolderHomeIcon.vue +0 -12
- package/src/objects/components/ObjectDatabasePage.vue +0 -100
- package/src/objects/components/ObjectPanel.vue +0 -554
- package/src/plans/components/PersonalPlanDialog.vue +0 -105
- package/src/shell/components/WorkspaceViewPage.vue +0 -127
- package/src/shell/components/WorkspaceViewTab.vue +0 -24
- package/src/styles/object-panel.css +0 -163
- package/src/workspace/components/GitInspectionPanel.vue +0 -35
- package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
- package/src/workspace/welcome-slogans.ts +0 -11
- package/src/workspace/workspace-git.ts +0 -35
- package/src/workspace/workspace-sync.ts +0 -46
- package/src/workspace/workspace-views.ts +0 -48
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { CheckCircle2, Globe, Plug, ShieldAlert } from 'lucide-vue-next';
|
|
4
|
+
import type { AssistantProposal } from '@tano/protocol';
|
|
5
|
+
import { t } from '../../i18n/i18n';
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{ proposal: AssistantProposal; busy?: boolean }>();
|
|
8
|
+
|
|
9
|
+
interface StructuredEntry {
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
complex: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function parseEntries(raw: string): { entries: StructuredEntry[]; rawFallback?: string } {
|
|
16
|
+
const trimmed = raw.trim();
|
|
17
|
+
if (!trimmed) return { entries: [] };
|
|
18
|
+
try {
|
|
19
|
+
const parsed: unknown = JSON.parse(trimmed);
|
|
20
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
21
|
+
const entries = Object.entries(parsed as Record<string, unknown>).map(([key, value]) => {
|
|
22
|
+
if (value === null) return { key, value: 'null', complex: false };
|
|
23
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
24
|
+
return { key, value: String(value), complex: false };
|
|
25
|
+
}
|
|
26
|
+
return { key, value: JSON.stringify(value, null, 2), complex: true };
|
|
27
|
+
});
|
|
28
|
+
return { entries };
|
|
29
|
+
}
|
|
30
|
+
return { entries: [], rawFallback: JSON.stringify(parsed, null, 2) };
|
|
31
|
+
} catch {
|
|
32
|
+
return { entries: [], rawFallback: raw };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const action = computed(() => props.proposal.pluginAction);
|
|
37
|
+
const isExternal = computed(() => action.value?.effect === 'external');
|
|
38
|
+
const parsedParams = computed(() => parseEntries(props.proposal.content));
|
|
39
|
+
const parsedReceipt = computed(() =>
|
|
40
|
+
props.proposal.status === 'applied' && props.proposal.applied?.after !== undefined
|
|
41
|
+
? parseEntries(props.proposal.applied.after)
|
|
42
|
+
: null,
|
|
43
|
+
);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<div class="plugin-tool-card" :class="{ 'plugin-tool-external': isExternal }">
|
|
48
|
+
<div class="plugin-tool-header">
|
|
49
|
+
<span class="plugin-tool-identity">
|
|
50
|
+
<Plug :size="13" />
|
|
51
|
+
<strong>{{ action?.pluginName ?? proposal.path }}</strong>
|
|
52
|
+
<span v-if="action" class="plugin-tool-name">{{ action.label ?? action.toolName }}</span>
|
|
53
|
+
</span>
|
|
54
|
+
<span class="plugin-effect-badge" :class="isExternal ? 'effect-external' : 'effect-write'">
|
|
55
|
+
<Globe v-if="isExternal" :size="11" />
|
|
56
|
+
<ShieldAlert v-else :size="11" />
|
|
57
|
+
{{ isExternal ? t('外部调用 · 需确认') : t('写入操作 · 需确认') }}
|
|
58
|
+
</span>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<p class="plugin-tool-hint">
|
|
62
|
+
{{
|
|
63
|
+
isExternal
|
|
64
|
+
? t('此操作将由插件发起外部调用,请确认参数后执行。')
|
|
65
|
+
: t('此操作将由插件执行写入,请确认参数后执行。')
|
|
66
|
+
}}
|
|
67
|
+
</p>
|
|
68
|
+
|
|
69
|
+
<div class="plugin-tool-section">
|
|
70
|
+
<div class="plugin-tool-section-label">{{ t('调用参数') }}</div>
|
|
71
|
+
<dl v-if="parsedParams.entries.length" class="plugin-tool-kv">
|
|
72
|
+
<template v-for="entry in parsedParams.entries" :key="entry.key">
|
|
73
|
+
<dt>{{ entry.key }}</dt>
|
|
74
|
+
<dd>
|
|
75
|
+
<pre v-if="entry.complex" class="plugin-tool-code"><code>{{ entry.value }}</code></pre>
|
|
76
|
+
<span v-else>{{ entry.value }}</span>
|
|
77
|
+
</dd>
|
|
78
|
+
</template>
|
|
79
|
+
</dl>
|
|
80
|
+
<pre v-else-if="parsedParams.rawFallback" class="plugin-tool-code"><code>{{ parsedParams.rawFallback }}</code></pre>
|
|
81
|
+
<p v-else class="plugin-tool-empty">{{ t('无额外参数') }}</p>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div v-if="parsedReceipt" class="plugin-tool-receipt" role="status">
|
|
85
|
+
<div class="plugin-tool-receipt-heading">
|
|
86
|
+
<CheckCircle2 :size="13" />
|
|
87
|
+
<span>{{ t('真实执行回执') }}</span>
|
|
88
|
+
</div>
|
|
89
|
+
<dl v-if="parsedReceipt.entries.length" class="plugin-tool-kv">
|
|
90
|
+
<template v-for="entry in parsedReceipt.entries" :key="`receipt-${entry.key}`">
|
|
91
|
+
<dt>{{ entry.key }}</dt>
|
|
92
|
+
<dd>
|
|
93
|
+
<pre v-if="entry.complex" class="plugin-tool-code"><code>{{ entry.value }}</code></pre>
|
|
94
|
+
<span v-else>{{ entry.value }}</span>
|
|
95
|
+
</dd>
|
|
96
|
+
</template>
|
|
97
|
+
</dl>
|
|
98
|
+
<pre v-else-if="parsedReceipt.rawFallback" class="plugin-tool-code"><code>{{ parsedReceipt.rawFallback }}</code></pre>
|
|
99
|
+
<p v-else class="plugin-tool-empty">{{ t('已执行,无返回数据') }}</p>
|
|
100
|
+
<details v-if="proposal.applied?.after" class="plugin-tool-raw">
|
|
101
|
+
<summary>{{ t('查看完整 JSON 回执') }}</summary>
|
|
102
|
+
<pre class="plugin-tool-code"><code>{{ proposal.applied.after }}</code></pre>
|
|
103
|
+
</details>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
.plugin-tool-card {
|
|
110
|
+
margin: 8px 0;
|
|
111
|
+
padding: 10px 12px;
|
|
112
|
+
border: 1px solid var(--line);
|
|
113
|
+
border-radius: 7px;
|
|
114
|
+
background: var(--paper);
|
|
115
|
+
font-size: 12px;
|
|
116
|
+
display: grid;
|
|
117
|
+
gap: 8px;
|
|
118
|
+
}
|
|
119
|
+
.plugin-tool-header {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-wrap: wrap;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
gap: 6px;
|
|
125
|
+
}
|
|
126
|
+
.plugin-tool-identity {
|
|
127
|
+
display: inline-flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: 5px;
|
|
130
|
+
min-width: 0;
|
|
131
|
+
color: var(--text);
|
|
132
|
+
}
|
|
133
|
+
.plugin-tool-identity svg {
|
|
134
|
+
flex-shrink: 0;
|
|
135
|
+
color: var(--muted);
|
|
136
|
+
}
|
|
137
|
+
.plugin-tool-name {
|
|
138
|
+
color: var(--text-secondary);
|
|
139
|
+
}
|
|
140
|
+
.plugin-effect-badge {
|
|
141
|
+
display: inline-flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 4px;
|
|
144
|
+
padding: 2px 7px;
|
|
145
|
+
border-radius: 999px;
|
|
146
|
+
font-size: 10px;
|
|
147
|
+
font-weight: 500;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
}
|
|
150
|
+
.effect-write {
|
|
151
|
+
background: var(--accent);
|
|
152
|
+
color: var(--text-secondary);
|
|
153
|
+
}
|
|
154
|
+
.effect-external {
|
|
155
|
+
background: color-mix(in srgb, var(--warning, #b97a16) 16%, var(--paper));
|
|
156
|
+
color: var(--warning, #9a620b);
|
|
157
|
+
}
|
|
158
|
+
.plugin-tool-hint {
|
|
159
|
+
margin: 0;
|
|
160
|
+
color: var(--muted);
|
|
161
|
+
font-size: 11px;
|
|
162
|
+
line-height: 1.5;
|
|
163
|
+
}
|
|
164
|
+
.plugin-tool-section {
|
|
165
|
+
display: grid;
|
|
166
|
+
gap: 6px;
|
|
167
|
+
}
|
|
168
|
+
.plugin-tool-section-label {
|
|
169
|
+
color: var(--muted);
|
|
170
|
+
font-size: 11px;
|
|
171
|
+
font-weight: 500;
|
|
172
|
+
}
|
|
173
|
+
.plugin-tool-kv {
|
|
174
|
+
display: grid;
|
|
175
|
+
grid-template-columns: minmax(72px, auto) minmax(0, 1fr);
|
|
176
|
+
gap: 5px 10px;
|
|
177
|
+
margin: 0;
|
|
178
|
+
padding: 8px 10px;
|
|
179
|
+
border-radius: 6px;
|
|
180
|
+
background: var(--surface);
|
|
181
|
+
}
|
|
182
|
+
.plugin-tool-kv dt {
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
font-family: var(--font-mono, monospace);
|
|
185
|
+
font-size: 11px;
|
|
186
|
+
word-break: break-word;
|
|
187
|
+
}
|
|
188
|
+
.plugin-tool-kv dd {
|
|
189
|
+
margin: 0;
|
|
190
|
+
min-width: 0;
|
|
191
|
+
color: var(--text);
|
|
192
|
+
overflow-wrap: anywhere;
|
|
193
|
+
}
|
|
194
|
+
.plugin-tool-code {
|
|
195
|
+
margin: 0;
|
|
196
|
+
padding: 6px 8px;
|
|
197
|
+
border-radius: 5px;
|
|
198
|
+
background: var(--surface);
|
|
199
|
+
font-size: 11px;
|
|
200
|
+
line-height: 1.45;
|
|
201
|
+
overflow: auto;
|
|
202
|
+
max-height: 180px;
|
|
203
|
+
}
|
|
204
|
+
.plugin-tool-kv .plugin-tool-code {
|
|
205
|
+
background: var(--paper);
|
|
206
|
+
}
|
|
207
|
+
.plugin-tool-empty {
|
|
208
|
+
margin: 0;
|
|
209
|
+
color: var(--muted);
|
|
210
|
+
font-size: 11px;
|
|
211
|
+
}
|
|
212
|
+
.plugin-tool-receipt {
|
|
213
|
+
display: grid;
|
|
214
|
+
gap: 6px;
|
|
215
|
+
padding-top: 8px;
|
|
216
|
+
border-top: 1px solid var(--line);
|
|
217
|
+
}
|
|
218
|
+
.plugin-tool-receipt-heading {
|
|
219
|
+
display: inline-flex;
|
|
220
|
+
align-items: center;
|
|
221
|
+
gap: 5px;
|
|
222
|
+
color: var(--green);
|
|
223
|
+
font-size: 11px;
|
|
224
|
+
font-weight: 500;
|
|
225
|
+
}
|
|
226
|
+
.plugin-tool-raw summary {
|
|
227
|
+
cursor: pointer;
|
|
228
|
+
color: var(--muted);
|
|
229
|
+
font-size: 11px;
|
|
230
|
+
user-select: none;
|
|
231
|
+
}
|
|
232
|
+
.plugin-tool-raw .plugin-tool-code {
|
|
233
|
+
margin-top: 6px;
|
|
234
|
+
}
|
|
235
|
+
</style>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
isAssistantModelId,
|
|
4
|
+
isAssistantReasoningSelection,
|
|
5
|
+
type AssistantConnection,
|
|
6
|
+
type AssistantQuotaConfig,
|
|
7
|
+
type AssistantReasoningSelection,
|
|
8
|
+
type AssistantSession,
|
|
9
|
+
type AssistantTransport,
|
|
10
|
+
} from '@tano/protocol';
|
|
11
|
+
import { recordHelpCompleted } from '../help/help-checklist';
|
|
12
|
+
import type { useWorkspaceStore } from '../stores/workspace';
|
|
13
|
+
|
|
14
|
+
export interface AssistantConnectionActionDeps {
|
|
15
|
+
transport: AssistantTransport | undefined;
|
|
16
|
+
canConfigure: boolean;
|
|
17
|
+
opened: Ref<boolean>;
|
|
18
|
+
loading: Ref<boolean>;
|
|
19
|
+
busy: Ref<boolean>;
|
|
20
|
+
applying: Ref<boolean>;
|
|
21
|
+
connections: Ref<AssistantConnection[]>;
|
|
22
|
+
connectionId: Ref<string>;
|
|
23
|
+
connection: ComputedRef<AssistantConnection | undefined>;
|
|
24
|
+
modelId: Ref<string>;
|
|
25
|
+
reasoningEffort: Ref<AssistantReasoningSelection>;
|
|
26
|
+
models: Ref<string[]>;
|
|
27
|
+
modelsLoading: Ref<boolean>;
|
|
28
|
+
modelsError: Ref<string>;
|
|
29
|
+
session: Ref<AssistantSession | null>;
|
|
30
|
+
workspace: ReturnType<typeof useWorkspaceStore>;
|
|
31
|
+
getGeneration: () => number;
|
|
32
|
+
newSession: () => void;
|
|
33
|
+
persist: (target?: AssistantSession | null) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createAssistantConnectionActions(deps: AssistantConnectionActionDeps) {
|
|
37
|
+
const {
|
|
38
|
+
transport,
|
|
39
|
+
canConfigure,
|
|
40
|
+
opened,
|
|
41
|
+
loading,
|
|
42
|
+
busy,
|
|
43
|
+
applying,
|
|
44
|
+
connections,
|
|
45
|
+
connectionId,
|
|
46
|
+
connection,
|
|
47
|
+
modelId,
|
|
48
|
+
reasoningEffort,
|
|
49
|
+
models,
|
|
50
|
+
modelsLoading,
|
|
51
|
+
modelsError,
|
|
52
|
+
session,
|
|
53
|
+
workspace,
|
|
54
|
+
getGeneration,
|
|
55
|
+
newSession,
|
|
56
|
+
persist,
|
|
57
|
+
} = deps;
|
|
58
|
+
|
|
59
|
+
let modelController: AbortController | undefined;
|
|
60
|
+
|
|
61
|
+
function abortModels() {
|
|
62
|
+
modelController?.abort();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function reloadConnections() {
|
|
66
|
+
if (!transport) return;
|
|
67
|
+
const epoch = getGeneration();
|
|
68
|
+
const loaded = (await transport.connections()).map(({ managed, ...item }) => ({
|
|
69
|
+
...item,
|
|
70
|
+
platformProvider: item.platformProvider ?? managed,
|
|
71
|
+
}));
|
|
72
|
+
if (epoch !== getGeneration()) return;
|
|
73
|
+
connections.value = loaded;
|
|
74
|
+
if (!connectionId.value && !session.value?.connectionId)
|
|
75
|
+
connectionId.value = connections.value.length === 1 ? connections.value[0].id : '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function reloadModels() {
|
|
79
|
+
modelController?.abort();
|
|
80
|
+
models.value = []; modelsError.value = ''; modelsLoading.value = false;
|
|
81
|
+
const selected = connection.value;
|
|
82
|
+
if (!transport || !selected || !opened.value) return;
|
|
83
|
+
const abort = new AbortController(); modelController = abort;
|
|
84
|
+
modelsLoading.value = true;
|
|
85
|
+
try {
|
|
86
|
+
const values = await transport.models(selected.id, abort.signal);
|
|
87
|
+
if (abort.signal.aborted || modelController !== abort || connectionId.value !== selected.id || !opened.value) return;
|
|
88
|
+
if (!Array.isArray(values) || values.length > 1000 || values.some(value => !isAssistantModelId(value)))
|
|
89
|
+
throw new Error('模型列表格式无效');
|
|
90
|
+
models.value = [...new Set(values)];
|
|
91
|
+
if (!models.value.length) modelsError.value = '服务未返回可用模型';
|
|
92
|
+
} catch (reason) {
|
|
93
|
+
if (!abort.signal.aborted && modelController === abort) modelsError.value = String(reason);
|
|
94
|
+
} finally {
|
|
95
|
+
if (modelController === abort) { modelsLoading.value = false; modelController = undefined; }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function refreshModels() {
|
|
100
|
+
if (busy.value || applying.value || loading.value) return;
|
|
101
|
+
modelsLoading.value = true; modelsError.value = '';
|
|
102
|
+
try { await reloadConnections(); await reloadModels(); }
|
|
103
|
+
catch (reason) { modelsError.value = reason instanceof Error ? reason.message : String(reason); }
|
|
104
|
+
finally { modelsLoading.value = false; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function readConnectionKey(id: string) {
|
|
108
|
+
if (!canConfigure || !connections.value.some(item => item.id === id && !item.platformProvider && item.hasKey && (!item.kind || item.kind === 'api')))
|
|
109
|
+
throw new Error('此连接无法读取 API 密钥');
|
|
110
|
+
if (!transport?.readConnectionKey) throw new Error('当前环境不支持读取已保存的密钥,请更新并重启桌面版');
|
|
111
|
+
return transport.readConnectionKey(id);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function queryQuota(id: string) {
|
|
115
|
+
if (!transport?.quota) throw new Error('当前环境不支持服务商额度查询,请使用桌面版');
|
|
116
|
+
if (!connections.value.some(item => item.id === id && !item.platformProvider)) throw new Error('此连接不支持个人额度查询');
|
|
117
|
+
return transport.quota(id);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function saveQuota(id: string, config: AssistantQuotaConfig, key?: string) {
|
|
121
|
+
if (!transport?.saveQuota) throw new Error('当前环境不支持额度配置,请使用桌面版');
|
|
122
|
+
if (!connections.value.some(item => item.id === id && !item.platformProvider)) throw new Error('连接已移除或由平台管理');
|
|
123
|
+
await transport.saveQuota(id, config, key);
|
|
124
|
+
await reloadConnections();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function checkConnection(id: string, signal: AbortSignal) {
|
|
128
|
+
signal.throwIfAborted();
|
|
129
|
+
if (!transport) throw new Error('当前运行环境未提供助手连接配置');
|
|
130
|
+
if (!connections.value.some(item => item.id === id)) throw new Error('模型连接已移除');
|
|
131
|
+
const values = await transport.models(id, signal);
|
|
132
|
+
signal.throwIfAborted();
|
|
133
|
+
if (!Array.isArray(values) || values.length > 1000 || values.some(value => !isAssistantModelId(value)))
|
|
134
|
+
throw new Error('模型列表格式无效');
|
|
135
|
+
return new Set(values).size;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function selectConnection(id: string, reset = false) {
|
|
139
|
+
if (busy.value || applying.value || loading.value) return;
|
|
140
|
+
if (!connections.value.some(item => item.id === id)) throw new Error('模型连接已移除');
|
|
141
|
+
if (id === connectionId.value && !reset) return;
|
|
142
|
+
connectionId.value = id; modelId.value = '';
|
|
143
|
+
reasoningEffort.value = connection.value?.reasoningEffort ?? 'medium';
|
|
144
|
+
// Connection settings are personal and can be edited from the standalone
|
|
145
|
+
// settings window, where no workspace conversation is loaded.
|
|
146
|
+
if (!session.value && workspace.workspace) newSession();
|
|
147
|
+
if (session.value) {
|
|
148
|
+
session.value.connectionId = id; delete session.value.model;
|
|
149
|
+
if (connection.value?.kind === 'codex-cli') session.value.reasoningEffort = reasoningEffort.value;
|
|
150
|
+
else delete session.value.reasoningEffort;
|
|
151
|
+
await persist();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function selectModel(id: string) {
|
|
156
|
+
if (busy.value || applying.value || loading.value) return;
|
|
157
|
+
const selected = id.trim();
|
|
158
|
+
if (!connection.value) throw new Error('请先选择模型连接');
|
|
159
|
+
if (!isAssistantModelId(selected)) throw new Error('模型 ID 无效');
|
|
160
|
+
if (!session.value) newSession();
|
|
161
|
+
modelId.value = selected; session.value!.model = selected; session.value!.connectionId = connectionId.value;
|
|
162
|
+
await persist();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function restoreModelSelection(target: AssistantSession | null) {
|
|
166
|
+
connectionId.value = target?.connectionId ?? (connections.value.length === 1 ? connections.value[0].id : '');
|
|
167
|
+
const previous = target ? [...target.messages].reverse().find(message => message.role === 'assistant' && message.model)?.model : undefined;
|
|
168
|
+
modelId.value = target?.model ?? (isAssistantModelId(previous) ? previous : '');
|
|
169
|
+
reasoningEffort.value = target?.reasoningEffort ?? connection.value?.reasoningEffort ?? (target ? 'cli-default' : 'medium');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function selectReasoningEffort(value: AssistantReasoningSelection) {
|
|
173
|
+
if (busy.value || applying.value || loading.value) return;
|
|
174
|
+
if (connection.value?.kind !== 'codex-cli') throw new Error('当前连接不支持选择推理强度');
|
|
175
|
+
if (!isAssistantReasoningSelection(value)) throw new Error('推理强度无效');
|
|
176
|
+
if (!session.value) newSession();
|
|
177
|
+
reasoningEffort.value = value;
|
|
178
|
+
session.value!.reasoningEffort = value;
|
|
179
|
+
session.value!.connectionId = connectionId.value;
|
|
180
|
+
await persist();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function saveConnection(config: Omit<AssistantConnection, 'hasKey'>, key?: string) {
|
|
184
|
+
if (!transport || busy.value || applying.value || loading.value) throw new Error('请先等待当前任务完成');
|
|
185
|
+
const previous = connections.value.find(item => item.id === config.id);
|
|
186
|
+
if (!canConfigure || config.platformProvider || previous?.platformProvider) throw new Error('此模型连接由平台管理员配置');
|
|
187
|
+
await transport.saveConnection(config, key);
|
|
188
|
+
recordHelpCompleted('assistant-connection');
|
|
189
|
+
await reloadConnections();
|
|
190
|
+
await selectConnection(
|
|
191
|
+
config.id,
|
|
192
|
+
previous?.endpoint !== config.endpoint ||
|
|
193
|
+
(previous?.kind ?? 'api') !== (config.kind ?? 'api') ||
|
|
194
|
+
previous?.cliPath !== config.cliPath,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const canImportCcSwitch = canConfigure && !!transport?.scanCcSwitch && !!transport?.importCcSwitch;
|
|
199
|
+
|
|
200
|
+
async function scanCcSwitch(path?: string) {
|
|
201
|
+
if (!canImportCcSwitch) throw new Error('当前环境不支持从 CC Switch 导入');
|
|
202
|
+
return transport!.scanCcSwitch!(path);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function importCcSwitch(ids: string[], path?: string) {
|
|
206
|
+
if (!canImportCcSwitch || busy.value || applying.value || loading.value) throw new Error('请先等待当前任务完成');
|
|
207
|
+
await transport!.importCcSwitch!(ids, path);
|
|
208
|
+
await reloadConnections();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function removeConnection(id: string) {
|
|
212
|
+
if (!transport || busy.value || applying.value || loading.value) throw new Error('请先等待当前任务完成');
|
|
213
|
+
if (!canConfigure || connections.value.find(item => item.id === id)?.platformProvider) throw new Error('此模型连接由平台管理员配置');
|
|
214
|
+
await transport.removeConnection(id);
|
|
215
|
+
await reloadConnections();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
abortModels,
|
|
220
|
+
canImportCcSwitch,
|
|
221
|
+
reloadConnections,
|
|
222
|
+
reloadModels,
|
|
223
|
+
refreshModels,
|
|
224
|
+
readConnectionKey,
|
|
225
|
+
queryQuota,
|
|
226
|
+
saveQuota,
|
|
227
|
+
checkConnection,
|
|
228
|
+
selectConnection,
|
|
229
|
+
selectModel,
|
|
230
|
+
restoreModelSelection,
|
|
231
|
+
selectReasoningEffort,
|
|
232
|
+
saveConnection,
|
|
233
|
+
scanCcSwitch,
|
|
234
|
+
importCcSwitch,
|
|
235
|
+
removeConnection,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { mentionIdFromTitle, parseReferenceUrl } from '@tano/protocol';
|
|
3
|
-
import type { MentionEvent } from '@tano/protocol';
|
|
4
|
-
import type { Nodes } from 'mdast';
|
|
5
|
-
|
|
6
|
-
/** Parse syntax, so code examples, metadata and images cannot dispatch work. */
|
|
7
|
-
export function documentMentionEvents(workspaceId: string, fileId: string, content: string, revision: string,
|
|
8
|
-
actorId: string, createdAt: number): MentionEvent[] {
|
|
9
|
-
const { tree, offset } = parseDocumentMarkdown(content);
|
|
10
|
-
const events: MentionEvent[] = [];
|
|
11
|
-
const seen = new Set<string>();
|
|
12
|
-
function visit(node: Nodes, block?: Nodes) {
|
|
13
|
-
if (['paragraph', 'heading', 'tableCell'].includes(node.type)) block = node;
|
|
14
|
-
if (node.type === 'link') {
|
|
15
|
-
const reference = parseReferenceUrl(node.url);
|
|
16
|
-
const mentionId = mentionIdFromTitle(node.title);
|
|
17
|
-
if (reference?.type !== 'person' || !mentionId || !block || !('position' in block) || !block.position || seen.has(mentionId)) return;
|
|
18
|
-
const from = (block.position.start.offset ?? 0) + offset;
|
|
19
|
-
const to = (block.position.end.offset ?? 0) + offset;
|
|
20
|
-
const body = content.slice(from, to);
|
|
21
|
-
if (!body.trim() || body.length > 20000) return;
|
|
22
|
-
seen.add(mentionId);
|
|
23
|
-
events.push({ id: JSON.stringify(['document', fileId, mentionId]), workspaceId, personId: reference.id,
|
|
24
|
-
actorId, body, revision, createdAt, source: { kind: 'document', fileId, mentionId,
|
|
25
|
-
anchor: { basis: 'source', baseHash: revision, spans: [{ from, to, text: body }],
|
|
26
|
-
prefix: content.slice(Math.max(0, from - 128), from), suffix: content.slice(to, to + 128) } } });
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if ('children' in node) node.children.forEach(child => visit(child, block));
|
|
30
|
-
}
|
|
31
|
-
visit(tree);
|
|
32
|
-
return events;
|
|
33
|
-
}
|
|
1
|
+
export * from '@tano/editor/document-mentions';
|