@ai_mind/ade-plugin-sdk 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +1248 -2
- package/cli/build.mjs +154 -0
- package/index.d.ts +77 -0
- package/index.mjs +9 -0
- package/package.json +21 -4
- package/types/adapter.d.ts +153 -0
- package/types/ade-types.d.ts +712 -0
- package/types/api.d.ts +207 -0
- package/types/plugins.d.ts +85 -0
package/types/api.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// 由 sdk/scripts/sync-types.mjs 从 ADE 宿主生成,请勿手工修改。
|
|
2
|
+
import type { PluginCommandContext, PluginConfig, PluginInstallRequest } from './plugins.js';
|
|
3
|
+
import type { AdeSettingsFile, AgentSettingInfo, AoneBoardData, AoneBoardRequest, AoneCreateField, AoneCreateRequest, AoneStatus, AoneUpdateRequest, AoneWorkItem, AoneWorkItemDetail, ChatApprovalResponse, ChatAdapterInfo, ChatAttachment, ChatAttachmentKind, ChatSessionInfo, ChatSessionRecord, CliModelOption, CliOption, CopiedEntry, DingTalkBlockWriteResult, DingTalkDocDownloadFormat, DingTalkDocItem, DingTalkDownloadResult, DingTalkJsonmlDocument, DingTalkJsonmlInput, DingTalkJsonmlReadOptions, DingTalkJsonmlWriteResult, DingTalkMinutesItem, DingTalkStatus, DingTalkUploadFolderNode, DingTalkUploadResult, DingTalkUploadJob, DingTalkUploadTarget, DingTalkUploadWorkspace, FileNode, FileStat, LogEntry, LogFilter, PluginInfo, Project, SettingsPatch, StructuredEvent, Worktree } from './ade-types.js';
|
|
4
|
+
export interface ChatEvent {
|
|
5
|
+
id: string;
|
|
6
|
+
data?: string;
|
|
7
|
+
code?: number;
|
|
8
|
+
message?: string;
|
|
9
|
+
info?: ChatSessionInfo;
|
|
10
|
+
record?: ChatSessionRecord;
|
|
11
|
+
}
|
|
12
|
+
declare const api: {
|
|
13
|
+
projects: {
|
|
14
|
+
list: () => Promise<Project[]>;
|
|
15
|
+
add: (dir: string) => Promise<Project>;
|
|
16
|
+
remove: (dir: string) => Promise<void>;
|
|
17
|
+
touch: (dir: string) => Promise<void>;
|
|
18
|
+
pickDirectory: (title?: string, defaultPath?: string) => Promise<string | null>;
|
|
19
|
+
pickMarkdownFile: () => Promise<string | null>;
|
|
20
|
+
};
|
|
21
|
+
worktrees: {
|
|
22
|
+
list: (projectPath: string) => Promise<Worktree[]>;
|
|
23
|
+
create: (projectPath: string, taskName: string) => Promise<Worktree[]>;
|
|
24
|
+
remove: (projectPath: string, worktreePath: string) => Promise<Worktree[]>;
|
|
25
|
+
};
|
|
26
|
+
files: {
|
|
27
|
+
tree: (dir: string) => Promise<FileNode[]>;
|
|
28
|
+
read: (filePath: string) => Promise<string>;
|
|
29
|
+
readBinary: (filePath: string) => Promise<ArrayBuffer>;
|
|
30
|
+
write: (filePath: string, content: string) => Promise<void>;
|
|
31
|
+
isMarkdown: (filePath: string) => Promise<boolean>;
|
|
32
|
+
stat: (filePath: string) => Promise<FileStat>;
|
|
33
|
+
/** 过滤出确实存在的普通文件(清理持久化的历史标签页用) */
|
|
34
|
+
filterExisting: (filePaths: string[]) => Promise<string[]>;
|
|
35
|
+
watch: (filePath: string, callback: () => void) => (() => void);
|
|
36
|
+
createFile: (dir: string, name: string) => Promise<void>;
|
|
37
|
+
createDir: (dir: string, name: string) => Promise<void>;
|
|
38
|
+
rename: (oldPath: string, newName: string, clipboardPaths?: string[]) => Promise<string>;
|
|
39
|
+
/** 复制到目标目录;同名时自动使用「副本」命名,返回实际创建的条目 */
|
|
40
|
+
copy: (sourcePaths: string[], targetDir: string) => Promise<CopiedEntry[]>;
|
|
41
|
+
/** 把文件列表写进系统剪贴板(Finder / 资源管理器可以直接粘贴);自动剔除不存在的路径 */
|
|
42
|
+
writeClipboard: (sourcePaths: string[]) => Promise<void>;
|
|
43
|
+
/** 读取系统剪贴板里的文件列表(Finder / 资源管理器复制的文件,或绝对路径文本) */
|
|
44
|
+
readClipboard: () => Promise<string[]>;
|
|
45
|
+
trash: (filePath: string) => Promise<void>;
|
|
46
|
+
reveal: (filePath: string) => Promise<void>;
|
|
47
|
+
openExternal: (filePath: string) => Promise<void>;
|
|
48
|
+
/** Electron 32+ 不再提供 File.path;只暴露单个用户拖入文件的本地路径。 */
|
|
49
|
+
pathForFile: (file: File) => string;
|
|
50
|
+
};
|
|
51
|
+
chat: {
|
|
52
|
+
listAdapters: () => Promise<ChatAdapterInfo[]>;
|
|
53
|
+
listSessions: () => Promise<ChatSessionInfo[]>;
|
|
54
|
+
listHistory: () => Promise<ChatSessionRecord[]>;
|
|
55
|
+
syncProjectHistory: (projectPath: string, cwdPaths: string[]) => Promise<ChatSessionRecord[]>;
|
|
56
|
+
getRecord: (id: string) => Promise<ChatSessionRecord | undefined>;
|
|
57
|
+
pickAttachments: (kinds?: ChatAttachmentKind[]) => Promise<ChatAttachment[]>;
|
|
58
|
+
adapterOptions: (adapterId: string, refresh?: boolean) => Promise<CliOption[]>;
|
|
59
|
+
adapterModels: (adapterId: string, refresh?: boolean) => Promise<CliModelOption[]>;
|
|
60
|
+
updateConfig: (id: string, config: Record<string, string>) => Promise<void>;
|
|
61
|
+
start: (adapterId: string, cwd: string, worktree: string, config?: Record<string, string>, projectPath?: string | null) => Promise<ChatSessionRecord>;
|
|
62
|
+
write: (id: string, data: string) => Promise<void>;
|
|
63
|
+
resize: (id: string, cols: number, rows: number) => Promise<void>;
|
|
64
|
+
sendMessage: (id: string, prompt: string, attachments?: ChatAttachment[]) => Promise<void>;
|
|
65
|
+
switchView: (id: string, view: "terminal" | "chat") => Promise<void>;
|
|
66
|
+
stop: (id: string) => Promise<void>;
|
|
67
|
+
cancelTurn: (id: string) => Promise<void>;
|
|
68
|
+
activate: (id: string) => Promise<void>;
|
|
69
|
+
rename: (id: string, name: string) => Promise<void>;
|
|
70
|
+
touch: (id: string) => Promise<void>;
|
|
71
|
+
deleteHistory: (id: string) => Promise<void>;
|
|
72
|
+
deleteHistories: (ids: string[]) => Promise<void>;
|
|
73
|
+
respondApproval: (id: string, requestId: string, response: ChatApprovalResponse) => Promise<void>;
|
|
74
|
+
onData: (cb: (e: ChatEvent) => void) => (() => void);
|
|
75
|
+
onEvent: (cb: (e: {
|
|
76
|
+
id: string;
|
|
77
|
+
event: StructuredEvent;
|
|
78
|
+
}) => void) => (() => void);
|
|
79
|
+
onInfo: (cb: (e: {
|
|
80
|
+
id: string;
|
|
81
|
+
info: ChatSessionInfo;
|
|
82
|
+
}) => void) => (() => void);
|
|
83
|
+
onRecord: (cb: (e: {
|
|
84
|
+
id: string;
|
|
85
|
+
record: ChatSessionRecord;
|
|
86
|
+
}) => void) => (() => void);
|
|
87
|
+
onExit: (cb: (e: ChatEvent) => void) => (() => void);
|
|
88
|
+
onError: (cb: (e: ChatEvent) => void) => (() => void);
|
|
89
|
+
onStopped: (cb: (e: ChatEvent) => void) => (() => void);
|
|
90
|
+
onDeleted: (cb: (e: ChatEvent) => void) => (() => void);
|
|
91
|
+
};
|
|
92
|
+
app: {
|
|
93
|
+
getVersion: () => Promise<string>;
|
|
94
|
+
copyText: (text: string) => Promise<void>;
|
|
95
|
+
closeWindow: () => Promise<void>;
|
|
96
|
+
onCloseTab: (cb: () => void) => (() => void);
|
|
97
|
+
openDownload: (url: string) => Promise<void>;
|
|
98
|
+
checkUpdate: () => Promise<void>;
|
|
99
|
+
getUpdateStatus: () => Promise<unknown>;
|
|
100
|
+
installUpdate: () => Promise<void>;
|
|
101
|
+
onUpdateStatus: (cb: (status: unknown) => void) => (() => void);
|
|
102
|
+
};
|
|
103
|
+
daemon: {
|
|
104
|
+
getInfo: () => Promise<{
|
|
105
|
+
serverId: string;
|
|
106
|
+
publicKeyB64: string;
|
|
107
|
+
relay: {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
endpoint: string;
|
|
110
|
+
useTls: boolean;
|
|
111
|
+
offerBaseUrl: string;
|
|
112
|
+
status: string;
|
|
113
|
+
};
|
|
114
|
+
offerUrl: string;
|
|
115
|
+
configPath: string;
|
|
116
|
+
}>;
|
|
117
|
+
updateRelay: (config: {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
endpoint: string;
|
|
120
|
+
useTls: boolean;
|
|
121
|
+
offerBaseUrl: string;
|
|
122
|
+
}) => Promise<unknown>;
|
|
123
|
+
};
|
|
124
|
+
plugins: {
|
|
125
|
+
list: () => Promise<PluginInfo[]>;
|
|
126
|
+
exportSdk: () => Promise<string | null>;
|
|
127
|
+
pick: (source: "directory" | "zip") => Promise<string | null>;
|
|
128
|
+
install: (request: PluginInstallRequest) => Promise<PluginInfo>;
|
|
129
|
+
setEnabled: (id: string, enabled: boolean) => Promise<void>;
|
|
130
|
+
uninstall: (id: string) => Promise<void>;
|
|
131
|
+
getConfig: (id: string) => Promise<PluginConfig>;
|
|
132
|
+
setConfig: (id: string, patch: PluginConfig) => Promise<PluginConfig>;
|
|
133
|
+
executeCommand: (id: string, command: string, args?: unknown, context?: PluginCommandContext) => Promise<unknown>;
|
|
134
|
+
invokeService: (id: string, name: string, method: string, args?: unknown[]) => Promise<unknown>;
|
|
135
|
+
onChanged: (cb: (plugins: PluginInfo[]) => void) => (() => void);
|
|
136
|
+
};
|
|
137
|
+
settings: {
|
|
138
|
+
get: () => Promise<AdeSettingsFile>;
|
|
139
|
+
set: (patch: SettingsPatch) => Promise<AdeSettingsFile>;
|
|
140
|
+
listAgents: () => Promise<AgentSettingInfo[]>;
|
|
141
|
+
onChanged: (cb: (file: AdeSettingsFile) => void) => (() => void);
|
|
142
|
+
};
|
|
143
|
+
dingtalk: {
|
|
144
|
+
getUploadJob: (filePath: string) => Promise<DingTalkUploadJob | null>;
|
|
145
|
+
runUploadJob: (request: {
|
|
146
|
+
filePath: string;
|
|
147
|
+
title?: string;
|
|
148
|
+
folder?: string;
|
|
149
|
+
workspace?: string;
|
|
150
|
+
nodeId?: string;
|
|
151
|
+
}, retry?: boolean) => Promise<DingTalkUploadJob>;
|
|
152
|
+
getStatus: () => Promise<DingTalkStatus>;
|
|
153
|
+
login: () => Promise<{
|
|
154
|
+
started: boolean;
|
|
155
|
+
}>;
|
|
156
|
+
restartWukong: () => Promise<{
|
|
157
|
+
restarted: boolean;
|
|
158
|
+
message: string;
|
|
159
|
+
}>;
|
|
160
|
+
searchDocs: (query: string, source?: "recent" | "mine") => Promise<DingTalkDocItem[]>;
|
|
161
|
+
listMinutes: (query: string) => Promise<DingTalkMinutesItem[]>;
|
|
162
|
+
previewDoc: (node: string, preferredName?: string) => Promise<DingTalkDownloadResult>;
|
|
163
|
+
downloadDoc: (node: string, targetDir: string, format?: DingTalkDocDownloadFormat, preferredName?: string) => Promise<DingTalkDownloadResult>;
|
|
164
|
+
downloadMinutes: (taskUuid: string, targetDir: string, outputName?: string, format?: "dingmin" | "markdown") => Promise<DingTalkDownloadResult>;
|
|
165
|
+
uploadMarkdown: (filePath: string, title: string, folder: string, workspace: string) => Promise<DingTalkUploadResult>;
|
|
166
|
+
listUploadWorkspaces: () => Promise<DingTalkUploadWorkspace[]>;
|
|
167
|
+
listUploadFolders: (workspaceId: string, parentNodeId?: string) => Promise<DingTalkUploadFolderNode[]>;
|
|
168
|
+
resolveUploadTarget: (input: string) => Promise<DingTalkUploadTarget>;
|
|
169
|
+
listUploadDocs: (workspaceId: string, parentNodeId?: string) => Promise<DingTalkUploadFolderNode[]>;
|
|
170
|
+
overwriteDoc: (nodeId: string, filePath: string) => Promise<DingTalkUploadResult>;
|
|
171
|
+
readDocJsonml: (nodeId: string, options?: DingTalkJsonmlReadOptions) => Promise<DingTalkJsonmlDocument>;
|
|
172
|
+
overwriteDocJsonml: (nodeId: string, input: DingTalkJsonmlInput) => Promise<DingTalkJsonmlWriteResult>;
|
|
173
|
+
createDocWithJsonml: (name: string, input: DingTalkJsonmlInput, location?: {
|
|
174
|
+
folder?: string;
|
|
175
|
+
workspace?: string;
|
|
176
|
+
}) => Promise<DingTalkJsonmlWriteResult>;
|
|
177
|
+
listDocBlockElements: (nodeId: string, options?: {
|
|
178
|
+
startIndex?: number;
|
|
179
|
+
contentFormat?: "element" | "jsonml";
|
|
180
|
+
}) => Promise<unknown[]>;
|
|
181
|
+
updateDocBlock: (nodeId: string, blockId: string, element: unknown) => Promise<DingTalkBlockWriteResult>;
|
|
182
|
+
insertDocBlock: (nodeId: string, index: number, element: unknown) => Promise<DingTalkBlockWriteResult>;
|
|
183
|
+
};
|
|
184
|
+
aone: {
|
|
185
|
+
getStatus: () => Promise<AoneStatus>;
|
|
186
|
+
loadBoard: (request: AoneBoardRequest) => Promise<AoneBoardData>;
|
|
187
|
+
getWorkItem: (id: string) => Promise<AoneWorkItemDetail>;
|
|
188
|
+
getCreateFields: (projectId: string, typeId: string) => Promise<AoneCreateField[]>;
|
|
189
|
+
createWorkItem: (request: AoneCreateRequest) => Promise<AoneWorkItem>;
|
|
190
|
+
updateWorkItem: (request: AoneUpdateRequest) => Promise<void>;
|
|
191
|
+
createComment: (id: string, message: string) => Promise<void>;
|
|
192
|
+
changeRelation: (action: "add" | "remove", id: string, relationType: string, target: string) => Promise<void>;
|
|
193
|
+
pickAttachment: () => Promise<string | null>;
|
|
194
|
+
uploadAttachment: (id: string, projectId: string, filePath: string) => Promise<void>;
|
|
195
|
+
downloadAttachment: (id: string, attachmentId: string, suggestedName: string) => Promise<string | null>;
|
|
196
|
+
deleteAttachment: (id: string, attachmentId: string) => Promise<void>;
|
|
197
|
+
};
|
|
198
|
+
logs: {
|
|
199
|
+
list: (filter?: LogFilter) => Promise<LogEntry[]>;
|
|
200
|
+
scopes: () => Promise<string[]>;
|
|
201
|
+
clear: () => Promise<boolean>;
|
|
202
|
+
dir: () => Promise<string>;
|
|
203
|
+
summary: () => Promise<string>;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export type AdeApi = typeof api;
|
|
207
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** ADE 插件 API 版本;独立于应用版本。 */
|
|
2
|
+
export const PLUGIN_API_VERSION = 1
|
|
3
|
+
|
|
4
|
+
export type PluginConfig = Record<string, string | number | boolean>
|
|
5
|
+
export interface PluginSetting {
|
|
6
|
+
type: 'string' | 'number' | 'boolean' | 'select'
|
|
7
|
+
label: string
|
|
8
|
+
description?: string
|
|
9
|
+
default?: string | number | boolean
|
|
10
|
+
options?: { value: string; label: string }[]
|
|
11
|
+
min?: number
|
|
12
|
+
max?: number
|
|
13
|
+
multiline?: boolean
|
|
14
|
+
secret?: boolean
|
|
15
|
+
}
|
|
16
|
+
export type PluginSettingsSchema = Record<string, PluginSetting>
|
|
17
|
+
|
|
18
|
+
export interface PluginManifest {
|
|
19
|
+
/** 旧插件沿用合法 name,其他旧名称生成稳定 ID。新插件应显式声明小写 ID。 */
|
|
20
|
+
id?: string
|
|
21
|
+
name: string
|
|
22
|
+
version: string
|
|
23
|
+
description?: string
|
|
24
|
+
apiVersion?: number
|
|
25
|
+
/** 目标 ADE 主版本;只约束 major,插件自身 version 独立。缺省兼容旧插件。 */
|
|
26
|
+
adeMajor?: number
|
|
27
|
+
defaultEnabled?: boolean
|
|
28
|
+
main?: string
|
|
29
|
+
renderer?: string
|
|
30
|
+
rendererFormat?: 'module' | 'register'
|
|
31
|
+
styles?: string[]
|
|
32
|
+
settings?: PluginSettingsSchema
|
|
33
|
+
adapters?: {
|
|
34
|
+
id: string
|
|
35
|
+
label: string
|
|
36
|
+
description?: string
|
|
37
|
+
kind: 'terminal' | 'sdk'
|
|
38
|
+
command?: string
|
|
39
|
+
}[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PluginInfo {
|
|
43
|
+
id: string
|
|
44
|
+
name: string
|
|
45
|
+
version: string
|
|
46
|
+
description?: string
|
|
47
|
+
path: string
|
|
48
|
+
enabled: boolean
|
|
49
|
+
builtin: boolean
|
|
50
|
+
status: 'disabled' | 'loading' | 'active' | 'error'
|
|
51
|
+
error?: string
|
|
52
|
+
adapters: string[]
|
|
53
|
+
revision: number
|
|
54
|
+
rendererUrl?: string
|
|
55
|
+
rendererFormat?: 'module' | 'register'
|
|
56
|
+
styleUrls?: string[]
|
|
57
|
+
settingsSchema: PluginSettingsSchema
|
|
58
|
+
config: PluginConfig
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PluginInstallRequest {
|
|
62
|
+
source: 'directory' | 'zip' | 'npm' | 'git'
|
|
63
|
+
location: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface PluginCommandContext {
|
|
67
|
+
projectPath: string | null
|
|
68
|
+
worktreePath: string | null
|
|
69
|
+
filePath: string | null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PluginViewInfo {
|
|
73
|
+
id: string
|
|
74
|
+
title: string
|
|
75
|
+
defaultVisible?: boolean
|
|
76
|
+
defaultSize?: number
|
|
77
|
+
minSize?: number
|
|
78
|
+
maxSize?: number
|
|
79
|
+
order?: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type PluginDisposer = () => void | Promise<void>
|
|
83
|
+
|
|
84
|
+
/** 内置扩展位置,也允许插件定义自己的子 slot。 */
|
|
85
|
+
export type PluginSlotName = 'statusBar.left' | 'statusBar.right' | 'editor.toolbar' | 'settings' | (string & {})
|