@elevo-ai/plugin-sdk 0.4.0 → 0.4.2

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/README.md CHANGED
@@ -28,16 +28,16 @@ export default function MyPluginApp() {
28
28
  });
29
29
  };
30
30
 
31
- const handleListArtifacts = async () => {
32
- const artifacts = await sdk.workspace.artifacts.list();
33
- console.log('Artifacts:', artifacts);
31
+ const handleListFiles = async () => {
32
+ const files = await sdk.workspace.files.list();
33
+ console.log('Files:', files);
34
34
  };
35
35
 
36
36
  return (
37
37
  <div>
38
38
  <h1>我的插件</h1>
39
39
  <button onClick={handleSendMessage}>发送消息</button>
40
- <button onClick={handleListArtifacts}>列出制品</button>
40
+ <button onClick={handleListFiles}>列出文件</button>
41
41
  </div>
42
42
  );
43
43
  }
@@ -53,9 +53,8 @@ import type {
53
53
 
54
54
  // Workspace API
55
55
  WorkspaceAPI,
56
- ArtifactsAPI,
57
- Artifact,
58
- ArtifactContent,
56
+ FilesAPI,
57
+ WorkspaceFile,
59
58
 
60
59
  // Conversation API
61
60
  ConversationAPI,
@@ -86,18 +85,18 @@ import type {
86
85
  | 属性/方法 | 描述 |
87
86
  |----------|------|
88
87
  | `id` | 当前工作空间 ID |
89
- | `artifacts` | 制品管理 API |
88
+ | `files` | 文件管理 API |
90
89
 
91
- ### ArtifactsAPI
90
+ ### FilesAPI
92
91
 
93
- 制品管理操作:
92
+ 文件管理操作:
94
93
 
95
94
  | 方法 | 描述 |
96
95
  |------|------|
97
- | `list(options?)` | 列出工作空间制品 |
98
- | `upload(file, options?)` | 上传文件作为制品 |
99
- | `download(artifactId)` | 下载制品 |
100
- | `getContent(artifactId)` | 获取制品内容(预览) |
96
+ | `list(dirPath?, pattern?)` | 列出目录中的文件 |
97
+ | `read(filePath)` | 读取文件内容 |
98
+ | `write(filePath, content)` | 写入文件内容 |
99
+ | `delete(filePath)` | 删除文件 |
101
100
 
102
101
  ### ConversationAPI
103
102
 
package/index.cjs.js CHANGED
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
 
7
7
  exports.usePluginSDK = _a.usePluginSDK;
8
8
  exports.useInjectCSS = _a.useInjectCSS;
9
- exports.CopilotPanel = _a.CopilotPanel;
9
+ exports.useWorkspaceFiles = _a.useWorkspaceFiles;
10
+ exports.WorkspaceFileTree = _a.WorkspaceFileTree;
package/index.d.ts CHANGED
@@ -1,32 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
- /**
4
- * Workspace artifact (file or document)
5
- */
6
- export interface Artifact {
7
- id: string;
8
- workspace_id: string;
9
- conversation_id: string | null;
10
- file_path: string;
11
- file_size: number;
12
- mime_type: string;
13
- created_at: string;
14
- created_by_agent: string | null;
15
- tags: string[];
16
- metadata: Record<string, unknown>;
17
- }
18
-
19
- /**
20
- * Artifact content response
21
- */
22
- export interface ArtifactContent {
23
- artifact_id: string;
24
- content: string;
25
- encoding: 'utf-8' | 'base64';
26
- is_preview: boolean;
27
- preview_size?: number;
28
- }
29
-
30
3
  /**
31
4
  * Workspace file information
32
5
  */
@@ -38,6 +11,7 @@ export interface WorkspaceFile {
38
11
  is_dir: boolean;
39
12
  mod_time: string;
40
13
  permission: 'readonly' | 'readwrite';
14
+ children?: WorkspaceFile[];
41
15
  }
42
16
 
43
17
  /**
@@ -71,44 +45,6 @@ export interface ChatPanelProps {
71
45
 
72
46
  // ==================== SDK 接口 ====================
73
47
 
74
- /**
75
- * Workspace artifacts API
76
- */
77
- export interface ArtifactsAPI {
78
- /**
79
- * List workspace artifacts
80
- * @param options - Optional filters (conversationId)
81
- */
82
- list(options?: { conversationId?: string }): Promise<Artifact[]>;
83
-
84
- /**
85
- * Upload a file as artifact
86
- * @param file - File to upload
87
- * @param options - Optional metadata (filePath, conversationId, tags)
88
- */
89
- upload(
90
- file: File,
91
- options?: {
92
- filePath?: string;
93
- conversationId?: string;
94
- tags?: string[];
95
- metadata?: Record<string, unknown>;
96
- }
97
- ): Promise<Artifact>;
98
-
99
- /**
100
- * Download an artifact
101
- * @param artifactId - Artifact ID
102
- */
103
- download(artifactId: string): Promise<Blob>;
104
-
105
- /**
106
- * Get artifact content (text or base64)
107
- * @param artifactId - Artifact ID
108
- */
109
- getContent(artifactId: string): Promise<ArtifactContent>;
110
- }
111
-
112
48
  /**
113
49
  * Workspace files API - Read/write files in the workspace directory
114
50
  */
@@ -163,7 +99,6 @@ export interface ConversationAPI {
163
99
  */
164
100
  export interface WorkspaceAPI {
165
101
  id: string;
166
- artifacts: ArtifactsAPI;
167
102
  files: FilesAPI;
168
103
  }
169
104
 
@@ -272,4 +207,49 @@ export interface ElevoPluginSDK {
272
207
 
273
208
  export declare function usePluginSDK(): ElevoPluginSDK;
274
209
  export declare function useInjectCSS(cssText: string): void;
275
- export declare function CopilotPanel(): React.ReactElement;
210
+ export declare function useWorkspaceFiles(options: UseWorkspaceFilesOptions): UseWorkspaceFilesReturn;
211
+ export declare function WorkspaceFileTree(props: WorkspaceFileTreeProps): React.ReactNode;
212
+
213
+ export interface UseWorkspaceFilesOptions {
214
+ workspaceId: string;
215
+ path?: string;
216
+ pattern?: string;
217
+ enabled?: boolean;
218
+ }
219
+
220
+ export interface UseWorkspaceFilesReturn {
221
+ files: WorkspaceFile[];
222
+ loading: boolean;
223
+ error: Error | null;
224
+ refresh: () => Promise<void>;
225
+ }
226
+
227
+ export interface WorkspaceFileTreeProps {
228
+ files: WorkspaceFile[];
229
+ loading?: boolean;
230
+ onFileClick?: (file: WorkspaceFile) => void;
231
+ onFolderSelect?: (file: WorkspaceFile) => void;
232
+ onRename?: (file: WorkspaceFile) => void;
233
+ onDelete?: (file: WorkspaceFile) => void;
234
+ onCreateFile?: (parentPath: string) => void;
235
+ onCreateFolder?: (parentPath: string) => void;
236
+ onUpload?: (parentPath: string) => void;
237
+ onMove?: (sourcePath: string, targetPath: string) => void;
238
+ onSyncFromGit?: (parentPath: string) => void;
239
+ /** Path-based metadata for custom icons, read-only state, badges */
240
+ fileMetadata?: Map<string, FileNodeMetadata>;
241
+ enableContextMenu?: boolean;
242
+ enableDragDrop?: boolean;
243
+ compact?: boolean;
244
+ emptyState?: React.ReactNode;
245
+ }
246
+
247
+ /** Metadata overlay for a file/folder path */
248
+ export interface FileNodeMetadata {
249
+ /** Custom icon type to render instead of default folder/file icon */
250
+ iconType?: 'git' | 'git-error';
251
+ /** Whether this node and its children are read-only (no rename/delete/upload) */
252
+ isReadOnly?: boolean;
253
+ /** Status badge text */
254
+ badge?: string;
255
+ }
package/index.esm.js CHANGED
@@ -2,4 +2,5 @@ var _a = window.__ELEVO_PLUGIN_API__ || {};
2
2
 
3
3
  export const usePluginSDK = _a.usePluginSDK;
4
4
  export const useInjectCSS = _a.useInjectCSS;
5
- export const CopilotPanel = _a.CopilotPanel;
5
+ export const useWorkspaceFiles = _a.useWorkspaceFiles;
6
+ export const WorkspaceFileTree = _a.WorkspaceFileTree;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevo-ai/plugin-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Elevo Plugin SDK - Build plugins for the Elevo platform",
5
5
  "type": "module",
6
6
  "main": "./index.cjs.js",