@reachv2/sdk 0.1.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/README.md +153 -0
- package/dist/client.d.ts +59 -0
- package/dist/client.js +107 -0
- package/dist/error.d.ts +6 -0
- package/dist/error.js +9 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +22 -0
- package/dist/resources/abis.d.ts +20 -0
- package/dist/resources/abis.js +17 -0
- package/dist/resources/accounts.d.ts +15 -0
- package/dist/resources/accounts.js +17 -0
- package/dist/resources/admin.d.ts +34 -0
- package/dist/resources/admin.js +41 -0
- package/dist/resources/agent-api.d.ts +61 -0
- package/dist/resources/agent-api.js +112 -0
- package/dist/resources/api-key.d.ts +42 -0
- package/dist/resources/api-key.js +17 -0
- package/dist/resources/auth.d.ts +24 -0
- package/dist/resources/auth.js +40 -0
- package/dist/resources/bot.d.ts +17 -0
- package/dist/resources/bot.js +29 -0
- package/dist/resources/channel.d.ts +23 -0
- package/dist/resources/channel.js +25 -0
- package/dist/resources/chat.d.ts +9 -0
- package/dist/resources/chat.js +9 -0
- package/dist/resources/content.d.ts +25 -0
- package/dist/resources/content.js +43 -0
- package/dist/resources/conversation.d.ts +19 -0
- package/dist/resources/conversation.js +24 -0
- package/dist/resources/dashboard-api.d.ts +31 -0
- package/dist/resources/dashboard-api.js +45 -0
- package/dist/resources/internalAgent.d.ts +70 -0
- package/dist/resources/internalAgent.js +60 -0
- package/dist/resources/knowledge.d.ts +17 -0
- package/dist/resources/knowledge.js +17 -0
- package/dist/resources/lightrag.d.ts +80 -0
- package/dist/resources/lightrag.js +92 -0
- package/dist/resources/orchestration.d.ts +46 -0
- package/dist/resources/orchestration.js +42 -0
- package/dist/resources/project.d.ts +14 -0
- package/dist/resources/project.js +20 -0
- package/dist/resources/scheduledTasks.d.ts +29 -0
- package/dist/resources/scheduledTasks.js +22 -0
- package/dist/resources/transaction.d.ts +28 -0
- package/dist/resources/transaction.js +24 -0
- package/dist/resources/tts.d.ts +17 -0
- package/dist/resources/tts.js +22 -0
- package/dist/types.d.ts +793 -0
- package/dist/types.js +1 -0
- package/package.json +47 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
export interface ReachClientConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
token?: string;
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Server API base URL (defaults to baseUrl). Used for auth, agentx, chat endpoints. */
|
|
6
|
+
serverBaseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export type BotType = "customer_service" | "sales" | "custom" | "transaction";
|
|
9
|
+
/** Agent 类型(bot.type 直通:support/sales/custom/transaction/omnichat/internal) */
|
|
10
|
+
export type AgentType = "support" | "sales" | "custom" | "transaction" | "omnichat" | "internal";
|
|
11
|
+
export type BotStatus = "running" | "stopped";
|
|
12
|
+
export type ChannelType = "telegram" | "whatsapp" | "webwidget";
|
|
13
|
+
export type ChannelStatus = "configured" | "unconfigured" | "pairing";
|
|
14
|
+
export type KnowledgeStatus = "processing" | "ready" | "error";
|
|
15
|
+
export type RequestMethod = "GET" | "POST" | "PATCH" | "DELETE";
|
|
16
|
+
export interface Pagination {
|
|
17
|
+
page: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
total: number;
|
|
20
|
+
totalPages: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PaginatedResponse<T> {
|
|
23
|
+
items: T[];
|
|
24
|
+
pagination: Pagination;
|
|
25
|
+
}
|
|
26
|
+
export interface Project {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ProjectCreateParams {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ProjectUpdateParams {
|
|
38
|
+
name?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface TransactionBotConfig {
|
|
42
|
+
chains: number[];
|
|
43
|
+
allowUnknownContracts: boolean;
|
|
44
|
+
enableSimulation: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface Bot {
|
|
47
|
+
id: string;
|
|
48
|
+
projectId: string;
|
|
49
|
+
name: string;
|
|
50
|
+
type: BotType;
|
|
51
|
+
status: BotStatus;
|
|
52
|
+
prompt: string;
|
|
53
|
+
welcomeMessage?: string;
|
|
54
|
+
config?: TransactionBotConfig;
|
|
55
|
+
stats: BotStats;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
}
|
|
59
|
+
export interface BotStats {
|
|
60
|
+
conversations: number;
|
|
61
|
+
tokens: number;
|
|
62
|
+
}
|
|
63
|
+
export interface BotCreateParams {
|
|
64
|
+
projectId: string;
|
|
65
|
+
name: string;
|
|
66
|
+
type: BotType;
|
|
67
|
+
prompt: string;
|
|
68
|
+
welcomeMessage?: string;
|
|
69
|
+
config?: TransactionBotConfig;
|
|
70
|
+
}
|
|
71
|
+
export interface BotUpdateParams {
|
|
72
|
+
name?: string;
|
|
73
|
+
type?: BotType;
|
|
74
|
+
prompt?: string;
|
|
75
|
+
welcomeMessage?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface KnowledgeDoc {
|
|
78
|
+
id: string;
|
|
79
|
+
botId: string;
|
|
80
|
+
title: string;
|
|
81
|
+
fileName: string;
|
|
82
|
+
format: string;
|
|
83
|
+
size: number;
|
|
84
|
+
status: KnowledgeStatus;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
}
|
|
87
|
+
export interface KnowledgeRecommendation {
|
|
88
|
+
botType: BotType;
|
|
89
|
+
title: string;
|
|
90
|
+
description: string;
|
|
91
|
+
}
|
|
92
|
+
export interface Channel {
|
|
93
|
+
id: string;
|
|
94
|
+
botId: string;
|
|
95
|
+
type: ChannelType;
|
|
96
|
+
status: ChannelStatus;
|
|
97
|
+
token?: string;
|
|
98
|
+
widgetId?: string;
|
|
99
|
+
embedCode?: string;
|
|
100
|
+
qrCode?: string;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ChannelConfigureParams {
|
|
105
|
+
type: ChannelType;
|
|
106
|
+
token?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface Conversation {
|
|
109
|
+
id: string;
|
|
110
|
+
botId: string;
|
|
111
|
+
channel: ChannelType;
|
|
112
|
+
status: "active" | "closed" | "transferred";
|
|
113
|
+
messageCount: number;
|
|
114
|
+
lastMessage?: string;
|
|
115
|
+
lastMessageAt?: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
}
|
|
118
|
+
export interface Message {
|
|
119
|
+
id: string;
|
|
120
|
+
conversationId: string;
|
|
121
|
+
role: "user" | "bot" | "human";
|
|
122
|
+
content: string;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ChatToolFunction {
|
|
126
|
+
name: string;
|
|
127
|
+
description: string;
|
|
128
|
+
parameters: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
export interface ChatToolDefinition {
|
|
131
|
+
type: 'function';
|
|
132
|
+
function: ChatToolFunction;
|
|
133
|
+
/** HTTP endpoint reach server POSTs {tool, arguments} to for execution */
|
|
134
|
+
callback_url: string;
|
|
135
|
+
/** Optional secret key for callback verification (sent as X-Tool-Key header) */
|
|
136
|
+
callback_key?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ChatParams {
|
|
139
|
+
message: string;
|
|
140
|
+
conversationId?: string;
|
|
141
|
+
tools?: ChatToolDefinition[];
|
|
142
|
+
}
|
|
143
|
+
export interface ChatResponse {
|
|
144
|
+
message: string;
|
|
145
|
+
conversationId: string;
|
|
146
|
+
}
|
|
147
|
+
export interface DashboardData {
|
|
148
|
+
projectCount: number;
|
|
149
|
+
botCount: number;
|
|
150
|
+
totalConversations: number;
|
|
151
|
+
totalTokens: number;
|
|
152
|
+
activeConversations: number;
|
|
153
|
+
bots: BotMetrics[];
|
|
154
|
+
}
|
|
155
|
+
export interface BotMetrics {
|
|
156
|
+
botId: string;
|
|
157
|
+
botName: string;
|
|
158
|
+
type: BotType;
|
|
159
|
+
status: BotStatus;
|
|
160
|
+
conversations: number;
|
|
161
|
+
tokens: number;
|
|
162
|
+
}
|
|
163
|
+
export interface TxIntent {
|
|
164
|
+
message: string;
|
|
165
|
+
userAddress: string;
|
|
166
|
+
chainId?: number;
|
|
167
|
+
context?: string;
|
|
168
|
+
/**
|
|
169
|
+
* 链上操作类型:显式指定常见操作(mint / vote / stake / claim / transfer / approve 等)
|
|
170
|
+
* 或租户 ABI 的函数名(如 "transferToken")/ 协议 action 的 id/name。
|
|
171
|
+
* 不传则服务端走自然语言解析;常见取值见 capabilities().actions[].action。
|
|
172
|
+
*/
|
|
173
|
+
action?: string;
|
|
174
|
+
/** 目标合约地址(0x 开头 40 位 hex;配租户 ABI / common-ops 精确指定目标合约) */
|
|
175
|
+
contractAddress?: string;
|
|
176
|
+
/** 协议 id:common-ops / tenant-{abiId}(来自 capabilities().actions[].protocol) */
|
|
177
|
+
protocolId?: string;
|
|
178
|
+
/** 操作函数参数(按 ABI 签名命名,如 { amount: '1000000', to: '0x...' };不传则服务端从消息解析) */
|
|
179
|
+
params?: Record<string, string>;
|
|
180
|
+
}
|
|
181
|
+
export interface TxStep {
|
|
182
|
+
label: string;
|
|
183
|
+
to: string;
|
|
184
|
+
value: string;
|
|
185
|
+
data: string;
|
|
186
|
+
gasLimit?: string;
|
|
187
|
+
}
|
|
188
|
+
export interface PreparedTransaction {
|
|
189
|
+
txId: string;
|
|
190
|
+
description: string;
|
|
191
|
+
steps: TxStep[];
|
|
192
|
+
sequential: boolean;
|
|
193
|
+
chainId: number;
|
|
194
|
+
/** 命中的协议 id(common-ops / tenant-{abiId}),供调用方核对 */
|
|
195
|
+
protocolId?: string;
|
|
196
|
+
/** 命中的链上操作类型(mint/vote/stake/claim 或租户 ABI 函数名) */
|
|
197
|
+
actionId?: string;
|
|
198
|
+
/** 实际编码的目标合约地址 */
|
|
199
|
+
contractAddress?: string;
|
|
200
|
+
warnings: string[];
|
|
201
|
+
expiresAt: number;
|
|
202
|
+
}
|
|
203
|
+
export interface ContractInfo {
|
|
204
|
+
address: string;
|
|
205
|
+
abi: unknown[];
|
|
206
|
+
name?: string;
|
|
207
|
+
methods: ContractMethod[];
|
|
208
|
+
}
|
|
209
|
+
export interface ContractMethod {
|
|
210
|
+
name: string;
|
|
211
|
+
signature: string;
|
|
212
|
+
inputs: {
|
|
213
|
+
name: string;
|
|
214
|
+
type: string;
|
|
215
|
+
}[];
|
|
216
|
+
outputs: {
|
|
217
|
+
name: string;
|
|
218
|
+
type: string;
|
|
219
|
+
}[];
|
|
220
|
+
stateMutability: string;
|
|
221
|
+
}
|
|
222
|
+
export interface SimulationResult {
|
|
223
|
+
success: boolean;
|
|
224
|
+
gasUsed: string;
|
|
225
|
+
logs?: string[];
|
|
226
|
+
error?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface DecodedCalldata {
|
|
229
|
+
methodName: string;
|
|
230
|
+
methodSignature: string;
|
|
231
|
+
params: Record<string, unknown>;
|
|
232
|
+
rawParams: unknown[];
|
|
233
|
+
}
|
|
234
|
+
export interface ProtocolSummary {
|
|
235
|
+
id: string;
|
|
236
|
+
name: string;
|
|
237
|
+
description: string;
|
|
238
|
+
chains: number[];
|
|
239
|
+
actions: string[];
|
|
240
|
+
}
|
|
241
|
+
export interface ProtocolRegistryEntry {
|
|
242
|
+
id: string;
|
|
243
|
+
name: string;
|
|
244
|
+
description: string;
|
|
245
|
+
deployments: ChainDeployment[];
|
|
246
|
+
actions: ProtocolAction[];
|
|
247
|
+
}
|
|
248
|
+
export interface ChainDeployment {
|
|
249
|
+
chainId: number;
|
|
250
|
+
contracts: Record<string, string>;
|
|
251
|
+
}
|
|
252
|
+
export interface ProtocolAction {
|
|
253
|
+
id: string;
|
|
254
|
+
name: string;
|
|
255
|
+
description: string;
|
|
256
|
+
contractRef: string;
|
|
257
|
+
functionSignature: string;
|
|
258
|
+
payable: boolean;
|
|
259
|
+
requiresApproval?: {
|
|
260
|
+
tokenContractRef: string;
|
|
261
|
+
spenderContractRef: string;
|
|
262
|
+
};
|
|
263
|
+
paramHints: ParamHint[];
|
|
264
|
+
prerequisites?: ProtocolAction[];
|
|
265
|
+
}
|
|
266
|
+
export interface ParamHint {
|
|
267
|
+
name: string;
|
|
268
|
+
type: string;
|
|
269
|
+
description: string;
|
|
270
|
+
source: "user_input" | "derived" | "user_address" | "computed";
|
|
271
|
+
computeHint?: string;
|
|
272
|
+
}
|
|
273
|
+
export interface WalletChallenge {
|
|
274
|
+
challenge: string;
|
|
275
|
+
timestamp: number;
|
|
276
|
+
nonce: string;
|
|
277
|
+
}
|
|
278
|
+
export interface WalletLoginParams {
|
|
279
|
+
walletAddress: string;
|
|
280
|
+
signature: string;
|
|
281
|
+
timestamp: number;
|
|
282
|
+
nonce: string;
|
|
283
|
+
}
|
|
284
|
+
export interface AuthResult {
|
|
285
|
+
token: string;
|
|
286
|
+
user: {
|
|
287
|
+
id: string;
|
|
288
|
+
username: string;
|
|
289
|
+
role: string;
|
|
290
|
+
name: string;
|
|
291
|
+
email: string;
|
|
292
|
+
walletAddress?: string;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/** 数学验证码(login/register 前置):svg 为 data URI,算式恒为非负结果 */
|
|
296
|
+
export interface CaptchaResponse {
|
|
297
|
+
token: string;
|
|
298
|
+
svg: string;
|
|
299
|
+
expiresIn: number;
|
|
300
|
+
}
|
|
301
|
+
/** 验证码作答参数(服务端校验通过才放行登录/注册) */
|
|
302
|
+
export interface CaptchaAnswer {
|
|
303
|
+
token: string;
|
|
304
|
+
answer: number;
|
|
305
|
+
}
|
|
306
|
+
export interface AgentXAgent {
|
|
307
|
+
id: number;
|
|
308
|
+
owner: string;
|
|
309
|
+
tokenURI: string;
|
|
310
|
+
name: string;
|
|
311
|
+
status: string;
|
|
312
|
+
}
|
|
313
|
+
export interface AgentXAgentDetail {
|
|
314
|
+
id: number;
|
|
315
|
+
owner: string;
|
|
316
|
+
tokenURI: string;
|
|
317
|
+
name: string;
|
|
318
|
+
status: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
}
|
|
321
|
+
export interface AgentXMarketplaceResult {
|
|
322
|
+
agents: AgentXAgent[];
|
|
323
|
+
total: number;
|
|
324
|
+
page: number;
|
|
325
|
+
pageSize: number;
|
|
326
|
+
}
|
|
327
|
+
export interface AgentXSubscriptionPlans {
|
|
328
|
+
plans: any[];
|
|
329
|
+
}
|
|
330
|
+
export interface AgentXSubscriptionCheck {
|
|
331
|
+
active: boolean;
|
|
332
|
+
}
|
|
333
|
+
export interface AgentXAgentContext {
|
|
334
|
+
agentId: number;
|
|
335
|
+
prompt: string;
|
|
336
|
+
skills: any[];
|
|
337
|
+
mcp: any;
|
|
338
|
+
owner?: string;
|
|
339
|
+
error?: string;
|
|
340
|
+
}
|
|
341
|
+
export interface AgentXPublishParams {
|
|
342
|
+
skills?: any[];
|
|
343
|
+
mcpUrl?: string;
|
|
344
|
+
}
|
|
345
|
+
export interface AgentXPublishResult {
|
|
346
|
+
success: boolean;
|
|
347
|
+
needsWallet: boolean;
|
|
348
|
+
message: string;
|
|
349
|
+
contractAddress: string;
|
|
350
|
+
contractAbi: string;
|
|
351
|
+
functionName: string;
|
|
352
|
+
args: string[];
|
|
353
|
+
value: string;
|
|
354
|
+
botId: string;
|
|
355
|
+
tokenURI: string;
|
|
356
|
+
}
|
|
357
|
+
export interface AgentXSkill {
|
|
358
|
+
id: number;
|
|
359
|
+
bot_id: string;
|
|
360
|
+
skill_name: string;
|
|
361
|
+
target_agent_id: number;
|
|
362
|
+
skill_filter: string[];
|
|
363
|
+
prompt_override: string;
|
|
364
|
+
is_active: boolean;
|
|
365
|
+
created_at: string;
|
|
366
|
+
}
|
|
367
|
+
export interface AgentXSkillCreateParams {
|
|
368
|
+
skillName: string;
|
|
369
|
+
targetAgentId: number;
|
|
370
|
+
skillFilter?: string[];
|
|
371
|
+
promptOverride?: string;
|
|
372
|
+
}
|
|
373
|
+
export interface AgentXAgentStatus {
|
|
374
|
+
agentId: number;
|
|
375
|
+
name: string;
|
|
376
|
+
owner: string;
|
|
377
|
+
status: 'online' | 'offline' | 'degraded' | 'unreachable' | 'error' | 'unknown';
|
|
378
|
+
pingMs: number | null;
|
|
379
|
+
lastSeen: string | null;
|
|
380
|
+
onChainStatus: string;
|
|
381
|
+
message?: string;
|
|
382
|
+
}
|
|
383
|
+
export interface AgentXAgentUsage {
|
|
384
|
+
agentId: number;
|
|
385
|
+
totalCalls: number;
|
|
386
|
+
totalTokens: number;
|
|
387
|
+
activeSubscribers: number;
|
|
388
|
+
dailyCalls: {
|
|
389
|
+
date: string;
|
|
390
|
+
calls: number;
|
|
391
|
+
}[];
|
|
392
|
+
}
|
|
393
|
+
export interface AgentXSubscriptionDetail {
|
|
394
|
+
agentId: number;
|
|
395
|
+
name: string;
|
|
396
|
+
owner: string;
|
|
397
|
+
status: string;
|
|
398
|
+
subscribedAt: string | null;
|
|
399
|
+
}
|
|
400
|
+
export interface AgentXSubscriptionList {
|
|
401
|
+
subscriptions: AgentXSubscriptionDetail[];
|
|
402
|
+
total: number;
|
|
403
|
+
}
|
|
404
|
+
export interface ServerChatParams {
|
|
405
|
+
message: string;
|
|
406
|
+
projectId?: string;
|
|
407
|
+
botId?: string;
|
|
408
|
+
useAgentLoop?: boolean;
|
|
409
|
+
userAddress?: string;
|
|
410
|
+
chainId?: number;
|
|
411
|
+
tools?: ChatToolDefinition[];
|
|
412
|
+
/**
|
|
413
|
+
* 用户自定义 LLM API Key(BYOK,可选)。
|
|
414
|
+
* 携带时:该次对话使用调用方自己的 Key 调用 LLM,不消耗商户配额;
|
|
415
|
+
* 未携带时:使用 Bot 配置的 provider(如有)或平台 LLM(按套餐配额)。
|
|
416
|
+
*/
|
|
417
|
+
llmApiKey?: string;
|
|
418
|
+
/** 与 llmApiKey 配套的可选 LLM 端点(OpenAI 兼容 /v1,默认平台端点) */
|
|
419
|
+
llmEndpoint?: string;
|
|
420
|
+
/** 与 llmApiKey 配套的可选模型名(默认平台模型) */
|
|
421
|
+
llmModel?: string;
|
|
422
|
+
}
|
|
423
|
+
/** 单次对话 token 用量明细 */
|
|
424
|
+
export interface ChatUsage {
|
|
425
|
+
input_tokens: number;
|
|
426
|
+
output_tokens: number;
|
|
427
|
+
}
|
|
428
|
+
/** 按用户地址的 token 用量汇总(日维度) */
|
|
429
|
+
export interface ChatUsageSummary {
|
|
430
|
+
userAddress: string;
|
|
431
|
+
days: number;
|
|
432
|
+
daily: {
|
|
433
|
+
day: string;
|
|
434
|
+
tokens_in: string;
|
|
435
|
+
tokens_out: string;
|
|
436
|
+
calls: string;
|
|
437
|
+
}[];
|
|
438
|
+
totals: {
|
|
439
|
+
tokensIn: number;
|
|
440
|
+
tokensOut: number;
|
|
441
|
+
calls: number;
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
export interface ServerChatResponse {
|
|
445
|
+
reply: string;
|
|
446
|
+
conversationId?: string;
|
|
447
|
+
tokensUsed?: number;
|
|
448
|
+
/** 本次对话真实 token 用量明细(input/output 拆分,用于成本核算) */
|
|
449
|
+
usage?: ChatUsage;
|
|
450
|
+
agentLoopUsed?: boolean;
|
|
451
|
+
toolsCalled?: boolean;
|
|
452
|
+
transaction?: PreparedTransaction;
|
|
453
|
+
/** 错误码:A2A 编排命中无订阅子 agent 时为 'a2a_agent_not_accessible'(HTTP 403);LLM Key 无效为 'LLM_KEY_INVALID'(HTTP 400) */
|
|
454
|
+
error?: string;
|
|
455
|
+
/** 结构化错误码(如 'LLM_KEY_INVALID' / 'LLM_UPSTREAM_ERROR') */
|
|
456
|
+
code?: string;
|
|
457
|
+
/** 订阅引导地址:配合 error 返回(如 /api/agentx/agents/{agentId}/plans) */
|
|
458
|
+
subscribeUrl?: string;
|
|
459
|
+
/** A2A 编排识别的意图(orchestrated 时返回) */
|
|
460
|
+
intent?: string;
|
|
461
|
+
/** A2A 编排命中的目标子 agent(orchestrated 时返回) */
|
|
462
|
+
targetAgentId?: string;
|
|
463
|
+
}
|
|
464
|
+
export interface AgentSummary {
|
|
465
|
+
id: string;
|
|
466
|
+
name: string;
|
|
467
|
+
type: AgentType;
|
|
468
|
+
description: string;
|
|
469
|
+
status: string;
|
|
470
|
+
projectId: string;
|
|
471
|
+
merchantId: string;
|
|
472
|
+
prompt: string;
|
|
473
|
+
agentxAgentId: number | null;
|
|
474
|
+
stats: {
|
|
475
|
+
conversations: number;
|
|
476
|
+
tokens: number;
|
|
477
|
+
};
|
|
478
|
+
createdAt: string;
|
|
479
|
+
}
|
|
480
|
+
export interface AgentListResult {
|
|
481
|
+
agents: AgentSummary[];
|
|
482
|
+
total: number;
|
|
483
|
+
}
|
|
484
|
+
export interface AgentListParams {
|
|
485
|
+
projectId?: string;
|
|
486
|
+
type?: AgentType;
|
|
487
|
+
}
|
|
488
|
+
export interface AgentChainInfo {
|
|
489
|
+
chainId: number;
|
|
490
|
+
name: string;
|
|
491
|
+
rpcUrl: string;
|
|
492
|
+
explorerUrl?: string;
|
|
493
|
+
symbol: string;
|
|
494
|
+
decimals: number;
|
|
495
|
+
}
|
|
496
|
+
export interface AgentActionType {
|
|
497
|
+
protocol: string;
|
|
498
|
+
protocolName: string;
|
|
499
|
+
action: string;
|
|
500
|
+
name: string;
|
|
501
|
+
description: string;
|
|
502
|
+
signature: string;
|
|
503
|
+
payable: boolean;
|
|
504
|
+
/** 目标合约地址(seed 协议部署或租户 ABI 配置的合约;common-ops 无部署时为 null) */
|
|
505
|
+
contractAddress?: string | null;
|
|
506
|
+
/** 租户 ABI 配置 id(protocol 为 tenant-{abiId} 时存在;配合 TxIntent.protocolId 精确调用) */
|
|
507
|
+
abiId?: string;
|
|
508
|
+
}
|
|
509
|
+
export interface AgentCapabilities {
|
|
510
|
+
type: AgentType;
|
|
511
|
+
name: string;
|
|
512
|
+
description: string;
|
|
513
|
+
chains: AgentChainInfo[];
|
|
514
|
+
actions: AgentActionType[];
|
|
515
|
+
}
|
|
516
|
+
export interface AgentChatParams {
|
|
517
|
+
message: string;
|
|
518
|
+
conversationId?: string;
|
|
519
|
+
/** 钱包地址:交易/综合 agent 构造链上操作时必填 */
|
|
520
|
+
userAddress?: string;
|
|
521
|
+
/** 目标链 id(Ethereum/BNB/Polygon/Arbitrum/Base/Optimism/OxaChain 等) */
|
|
522
|
+
chainId?: number;
|
|
523
|
+
agentxAgentId?: number;
|
|
524
|
+
tools?: ChatToolDefinition[];
|
|
525
|
+
}
|
|
526
|
+
export interface AgentChatResult {
|
|
527
|
+
reply: string;
|
|
528
|
+
model?: string;
|
|
529
|
+
tokensUsed?: number;
|
|
530
|
+
/** 交易/综合 agent 的链上操作载荷(不签名,由调用方 wallet 弹窗确认) */
|
|
531
|
+
transaction?: PreparedTransaction;
|
|
532
|
+
}
|
|
533
|
+
/** 商户租户合约 ABI 记录(POST /api/merchant/abis 返回的 row 结构) */
|
|
534
|
+
export interface MerchantAbi {
|
|
535
|
+
id: string;
|
|
536
|
+
merchant_id: string;
|
|
537
|
+
name: string;
|
|
538
|
+
chain_id: number;
|
|
539
|
+
contract_address: string;
|
|
540
|
+
abi: unknown[];
|
|
541
|
+
description?: string | null;
|
|
542
|
+
created_at: string;
|
|
543
|
+
updated_at: string;
|
|
544
|
+
}
|
|
545
|
+
/** 新增 ABI 参数(对应 POST /api/merchant/abis body) */
|
|
546
|
+
export interface MerchantAbiCreateParams {
|
|
547
|
+
name: string;
|
|
548
|
+
chainId: number;
|
|
549
|
+
contractAddress: string;
|
|
550
|
+
abi: unknown[];
|
|
551
|
+
description?: string;
|
|
552
|
+
}
|
|
553
|
+
export interface LightRAGKeyInfo {
|
|
554
|
+
id: string;
|
|
555
|
+
tenant_id: string;
|
|
556
|
+
name: string;
|
|
557
|
+
key_prefix: string;
|
|
558
|
+
created_at: string;
|
|
559
|
+
last_used_at?: string;
|
|
560
|
+
expires_at?: string;
|
|
561
|
+
active: boolean;
|
|
562
|
+
}
|
|
563
|
+
export interface LightRAGDocumentParams {
|
|
564
|
+
text: string;
|
|
565
|
+
file_name?: string;
|
|
566
|
+
/** Per-user namespace within a bot (defaults to botId = shared) */
|
|
567
|
+
namespace?: string;
|
|
568
|
+
}
|
|
569
|
+
export interface LightRAGQueryParams {
|
|
570
|
+
query: string;
|
|
571
|
+
mode?: "mix" | "local" | "global" | "hybrid" | "naive";
|
|
572
|
+
/** Per-user namespace within a bot (defaults to botId = shared) */
|
|
573
|
+
namespace?: string;
|
|
574
|
+
}
|
|
575
|
+
export interface LightRAGQueryResult {
|
|
576
|
+
context: string;
|
|
577
|
+
mode: string;
|
|
578
|
+
tenant?: string;
|
|
579
|
+
namespace?: string;
|
|
580
|
+
}
|
|
581
|
+
export interface LightRAGBatchItem {
|
|
582
|
+
file_name: string;
|
|
583
|
+
doc_id?: string;
|
|
584
|
+
status?: string;
|
|
585
|
+
[key: string]: unknown;
|
|
586
|
+
}
|
|
587
|
+
export interface LightRAGBatchError {
|
|
588
|
+
file_name: string;
|
|
589
|
+
error: string;
|
|
590
|
+
}
|
|
591
|
+
export interface LightRAGBatchResult {
|
|
592
|
+
/** 成功上传的文档数 */
|
|
593
|
+
count: number;
|
|
594
|
+
/** 整体状态:uploaded(全部成功)/ partial(部分失败)/ failed(全部失败) */
|
|
595
|
+
status: "uploaded" | "partial" | "failed";
|
|
596
|
+
/** 成功上传的文档明细 */
|
|
597
|
+
documents: LightRAGBatchItem[];
|
|
598
|
+
/** 失败项明细 */
|
|
599
|
+
errors: LightRAGBatchError[];
|
|
600
|
+
}
|
|
601
|
+
export interface GlobalAnalytics {
|
|
602
|
+
botCount: number;
|
|
603
|
+
activeBots: number;
|
|
604
|
+
totalConversations: number;
|
|
605
|
+
totalTokens: number;
|
|
606
|
+
bots: BotMetrics[];
|
|
607
|
+
}
|
|
608
|
+
export interface AdminDashboard {
|
|
609
|
+
merchants: number;
|
|
610
|
+
activeMerchants: number;
|
|
611
|
+
projects: number;
|
|
612
|
+
totalTokens: number;
|
|
613
|
+
totalConversations: number;
|
|
614
|
+
activeBots: number;
|
|
615
|
+
revenue: number;
|
|
616
|
+
monthlyRevenue: {
|
|
617
|
+
month: string;
|
|
618
|
+
revenue: number;
|
|
619
|
+
}[];
|
|
620
|
+
monthlyUsers: {
|
|
621
|
+
month: string;
|
|
622
|
+
users: number;
|
|
623
|
+
}[];
|
|
624
|
+
}
|
|
625
|
+
export interface AdminMerchant {
|
|
626
|
+
id: string;
|
|
627
|
+
username: string;
|
|
628
|
+
name: string;
|
|
629
|
+
email: string;
|
|
630
|
+
agentId: string;
|
|
631
|
+
plan: string;
|
|
632
|
+
status: string;
|
|
633
|
+
createdAt: string;
|
|
634
|
+
projectsCount: number;
|
|
635
|
+
totalTokens: number;
|
|
636
|
+
totalConversations: number;
|
|
637
|
+
}
|
|
638
|
+
export interface AdminMerchantDetail extends AdminMerchant {
|
|
639
|
+
projects: Project[];
|
|
640
|
+
}
|
|
641
|
+
export interface AdminBillingRecord {
|
|
642
|
+
id: string;
|
|
643
|
+
merchantId: string;
|
|
644
|
+
merchantName: string;
|
|
645
|
+
plan: string;
|
|
646
|
+
amount: number;
|
|
647
|
+
status: string;
|
|
648
|
+
date: string;
|
|
649
|
+
description: string;
|
|
650
|
+
}
|
|
651
|
+
export interface AdminCreateBillingParams {
|
|
652
|
+
merchantId: string;
|
|
653
|
+
merchantName?: string;
|
|
654
|
+
plan: string;
|
|
655
|
+
amount: number;
|
|
656
|
+
status?: string;
|
|
657
|
+
description?: string;
|
|
658
|
+
}
|
|
659
|
+
export interface LlmSettings {
|
|
660
|
+
provider: string;
|
|
661
|
+
model: string;
|
|
662
|
+
api_key: string;
|
|
663
|
+
base_url: string;
|
|
664
|
+
}
|
|
665
|
+
export interface LlmUpdateParams {
|
|
666
|
+
provider?: string;
|
|
667
|
+
model?: string;
|
|
668
|
+
api_key: string;
|
|
669
|
+
base_url?: string;
|
|
670
|
+
}
|
|
671
|
+
export type ConversationTaskStatus = "queued" | "running" | "done" | "error" | "cancelled";
|
|
672
|
+
/** AgentX 后台任务(创建后异步执行,轮询 status/result) */
|
|
673
|
+
export interface ConversationTask {
|
|
674
|
+
id: string;
|
|
675
|
+
sessionId: string;
|
|
676
|
+
tenant: string;
|
|
677
|
+
agentId?: number | null;
|
|
678
|
+
endUserId?: string | null;
|
|
679
|
+
message: string;
|
|
680
|
+
status: ConversationTaskStatus;
|
|
681
|
+
enableMemory: boolean;
|
|
682
|
+
prompt?: string | null;
|
|
683
|
+
skills?: unknown;
|
|
684
|
+
result?: string | null;
|
|
685
|
+
error?: string | null;
|
|
686
|
+
usage?: unknown;
|
|
687
|
+
iterations?: number | null;
|
|
688
|
+
createdAt: string;
|
|
689
|
+
startedAt?: string | null;
|
|
690
|
+
finishedAt?: string | null;
|
|
691
|
+
}
|
|
692
|
+
/** 会话:多个任务的容器(AgentX 侧持久化) */
|
|
693
|
+
export interface ConversationSession {
|
|
694
|
+
id: string;
|
|
695
|
+
tenant: string;
|
|
696
|
+
agentId?: number | null;
|
|
697
|
+
endUserId?: string | null;
|
|
698
|
+
title?: string | null;
|
|
699
|
+
}
|
|
700
|
+
export interface ConversationCapabilities {
|
|
701
|
+
parallelTasks: boolean;
|
|
702
|
+
parallelTasksOverride: boolean | null;
|
|
703
|
+
mode?: string;
|
|
704
|
+
}
|
|
705
|
+
export interface ConversationMessage {
|
|
706
|
+
role: "user" | "assistant";
|
|
707
|
+
content: string;
|
|
708
|
+
}
|
|
709
|
+
export interface OrchestrationTaskParams {
|
|
710
|
+
/** AgentX agent id(缺省时可用 prompt/skills 走 inline 模式) */
|
|
711
|
+
agentId?: number;
|
|
712
|
+
message: string;
|
|
713
|
+
/** Inline 系统提示词 */
|
|
714
|
+
prompt?: string;
|
|
715
|
+
/** Inline 技能(MCP/HTTP 工具定义) */
|
|
716
|
+
skills?: Record<string, unknown>[];
|
|
717
|
+
enableMemory?: boolean;
|
|
718
|
+
history?: ConversationMessage[];
|
|
719
|
+
}
|
|
720
|
+
export interface OrchestrateParams {
|
|
721
|
+
/** 缺省时自动创建会话 */
|
|
722
|
+
sessionId?: string;
|
|
723
|
+
tasks: OrchestrationTaskParams[];
|
|
724
|
+
enableMemory?: boolean;
|
|
725
|
+
}
|
|
726
|
+
export interface OrchestratedTaskResult {
|
|
727
|
+
agentId?: number | null;
|
|
728
|
+
taskId: string | null;
|
|
729
|
+
status: string;
|
|
730
|
+
ok: boolean;
|
|
731
|
+
error?: string;
|
|
732
|
+
code?: string;
|
|
733
|
+
}
|
|
734
|
+
export interface OrchestrateResult {
|
|
735
|
+
sessionId: string;
|
|
736
|
+
tasks: OrchestratedTaskResult[];
|
|
737
|
+
parallelTasksEnabled: boolean;
|
|
738
|
+
}
|
|
739
|
+
export type ScheduledTaskTriggerType = "once" | "cron";
|
|
740
|
+
export type ScheduledTaskStatus = "active" | "running" | "completed" | "cancelled" | "failed";
|
|
741
|
+
export interface ScheduledTask {
|
|
742
|
+
id: string;
|
|
743
|
+
botId: string;
|
|
744
|
+
projectId: string;
|
|
745
|
+
merchantId: string;
|
|
746
|
+
agentId?: number | null;
|
|
747
|
+
description: string;
|
|
748
|
+
message: string;
|
|
749
|
+
triggerType: ScheduledTaskTriggerType;
|
|
750
|
+
cronExpr?: string | null;
|
|
751
|
+
runAt?: string | null;
|
|
752
|
+
status: ScheduledTaskStatus;
|
|
753
|
+
nextRunAt?: string | null;
|
|
754
|
+
lastRunAt?: string | null;
|
|
755
|
+
lastResult?: {
|
|
756
|
+
ok?: boolean;
|
|
757
|
+
reply?: string;
|
|
758
|
+
error?: string;
|
|
759
|
+
model?: string;
|
|
760
|
+
at?: string;
|
|
761
|
+
} | null;
|
|
762
|
+
runCount: number;
|
|
763
|
+
createdAt: string;
|
|
764
|
+
}
|
|
765
|
+
export type MonitorConnectorKind = "http_poll" | "webhook" | "local";
|
|
766
|
+
export interface EnterpriseDoc {
|
|
767
|
+
id: string;
|
|
768
|
+
merchant_id: string;
|
|
769
|
+
name: string;
|
|
770
|
+
file_size: number;
|
|
771
|
+
created_at: string;
|
|
772
|
+
}
|
|
773
|
+
export interface MonitorConnector {
|
|
774
|
+
id: string;
|
|
775
|
+
bot_id: string;
|
|
776
|
+
merchant_id: string;
|
|
777
|
+
kind: MonitorConnectorKind;
|
|
778
|
+
name: string;
|
|
779
|
+
config: Record<string, unknown>;
|
|
780
|
+
status: string;
|
|
781
|
+
last_poll_at: string | null;
|
|
782
|
+
last_event_at: string | null;
|
|
783
|
+
created_at: string;
|
|
784
|
+
}
|
|
785
|
+
export interface MonitorEvent {
|
|
786
|
+
id: number;
|
|
787
|
+
connector_id: string | null;
|
|
788
|
+
bot_id: string;
|
|
789
|
+
merchant_id: string;
|
|
790
|
+
source: string;
|
|
791
|
+
payload: Record<string, unknown>;
|
|
792
|
+
received_at: string;
|
|
793
|
+
}
|