@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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentApi — Reach 唯一 Agent 入口(P2.4.3 统一)。
|
|
3
|
+
*
|
|
4
|
+
* 吸收三侧方法面(A.5.2/A.2.3 AgentX 合版):
|
|
5
|
+
* - S agent(网关 /api/v1/agents/*):list / get / capabilities / chat / prepareTransaction
|
|
6
|
+
* - S agentx(server /api/agentx/* + /api/merchant/*):链上市场 / 订阅 / 状态用量 / 发布 / 技能
|
|
7
|
+
* - A agents(server /api/agents/*):marketplace → listMarketplace、run / clone
|
|
8
|
+
*
|
|
9
|
+
* 端点保持两侧现状(agent 走网关 /api/v1、agentx/agents 走 server),
|
|
10
|
+
* 待 2.4.5 统一网关后全部走网关(A.2.4:SDK 只走网关)。
|
|
11
|
+
* 统一 Agent 资源模型:S「Bot 可发布为 Agent」+ A「平台原生 Agent 市场」,见 A.2.5。
|
|
12
|
+
*/
|
|
13
|
+
export class AgentApi {
|
|
14
|
+
constructor(gatewayRequest, serverRequest) {
|
|
15
|
+
this.gatewayRequest = gatewayRequest;
|
|
16
|
+
this.serverRequest = serverRequest;
|
|
17
|
+
}
|
|
18
|
+
// ═══ 调用方 Agent(gateway /api/v1/agents/*,S agent 基线;吸收 A agents.list/get)═══
|
|
19
|
+
/** 列出调用方可用的 agent(可按 projectId / type 过滤) */
|
|
20
|
+
list(params) {
|
|
21
|
+
const query = new URLSearchParams();
|
|
22
|
+
if (params?.projectId)
|
|
23
|
+
query.set("projectId", params.projectId);
|
|
24
|
+
if (params?.type)
|
|
25
|
+
query.set("type", params.type);
|
|
26
|
+
const qs = query.toString();
|
|
27
|
+
return this.gatewayRequest("GET", `/api/v1/agents${qs ? `?${qs}` : ""}`);
|
|
28
|
+
}
|
|
29
|
+
/** 获取单个 agent 详情 */
|
|
30
|
+
get(id) {
|
|
31
|
+
return this.gatewayRequest("GET", `/api/v1/agents/${id}`);
|
|
32
|
+
}
|
|
33
|
+
/** 该 agent 支持什么:类型、可用链、可执行的链上操作类型 */
|
|
34
|
+
capabilities(id) {
|
|
35
|
+
return this.gatewayRequest("GET", `/api/v1/agents/${id}/capabilities`);
|
|
36
|
+
}
|
|
37
|
+
/** 直接与该 agent 对话(RAG + 交易构造由服务端完成,返回 transaction 载荷) */
|
|
38
|
+
chat(id, params) {
|
|
39
|
+
return this.gatewayRequest("POST", `/api/v1/agents/${id}/chat`, params);
|
|
40
|
+
}
|
|
41
|
+
/** 构造链上交易(不签名;返回步骤/calldata,由调用方 wallet 弹窗确认) */
|
|
42
|
+
prepareTransaction(id, intent) {
|
|
43
|
+
return this.gatewayRequest("POST", `/api/v1/agents/${id}/transaction/prepare`, intent);
|
|
44
|
+
}
|
|
45
|
+
// ═══ Agent 运行 / 克隆(server /api/agents/*,A agents)═══
|
|
46
|
+
/** 运行一个 agent(A:平台原生 Agent 市场模式) */
|
|
47
|
+
run(id, message, skillNames = []) {
|
|
48
|
+
return this.serverRequest("POST", `/api/agents/${id}/run`, {
|
|
49
|
+
message,
|
|
50
|
+
skillNames,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** 克隆 agent 到工作区 */
|
|
54
|
+
clone(id) {
|
|
55
|
+
return this.serverRequest("POST", `/api/agents/${id}/clone`, {});
|
|
56
|
+
}
|
|
57
|
+
// ═══ AgentX 链上市场(server /api/agentx/*,S agentx;marketplace 吸收 A agents.marketplace)═══
|
|
58
|
+
/** 列出 AgentX 链上市场中的 Agent(吸收 A agents.marketplace → /api/agents/marketplace/search) */
|
|
59
|
+
listMarketplace(params) {
|
|
60
|
+
const query = new URLSearchParams();
|
|
61
|
+
if (params?.page)
|
|
62
|
+
query.set("page", String(params.page));
|
|
63
|
+
if (params?.pageSize)
|
|
64
|
+
query.set("pageSize", String(params.pageSize));
|
|
65
|
+
if (params?.search)
|
|
66
|
+
query.set("search", params.search);
|
|
67
|
+
if (params?.type)
|
|
68
|
+
query.set("type", params.type);
|
|
69
|
+
return this.serverRequest("GET", `/api/agentx/marketplace?${query.toString()}`);
|
|
70
|
+
}
|
|
71
|
+
/** 获取 AgentX Agent 详情 */
|
|
72
|
+
getAgent(agentId) {
|
|
73
|
+
return this.serverRequest("GET", `/api/agentx/agents/${agentId}`);
|
|
74
|
+
}
|
|
75
|
+
/** 获取 Agent 的订阅计划 */
|
|
76
|
+
getPlans(agentId) {
|
|
77
|
+
return this.serverRequest("GET", `/api/agentx/agents/${agentId}/plans`);
|
|
78
|
+
}
|
|
79
|
+
/** 检查用户对 Agent 的订阅状态 */
|
|
80
|
+
checkSubscription(agentId, subscriberAddress) {
|
|
81
|
+
return this.serverRequest("GET", `/api/agentx/subscriptions/check?agentId=${agentId}&subscriberAddress=${encodeURIComponent(subscriberAddress)}`);
|
|
82
|
+
}
|
|
83
|
+
/** 列出用户的所有订阅 */
|
|
84
|
+
listSubscriptions(subscriberAddress) {
|
|
85
|
+
return this.serverRequest("GET", `/api/agentx/subscriptions/my?subscriberAddress=${encodeURIComponent(subscriberAddress)}`);
|
|
86
|
+
}
|
|
87
|
+
/** 获取 Agent 运行状态(在线/离线/延迟等) */
|
|
88
|
+
getAgentStatus(agentId) {
|
|
89
|
+
return this.serverRequest("GET", `/api/agentx/agents/${agentId}/status`);
|
|
90
|
+
}
|
|
91
|
+
/** 获取 Agent 用量统计(调用次数、Token 消耗、活跃订阅者) */
|
|
92
|
+
getAgentUsage(agentId) {
|
|
93
|
+
return this.serverRequest("GET", `/api/agentx/agents/${agentId}/usage`);
|
|
94
|
+
}
|
|
95
|
+
/** 加载 Agent 上下文(需要有效订阅) */
|
|
96
|
+
loadAgentContext(agentId, subscriberAddress) {
|
|
97
|
+
return this.serverRequest("POST", `/api/agentx/agents/${agentId}/load-context`, { subscriberAddress });
|
|
98
|
+
}
|
|
99
|
+
// ═══ AgentX 发布与技能(server /api/merchant/*,S agentx)═══
|
|
100
|
+
/** 将 Bot 发布到 AgentX 市场,返回链上交易参数 */
|
|
101
|
+
publishBot(projectId, botId, params) {
|
|
102
|
+
return this.serverRequest("POST", `/api/merchant/projects/${projectId}/bots/${botId}/publish-agentx`, params || {});
|
|
103
|
+
}
|
|
104
|
+
/** 获取 Bot 的 A2A 技能列表 */
|
|
105
|
+
listSkills(projectId, botId) {
|
|
106
|
+
return this.serverRequest("GET", `/api/merchant/projects/${projectId}/bots/${botId}/agentx-skills`);
|
|
107
|
+
}
|
|
108
|
+
/** 给 Bot 添加 A2A 技能(链接到另一个 AgentX Agent) */
|
|
109
|
+
addSkill(projectId, botId, params) {
|
|
110
|
+
return this.serverRequest("POST", `/api/merchant/projects/${projectId}/bots/${botId}/agentx-skills`, params);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/** API Key data returned from list (no full key) */
|
|
4
|
+
export interface ApiKeyInfo {
|
|
5
|
+
id: number;
|
|
6
|
+
key_prefix: string;
|
|
7
|
+
app_name: string;
|
|
8
|
+
tenant_id: number | null;
|
|
9
|
+
permissions: string[];
|
|
10
|
+
is_active: boolean;
|
|
11
|
+
created_by: string;
|
|
12
|
+
last_used_at: string | null;
|
|
13
|
+
created_at: string;
|
|
14
|
+
revoked_at: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** API Key creation response (full key shown once) */
|
|
17
|
+
export interface ApiKeyCreated {
|
|
18
|
+
key: string;
|
|
19
|
+
keyPrefix: string;
|
|
20
|
+
appName: string;
|
|
21
|
+
permissions: string[];
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class ApiKeyResource {
|
|
25
|
+
private request;
|
|
26
|
+
constructor(request: RequestFn);
|
|
27
|
+
/** 创建新的 API Key(需要 admin JWT),返回完整 key(仅显示一次) */
|
|
28
|
+
create(params: {
|
|
29
|
+
appName: string;
|
|
30
|
+
tenantId?: number;
|
|
31
|
+
permissions?: string[];
|
|
32
|
+
}): Promise<ApiKeyCreated>;
|
|
33
|
+
/** 列出所有 API Key(需要 admin JWT),不返回完整 key */
|
|
34
|
+
list(): Promise<{
|
|
35
|
+
keys: ApiKeyInfo[];
|
|
36
|
+
}>;
|
|
37
|
+
/** 吊销(停用)一个 API Key(需要 admin JWT) */
|
|
38
|
+
revoke(keyId: number): Promise<{
|
|
39
|
+
revoked: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class ApiKeyResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
/** 创建新的 API Key(需要 admin JWT),返回完整 key(仅显示一次) */
|
|
6
|
+
create(params) {
|
|
7
|
+
return this.request("POST", "/api/v1/api-keys", params);
|
|
8
|
+
}
|
|
9
|
+
/** 列出所有 API Key(需要 admin JWT),不返回完整 key */
|
|
10
|
+
list() {
|
|
11
|
+
return this.request("GET", "/api/v1/api-keys");
|
|
12
|
+
}
|
|
13
|
+
/** 吊销(停用)一个 API Key(需要 admin JWT) */
|
|
14
|
+
revoke(keyId) {
|
|
15
|
+
return this.request("DELETE", `/api/v1/api-keys/${keyId}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestMethod, WalletChallenge, WalletLoginParams, AuthResult, CaptchaResponse, CaptchaAnswer } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class AuthResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
/** 获取钱包签名挑战 */
|
|
7
|
+
getChallenge(walletAddress: string): Promise<WalletChallenge>;
|
|
8
|
+
/** 钱包签名登录,返回 token + user */
|
|
9
|
+
walletLogin(params: WalletLoginParams): Promise<AuthResult>;
|
|
10
|
+
/**
|
|
11
|
+
* 获取数学验证码(login/register 前置)。
|
|
12
|
+
* svg 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
|
|
13
|
+
*/
|
|
14
|
+
getCaptcha(): Promise<CaptchaResponse>;
|
|
15
|
+
/** 用户名密码登录(服务端强制要求验证码,必须传 captcha) */
|
|
16
|
+
login(username: string, password: string, captcha?: CaptchaAnswer): Promise<AuthResult>;
|
|
17
|
+
/** 用户名密码注册(服务端强制要求验证码,必须传 captcha) */
|
|
18
|
+
register(username: string, password: string, opts?: {
|
|
19
|
+
name?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
captcha?: CaptchaAnswer;
|
|
22
|
+
}): Promise<AuthResult>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class AuthResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
/** 获取钱包签名挑战 */
|
|
6
|
+
getChallenge(walletAddress) {
|
|
7
|
+
return this.request("POST", "/api/auth/wallet-challenge", { address: walletAddress });
|
|
8
|
+
}
|
|
9
|
+
/** 钱包签名登录,返回 token + user */
|
|
10
|
+
walletLogin(params) {
|
|
11
|
+
return this.request("POST", "/api/auth/wallet-login", params);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 获取数学验证码(login/register 前置)。
|
|
15
|
+
* svg 为 `data:image/svg+xml;base64,...`,算式形如 "7 + 5 = ?",结果恒为非负。
|
|
16
|
+
*/
|
|
17
|
+
getCaptcha() {
|
|
18
|
+
return this.request("POST", "/api/auth/captcha");
|
|
19
|
+
}
|
|
20
|
+
/** 用户名密码登录(服务端强制要求验证码,必须传 captcha) */
|
|
21
|
+
login(username, password, captcha) {
|
|
22
|
+
return this.request("POST", "/api/auth/login", {
|
|
23
|
+
username,
|
|
24
|
+
password,
|
|
25
|
+
captchaToken: captcha?.token,
|
|
26
|
+
captchaAnswer: captcha?.answer,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** 用户名密码注册(服务端强制要求验证码,必须传 captcha) */
|
|
30
|
+
register(username, password, opts) {
|
|
31
|
+
return this.request("POST", "/api/auth/register", {
|
|
32
|
+
username,
|
|
33
|
+
password,
|
|
34
|
+
name: opts?.name,
|
|
35
|
+
email: opts?.email,
|
|
36
|
+
captchaToken: opts?.captcha?.token,
|
|
37
|
+
captchaAnswer: opts?.captcha?.answer,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RequestMethod, Bot, BotCreateParams, BotUpdateParams, ChatParams, ChatResponse } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class BotResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
create(params: BotCreateParams): Promise<Bot>;
|
|
7
|
+
list(projectId: string): Promise<Bot[]>;
|
|
8
|
+
get(id: string): Promise<Bot>;
|
|
9
|
+
update(id: string, params: BotUpdateParams): Promise<Bot>;
|
|
10
|
+
delete(id: string): Promise<{
|
|
11
|
+
deleted: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
start(id: string): Promise<Bot>;
|
|
14
|
+
stop(id: string): Promise<Bot>;
|
|
15
|
+
chat(botId: string, params: ChatParams): Promise<ChatResponse>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class BotResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
create(params) {
|
|
6
|
+
return this.request("POST", "/api/v1/bots", params);
|
|
7
|
+
}
|
|
8
|
+
list(projectId) {
|
|
9
|
+
return this.request("GET", `/api/v1/bots?projectId=${projectId}`);
|
|
10
|
+
}
|
|
11
|
+
get(id) {
|
|
12
|
+
return this.request("GET", `/api/v1/bots/${id}`);
|
|
13
|
+
}
|
|
14
|
+
update(id, params) {
|
|
15
|
+
return this.request("PATCH", `/api/v1/bots/${id}`, params);
|
|
16
|
+
}
|
|
17
|
+
delete(id) {
|
|
18
|
+
return this.request("DELETE", `/api/v1/bots/${id}`);
|
|
19
|
+
}
|
|
20
|
+
start(id) {
|
|
21
|
+
return this.request("POST", `/api/v1/bots/${id}/start`);
|
|
22
|
+
}
|
|
23
|
+
stop(id) {
|
|
24
|
+
return this.request("POST", `/api/v1/bots/${id}/stop`);
|
|
25
|
+
}
|
|
26
|
+
chat(botId, params) {
|
|
27
|
+
return this.request("POST", `/api/v1/bots/${botId}/chat`, params);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RequestMethod, Channel, ChannelConfigureParams } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class ChannelResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
configure(botId: string, params: ChannelConfigureParams): Promise<Channel>;
|
|
7
|
+
list(botId: string): Promise<Channel[]>;
|
|
8
|
+
/** 获取单个通道详情 */
|
|
9
|
+
get(botId: string, type: string): Promise<Channel>;
|
|
10
|
+
/** 更新单个通道配置 */
|
|
11
|
+
update(botId: string, type: string, params: {
|
|
12
|
+
config?: Record<string, unknown>;
|
|
13
|
+
status?: string;
|
|
14
|
+
}): Promise<Channel>;
|
|
15
|
+
getWidgetId(botId: string): Promise<{
|
|
16
|
+
widgetId: string;
|
|
17
|
+
embedCode: string;
|
|
18
|
+
}>;
|
|
19
|
+
remove(channelId: string): Promise<{
|
|
20
|
+
removed: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ChannelResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
configure(botId, params) {
|
|
6
|
+
return this.request("POST", `/api/v1/bots/${botId}/channels`, params);
|
|
7
|
+
}
|
|
8
|
+
list(botId) {
|
|
9
|
+
return this.request("GET", `/api/v1/bots/${botId}/channels`);
|
|
10
|
+
}
|
|
11
|
+
/** 获取单个通道详情 */
|
|
12
|
+
get(botId, type) {
|
|
13
|
+
return this.request("GET", `/api/v1/bots/${botId}/channels/${type}`);
|
|
14
|
+
}
|
|
15
|
+
/** 更新单个通道配置 */
|
|
16
|
+
update(botId, type, params) {
|
|
17
|
+
return this.request("PATCH", `/api/v1/bots/${botId}/channels/${type}`, params);
|
|
18
|
+
}
|
|
19
|
+
getWidgetId(botId) {
|
|
20
|
+
return this.request("GET", `/api/v1/bots/${botId}/channels/widget`);
|
|
21
|
+
}
|
|
22
|
+
remove(channelId) {
|
|
23
|
+
return this.request("DELETE", `/api/v1/channels/${channelId}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestMethod, ServerChatParams, ServerChatResponse } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class ChatResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
/** 通过 Server API 发送聊天消息(支持 RAG + AgentX AgentLoop) */
|
|
7
|
+
send(params: ServerChatParams): Promise<ServerChatResponse>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Content 资源 — 社媒文案生成与内容管理(源自 aiops-saas @aiops/sdk ContentApi)。
|
|
5
|
+
* 端点走 Server API(/api/content/*),与社媒域 MCP 工具同源。
|
|
6
|
+
*/
|
|
7
|
+
export declare class ContentResource {
|
|
8
|
+
private request;
|
|
9
|
+
constructor(request: RequestFn);
|
|
10
|
+
/** 生成社媒文案 */
|
|
11
|
+
generate(topic: string, platform?: string, style?: string, opts?: Record<string, unknown>): Promise<any>;
|
|
12
|
+
/** 内容列表(分页) */
|
|
13
|
+
list(params?: Record<string, unknown>): Promise<any>;
|
|
14
|
+
/** 支持的平台 */
|
|
15
|
+
platforms(): Promise<any>;
|
|
16
|
+
/** 支持的写作风格 */
|
|
17
|
+
styles(): Promise<any>;
|
|
18
|
+
/** 单个内容 */
|
|
19
|
+
get(id: string): Promise<any>;
|
|
20
|
+
/** 更新内容 */
|
|
21
|
+
update(id: string, data: unknown): Promise<any>;
|
|
22
|
+
/** 删除内容 */
|
|
23
|
+
delete(id: string): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content 资源 — 社媒文案生成与内容管理(源自 aiops-saas @aiops/sdk ContentApi)。
|
|
3
|
+
* 端点走 Server API(/api/content/*),与社媒域 MCP 工具同源。
|
|
4
|
+
*/
|
|
5
|
+
export class ContentResource {
|
|
6
|
+
constructor(request) {
|
|
7
|
+
this.request = request;
|
|
8
|
+
}
|
|
9
|
+
/** 生成社媒文案 */
|
|
10
|
+
generate(topic, platform = "twitter", style = "casual", opts = {}) {
|
|
11
|
+
return this.request("POST", "/api/content/generate", {
|
|
12
|
+
topic,
|
|
13
|
+
platform,
|
|
14
|
+
style,
|
|
15
|
+
...opts,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** 内容列表(分页) */
|
|
19
|
+
list(params = {}) {
|
|
20
|
+
const qs = new URLSearchParams(params).toString();
|
|
21
|
+
return this.request("GET", `/api/content/list${qs ? `?${qs}` : ""}`);
|
|
22
|
+
}
|
|
23
|
+
/** 支持的平台 */
|
|
24
|
+
platforms() {
|
|
25
|
+
return this.request("GET", "/api/content/platforms");
|
|
26
|
+
}
|
|
27
|
+
/** 支持的写作风格 */
|
|
28
|
+
styles() {
|
|
29
|
+
return this.request("GET", "/api/content/styles");
|
|
30
|
+
}
|
|
31
|
+
/** 单个内容 */
|
|
32
|
+
get(id) {
|
|
33
|
+
return this.request("GET", `/api/content/${id}`);
|
|
34
|
+
}
|
|
35
|
+
/** 更新内容 */
|
|
36
|
+
update(id, data) {
|
|
37
|
+
return this.request("PATCH", `/api/content/${id}`, data);
|
|
38
|
+
}
|
|
39
|
+
/** 删除内容 */
|
|
40
|
+
delete(id) {
|
|
41
|
+
return this.request("DELETE", `/api/content/${id}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestMethod, Conversation, Message, PaginatedResponse } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class ConversationResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
list(botId: string, params?: {
|
|
7
|
+
page?: number;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
}): Promise<PaginatedResponse<Conversation>>;
|
|
10
|
+
get(id: string): Promise<{
|
|
11
|
+
conversation: Conversation;
|
|
12
|
+
messages: Message[];
|
|
13
|
+
}>;
|
|
14
|
+
reply(id: string, message: string): Promise<Message>;
|
|
15
|
+
transfer(id: string, reason?: string): Promise<{
|
|
16
|
+
transferred: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class ConversationResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
list(botId, params) {
|
|
6
|
+
const query = params
|
|
7
|
+
? "?" + new URLSearchParams(Object.entries(params)
|
|
8
|
+
.filter(([, v]) => v !== undefined)
|
|
9
|
+
.map(([k, v]) => [k, String(v)])).toString()
|
|
10
|
+
: "";
|
|
11
|
+
return this.request("GET", `/api/v1/bots/${botId}/conversations${query}`);
|
|
12
|
+
}
|
|
13
|
+
get(id) {
|
|
14
|
+
return this.request("GET", `/api/v1/conversations/${id}`);
|
|
15
|
+
}
|
|
16
|
+
reply(id, message) {
|
|
17
|
+
return this.request("POST", `/api/v1/conversations/${id}/reply`, {
|
|
18
|
+
message,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
transfer(id, reason) {
|
|
22
|
+
return this.request("POST", `/api/v1/conversations/${id}/transfer`, { reason });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RequestMethod, DashboardData, BotMetrics, GlobalAnalytics, ChatUsageSummary } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* DashboardApi — 统一数据看板(P2.4.4 合版,A.2.3 按 crm/social 域参数化聚合)。
|
|
5
|
+
*
|
|
6
|
+
* 吸收:
|
|
7
|
+
* - S analytics(网关 /api/v1/*,客服指标):global / dashboard / botMetrics / summaryByUser
|
|
8
|
+
* - A dashboard(server /api/dashboard/*,社媒运营看板):overview / quota / trend
|
|
9
|
+
*
|
|
10
|
+
* 端点保持两侧现状,待 2.4.5 统一网关后全部走网关。
|
|
11
|
+
*/
|
|
12
|
+
export declare class DashboardApi {
|
|
13
|
+
private gatewayRequest;
|
|
14
|
+
private serverRequest;
|
|
15
|
+
constructor(gatewayRequest: RequestFn, serverRequest: RequestFn);
|
|
16
|
+
/** 全局分析(跨所有 bot) */
|
|
17
|
+
global(): Promise<GlobalAnalytics>;
|
|
18
|
+
/** 项目级看板 */
|
|
19
|
+
dashboard(projectId: string): Promise<DashboardData>;
|
|
20
|
+
/** Bot 级指标 */
|
|
21
|
+
botMetrics(botId: string): Promise<BotMetrics>;
|
|
22
|
+
/** 按用户地址汇总 token 用量(日维度 + 累计),用于成本核算与对账 */
|
|
23
|
+
summaryByUser(userAddress: string, days?: number): Promise<ChatUsageSummary>;
|
|
24
|
+
/** 每日用量概览 */
|
|
25
|
+
overview(): Promise<any>;
|
|
26
|
+
/** 配额 / 限额 */
|
|
27
|
+
quota(): Promise<any>;
|
|
28
|
+
/** 用量趋势(默认 30 天) */
|
|
29
|
+
trend(days?: number): Promise<any>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DashboardApi — 统一数据看板(P2.4.4 合版,A.2.3 按 crm/social 域参数化聚合)。
|
|
3
|
+
*
|
|
4
|
+
* 吸收:
|
|
5
|
+
* - S analytics(网关 /api/v1/*,客服指标):global / dashboard / botMetrics / summaryByUser
|
|
6
|
+
* - A dashboard(server /api/dashboard/*,社媒运营看板):overview / quota / trend
|
|
7
|
+
*
|
|
8
|
+
* 端点保持两侧现状,待 2.4.5 统一网关后全部走网关。
|
|
9
|
+
*/
|
|
10
|
+
export class DashboardApi {
|
|
11
|
+
constructor(gatewayRequest, serverRequest) {
|
|
12
|
+
this.gatewayRequest = gatewayRequest;
|
|
13
|
+
this.serverRequest = serverRequest;
|
|
14
|
+
}
|
|
15
|
+
// ═══ crm 域 — 客服指标(gateway /api/v1/*,S analytics 基线)═══
|
|
16
|
+
/** 全局分析(跨所有 bot) */
|
|
17
|
+
global() {
|
|
18
|
+
return this.gatewayRequest("GET", "/api/v1/analytics");
|
|
19
|
+
}
|
|
20
|
+
/** 项目级看板 */
|
|
21
|
+
dashboard(projectId) {
|
|
22
|
+
return this.gatewayRequest("GET", `/api/v1/projects/${projectId}/analytics`);
|
|
23
|
+
}
|
|
24
|
+
/** Bot 级指标 */
|
|
25
|
+
botMetrics(botId) {
|
|
26
|
+
return this.gatewayRequest("GET", `/api/v1/bots/${botId}/analytics`);
|
|
27
|
+
}
|
|
28
|
+
/** 按用户地址汇总 token 用量(日维度 + 累计),用于成本核算与对账 */
|
|
29
|
+
summaryByUser(userAddress, days = 7) {
|
|
30
|
+
return this.gatewayRequest("GET", `/api/v1/usage/summary?userAddress=${encodeURIComponent(userAddress)}&days=${days}`);
|
|
31
|
+
}
|
|
32
|
+
// ═══ social 域 — 社媒运营看板(server /api/dashboard/*,A dashboard 基线)═══
|
|
33
|
+
/** 每日用量概览 */
|
|
34
|
+
overview() {
|
|
35
|
+
return this.serverRequest("GET", "/api/dashboard/overview");
|
|
36
|
+
}
|
|
37
|
+
/** 配额 / 限额 */
|
|
38
|
+
quota() {
|
|
39
|
+
return this.serverRequest("GET", "/api/dashboard/quota");
|
|
40
|
+
}
|
|
41
|
+
/** 用量趋势(默认 30 天) */
|
|
42
|
+
trend(days = 30) {
|
|
43
|
+
return this.serverRequest("GET", `/api/dashboard/trend?days=${days}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RequestMethod, EnterpriseDoc, MonitorConnector, MonitorConnectorKind, MonitorEvent } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class InternalAgentResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
/** 列出企业知识文档 */
|
|
7
|
+
listEnterpriseDocs(): Promise<EnterpriseDoc[]>;
|
|
8
|
+
/** 插入企业知识文档(文本) */
|
|
9
|
+
insertEnterpriseDoc(params: {
|
|
10
|
+
text: string;
|
|
11
|
+
fileName?: string;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
doc_id: string;
|
|
15
|
+
namespace: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** 删除企业知识文档 */
|
|
18
|
+
deleteEnterpriseDoc(docId: string): Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
doc_id: string;
|
|
21
|
+
deleted: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
/** 查询企业知识库(返回上下文,不生成 LLM 回答) */
|
|
24
|
+
queryEnterprise(params: {
|
|
25
|
+
query: string;
|
|
26
|
+
mode?: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
context: string;
|
|
29
|
+
mode: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** 列出某 bot 的监控连接器 */
|
|
32
|
+
listConnectors(projectId: string, botId: string): Promise<MonitorConnector[]>;
|
|
33
|
+
/**
|
|
34
|
+
* 创建监控连接器。
|
|
35
|
+
* kind = http_poll(平台轮询,需 config.url)| webhook(平台接收推送)| local(本地部署 agent 回传)。
|
|
36
|
+
* webhook / local 返回 token(仅创建时一次),供上报/本地部署配置使用。
|
|
37
|
+
*/
|
|
38
|
+
createConnector(projectId: string, botId: string, params: {
|
|
39
|
+
kind: MonitorConnectorKind;
|
|
40
|
+
name?: string;
|
|
41
|
+
config?: Record<string, unknown>;
|
|
42
|
+
}): Promise<MonitorConnector & {
|
|
43
|
+
token?: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** 更新连接器(name / status / config) */
|
|
46
|
+
updateConnector(projectId: string, botId: string, connectorId: string, params: {
|
|
47
|
+
name?: string;
|
|
48
|
+
status?: string;
|
|
49
|
+
config?: Record<string, unknown>;
|
|
50
|
+
}): Promise<MonitorConnector>;
|
|
51
|
+
/** 删除连接器 */
|
|
52
|
+
deleteConnector(projectId: string, botId: string, connectorId: string): Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
/** 查询监控事件(新→旧,支持 limit / keyword / sinceHours 过滤) */
|
|
56
|
+
queryMonitorEvents(projectId: string, botId: string, params?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
keyword?: string;
|
|
59
|
+
sinceHours?: number;
|
|
60
|
+
}): Promise<MonitorEvent[]>;
|
|
61
|
+
/** webhook 推送 / 本地部署 agent 上报事件(无需 JWT,凭连接器 token) */
|
|
62
|
+
ingestEvent(params: {
|
|
63
|
+
connectorId: string;
|
|
64
|
+
token: string;
|
|
65
|
+
payload: Record<string, unknown>;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
70
|
+
export {};
|