adp-openclaw 0.0.70 → 0.0.72
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/dist/index.d.ts +13 -0
- package/dist/index.js +190 -0
- package/dist/src/adp-upload-tool.d.ts +246 -0
- package/dist/src/adp-upload-tool.js +567 -0
- package/dist/src/channel.d.ts +18 -0
- package/dist/src/channel.js +259 -0
- package/dist/src/config-schema.d.ts +18 -0
- package/dist/src/config-schema.js +8 -0
- package/dist/src/monitor.d.ts +12 -0
- package/dist/src/monitor.js +794 -0
- package/dist/src/onboarding.d.ts +3 -0
- package/dist/src/onboarding.js +113 -0
- package/dist/src/runtime.d.ts +17 -0
- package/dist/src/runtime.js +26 -0
- package/dist/src/session-history.d.ts +161 -0
- package/dist/src/session-history.js +796 -0
- package/dist/src/tool-result-message-blocks.d.ts +55 -0
- package/dist/src/tool-result-message-blocks.js +193 -0
- package/package.json +13 -2
- package/index.ts +0 -265
- package/src/adp-upload-tool.test.ts +0 -122
- package/src/adp-upload-tool.ts +0 -819
- package/src/channel.ts +0 -297
- package/src/config-schema.ts +0 -8
- package/src/monitor.ts +0 -954
- package/src/onboarding.ts +0 -139
- package/src/runtime.ts +0 -48
- package/src/session-history.ts +0 -1081
- package/src/tool-result-message-blocks.ts +0 -259
- package/uploadfile.pb +0 -33
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
|
+
export { getOpenClawChatHistory, listOpenClawSessions, getSessionPreviews, getChatHistoryByConversationId, resolveSessionKey, configureSessionFileReader, getSessionFileConfig, getOpenClawChatHistoryViaCli, listOpenClawSessionsViaCli, getChatHistory, listSessions, type OpenClawSession, type OpenClawMessage, type ChatHistoryResponse, type SessionsListResponse, type SessionFileConfig, } from "./src/session-history.js";
|
|
3
|
+
export { ADP_UPLOAD_TOOL_NAME, ADP_UPLOAD_TOOL_SCHEMA, ADP_UPLOAD_TOOL_MAX_PATHS, ADP_UPLOAD_TOOL_MIN_PATHS, ADP_UPLOAD_TOOL_MAX_CONCURRENCY, ADP_UPLOAD_VALIDATION_MESSAGE, adpUploadFile, adpUploadFiles, adpUploadFileWithConfig, adpUploadFilesWithConfig, getStorageCredential, uploadFileToCos, resolveClientToken, AdpUploader, parseAdpUploadToolParams, uploadFilesToAdpEndpoint, executeAdpUploadTool, type UploadResult, type AdpUploadToolParams, type AdpUploadToolResult, type UploadedFileInfo, type AdpUploadOptions, type DescribeRemoteBotStorageCredentialReq, type DescribeRemoteBotStorageCredentialRsp, type Credentials, } from "./src/adp-upload-tool.js";
|
|
4
|
+
export { dispatchToolResultToMessageBlocks, buildToolResultSessionContentBlocks, formatUploadResultForUser, formatUploadResultAsMarkdown, type ResourceLinkBlock, type TextBlock, type ContentBlock, type MessageBlock, } from "./src/tool-result-message-blocks.js";
|
|
5
|
+
declare const plugin: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
configSchema: any;
|
|
10
|
+
register(api: OpenClawPluginApi): void;
|
|
11
|
+
};
|
|
12
|
+
export default plugin;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
2
|
+
import { adpOpenclawPlugin } from "./src/channel.js";
|
|
3
|
+
import { setAdpOpenclawRuntime } from "./src/runtime.js";
|
|
4
|
+
import { ADP_UPLOAD_TOOL_NAME, ADP_UPLOAD_TOOL_SCHEMA, parseAdpUploadToolParams, uploadFilesToAdpEndpoint, uploadResultEmitter, UPLOAD_RESULT_EVENT, } from "./src/adp-upload-tool.js";
|
|
5
|
+
// Track whether register() has been called at least once (for log dedup)
|
|
6
|
+
let _registerCallCount = 0;
|
|
7
|
+
// Export session history functions for external use
|
|
8
|
+
// NOTE: These are re-exported for external consumers. The session-history module
|
|
9
|
+
// is heavy (uses node:child_process, node:fs) but these exports do not affect
|
|
10
|
+
// register() performance since they are only loaded when actually imported by consumers.
|
|
11
|
+
export { getOpenClawChatHistory, listOpenClawSessions, getSessionPreviews, getChatHistoryByConversationId, resolveSessionKey, configureSessionFileReader, getSessionFileConfig,
|
|
12
|
+
// CLI-based functions
|
|
13
|
+
getOpenClawChatHistoryViaCli, listOpenClawSessionsViaCli,
|
|
14
|
+
// Auto-selecting functions
|
|
15
|
+
getChatHistory, listSessions, } from "./src/session-history.js";
|
|
16
|
+
// Export ADP upload tool functions and types
|
|
17
|
+
export {
|
|
18
|
+
// Tool name and schema
|
|
19
|
+
ADP_UPLOAD_TOOL_NAME, ADP_UPLOAD_TOOL_SCHEMA, ADP_UPLOAD_TOOL_MAX_PATHS, ADP_UPLOAD_TOOL_MIN_PATHS, ADP_UPLOAD_TOOL_MAX_CONCURRENCY, ADP_UPLOAD_VALIDATION_MESSAGE,
|
|
20
|
+
// Main functions
|
|
21
|
+
adpUploadFile, adpUploadFiles, adpUploadFileWithConfig, adpUploadFilesWithConfig, getStorageCredential, uploadFileToCos, resolveClientToken,
|
|
22
|
+
// Class
|
|
23
|
+
AdpUploader,
|
|
24
|
+
// Tool execution functions
|
|
25
|
+
parseAdpUploadToolParams, uploadFilesToAdpEndpoint, executeAdpUploadTool, } from "./src/adp-upload-tool.js";
|
|
26
|
+
// Export tool result message blocks functions
|
|
27
|
+
export { dispatchToolResultToMessageBlocks, buildToolResultSessionContentBlocks, formatUploadResultForUser, formatUploadResultAsMarkdown, } from "./src/tool-result-message-blocks.js";
|
|
28
|
+
// Helper to format tool result as JSON string
|
|
29
|
+
const formatToolResultJson = (result) => JSON.stringify(result, null, 2) ?? "upload failed";
|
|
30
|
+
const plugin = {
|
|
31
|
+
id: "adp-openclaw",
|
|
32
|
+
name: "ADP OpenClaw",
|
|
33
|
+
description: "ADP channel plugin backed by a Go WebSocket server",
|
|
34
|
+
configSchema: emptyPluginConfigSchema(),
|
|
35
|
+
register(api) {
|
|
36
|
+
_registerCallCount++;
|
|
37
|
+
// Only log on first registration to avoid flooding logs
|
|
38
|
+
// (OpenClaw framework calls register() for each subsystem independently)
|
|
39
|
+
if (_registerCallCount === 1) {
|
|
40
|
+
api.logger.info?.("[adp-openclaw] Plugin register() called");
|
|
41
|
+
api.logger.info?.(`[adp-openclaw] Registering tool factory: ${ADP_UPLOAD_TOOL_NAME}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
api.logger.debug?.(`[adp-openclaw] Plugin register() called (call #${_registerCallCount})`);
|
|
45
|
+
}
|
|
46
|
+
setAdpOpenclawRuntime(api.runtime);
|
|
47
|
+
api.registerTool((ctx) => {
|
|
48
|
+
// Only expose this tool when the message comes from the adp-openclaw channel
|
|
49
|
+
const channel = ctx.messageChannel ?? "";
|
|
50
|
+
if (channel && channel !== "adp-openclaw") {
|
|
51
|
+
api.logger.debug?.(`[adp-openclaw] Skipping ${ADP_UPLOAD_TOOL_NAME} for channel: ${channel}`);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
name: ADP_UPLOAD_TOOL_NAME,
|
|
56
|
+
description: "If you can see this tool description, you are connected to the ADP server. " +
|
|
57
|
+
"Use this tool to send 1-10 local files of any type (including images and documents) to the user. " +
|
|
58
|
+
"A successful call means the files were uploaded and download URLs are returned. " +
|
|
59
|
+
"IMPORTANT: You MUST include the download URLs in your response to the user, " +
|
|
60
|
+
"and remind the user that the download links are valid for 24 hours. " +
|
|
61
|
+
"Parameters must be local filesystem paths only.",
|
|
62
|
+
parameters: ADP_UPLOAD_TOOL_SCHEMA,
|
|
63
|
+
async execute(toolCallId, params) {
|
|
64
|
+
// Get bot token from channel config
|
|
65
|
+
const getClientToken = () => {
|
|
66
|
+
try {
|
|
67
|
+
const cfg = api.runtime?.config?.loadConfig?.();
|
|
68
|
+
const channelCfg = cfg?.channels?.["adp-openclaw"];
|
|
69
|
+
return channelCfg?.clientToken?.trim() || process.env.ADP_OPENCLAW_CLIENT_TOKEN;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return process.env.ADP_OPENCLAW_CLIENT_TOKEN;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// Parse and validate parameters
|
|
76
|
+
const parsed = parseAdpUploadToolParams(params);
|
|
77
|
+
if (!parsed.ok) {
|
|
78
|
+
const errorResult = {
|
|
79
|
+
ok: false,
|
|
80
|
+
error: formatToolResultJson(parsed.error),
|
|
81
|
+
};
|
|
82
|
+
api.logger.debug?.(`[${ADP_UPLOAD_TOOL_NAME}] validation failed toolCallId=${toolCallId} error=${errorResult.error}`);
|
|
83
|
+
return {
|
|
84
|
+
output: errorResult,
|
|
85
|
+
result: errorResult,
|
|
86
|
+
details: errorResult,
|
|
87
|
+
content: [{ type: "text", text: formatToolResultJson(parsed.error) }],
|
|
88
|
+
isError: true,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// Get bot token
|
|
92
|
+
const botToken = getClientToken();
|
|
93
|
+
if (!botToken) {
|
|
94
|
+
const errorResult = {
|
|
95
|
+
ok: false,
|
|
96
|
+
error: "missing bot token for file upload - please configure clientToken in adp-openclaw channel settings",
|
|
97
|
+
};
|
|
98
|
+
api.logger.debug?.(`[${ADP_UPLOAD_TOOL_NAME}] token missing toolCallId=${toolCallId} paths=${JSON.stringify(parsed.value.paths)}`);
|
|
99
|
+
return {
|
|
100
|
+
output: errorResult,
|
|
101
|
+
result: errorResult,
|
|
102
|
+
details: errorResult,
|
|
103
|
+
content: [{ type: "text", text: errorResult.error }],
|
|
104
|
+
isError: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Execute upload
|
|
108
|
+
const uploadResult = await uploadFilesToAdpEndpoint(parsed.value.paths, {
|
|
109
|
+
botToken,
|
|
110
|
+
fileType: parsed.value.fileType,
|
|
111
|
+
});
|
|
112
|
+
if (!uploadResult.ok) {
|
|
113
|
+
const errorResult = {
|
|
114
|
+
ok: false,
|
|
115
|
+
error: formatToolResultJson(uploadResult.error),
|
|
116
|
+
};
|
|
117
|
+
api.logger.debug?.(`[${ADP_UPLOAD_TOOL_NAME}] upload failed toolCallId=${toolCallId} paths=${JSON.stringify(parsed.value.paths)} error=${errorResult.error}`);
|
|
118
|
+
return {
|
|
119
|
+
output: errorResult,
|
|
120
|
+
result: errorResult,
|
|
121
|
+
details: errorResult,
|
|
122
|
+
content: [{ type: "text", text: formatToolResultJson(uploadResult.error) }],
|
|
123
|
+
isError: true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Success - format result with download URLs
|
|
127
|
+
const successResult = {
|
|
128
|
+
ok: true,
|
|
129
|
+
files: uploadResult.files,
|
|
130
|
+
};
|
|
131
|
+
api.logger.debug?.(`[${ADP_UPLOAD_TOOL_NAME}] upload success toolCallId=${toolCallId} count=${successResult.files?.length ?? 0} paths=${JSON.stringify(parsed.value.paths)}`);
|
|
132
|
+
// Debug: print full downloadUrl for each file
|
|
133
|
+
for (const file of (successResult.files || [])) {
|
|
134
|
+
api.logger.info?.(`[${ADP_UPLOAD_TOOL_NAME}] file.downloadUrl: ${file.downloadUrl}`);
|
|
135
|
+
api.logger.info?.(`[${ADP_UPLOAD_TOOL_NAME}] file.uri: ${file.uri}`);
|
|
136
|
+
}
|
|
137
|
+
// 发射上传结果事件,让 monitor.ts 能够直接获取完整的下载链接
|
|
138
|
+
uploadResultEmitter.emit(UPLOAD_RESULT_EVENT, {
|
|
139
|
+
toolCallId,
|
|
140
|
+
result: successResult,
|
|
141
|
+
});
|
|
142
|
+
// Build content with resource links and download URLs
|
|
143
|
+
const content = [];
|
|
144
|
+
// Add resource links for each file
|
|
145
|
+
for (const file of (successResult.files || [])) {
|
|
146
|
+
content.push({
|
|
147
|
+
type: "resource_link",
|
|
148
|
+
uri: file.downloadUrl || file.uri, // 使用带签名的下载链接
|
|
149
|
+
name: file.name,
|
|
150
|
+
mimeType: file.mimeType,
|
|
151
|
+
downloadUrl: file.downloadUrl, // 也包含 downloadUrl 字段
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// Add a text summary with download URLs for AI to include in response
|
|
155
|
+
// 注意:URL 包含签名参数,必须完整保留,不能截断或修改
|
|
156
|
+
const urlSummary = (successResult.files || [])
|
|
157
|
+
.map((f) => {
|
|
158
|
+
const url = f.downloadUrl || f.uri;
|
|
159
|
+
// 把完整 URL 作为代码块,防止 AI 截断或修改
|
|
160
|
+
return `- **${f.name}**: \`${url}\``;
|
|
161
|
+
})
|
|
162
|
+
.join("\n");
|
|
163
|
+
api.logger.info?.(`[${ADP_UPLOAD_TOOL_NAME}] urlSummary: ${urlSummary}`);
|
|
164
|
+
content.push({
|
|
165
|
+
type: "text",
|
|
166
|
+
text: `Files uploaded successfully:\n${urlSummary}\n\n⚠️ IMPORTANT: The URLs above contain authentication signatures. You MUST copy the ENTIRE URL exactly as shown (including all query parameters after the "?"). Do NOT truncate or modify the URLs in any way. The links are valid for 24 hours.`,
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
output: successResult,
|
|
170
|
+
result: successResult,
|
|
171
|
+
details: successResult,
|
|
172
|
+
content,
|
|
173
|
+
isError: false,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
}; // end of tool object
|
|
177
|
+
}); // end of factory function passed to registerTool
|
|
178
|
+
// Log tool registration success (only first time)
|
|
179
|
+
if (_registerCallCount === 1) {
|
|
180
|
+
api.logger.info?.(`[adp-openclaw] Tool ${ADP_UPLOAD_TOOL_NAME} registered successfully`);
|
|
181
|
+
}
|
|
182
|
+
// Register the channel plugin
|
|
183
|
+
api.registerChannel({ plugin: adpOpenclawPlugin });
|
|
184
|
+
if (_registerCallCount === 1) {
|
|
185
|
+
api.logger.info?.("[adp-openclaw] Plugin registration complete");
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
export default plugin;
|
|
190
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADP Upload Tool
|
|
3
|
+
*
|
|
4
|
+
* 功能:
|
|
5
|
+
* 1. 通过固定接口获取预签名的上传URL和下载URL
|
|
6
|
+
* 2. 使用预签名URL直接PUT上传文件到COS
|
|
7
|
+
* 3. 返回文件下载链接
|
|
8
|
+
*
|
|
9
|
+
* 注意:机器人 token 从 adp-openclaw 插件配置的 clientToken 读取
|
|
10
|
+
*/
|
|
11
|
+
import { EventEmitter } from "node:events";
|
|
12
|
+
import type { AdpOpenclawChannelConfig } from "./channel.js";
|
|
13
|
+
/** 上传结果事件发射器,用于通知其他模块上传完成 */
|
|
14
|
+
export declare const uploadResultEmitter: EventEmitter<[never]>;
|
|
15
|
+
/** 上传结果事件名称 */
|
|
16
|
+
export declare const UPLOAD_RESULT_EVENT = "adp-upload-result";
|
|
17
|
+
/** 存储凭证请求参数 */
|
|
18
|
+
export interface DescribeRemoteBotStorageCredentialReq {
|
|
19
|
+
token: string;
|
|
20
|
+
file_type?: string;
|
|
21
|
+
}
|
|
22
|
+
/** 临时凭证信息 */
|
|
23
|
+
export interface Credentials {
|
|
24
|
+
token: string;
|
|
25
|
+
tmp_secret_id: string;
|
|
26
|
+
tmp_secret_key: string;
|
|
27
|
+
}
|
|
28
|
+
/** 存储凭证响应 */
|
|
29
|
+
export interface DescribeRemoteBotStorageCredentialRsp {
|
|
30
|
+
credentials: Credentials;
|
|
31
|
+
expired_time: number;
|
|
32
|
+
start_time: number;
|
|
33
|
+
bucket: string;
|
|
34
|
+
region: string;
|
|
35
|
+
file_path: string;
|
|
36
|
+
upload_url: string;
|
|
37
|
+
file_url: string;
|
|
38
|
+
}
|
|
39
|
+
/** 上传结果 */
|
|
40
|
+
export interface UploadResult {
|
|
41
|
+
ok: boolean;
|
|
42
|
+
fileUrl?: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 获取COS临时密钥
|
|
47
|
+
*/
|
|
48
|
+
export declare function getStorageCredential(token: string, fileType?: string): Promise<DescribeRemoteBotStorageCredentialRsp>;
|
|
49
|
+
/**
|
|
50
|
+
* 上传文件到COS(使用预签名URL直接PUT上传)
|
|
51
|
+
*
|
|
52
|
+
* @param filePath - 本地文件路径
|
|
53
|
+
* @param credential - 存储凭证(包含预签名的 upload_url 和 file_url)
|
|
54
|
+
* @returns 文件下载URL
|
|
55
|
+
*/
|
|
56
|
+
export declare function uploadFileToCos(filePath: string, credential: DescribeRemoteBotStorageCredentialRsp): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* 从插件配置或环境变量中获取 clientToken
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveClientToken(channelCfg?: AdpOpenclawChannelConfig): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* ADP 上传工具主函数(使用显式传入的 token)
|
|
63
|
+
*
|
|
64
|
+
* @param filePath - 要上传的本地文件路径
|
|
65
|
+
* @param botToken - 机器人 token
|
|
66
|
+
* @param fileType - 文件类型(可选)
|
|
67
|
+
* @returns 上传结果,包含下载链接或错误信息
|
|
68
|
+
*/
|
|
69
|
+
export declare function adpUploadFile(filePath: string, botToken: string, fileType?: string): Promise<UploadResult>;
|
|
70
|
+
/**
|
|
71
|
+
* ADP 上传工具主函数(从配置读取 token)
|
|
72
|
+
*
|
|
73
|
+
* @param filePath - 要上传的本地文件路径
|
|
74
|
+
* @param channelCfg - adp-openclaw 插件配置(包含 clientToken)
|
|
75
|
+
* @param fileType - 文件类型(可选)
|
|
76
|
+
* @returns 上传结果,包含下载签名链接或错误信息
|
|
77
|
+
*/
|
|
78
|
+
export declare function adpUploadFileWithConfig(filePath: string, channelCfg?: AdpOpenclawChannelConfig, fileType?: string): Promise<UploadResult>;
|
|
79
|
+
/**
|
|
80
|
+
* 批量上传文件(使用显式传入的 token)
|
|
81
|
+
*
|
|
82
|
+
* 注意:每个文件需要独立获取预签名URL,因为服务端为每个文件生成唯一路径
|
|
83
|
+
*
|
|
84
|
+
* @param filePaths - 要上传的本地文件路径列表
|
|
85
|
+
* @param botToken - 机器人 token
|
|
86
|
+
* @param fileType - 文件类型(可选)
|
|
87
|
+
* @returns 上传结果列表
|
|
88
|
+
*/
|
|
89
|
+
export declare function adpUploadFiles(filePaths: string[], botToken: string, fileType?: string): Promise<UploadResult[]>;
|
|
90
|
+
/**
|
|
91
|
+
* 批量上传文件(从配置读取 token)
|
|
92
|
+
*
|
|
93
|
+
* @param filePaths - 要上传的本地文件路径列表
|
|
94
|
+
* @param channelCfg - adp-openclaw 插件配置(包含 clientToken)
|
|
95
|
+
* @param fileType - 文件类型(可选)
|
|
96
|
+
* @returns 上传结果列表
|
|
97
|
+
*/
|
|
98
|
+
export declare function adpUploadFilesWithConfig(filePaths: string[], channelCfg?: AdpOpenclawChannelConfig, fileType?: string): Promise<UploadResult[]>;
|
|
99
|
+
/**
|
|
100
|
+
* ADP 上传工具类
|
|
101
|
+
*
|
|
102
|
+
* 封装了从 adp-openclaw 配置读取 clientToken 的逻辑
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* import { AdpUploader } from "./adp-upload-tool.js";
|
|
107
|
+
*
|
|
108
|
+
* // 从插件配置创建上传器
|
|
109
|
+
* const uploader = new AdpUploader(channelConfig);
|
|
110
|
+
*
|
|
111
|
+
* // 或者从环境变量创建(不传参数)
|
|
112
|
+
* const uploader = new AdpUploader();
|
|
113
|
+
*
|
|
114
|
+
* // 单文件上传
|
|
115
|
+
* const result = await uploader.upload("/path/to/file.pdf");
|
|
116
|
+
*
|
|
117
|
+
* // 批量上传
|
|
118
|
+
* const results = await uploader.uploadMultiple(["/path/to/file1.pdf", "/path/to/file2.png"]);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare class AdpUploader {
|
|
122
|
+
private clientToken;
|
|
123
|
+
/**
|
|
124
|
+
* 创建 ADP 上传器实例
|
|
125
|
+
*
|
|
126
|
+
* @param channelCfg - adp-openclaw 插件配置,如果不传则从环境变量读取
|
|
127
|
+
*/
|
|
128
|
+
constructor(channelCfg?: AdpOpenclawChannelConfig);
|
|
129
|
+
/**
|
|
130
|
+
* 检查是否已配置 token
|
|
131
|
+
*/
|
|
132
|
+
isConfigured(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* 获取当前使用的 token(脱敏显示)
|
|
135
|
+
*/
|
|
136
|
+
getTokenPreview(): string | null;
|
|
137
|
+
/**
|
|
138
|
+
* 上传单个文件
|
|
139
|
+
*
|
|
140
|
+
* @param filePath - 要上传的本地文件路径
|
|
141
|
+
* @param fileType - 文件类型(可选)
|
|
142
|
+
* @returns 上传结果
|
|
143
|
+
*/
|
|
144
|
+
upload(filePath: string, fileType?: string): Promise<UploadResult>;
|
|
145
|
+
/**
|
|
146
|
+
* 批量上传文件
|
|
147
|
+
*
|
|
148
|
+
* @param filePaths - 要上传的本地文件路径列表
|
|
149
|
+
* @param fileType - 文件类型(可选)
|
|
150
|
+
* @returns 上传结果列表
|
|
151
|
+
*/
|
|
152
|
+
uploadMultiple(filePaths: string[], fileType?: string): Promise<UploadResult[]>;
|
|
153
|
+
}
|
|
154
|
+
export declare const ADP_UPLOAD_TOOL_NAME = "adp_upload_file";
|
|
155
|
+
export declare const ADP_UPLOAD_TOOL_SCHEMA: {
|
|
156
|
+
title: string;
|
|
157
|
+
type: string;
|
|
158
|
+
description: string;
|
|
159
|
+
additionalProperties: boolean;
|
|
160
|
+
required: string[];
|
|
161
|
+
properties: {
|
|
162
|
+
paths: {
|
|
163
|
+
type: string;
|
|
164
|
+
minItems: number;
|
|
165
|
+
maxItems: number;
|
|
166
|
+
description: string;
|
|
167
|
+
items: {
|
|
168
|
+
type: string;
|
|
169
|
+
minLength: number;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
fileType: {
|
|
174
|
+
type: string;
|
|
175
|
+
description: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
export declare const ADP_UPLOAD_TOOL_MAX_PATHS = 10;
|
|
180
|
+
export declare const ADP_UPLOAD_TOOL_MIN_PATHS = 1;
|
|
181
|
+
export declare const ADP_UPLOAD_TOOL_MAX_CONCURRENCY = 3;
|
|
182
|
+
export declare const ADP_UPLOAD_VALIDATION_MESSAGE: string;
|
|
183
|
+
interface ValidationError {
|
|
184
|
+
ok: false;
|
|
185
|
+
error: {
|
|
186
|
+
code: number;
|
|
187
|
+
message: string;
|
|
188
|
+
data: {
|
|
189
|
+
field: string;
|
|
190
|
+
reason: string;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
interface ValidationSuccess<T> {
|
|
195
|
+
ok: true;
|
|
196
|
+
value: T;
|
|
197
|
+
}
|
|
198
|
+
type ValidationResult<T> = ValidationError | ValidationSuccess<T>;
|
|
199
|
+
export interface AdpUploadToolParams {
|
|
200
|
+
paths: string[];
|
|
201
|
+
fileType?: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 解析 ADP 上传工具参数
|
|
205
|
+
*/
|
|
206
|
+
export declare const parseAdpUploadToolParams: (params: unknown) => ValidationResult<AdpUploadToolParams>;
|
|
207
|
+
/** 成功上传的文件信息 */
|
|
208
|
+
export interface UploadedFileInfo {
|
|
209
|
+
uri: string;
|
|
210
|
+
name: string;
|
|
211
|
+
mimeType: string;
|
|
212
|
+
downloadUrl?: string;
|
|
213
|
+
}
|
|
214
|
+
/** 完整上传结果 */
|
|
215
|
+
export interface AdpUploadToolResult {
|
|
216
|
+
ok: boolean;
|
|
217
|
+
files?: UploadedFileInfo[];
|
|
218
|
+
/** 预格式化的消息,AI 可以直接展示给用户(不要用代码块包装) */
|
|
219
|
+
message?: string;
|
|
220
|
+
error?: {
|
|
221
|
+
code: number;
|
|
222
|
+
message: string;
|
|
223
|
+
data?: {
|
|
224
|
+
field: string;
|
|
225
|
+
reason: string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export interface AdpUploadOptions {
|
|
230
|
+
botToken: string;
|
|
231
|
+
fileType?: string;
|
|
232
|
+
maxConcurrency?: number;
|
|
233
|
+
requestTimeoutMs?: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 上传文件到 ADP 存储(返回兼容 kimi 格式的结果)
|
|
237
|
+
*
|
|
238
|
+
* 注意:每个文件需要独立获取预签名URL,因为服务端为每个文件生成唯一路径
|
|
239
|
+
*/
|
|
240
|
+
export declare const uploadFilesToAdpEndpoint: (paths: string[], options: AdpUploadOptions) => Promise<AdpUploadToolResult>;
|
|
241
|
+
/**
|
|
242
|
+
* 执行 ADP 上传工具(解析参数并上传)
|
|
243
|
+
*/
|
|
244
|
+
export declare const executeAdpUploadTool: (params: unknown, botToken: string, options?: Partial<AdpUploadOptions>) => Promise<AdpUploadToolResult>;
|
|
245
|
+
export {};
|
|
246
|
+
//# sourceMappingURL=adp-upload-tool.d.ts.map
|