@tano.page/workbench 0.15.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 (118) hide show
  1. package/package.json +35 -14
  2. package/src/App.vue +68 -797
  3. package/src/assistant/agent-identities.ts +1 -97
  4. package/src/assistant/agent-task-context.ts +1 -54
  5. package/src/assistant/attachments.ts +1 -1
  6. package/src/assistant/completion.ts +1 -61
  7. package/src/assistant/components/AssistantPanel.vue +1 -1
  8. package/src/assistant/connection-actions.ts +237 -0
  9. package/src/assistant/document-mentions.ts +1 -33
  10. package/src/assistant/engine.ts +1 -585
  11. package/src/assistant/execution.ts +6 -33
  12. package/src/assistant/hash.ts +1 -4
  13. package/src/assistant/language.ts +10 -37
  14. package/src/assistant/plugin-bridge-builder.ts +146 -0
  15. package/src/assistant/prompts.ts +1 -65
  16. package/src/assistant/proposal-actions.ts +336 -0
  17. package/src/assistant/store.ts +87 -554
  18. package/src/assistant/structures.ts +1 -157
  19. package/src/assistant/tasks.ts +8 -94
  20. package/src/assistant/tool-rules.ts +1 -7
  21. package/src/composables/use-workbench-help.ts +177 -0
  22. package/src/composables/use-workbench-lifecycle.ts +249 -0
  23. package/src/composables/use-workbench-settings.ts +185 -0
  24. package/src/composables/use-workbench-shortcuts.ts +37 -1022
  25. package/src/composables/use-workbench-views.ts +325 -0
  26. package/src/documents/components/DocumentActionMenu.vue +279 -0
  27. package/src/documents/components/DocumentInspector.vue +168 -0
  28. package/src/documents/components/DocumentPane.vue +482 -0
  29. package/src/documents/description-merge.ts +1 -9
  30. package/src/files/components/FileMetadataPanel.vue +49 -15
  31. package/src/i18n/locale-catalogs.ts +7 -6
  32. package/src/i18n/locale-registry.ts +8 -6
  33. package/src/i18n/locales/de-DE.json +23 -1
  34. package/src/i18n/locales/en-US.json +23 -1
  35. package/src/i18n/locales/es-ES.json +23 -1
  36. package/src/i18n/locales/ja-JP.json +23 -1
  37. package/src/i18n/locales/zh-TW.json +23 -1
  38. package/src/mail/components/MailAccountDialog.vue +1 -0
  39. package/src/mail/components/MailComposerDialog.vue +1 -0
  40. package/src/mail/components/MailWorkspaceView.vue +1 -0
  41. package/src/mail/components/SidebarMail.vue +1 -0
  42. package/src/objects/content-references.ts +6 -56
  43. package/src/objects/wiki-links.ts +1 -48
  44. package/src/objects/workspace-objects.ts +2 -3
  45. package/src/plans/calendar.ts +2 -2
  46. package/src/plans/components/CalendarAgendaView.vue +165 -0
  47. package/src/plans/components/CalendarFilterBar.vue +128 -0
  48. package/src/plans/components/CalendarMonthView.vue +224 -0
  49. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  50. package/src/plans/components/CalendarTimelineView.vue +517 -0
  51. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  52. package/src/plans/components/CalendarView.vue +162 -2106
  53. package/src/plans/components/CalendarYearView.vue +138 -0
  54. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  55. package/src/plans/components/calendar-shared.css +192 -0
  56. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  57. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  58. package/src/plugins/components/PluginDetailPage.vue +10 -6
  59. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  60. package/src/plugins/components/PluginExplorer.vue +6 -4
  61. package/src/plugins/components/PluginImportDialog.vue +1 -1
  62. package/src/plugins/components/PluginInstaller.vue +269 -178
  63. package/src/plugins/components/PluginMaintenance.vue +37 -49
  64. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  65. package/src/plugins/components/PluginSettingsForm.vue +2 -1
  66. package/src/plugins/components/PluginsTabPage.vue +61 -0
  67. package/src/plugins/components/plugin-center.css +5 -0
  68. package/src/plugins/data.ts +9 -86
  69. package/src/plugins/editor-plugin-adapters.ts +169 -0
  70. package/src/plugins/plugin-data.ts +2 -3
  71. package/src/plugins/plugin-rpc-router.ts +558 -0
  72. package/src/plugins/plugin-sdk.ts +1 -260
  73. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  74. package/src/plugins/queries.ts +1 -75
  75. package/src/plugins/view-header.ts +2 -7
  76. package/src/runtime.ts +3 -2
  77. package/src/settings/components/SettingsPanel.vue +8 -3
  78. package/src/settings/components/WorkbenchSettings.vue +20 -7
  79. package/src/settings/components/settings-context.ts +1 -1
  80. package/src/settings/settings-tab.ts +1 -0
  81. package/src/shell/command-palette.ts +3 -3
  82. package/src/shell/components/EditorToolbar.vue +8 -9
  83. package/src/shell/components/EditorTools.vue +1 -5
  84. package/src/shell/components/PaneTopbar.vue +393 -0
  85. package/src/shell/components/SelectionToolbar.vue +0 -2
  86. package/src/shell/components/WorkbenchContextMenus.vue +37 -26
  87. package/src/shell/components/WorkbenchModals.vue +22 -18
  88. package/src/shell/components/WorkbenchPanes.vue +358 -1512
  89. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  90. package/src/shell/pane-registry.ts +69 -0
  91. package/src/shell/use-surface-dismissal.ts +219 -0
  92. package/src/shell/use-workbench-commands.ts +599 -0
  93. package/src/shell/use-workbench-keybindings.ts +337 -0
  94. package/src/shell/use-workbench.ts +488 -1081
  95. package/src/shell/workbench-context.ts +30 -3
  96. package/src/stores/workspace-document-io.ts +807 -0
  97. package/src/stores/workspace-file-ops.ts +1 -1
  98. package/src/stores/workspace-knowledge.ts +1 -1
  99. package/src/stores/workspace-lifecycle.ts +459 -0
  100. package/src/stores/workspace-plugins-state.ts +71 -599
  101. package/src/stores/workspace-session.ts +287 -0
  102. package/src/stores/workspace-tabs-layout.ts +1 -1
  103. package/src/stores/workspace-types.ts +50 -0
  104. package/src/stores/workspace.ts +163 -1345
  105. package/src/styles.css +0 -1
  106. package/src/tabs/components/DesktopTabs.vue +19 -11
  107. package/src/windows/AuxiliaryWindows.vue +2 -2
  108. package/src/windows/use-window-event-bridge.ts +152 -0
  109. package/src/workspace/components/TemplateLibrary.vue +1 -1
  110. package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
  111. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  112. package/src/assistant/locales/de-DE.json +0 -129
  113. package/src/assistant/locales/en-US.json +0 -129
  114. package/src/assistant/locales/es-ES.json +0 -129
  115. package/src/assistant/locales/ja-JP.json +0 -129
  116. package/src/assistant/locales/zh-CN.json +0 -129
  117. package/src/assistant/locales/zh-TW.json +0 -129
  118. package/src/assistant/task-prompts.json +0 -39
@@ -1,260 +1 @@
1
- /** Public, browser-first SDK. Import types only; the runtime supplies `tano` to activate(). */
2
- import type {
3
- PluginViewNode,
4
- PluginJson,
5
- WorkspaceObject,
6
- WorkspaceRelation,
7
- PluginConnectionRequest,
8
- PluginConnectionResponse,
9
- PluginPlatform,
10
- PluginEngines,
11
- PluginErrorCode,
12
- PluginStatusBarItem,
13
- PluginUiPickOptions,
14
- PluginUiPromptOptions,
15
- PluginUiConfirmOptions,
16
- PluginUiTone,
17
- PluginSlashCommandDefinition,
18
- PluginActiveEditorSnapshot,
19
- PluginFrontmatterPatch,
20
- PluginCodeBlockRendererDefinition,
21
- PluginEditorDecorationTone,
22
- PluginEditorDecoration,
23
- PluginAttachmentWriteRequest,
24
- WorkspacePersonalPluginPolicy,
25
- PluginAssistantToolEffect,
26
- PluginAssistantToolDefinition,
27
- PluginAssistantContextProviderDefinition,
28
- PluginAiCompleteRequest,
29
- PluginAiStructuredRequest,
30
- PluginAiCompleteResult,
31
- PluginAiStructuredResult,
32
- PluginServiceDefinition,
33
- PluginServiceDependency,
34
- } from '@tano/protocol';
35
- export type {
36
- PluginManifest,
37
- ExecutablePluginManifest,
38
- PluginPackage,
39
- PluginPackageAssets,
40
- PluginArchiveV2,
41
- PluginServiceDefinition,
42
- PluginServiceDependency,
43
- PluginPermission,
44
- PluginViewDefinition,
45
- PluginViewLocation,
46
- PluginViewLayout,
47
- PluginStatusBarAlign,
48
- PluginStatusBarTone,
49
- PluginStatusBarItem,
50
- PluginUiTone,
51
- PluginUiPickItem,
52
- PluginUiPickOptions,
53
- PluginUiPromptOptions,
54
- PluginUiConfirmOptions,
55
- PluginUiToastOptions,
56
- PluginSlashCommandDefinition,
57
- PluginActiveEditorSnapshot,
58
- PluginFrontmatterPatch,
59
- PluginCodeBlockRendererDefinition,
60
- PluginEditorDecorationTone,
61
- PluginEditorDecoration,
62
- PluginAttachmentWriteRequest,
63
- WorkspacePersonalPluginPolicy,
64
- PluginAssistantToolEffect,
65
- PluginAssistantToolDefinition,
66
- PluginAssistantContextProviderDefinition,
67
- PluginAiCompleteRequest,
68
- PluginAiStructuredRequest,
69
- PluginAiCompleteResult,
70
- PluginAiStructuredResult,
71
- PluginFileHandlerMode,
72
- PluginFileHandlerDefinition,
73
- PluginSettingFieldType,
74
- PluginSettingField,
75
- PluginActivationEvent,
76
- PluginPlatform,
77
- PluginEngines,
78
- PluginErrorCode,
79
- PluginViewNode,
80
- PluginJson,
81
- PluginUiBundle,
82
- } from '@tano/protocol';
83
- export interface PluginAssistantCallContext {
84
- workspaceId: string;
85
- activeFileId?: string;
86
- }
87
- export interface PluginAssistantContextResult {
88
- title?: string;
89
- content: string;
90
- metadata?: PluginJson;
91
- }
92
- export interface PluginHostInfo {
93
- coreVersion: string;
94
- apiVersion: string;
95
- platform: PluginPlatform;
96
- capabilities: string[];
97
- }
98
- export interface TanoPluginError extends Error {
99
- readonly code: PluginErrorCode;
100
- readonly retryable: boolean;
101
- }
102
- /** Runs inside the custom UI frame; workspace access stays in the plugin's Worker. */
103
- export interface TanoPluginViewApi {
104
- /** Read-only host appearance, also applied as CSS variables inside the isolated UI. */
105
- theme(): import('../appearance/theme').ResolvedTheme;
106
- onTheme(handler: (theme: import('../appearance/theme').ResolvedTheme) => void): () => void;
107
- postMessage(message: PluginJson): Promise<void>;
108
- onState(handler: (state: PluginJson) => void): () => void;
109
- }
110
- export interface PluginDocument { id: string; path: string; content: string; hash: string }
111
- export interface PluginObjectSnapshot { id: string; object: WorkspaceObject; hash: string }
112
- export interface PluginPage<T> { items: T[]; nextCursor?: string; total?: number; skipped?: string[] }
113
- export interface PluginPageOptions { limit?: number; cursor?: string; direction?: 'asc' | 'desc' }
114
- export interface PluginDocumentQuery extends PluginPageOptions { query?: string; pathPrefix?: string; readOnly?: boolean; sort?: 'path' | 'name' | 'modified' }
115
- export interface PluginObjectQuery extends PluginPageOptions { query?: string; type?: string; archived?: boolean; properties?: Record<string, string | number | boolean | null>; sort?: 'name' | 'type' | 'id' }
116
- export interface PluginRelationQuery extends PluginPageOptions { type?: string; sourceId?: string; targetId?: string }
117
- export interface PluginDocumentEntry { id: string; name: string; path: string; readOnly: boolean }
118
- export interface PluginSearchHit extends PluginDocumentEntry { snippet: string; offset: number; hash: string }
119
- /** Offsets are UTF-16 indices into the exact content returned by read(). Edits must not overlap. */
120
- export interface PluginTextEdit { from: number; to: number; insert: string }
121
- export interface PluginAutomationExecution {
122
- runId: string;
123
- automationId: string;
124
- trigger: 'manual' | 'schedule' | 'webhook';
125
- scheduledAt: string;
126
- /** Owner-configured task parameters, unchanged by external delivery. */
127
- payload: PluginJson;
128
- /** Untrusted external JSON, present only for a Webhook trigger. */
129
- webhook?: PluginJson;
130
- }
131
- /** A server run has no editor UI, device storage, native commands or foreground event subscriptions. */
132
- export type TanoAutomationApi = Pick<TanoPluginApi, 'context' | 'objects' | 'relations' | 'network' | 'connections'> & {
133
- documents: Omit<TanoPluginApi['documents'], 'open'>;
134
- };
135
- export interface PluginGitEntry { path: string; index: string; worktree: string; originalPath: string | null }
136
- export interface PluginGitStatus { branch: string | null; detached: boolean; entries: PluginGitEntry[] }
137
- export interface PluginGitDiff { path: string; staged: boolean; patch: string }
138
- export interface PluginGitCommit { id: string; shortId: string; author: string; date: string; subject: string }
139
- export interface PluginGitLog { path: string | null; commits: PluginGitCommit[] }
140
- export type PluginChangeKind = 'created' | 'updated' | 'deleted';
141
- export type PluginEvent = { type: 'workspace.changed'; fileId?: string } | {
142
- type: 'documents.changed' | 'objects.changed' | 'relations.changed';
143
- changes: { id: string; kind: PluginChangeKind }[];
144
- /** Too many changes for a delta: discard cached query results and query again. */
145
- reset?: boolean;
146
- };
147
- export interface TanoPluginApi {
148
- /** Read-only binary snapshot in bounded base64 chunks, plus optional bounded attachment write. */
149
- attachments: {
150
- read(fileId: string, offset?: number, revision?: string): Promise<{ path: string; revision: string; offset: number; total: number; chunk: string }>;
151
- write(request: PluginAttachmentWriteRequest): Promise<{ path: string; name: string; image: boolean; url: string }>;
152
- };
153
- context(): Promise<{ workspaceId: string; pluginId: string; settings: Record<string, unknown> }>;
154
- /** Host runtime version, platform mode, and supported capabilities for graceful feature detection. */
155
- hostInfo(): Promise<PluginHostInfo>;
156
- /** Register a graceful cleanup handler invoked before the host terminates this plugin instance. */
157
- lifecycle: { onDeactivate(handler: () => void | Promise<void>): () => void };
158
- /** Read-only access to binary assets bundled inside this plugin's own v2 ZIP package (`assets/bin/*`). */
159
- assets: {
160
- list(): Promise<string[]>;
161
- read(path: string): Promise<{ path: string; bytes: number; base64: string }>;
162
- };
163
- documents: {
164
- list(): Promise<PluginDocumentEntry[]>;
165
- query(options?: PluginDocumentQuery): Promise<PluginPage<PluginDocumentEntry>>;
166
- /** Literal full-text search. An empty page can still carry nextCursor. */
167
- search(query: string, options?: Omit<PluginDocumentQuery, 'query' | 'sort'>): Promise<PluginPage<PluginSearchHit>>;
168
- read(fileId: string): Promise<PluginDocument>;
169
- write(fileId: string, content: string, baseHash: string): Promise<{ id: string; hash: string; status: 'applied' | 'saved' }>;
170
- edit(fileId: string, edits: PluginTextEdit[], baseHash: string): Promise<{ id: string; hash: string; status: 'applied' | 'saved' }>;
171
- create(path: string, content: string): Promise<{ id: string; path: string }>;
172
- move(fileId: string, destination: string, baseHash: string): Promise<{ id: string; path: string }>;
173
- trash(fileId: string, baseHash: string): Promise<{ id: string; path: string; trashed: true }>;
174
- open(fileId: string): Promise<void>;
175
- frontmatter: {
176
- read(fileId: string): Promise<{ id: string; hasFrontmatter: boolean; data: Record<string, PluginJson>; hash: string }>;
177
- update(
178
- fileId: string,
179
- patch: PluginFrontmatterPatch,
180
- baseHash: string,
181
- ): Promise<{ id: string; hash: string; data: Record<string, PluginJson>; status: 'applied' | 'saved' }>;
182
- };
183
- };
184
- /** Active editor selection, single-step undoable cursor transactions, and declarative decorations. */
185
- editor: {
186
- active(): Promise<PluginActiveEditorSnapshot | null>;
187
- insert(text: string): Promise<{ fileId: string; hash: string; status: 'applied' }>;
188
- replaceSelection(text: string): Promise<{ fileId: string; hash: string; status: 'applied' }>;
189
- setDecorations(fileId: string, decorations: PluginEditorDecoration[]): Promise<void>;
190
- clearDecorations(fileId?: string): Promise<void>;
191
- };
192
- objects: {
193
- list(): Promise<PluginObjectSnapshot[]>;
194
- query(options?: PluginObjectQuery): Promise<PluginPage<PluginObjectSnapshot>>;
195
- read(objectId: string): Promise<PluginObjectSnapshot>;
196
- create(object: Pick<WorkspaceObject, 'type' | 'name' | 'description' | 'properties' | 'archived'>): Promise<WorkspaceObject>;
197
- update(object: WorkspaceObject, baseHash: string): Promise<WorkspaceObject>;
198
- };
199
- relations: { list(): Promise<WorkspaceRelation[]>; query(options?: PluginRelationQuery): Promise<PluginPage<WorkspaceRelation>>; add(relation: WorkspaceRelation): Promise<void>; remove(relation: WorkspaceRelation): Promise<void> };
200
- /** Device-local application state. User content belongs in documents and objects. */
201
- storage: { get(key: string): Promise<unknown>; set(key: string, value: unknown): Promise<void>; remove(key: string): Promise<void>; usage(): Promise<{ used: number; limit: number }> };
202
- network: { get(url: string): Promise<string> };
203
- /** Host injects the current user's separately granted credential; keys never enter the SDK. */
204
- connections: { request(origin: string, request: PluginConnectionRequest): Promise<PluginConnectionResponse> };
205
- native: {
206
- invoke(command: 'git.status', args?: Record<string, never>): Promise<PluginGitStatus>;
207
- invoke(command: 'git.diff', args: { path: string; staged?: boolean }): Promise<PluginGitDiff>;
208
- invoke(command: 'git.log', args?: { path?: string; limit?: number }): Promise<PluginGitLog>;
209
- invoke(command: string, args?: unknown): Promise<unknown>;
210
- };
211
- commands: { register(id: string, handler: (context?: { fileId?: string; workspaceId: string; viewAlreadyOpen?: boolean }) => void | Promise<void>): Promise<void> };
212
- views: {
213
- /** Host-rendered controls at the right of this view's breadcrumb row. */
214
- setHeader(id: string, header: import('./view-header').PluginViewHeader): Promise<void>;
215
- render(id: string, tree: PluginViewNode): Promise<void>;
216
- renderCustom(id: string, state: PluginJson): Promise<void>;
217
- open(id: string): Promise<void>;
218
- onAction(id: string, handler: (event: { action: string; values: Record<string, string> }) => void | Promise<void>): () => void;
219
- onMessage(id: string, handler: (message: PluginJson) => void | Promise<void>): () => void;
220
- };
221
- /** Host-managed lightweight UI primitives and status bar items; no iframe frontend required. */
222
- ui: {
223
- pick(options: PluginUiPickOptions): Promise<string | null>;
224
- prompt(options: PluginUiPromptOptions): Promise<string | null>;
225
- confirm(options: PluginUiConfirmOptions): Promise<boolean>;
226
- toast(message: string, tone?: PluginUiTone): Promise<void>;
227
- setStatusBar(item: PluginStatusBarItem): Promise<void>;
228
- removeStatusBar(id: string): Promise<void>;
229
- };
230
- /** Host-managed model completion using the user's configured connection; API keys never enter the sandbox. */
231
- ai: {
232
- complete(request: PluginAiCompleteRequest): Promise<PluginAiCompleteResult>;
233
- structured<T = PluginJson>(request: PluginAiStructuredRequest): Promise<PluginAiStructuredResult<T>>;
234
- };
235
- /** Register handlers for manifest-declared assistantTools and assistantContextProviders. */
236
- assistant: {
237
- registerTool(
238
- name: string,
239
- handler: (args: Record<string, unknown>, context: PluginAssistantCallContext) => PluginJson | Promise<PluginJson>,
240
- ): Promise<void>;
241
- registerContextProvider(
242
- id: string,
243
- handler: (
244
- query: string,
245
- context: PluginAssistantCallContext,
246
- ) => PluginAssistantContextResult | string | Promise<PluginAssistantContextResult | string>,
247
- ): Promise<void>;
248
- };
249
- /** Stateless cross-plugin RPC message bus (zero shared memory). */
250
- services: {
251
- register(
252
- name: string,
253
- handler: (payload: PluginJson, caller: { pluginId: string }) => PluginJson | Promise<PluginJson>,
254
- ): Promise<void>;
255
- call<T = PluginJson>(pluginId: string, service: string, payload?: PluginJson): Promise<T>;
256
- available(pluginId: string, service: string): Promise<boolean>;
257
- };
258
- events: { subscribe(handler: (event: PluginEvent) => void | Promise<void>, options?: { types?: PluginEvent['type'][]; ids?: string[] }): () => void };
259
- notify(message: string): Promise<void>;
260
- }
1
+ export * from '@tano/protocol/plugin-sdk';
@@ -0,0 +1,167 @@
1
+ import { shallowRef } from 'vue';
2
+ import type {
3
+ PluginUiConfirmOptions,
4
+ PluginUiPickOptions,
5
+ PluginUiPromptOptions,
6
+ PluginUiTone,
7
+ } from '@tano/protocol';
8
+
9
+ export type PluginUiDialogRequest =
10
+ | {
11
+ id: string;
12
+ kind: 'pick';
13
+ pluginId: string;
14
+ pluginName: string;
15
+ options: PluginUiPickOptions;
16
+ }
17
+ | {
18
+ id: string;
19
+ kind: 'prompt';
20
+ pluginId: string;
21
+ pluginName: string;
22
+ options: PluginUiPromptOptions;
23
+ }
24
+ | {
25
+ id: string;
26
+ kind: 'confirm';
27
+ pluginId: string;
28
+ pluginName: string;
29
+ options: PluginUiConfirmOptions;
30
+ };
31
+
32
+ export interface PluginUiToastItem {
33
+ id: string;
34
+ pluginId: string;
35
+ pluginName: string;
36
+ message: string;
37
+ tone: PluginUiTone;
38
+ }
39
+
40
+ export function createPluginUiDialogs() {
41
+ const activePluginDialog = shallowRef<PluginUiDialogRequest | null>(null);
42
+ const pluginToasts = shallowRef<PluginUiToastItem[]>([]);
43
+ const toastTimers = new Map<string, ReturnType<typeof setTimeout>>();
44
+
45
+ let activeDialogControl: {
46
+ id: string;
47
+ resolve: (value: string | boolean | null) => void;
48
+ reject: (error: Error) => void;
49
+ cleanup: () => void;
50
+ } | null = null;
51
+
52
+ function cancelActivePluginDialog(reason = '插件交互已取消') {
53
+ const current = activeDialogControl;
54
+ if (!current) return;
55
+ activeDialogControl = null;
56
+ activePluginDialog.value = null;
57
+ current.cleanup();
58
+ current.reject(new Error(reason));
59
+ }
60
+
61
+ function resolvePluginDialog(id: string, value: string | boolean | null) {
62
+ const current = activeDialogControl;
63
+ if (!current || current.id !== id) return;
64
+ activeDialogControl = null;
65
+ activePluginDialog.value = null;
66
+ current.cleanup();
67
+ current.resolve(value);
68
+ }
69
+
70
+ function dismissPluginToast(id: string) {
71
+ const timer = toastTimers.get(id);
72
+ if (timer) {
73
+ clearTimeout(timer);
74
+ toastTimers.delete(id);
75
+ }
76
+ pluginToasts.value = pluginToasts.value.filter((item) => item.id !== id);
77
+ }
78
+
79
+ function clearPluginToasts() {
80
+ for (const timer of toastTimers.values()) clearTimeout(timer);
81
+ toastTimers.clear();
82
+ pluginToasts.value = [];
83
+ }
84
+
85
+ function showPluginToast(params: Record<string, unknown>) {
86
+ const id = crypto.randomUUID();
87
+ const item: PluginUiToastItem = {
88
+ id,
89
+ pluginId: String(params.pluginId ?? ''),
90
+ pluginName: String(params.pluginName ?? ''),
91
+ message: String(params.message ?? ''),
92
+ tone: (params.tone as PluginUiTone | undefined) ?? 'info',
93
+ };
94
+ const next = [...pluginToasts.value, item];
95
+ while (next.length > 3) {
96
+ const removed = next.shift();
97
+ if (removed) {
98
+ const timer = toastTimers.get(removed.id);
99
+ if (timer) {
100
+ clearTimeout(timer);
101
+ toastTimers.delete(removed.id);
102
+ }
103
+ }
104
+ }
105
+ pluginToasts.value = next;
106
+ toastTimers.set(
107
+ id,
108
+ setTimeout(() => dismissPluginToast(id), 4500),
109
+ );
110
+ }
111
+
112
+ function openPluginDialog(
113
+ method: 'ui.pick' | 'ui.prompt' | 'ui.confirm',
114
+ params: Record<string, unknown>,
115
+ ): Promise<string | boolean | null> {
116
+ if (activeDialogControl) {
117
+ return Promise.reject(new Error('当前已有插件交互弹窗正在等待响应,请稍后重试'));
118
+ }
119
+ const id = crypto.randomUUID();
120
+ const signal = params.signal instanceof AbortSignal ? params.signal : undefined;
121
+ if (signal?.aborted) return Promise.reject(new Error('插件已停止'));
122
+ return new Promise<string | boolean | null>((resolve, reject) => {
123
+ const onAbort = () => cancelActivePluginDialog('插件已停止');
124
+ signal?.addEventListener('abort', onAbort, { once: true });
125
+ const cleanup = () => signal?.removeEventListener('abort', onAbort);
126
+ activeDialogControl = { id, resolve, reject, cleanup };
127
+ const pluginId = String(params.pluginId ?? '');
128
+ const pluginName = String(params.pluginName ?? '');
129
+ if (method === 'ui.pick') {
130
+ activePluginDialog.value = {
131
+ id,
132
+ kind: 'pick',
133
+ pluginId,
134
+ pluginName,
135
+ options: params.options as PluginUiPickOptions,
136
+ };
137
+ } else if (method === 'ui.prompt') {
138
+ activePluginDialog.value = {
139
+ id,
140
+ kind: 'prompt',
141
+ pluginId,
142
+ pluginName,
143
+ options: params.options as PluginUiPromptOptions,
144
+ };
145
+ } else {
146
+ activePluginDialog.value = {
147
+ id,
148
+ kind: 'confirm',
149
+ pluginId,
150
+ pluginName,
151
+ options: params.options as PluginUiConfirmOptions,
152
+ };
153
+ }
154
+ });
155
+ }
156
+
157
+ return {
158
+ activePluginDialog,
159
+ pluginToasts,
160
+ cancelActivePluginDialog,
161
+ resolvePluginDialog,
162
+ dismissPluginToast,
163
+ clearPluginToasts,
164
+ showPluginToast,
165
+ openPluginDialog,
166
+ };
167
+ }
@@ -1,75 +1 @@
1
- import { canonicalPluginJson, isMarkdown, isWorkspaceInternalPath, matchesPluginPathScopes, pluginRecord } from '@tano/protocol';
2
- import type { Workspace, WorkspaceRelation, WorkspaceObject } from '@tano/protocol';
3
- import type { PluginDocumentEntry, PluginPageOptions } from './plugin-sdk';
4
- import { assistantHash } from '../assistant/hash';
5
- import { compareQueryText, PluginQueryPager, pluginQueryOptions, queryBoolean, queryText } from './data';
6
-
7
- export interface PluginQueryContext {
8
- workspace: Workspace;
9
- objects: { object: WorkspaceObject; snapshot: { hash: string } }[];
10
- relations: WorkspaceRelation[];
11
- drafts: { id: string; content: string; conflict?: unknown; missing: boolean }[];
12
- read(path: string): Promise<{ content: string }>;
13
- assertCurrent(): void;
14
- /** Host revision, for stores whose timestamp and size alone do not identify a content version. */
15
- revision?: unknown;
16
- }
17
- export async function queryPluginData(method: string, params: Record<string, unknown>, pager: PluginQueryPager, context: PluginQueryContext) {
18
- const { workspace, objects, relations, drafts, assertCurrent } = context;
19
- const scope = `${workspace.id}:${String(params.queryScope)}`;
20
- const pathScopes = Array.isArray(params.pathScopes) ? (params.pathScopes as string[]) : undefined;
21
- if (method === 'documents.query' || method === 'documents.search') {
22
- const options = pluginQueryOptions(params.options, method === 'documents.search' ? ['query', 'pathPrefix', 'readOnly'] : ['query', 'pathPrefix', 'readOnly', 'sort']);
23
- const query = queryText(options.query) ?? '', prefix = queryText(options.pathPrefix, 1000) ?? '', readOnly = queryBoolean(options.readOnly);
24
- if (options.sort !== undefined && !['path', 'name', 'modified'].includes(String(options.sort))) throw new Error('文档排序字段无效');
25
- if (method === 'documents.search' && !query.trim()) throw new Error('请输入搜索文本');
26
- const rows = workspace.files.filter(row => row.kind === 'file' && isMarkdown(row.path) && !isWorkspaceInternalPath(row.path) &&
27
- matchesPluginPathScopes(row.path, pathScopes) &&
28
- row.path.startsWith(prefix) && (readOnly === undefined || !!(workspace.readOnly || row.readOnly) === readOnly) &&
29
- (method === 'documents.search' || `${row.path}\n${row.name}`.toLowerCase().includes(query.toLowerCase())));
30
- const sort = String(options.sort ?? 'path'), direction = options.direction === 'desc' ? -1 : 1;
31
- rows.sort((a, b) => direction * ((sort === 'modified' ? a.modified - b.modified : compareQueryText(sort === 'name' ? a.name : a.path, sort === 'name' ? b.name : b.path)) || compareQueryText(a.id, b.id)));
32
- const metadata = (row: typeof rows[number]): PluginDocumentEntry => ({ id: row.id, name: row.name, path: row.path, readOnly: !!(workspace.readOnly || row.readOnly) });
33
- const revision = [context.revision ?? null, rows.map(row => [row.id, row.path, row.name, row.modified, row.size, metadata(row).readOnly]),
34
- method === 'documents.search' ? drafts.map(row => [row.id, row.content, !!row.conflict, row.missing]) : []];
35
- if (method === 'documents.query') return pager.page(scope, method, options as PluginPageOptions, revision, rows, async row => metadata(row), assertCurrent);
36
- const draftsById = new Map(drafts.map(draft => [draft.id, draft]));
37
- const skipped: string[] = [];
38
- const pattern = new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'iu');
39
- const page = await pager.page(scope, method, options as PluginPageOptions, revision, rows, async row => {
40
- const draft = draftsById.get(row.id);
41
- if (draft?.conflict || draft?.missing || (!draft && row.size > 512000)) { skipped.push(row.id); return; }
42
- assertCurrent();
43
- const content = draft?.content ?? (await context.read(row.path)).content;
44
- assertCurrent();
45
- if (content.length > 512000) { skipped.push(row.id); return; }
46
- const match = pattern.exec(content);
47
- if (!match) return;
48
- return { ...metadata(row), snippet: content.slice(Math.max(0, match.index - 60), match.index + query.length + 120), offset: match.index, hash: await assistantHash(content) };
49
- }, assertCurrent, 25);
50
- return { ...page, skipped };
51
- }
52
- if (method === 'objects.query') {
53
- const options = pluginQueryOptions(params.options, ['query', 'type', 'archived', 'properties', 'sort']);
54
- const query = (queryText(options.query) ?? '').toLowerCase(), type = queryText(options.type), archived = queryBoolean(options.archived);
55
- if (options.sort !== undefined && !['name', 'type', 'id'].includes(String(options.sort))) throw new Error('对象排序字段无效');
56
- const properties = options.properties ?? {};
57
- if (!pluginRecord(properties) || Object.keys(properties).length > 10 || Object.entries(properties).some(([key, value]) => key.length > 100 ||
58
- (value !== null && !['string', 'number', 'boolean'].includes(typeof value)) || (typeof value === 'number' && !Number.isFinite(value)) ||
59
- (typeof value === 'string' && value.length > 200))) throw new Error('属性筛选只支持最多 10 个标量条件');
60
- const rows = objects.filter(({ object }) => (!type || object.type === type) && (archived === undefined || object.archived === archived) &&
61
- `${object.name}\n${object.description}`.toLowerCase().includes(query) && Object.entries(properties).every(([key, value]) => Object.hasOwn(object.properties, key) && object.properties[key] === value));
62
- const sort = (options.sort ?? 'name') as 'name' | 'type' | 'id', direction = options.direction === 'desc' ? -1 : 1;
63
- rows.sort((a, b) => direction * (compareQueryText(a.object[sort], b.object[sort]) || compareQueryText(a.object.id, b.object.id)));
64
- return pager.page(scope, method, options as PluginPageOptions, rows.map(row => [row.object.id, row.snapshot.hash]), rows,
65
- async row => ({ id: row.object.id, object: JSON.parse(JSON.stringify(row.object)), hash: row.snapshot.hash }), assertCurrent);
66
- }
67
- if (method === 'relations.query') {
68
- const options = pluginQueryOptions(params.options, ['type', 'sourceId', 'targetId']);
69
- const type = queryText(options.type), source = queryText(options.sourceId), target = queryText(options.targetId);
70
- const rows = relations.filter(row => (!type || row.type === type) && (!source || row.source.id === source) && (!target || row.target.id === target));
71
- rows.sort((a, b) => (options.direction === 'desc' ? -1 : 1) * compareQueryText(a.id, b.id));
72
- return pager.page(scope, method, options as PluginPageOptions, canonicalPluginJson(rows), rows, async row => JSON.parse(JSON.stringify(row)), assertCurrent);
73
- }
74
- throw new Error('不支持此查询');
75
- }
1
+ export { queryPluginData, type PluginQueryContext } from '@tano/protocol/plugin-data';
@@ -1,12 +1,7 @@
1
1
  import { pluginRecord, type PluginJson } from '@tano/protocol';
2
+ import type { PluginViewHeader } from '@tano/protocol/plugin-sdk';
2
3
  import type { PluginRuntimeState } from './host';
3
- export interface PluginViewHeader {
4
- title: string;
5
- status?: string;
6
- statusAfter?: string;
7
- previewInfo?: { label: string; detail: string };
8
- actions: { id: string; label: string; icon?: 'open' | 'previous' | 'next' | 'minus' | 'plus' | 'fit' | 'info'; disabled?: boolean; accept?: string; group?: string }[];
9
- }
4
+ export type { PluginViewHeader };
10
5
  export function parseViewHeader(value: PluginJson): PluginViewHeader {
11
6
  if (!pluginRecord(value) || typeof value.title !== 'string' || value.title.length > 200 ||
12
7
  (value.status !== undefined && (typeof value.status !== 'string' || value.status.length > 80)) ||
package/src/runtime.ts CHANGED
@@ -158,8 +158,9 @@ export interface WorkbenchExtensions {
158
158
  documentStatus?(id: string): DocumentSyncStatus | undefined;
159
159
  /**
160
160
  * workspace-menu-layout can wrap built-in workspace actions through its default slot.
161
- * plugin-publishing receives WorkbenchActions in the plugin center's My submissions view.
162
- * plugin-forge receives WorkbenchActions + { canPublish } in the plugin center's Forge & Overlay view.
161
+ * plugin-customize receives WorkbenchActions in the plugin center's user-facing customization tab.
162
+ * plugin-forge receives WorkbenchActions + { canPublish, developerMode } inside the Developer Area.
163
+ * plugin-publishing receives WorkbenchActions inside the Developer Area's submissions view.
163
164
  */
164
165
  regions: Record<string, Component>;
165
166
  views?: readonly WorkbenchView[];
@@ -97,8 +97,12 @@ const displayModeDescription = computed(() =>
97
97
  ? '当前配色主题仅支持深色。'
98
98
  : '选择浅色、深色或跟随系统,偏好在工作区间共用。',
99
99
  );
100
- const showDeveloperMode = computed(() => props.native && !props.mobile);
101
- const developerModeDescription = '开启后,右键单击顶部标签栏的空白处,即可打开调试窗口。';
100
+ const showDeveloperMode = computed(() => !props.mobile);
101
+ const developerModeDescription = computed(() =>
102
+ props.native
103
+ ? '开启后,可在插件中心访问开发者区(导入、工坊、调试与投稿),也可右键顶部标签栏空白处打开调试窗口。'
104
+ : '开启后,可在插件中心访问开发者区(导入插件、工坊、开发监听、运行日志与投稿)。',
105
+ );
102
106
  const rules = computed(() => props.capabilities ?? defaultCapabilities);
103
107
  const splitFonts = computed(
104
108
  () =>
@@ -189,7 +193,7 @@ const settingSearchEntries = computed<SettingSearchEntry[]>(() =>
189
193
  frostActive: frostActive.value,
190
194
  splitFontsEnabled: splitFonts.value.enabled,
191
195
  showDeveloperMode: showDeveloperMode.value,
192
- developerModeDescription,
196
+ developerModeDescription: developerModeDescription.value,
193
197
  }),
194
198
  );
195
199
  const availableExtraPages = computed(() =>
@@ -398,6 +402,7 @@ function keydown(event: KeyboardEvent) {
398
402
  <section
399
403
  ref="settingsDialog"
400
404
  class="settings-dialog workbench-modal-surface"
405
+ :class="{ 'settings-tabbed-dialog': tabbed }"
401
406
  tabindex="-1"
402
407
  :role="tabbed ? 'region' : 'dialog'"
403
408
  :aria-modal="!windowed && !tabbed ? true : undefined"
@@ -1,16 +1,29 @@
1
1
  <script setup lang="ts">
2
2
  import { inject, toRefs } from 'vue';
3
+ import { mobile } from '../../platform/platform';
3
4
  import { SettingsPanel } from '../../shell/workbench-async-components';
4
- import { workbenchContextKey } from '../../shell/workbench-context';
5
+ import {
6
+ workbenchDocumentsKey,
7
+ workbenchModalsKey,
8
+ workbenchPrefsKey,
9
+ workbenchShellKey,
10
+ } from '../../shell/workbench-context';
5
11
  import { useWindowContext } from '../../windows/context';
12
+ import { native } from '../../workspace/adapter';
6
13
  defineProps<{ tabbed?: boolean; windowed?: boolean }>();
7
- const context = inject(workbenchContextKey);
8
- if (!context) throw new Error('Workbench context is required');
14
+ const shell = inject(workbenchShellKey);
15
+ const prefs = inject(workbenchPrefsKey);
16
+ const documents = inject(workbenchDocumentsKey);
17
+ const modals = inject(workbenchModalsKey);
18
+ if (!shell || !prefs || !documents || !modals) throw new Error('Workbench context is required');
9
19
  const windowContext = useWindowContext();
10
- const { native, mobile, workspace, shortcuts, store, tabsEnabled, extensions, updates, editorPreferences, showPageTitle, showDocumentProperties, showOutline, outlineOnLeft, active, openingSettingsWindow, openSettingsTab, openSettingsInNewWindow, settingsPage, workspaceExporting, workspaceExportError, workspaceDeletionError, deleteWorkspace, exportWorkspace, defaultSource, theme, appearance, appearanceController, visualFontChoice, customFontName, splitFontSettings, revealMarkdown, toolbarMode, showDocumentDiscussion, visualFontSize, sourceFontSize, appVersion, documentationBaseUrl, assistant, settingsAction, settingsContext } = toRefs(context);
20
+ const { workspace, store, extensions, updates, active, appVersion, documentationBaseUrl, assistant } = toRefs(shell);
21
+ const { shortcuts, tabsEnabled, editorPreferences, showPageTitle, showDocumentProperties, defaultSource, theme, appearance, appearanceController, visualFontChoice, customFontName, splitFontSettings, revealMarkdown, toolbarMode, showDocumentDiscussion, visualFontSize, sourceFontSize } = toRefs(prefs);
22
+ const { showOutline, outlineOnLeft } = toRefs(documents);
23
+ const { openingSettingsWindow, openSettingsTab, openSettingsInNewWindow, settingsPage, workspaceExporting, workspaceExportError, workspaceDeletionError, deleteWorkspace, exportWorkspace, settingsAction, settingsContext } = toRefs(modals);
11
24
  function closeSettings() {
12
- if (windowContext.id === 'settings') void context!.auxiliaryWindows.close('settings');
13
- else context!.settingsPanel = false;
25
+ if (windowContext.id === 'settings') void shell!.auxiliaryWindows.close('settings');
26
+ else modals!.settingsPanel = false;
14
27
  }
15
28
  </script>
16
29
  <template>
@@ -45,7 +58,7 @@ function closeSettings() {
45
58
  :mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
46
59
  :native="native"
47
60
  :mobile="mobile"
48
- v-model:developer-mode="context.developerMode"
61
+ v-model:developer-mode="prefs.developerMode"
49
62
  :default-source="defaultSource"
50
63
  :theme="theme"
51
64
  :appearance="appearance"
@@ -81,7 +81,7 @@ export interface SettingsPanelContext {
81
81
  displayMode: ComputedRef<ThemePreference>;
82
82
  displayModeDescription: ComputedRef<string>;
83
83
  showDeveloperMode: ComputedRef<boolean>;
84
- developerModeDescription: string;
84
+ developerModeDescription: ComputedRef<string>;
85
85
  splitFonts: ComputedRef<SplitFontSettings>;
86
86
  emitUpdateDeveloperMode: (value: boolean) => void;
87
87
  emitUpdateDefaultSource: (value: boolean) => void;
@@ -0,0 +1 @@
1
+ export const SETTINGS_TAB_ID = 'view:settings';
@@ -39,7 +39,7 @@ export function editorPaletteCommands(options: {
39
39
  if (!options.editable || options.source) return [];
40
40
  const { context, features, run } = options;
41
41
  const blocks = blockTypes.flatMap<WorkbenchCommand>(item => {
42
- if (formCommands.has(item.command) || !commandEnabled(item.command, undefined, features)) return [];
42
+ if (formCommands.has(item.command) || !commandEnabled(item.command, features)) return [];
43
43
  if (!context.canTransform && !insertionCommands.has(item.command) && !wrappingCommands.has(item.command)) return [];
44
44
  if (item.command === 'heading') return Array.from({ length: 6 }, (_, index) => ({
45
45
  id: `editor.heading.${index + 1}`, category: t('格式'), label: t('转换为 {0} 级标题', [index + 1]),
@@ -52,13 +52,13 @@ export function editorPaletteCommands(options: {
52
52
  run: () => run(item.command) }];
53
53
  });
54
54
  const inline = inlineTypes.filter(item => !formCommands.has(item.command)
55
- && commandEnabled(item.command, undefined, features)
55
+ && commandEnabled(item.command, features)
56
56
  && (!context.inlineSource || ['bold', 'italic', 'code'].includes(item.command))
57
57
  && (context.canStyleText || !['bold', 'italic', 'code'].includes(item.command)))
58
58
  .map(item => ({ id: `editor.${item.command}`, category: t('格式'), label: t(item.label),
59
59
  keywords: item.type, run: () => run(item.command) }));
60
60
  const styles = context.canStyleText && !context.inlineSource
61
- ? extraStyles.filter(item => commandEnabled(item.command, undefined, features))
61
+ ? extraStyles.filter(item => commandEnabled(item.command, features))
62
62
  .map(item => ({ id: `editor.${item.command}`, category: t('格式'), label: t(item.label), run: () => run(item.command) }))
63
63
  : [];
64
64
  return [...blocks, ...inline, ...styles];