@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,60 @@
|
|
|
1
|
+
export class InternalAgentResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
// ── 企业级共享知识库(按商户隔离,namespace = ent-{merchant_id})──
|
|
6
|
+
/** 列出企业知识文档 */
|
|
7
|
+
listEnterpriseDocs() {
|
|
8
|
+
return this.request("GET", "/api/merchant/knowledge/enterprise");
|
|
9
|
+
}
|
|
10
|
+
/** 插入企业知识文档(文本) */
|
|
11
|
+
insertEnterpriseDoc(params) {
|
|
12
|
+
return this.request("POST", "/api/merchant/knowledge/enterprise", params);
|
|
13
|
+
}
|
|
14
|
+
/** 删除企业知识文档 */
|
|
15
|
+
deleteEnterpriseDoc(docId) {
|
|
16
|
+
return this.request("DELETE", `/api/merchant/knowledge/enterprise/${encodeURIComponent(docId)}`);
|
|
17
|
+
}
|
|
18
|
+
/** 查询企业知识库(返回上下文,不生成 LLM 回答) */
|
|
19
|
+
queryEnterprise(params) {
|
|
20
|
+
return this.request("POST", "/api/merchant/knowledge/enterprise/query", params);
|
|
21
|
+
}
|
|
22
|
+
// ── 监控连接器 ──
|
|
23
|
+
/** 列出某 bot 的监控连接器 */
|
|
24
|
+
listConnectors(projectId, botId) {
|
|
25
|
+
return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/connectors`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 创建监控连接器。
|
|
29
|
+
* kind = http_poll(平台轮询,需 config.url)| webhook(平台接收推送)| local(本地部署 agent 回传)。
|
|
30
|
+
* webhook / local 返回 token(仅创建时一次),供上报/本地部署配置使用。
|
|
31
|
+
*/
|
|
32
|
+
createConnector(projectId, botId, params) {
|
|
33
|
+
return this.request("POST", `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/connectors`, params);
|
|
34
|
+
}
|
|
35
|
+
/** 更新连接器(name / status / config) */
|
|
36
|
+
updateConnector(projectId, botId, connectorId, params) {
|
|
37
|
+
return this.request("PATCH", `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/connectors/${encodeURIComponent(connectorId)}`, params);
|
|
38
|
+
}
|
|
39
|
+
/** 删除连接器 */
|
|
40
|
+
deleteConnector(projectId, botId, connectorId) {
|
|
41
|
+
return this.request("DELETE", `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/connectors/${encodeURIComponent(connectorId)}`);
|
|
42
|
+
}
|
|
43
|
+
/** 查询监控事件(新→旧,支持 limit / keyword / sinceHours 过滤) */
|
|
44
|
+
queryMonitorEvents(projectId, botId, params) {
|
|
45
|
+
const qs = new URLSearchParams();
|
|
46
|
+
if (params?.limit)
|
|
47
|
+
qs.set("limit", String(params.limit));
|
|
48
|
+
if (params?.keyword)
|
|
49
|
+
qs.set("keyword", params.keyword);
|
|
50
|
+
if (params?.sinceHours != null)
|
|
51
|
+
qs.set("sinceHours", String(params.sinceHours));
|
|
52
|
+
const query = qs.toString() ? `?${qs.toString()}` : "";
|
|
53
|
+
return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/monitor/events${query}`);
|
|
54
|
+
}
|
|
55
|
+
// ── 监控事件入口(公开,token 校验)──
|
|
56
|
+
/** webhook 推送 / 本地部署 agent 上报事件(无需 JWT,凭连接器 token) */
|
|
57
|
+
ingestEvent(params) {
|
|
58
|
+
return this.request("POST", "/api/monitor/ingest", params);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RequestMethod, KnowledgeDoc, KnowledgeRecommendation, BotType } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class KnowledgeResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
upload(botId: string, params: {
|
|
7
|
+
content: string;
|
|
8
|
+
title: string;
|
|
9
|
+
format?: string;
|
|
10
|
+
}): Promise<KnowledgeDoc>;
|
|
11
|
+
list(botId: string): Promise<KnowledgeDoc[]>;
|
|
12
|
+
delete(id: string): Promise<{
|
|
13
|
+
deleted: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
recommendations(botType: BotType): Promise<KnowledgeRecommendation[]>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class KnowledgeResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
upload(botId, params) {
|
|
6
|
+
return this.request("POST", `/api/v1/bots/${botId}/knowledge`, params);
|
|
7
|
+
}
|
|
8
|
+
list(botId) {
|
|
9
|
+
return this.request("GET", `/api/v1/bots/${botId}/knowledge`);
|
|
10
|
+
}
|
|
11
|
+
delete(id) {
|
|
12
|
+
return this.request("DELETE", `/api/v1/knowledge/${id}`);
|
|
13
|
+
}
|
|
14
|
+
recommendations(botType) {
|
|
15
|
+
return this.request("GET", `/api/v1/knowledge/recommendations?botType=${botType}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { LightRAGKeyInfo, LightRAGDocumentParams, LightRAGQueryParams, LightRAGQueryResult, LightRAGBatchResult, RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* LightRAG Knowledge Base management.
|
|
5
|
+
*
|
|
6
|
+
* One botId = one LightRAG tenant. External apps can:
|
|
7
|
+
* - Manage API keys for direct LightRAG service access
|
|
8
|
+
* - Insert/query/delete documents in the RAG vector store
|
|
9
|
+
*
|
|
10
|
+
* Per-user isolation: pass `namespace` to scope documents/queries to a specific user.
|
|
11
|
+
* Defaults to botId (shared knowledge).
|
|
12
|
+
*/
|
|
13
|
+
export declare class LightRAGResource {
|
|
14
|
+
private request;
|
|
15
|
+
constructor(request: RequestFn);
|
|
16
|
+
/**
|
|
17
|
+
* List all active API keys for a bot's knowledge base.
|
|
18
|
+
*/
|
|
19
|
+
listKeys(botId: string): Promise<{
|
|
20
|
+
keys: LightRAGKeyInfo[];
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Generate a new API key for a bot's knowledge base.
|
|
24
|
+
* The full key is returned only once — save it immediately.
|
|
25
|
+
*
|
|
26
|
+
* @param botId - Bot ID (tenant)
|
|
27
|
+
* @param name - Key label (e.g. "production", "dev")
|
|
28
|
+
* @param expiresDays - Days until expiration (0 = never)
|
|
29
|
+
*/
|
|
30
|
+
generateKey(botId: string, name?: string, expiresDays?: number): Promise<LightRAGKeyInfo & {
|
|
31
|
+
key: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Revoke an API key. Takes effect immediately.
|
|
35
|
+
*/
|
|
36
|
+
revokeKey(keyId: string): Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Insert/update a text document into the bot's RAG knowledge base.
|
|
41
|
+
*
|
|
42
|
+
* @param botId - Bot ID (tenant)
|
|
43
|
+
* @param params - Document text + optional file_name and namespace
|
|
44
|
+
*/
|
|
45
|
+
insertDocument(botId: string, params: LightRAGDocumentParams): Promise<{
|
|
46
|
+
success: boolean;
|
|
47
|
+
doc_id: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Batch insert multiple documents into the bot's RAG knowledge base.
|
|
51
|
+
* 服务端逐篇直传(不依赖 InfraX 异步任务),返回每篇上传结果。
|
|
52
|
+
*
|
|
53
|
+
* @param botId - Bot ID (tenant)
|
|
54
|
+
* @param documents - Array of { text, file_name? }
|
|
55
|
+
* @param namespace - Per-user namespace (optional)
|
|
56
|
+
*/
|
|
57
|
+
insertDocuments(botId: string, documents: {
|
|
58
|
+
text: string;
|
|
59
|
+
file_name?: string;
|
|
60
|
+
}[], namespace?: string): Promise<LightRAGBatchResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Delete a document from the bot's RAG knowledge base.
|
|
63
|
+
*
|
|
64
|
+
* @param botId - Bot ID (tenant)
|
|
65
|
+
* @param docId - Document ID (file_name used at insert)
|
|
66
|
+
* @param namespace - Per-user namespace (optional)
|
|
67
|
+
*/
|
|
68
|
+
deleteDocument(botId: string, docId: string, namespace?: string): Promise<{
|
|
69
|
+
deleted: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Query the bot's RAG knowledge base for relevant context.
|
|
73
|
+
* Returns raw context (entities, relations, chunks) — no LLM answer.
|
|
74
|
+
*
|
|
75
|
+
* @param botId - Bot ID (tenant)
|
|
76
|
+
* @param params - Query text, optional mode and namespace
|
|
77
|
+
*/
|
|
78
|
+
query(botId: string, params: LightRAGQueryParams): Promise<LightRAGQueryResult>;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LightRAG Knowledge Base management.
|
|
3
|
+
*
|
|
4
|
+
* One botId = one LightRAG tenant. External apps can:
|
|
5
|
+
* - Manage API keys for direct LightRAG service access
|
|
6
|
+
* - Insert/query/delete documents in the RAG vector store
|
|
7
|
+
*
|
|
8
|
+
* Per-user isolation: pass `namespace` to scope documents/queries to a specific user.
|
|
9
|
+
* Defaults to botId (shared knowledge).
|
|
10
|
+
*/
|
|
11
|
+
export class LightRAGResource {
|
|
12
|
+
constructor(request) {
|
|
13
|
+
this.request = request;
|
|
14
|
+
}
|
|
15
|
+
// ── API Key Management ─────────────────────────────
|
|
16
|
+
/**
|
|
17
|
+
* List all active API keys for a bot's knowledge base.
|
|
18
|
+
*/
|
|
19
|
+
async listKeys(botId) {
|
|
20
|
+
return this.request("GET", `/api/v1/lightrag-keys/${botId}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate a new API key for a bot's knowledge base.
|
|
24
|
+
* The full key is returned only once — save it immediately.
|
|
25
|
+
*
|
|
26
|
+
* @param botId - Bot ID (tenant)
|
|
27
|
+
* @param name - Key label (e.g. "production", "dev")
|
|
28
|
+
* @param expiresDays - Days until expiration (0 = never)
|
|
29
|
+
*/
|
|
30
|
+
async generateKey(botId, name = "default", expiresDays = 0) {
|
|
31
|
+
return this.request("POST", `/api/v1/lightrag-keys/${botId}`, { name, expires_days: expiresDays });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Revoke an API key. Takes effect immediately.
|
|
35
|
+
*/
|
|
36
|
+
async revokeKey(keyId) {
|
|
37
|
+
return this.request("POST", `/api/v1/lightrag-keys/${keyId}/revoke`);
|
|
38
|
+
}
|
|
39
|
+
// ── Document Operations ─────────────────────────────
|
|
40
|
+
/**
|
|
41
|
+
* Insert/update a text document into the bot's RAG knowledge base.
|
|
42
|
+
*
|
|
43
|
+
* @param botId - Bot ID (tenant)
|
|
44
|
+
* @param params - Document text + optional file_name and namespace
|
|
45
|
+
*/
|
|
46
|
+
async insertDocument(botId, params) {
|
|
47
|
+
return this.request("POST", `/api/v1/bots/${botId}/lightrag/documents`, {
|
|
48
|
+
text: params.text,
|
|
49
|
+
file_name: params.file_name,
|
|
50
|
+
namespace: params.namespace,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Batch insert multiple documents into the bot's RAG knowledge base.
|
|
55
|
+
* 服务端逐篇直传(不依赖 InfraX 异步任务),返回每篇上传结果。
|
|
56
|
+
*
|
|
57
|
+
* @param botId - Bot ID (tenant)
|
|
58
|
+
* @param documents - Array of { text, file_name? }
|
|
59
|
+
* @param namespace - Per-user namespace (optional)
|
|
60
|
+
*/
|
|
61
|
+
async insertDocuments(botId, documents, namespace) {
|
|
62
|
+
return this.request("POST", `/api/v1/bots/${botId}/lightrag/documents/batch`, {
|
|
63
|
+
documents,
|
|
64
|
+
namespace,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete a document from the bot's RAG knowledge base.
|
|
69
|
+
*
|
|
70
|
+
* @param botId - Bot ID (tenant)
|
|
71
|
+
* @param docId - Document ID (file_name used at insert)
|
|
72
|
+
* @param namespace - Per-user namespace (optional)
|
|
73
|
+
*/
|
|
74
|
+
async deleteDocument(botId, docId, namespace) {
|
|
75
|
+
const nsQuery = namespace ? `?namespace=${encodeURIComponent(namespace)}` : "";
|
|
76
|
+
return this.request("DELETE", `/api/v1/bots/${botId}/lightrag/documents/${encodeURIComponent(docId)}${nsQuery}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Query the bot's RAG knowledge base for relevant context.
|
|
80
|
+
* Returns raw context (entities, relations, chunks) — no LLM answer.
|
|
81
|
+
*
|
|
82
|
+
* @param botId - Bot ID (tenant)
|
|
83
|
+
* @param params - Query text, optional mode and namespace
|
|
84
|
+
*/
|
|
85
|
+
async query(botId, params) {
|
|
86
|
+
return this.request("POST", `/api/v1/bots/${botId}/lightrag/query`, {
|
|
87
|
+
query: params.query,
|
|
88
|
+
mode: params.mode,
|
|
89
|
+
namespace: params.namespace,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RequestMethod, ConversationCapabilities, ConversationSession, ConversationTask, OrchestrateParams, OrchestrateResult } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Conversation Orchestration(多 task × 多 agent)
|
|
5
|
+
* 基于 Reach Server 的 /api/conversation/* 端点(内部转发 AgentX ConversationClient)。
|
|
6
|
+
* 任务为后台执行,创建即返回(status: queued),轮询 getTask/listTasks 获取结果。
|
|
7
|
+
*/
|
|
8
|
+
export declare class OrchestrationResource {
|
|
9
|
+
private request;
|
|
10
|
+
constructor(request: RequestFn);
|
|
11
|
+
/** 能力探测:parallelTasks 等。parallelTasks=false 时不应使用 orchestrate。 */
|
|
12
|
+
capabilities(): Promise<ConversationCapabilities>;
|
|
13
|
+
/** 创建会话(多个任务的容器) */
|
|
14
|
+
createSession(params?: {
|
|
15
|
+
title?: string;
|
|
16
|
+
agentId?: number;
|
|
17
|
+
}): Promise<ConversationSession>;
|
|
18
|
+
/** 创建单个后台任务(agentId 或 inline prompt/skills 模式) */
|
|
19
|
+
createTask(params: {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
agentId?: number;
|
|
22
|
+
message: string;
|
|
23
|
+
prompt?: string;
|
|
24
|
+
skills?: Record<string, unknown>[];
|
|
25
|
+
enableMemory?: boolean;
|
|
26
|
+
history?: {
|
|
27
|
+
role: "user" | "assistant";
|
|
28
|
+
content: string;
|
|
29
|
+
}[];
|
|
30
|
+
}): Promise<ConversationTask>;
|
|
31
|
+
/** 查询单个任务 */
|
|
32
|
+
getTask(taskId: string): Promise<ConversationTask>;
|
|
33
|
+
/** 列出会话下的所有任务 */
|
|
34
|
+
listTasks(sessionId: string): Promise<{
|
|
35
|
+
tasks: ConversationTask[];
|
|
36
|
+
}>;
|
|
37
|
+
/** 取消任务(queued → 直接取消,running → 中止) */
|
|
38
|
+
cancelTask(taskId: string): Promise<ConversationTask>;
|
|
39
|
+
/**
|
|
40
|
+
* 多 Agent 并行编排:一次创建多个任务(每个任务可指定不同 agent)。
|
|
41
|
+
* AgentX 侧禁用并行任务时返回 HTTP 403(parallel_tasks_disabled),
|
|
42
|
+
* 调用方应降级为 createTask 逐个创建或单轮 chat()。
|
|
43
|
+
*/
|
|
44
|
+
orchestrate(params: OrchestrateParams): Promise<OrchestrateResult>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation Orchestration(多 task × 多 agent)
|
|
3
|
+
* 基于 Reach Server 的 /api/conversation/* 端点(内部转发 AgentX ConversationClient)。
|
|
4
|
+
* 任务为后台执行,创建即返回(status: queued),轮询 getTask/listTasks 获取结果。
|
|
5
|
+
*/
|
|
6
|
+
export class OrchestrationResource {
|
|
7
|
+
constructor(request) {
|
|
8
|
+
this.request = request;
|
|
9
|
+
}
|
|
10
|
+
/** 能力探测:parallelTasks 等。parallelTasks=false 时不应使用 orchestrate。 */
|
|
11
|
+
capabilities() {
|
|
12
|
+
return this.request("GET", "/api/conversation/capabilities");
|
|
13
|
+
}
|
|
14
|
+
/** 创建会话(多个任务的容器) */
|
|
15
|
+
createSession(params) {
|
|
16
|
+
return this.request("POST", "/api/conversation/sessions", params || {});
|
|
17
|
+
}
|
|
18
|
+
/** 创建单个后台任务(agentId 或 inline prompt/skills 模式) */
|
|
19
|
+
createTask(params) {
|
|
20
|
+
return this.request("POST", "/api/conversation/tasks", params);
|
|
21
|
+
}
|
|
22
|
+
/** 查询单个任务 */
|
|
23
|
+
getTask(taskId) {
|
|
24
|
+
return this.request("GET", `/api/conversation/tasks/${taskId}`);
|
|
25
|
+
}
|
|
26
|
+
/** 列出会话下的所有任务 */
|
|
27
|
+
listTasks(sessionId) {
|
|
28
|
+
return this.request("GET", `/api/conversation/sessions/${sessionId}/tasks`);
|
|
29
|
+
}
|
|
30
|
+
/** 取消任务(queued → 直接取消,running → 中止) */
|
|
31
|
+
cancelTask(taskId) {
|
|
32
|
+
return this.request("POST", `/api/conversation/tasks/${taskId}/cancel`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 多 Agent 并行编排:一次创建多个任务(每个任务可指定不同 agent)。
|
|
36
|
+
* AgentX 侧禁用并行任务时返回 HTTP 403(parallel_tasks_disabled),
|
|
37
|
+
* 调用方应降级为 createTask 逐个创建或单轮 chat()。
|
|
38
|
+
*/
|
|
39
|
+
orchestrate(params) {
|
|
40
|
+
return this.request("POST", "/api/conversation/orchestrate", params);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RequestMethod, Project, ProjectCreateParams, ProjectUpdateParams } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class ProjectResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
create(params: ProjectCreateParams): Promise<Project>;
|
|
7
|
+
list(): Promise<Project[]>;
|
|
8
|
+
get(id: string): Promise<Project>;
|
|
9
|
+
update(id: string, params: ProjectUpdateParams): Promise<Project>;
|
|
10
|
+
delete(id: string): Promise<{
|
|
11
|
+
deleted: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class ProjectResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
create(params) {
|
|
6
|
+
return this.request("POST", "/api/v1/projects", params);
|
|
7
|
+
}
|
|
8
|
+
list() {
|
|
9
|
+
return this.request("GET", "/api/v1/projects");
|
|
10
|
+
}
|
|
11
|
+
get(id) {
|
|
12
|
+
return this.request("GET", `/api/v1/projects/${id}`);
|
|
13
|
+
}
|
|
14
|
+
update(id, params) {
|
|
15
|
+
return this.request("PATCH", `/api/v1/projects/${id}`, params);
|
|
16
|
+
}
|
|
17
|
+
delete(id) {
|
|
18
|
+
return this.request("DELETE", `/api/v1/projects/${id}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RequestMethod, ScheduledTask, ScheduledTaskTriggerType } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Scheduled Tasks(主 agent 定时任务)
|
|
5
|
+
* 对话内主 agent 通过 schedule_task 工具创建;此资源用于商户侧
|
|
6
|
+
* 查看/创建/取消,管理同一 scheduled_tasks 存储。
|
|
7
|
+
*/
|
|
8
|
+
export declare class ScheduledTasksResource {
|
|
9
|
+
private request;
|
|
10
|
+
constructor(request: RequestFn);
|
|
11
|
+
/** 列出某 bot 的定时任务(新→旧) */
|
|
12
|
+
list(botId: string): Promise<{
|
|
13
|
+
tasks: ScheduledTask[];
|
|
14
|
+
}>;
|
|
15
|
+
/** 创建定时任务(once 一次性 / cron 重复) */
|
|
16
|
+
create(params: {
|
|
17
|
+
botId: string;
|
|
18
|
+
projectId?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
message: string;
|
|
21
|
+
triggerType: ScheduledTaskTriggerType;
|
|
22
|
+
cronExpr?: string;
|
|
23
|
+
runAt?: string;
|
|
24
|
+
agentId?: number;
|
|
25
|
+
}): Promise<ScheduledTask>;
|
|
26
|
+
/** 取消定时任务 */
|
|
27
|
+
cancel(id: string): Promise<ScheduledTask>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduled Tasks(主 agent 定时任务)
|
|
3
|
+
* 对话内主 agent 通过 schedule_task 工具创建;此资源用于商户侧
|
|
4
|
+
* 查看/创建/取消,管理同一 scheduled_tasks 存储。
|
|
5
|
+
*/
|
|
6
|
+
export class ScheduledTasksResource {
|
|
7
|
+
constructor(request) {
|
|
8
|
+
this.request = request;
|
|
9
|
+
}
|
|
10
|
+
/** 列出某 bot 的定时任务(新→旧) */
|
|
11
|
+
list(botId) {
|
|
12
|
+
return this.request("GET", `/api/merchant/bots/${encodeURIComponent(botId)}/scheduled-tasks`);
|
|
13
|
+
}
|
|
14
|
+
/** 创建定时任务(once 一次性 / cron 重复) */
|
|
15
|
+
create(params) {
|
|
16
|
+
return this.request("POST", "/api/scheduled-tasks", params);
|
|
17
|
+
}
|
|
18
|
+
/** 取消定时任务 */
|
|
19
|
+
cancel(id) {
|
|
20
|
+
return this.request("POST", `/api/scheduled-tasks/${id}/cancel`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RequestMethod, TxIntent, PreparedTransaction, ContractInfo, SimulationResult, DecodedCalldata, ProtocolRegistryEntry, ProtocolSummary } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export declare class TransactionResource {
|
|
4
|
+
private request;
|
|
5
|
+
constructor(request: RequestFn);
|
|
6
|
+
prepare(botId: string, intent: TxIntent): Promise<PreparedTransaction>;
|
|
7
|
+
simulate(params: {
|
|
8
|
+
to: string;
|
|
9
|
+
data: string;
|
|
10
|
+
value: string;
|
|
11
|
+
chainId: number;
|
|
12
|
+
from: string;
|
|
13
|
+
}): Promise<SimulationResult>;
|
|
14
|
+
lookupContract(params: {
|
|
15
|
+
contractAddress: string;
|
|
16
|
+
chainId: number;
|
|
17
|
+
}): Promise<ContractInfo>;
|
|
18
|
+
decodeCalldata(params: {
|
|
19
|
+
data: string;
|
|
20
|
+
contractAddress: string;
|
|
21
|
+
chainId: number;
|
|
22
|
+
}): Promise<DecodedCalldata>;
|
|
23
|
+
listProtocols(chainId?: number): Promise<ProtocolSummary[]>;
|
|
24
|
+
registerProtocol(protocol: ProtocolRegistryEntry): Promise<{
|
|
25
|
+
registered: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class TransactionResource {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
prepare(botId, intent) {
|
|
6
|
+
return this.request("POST", `/api/v1/bots/${botId}/transaction/prepare`, intent);
|
|
7
|
+
}
|
|
8
|
+
simulate(params) {
|
|
9
|
+
return this.request("POST", "/api/v1/transaction/simulate", params);
|
|
10
|
+
}
|
|
11
|
+
lookupContract(params) {
|
|
12
|
+
return this.request("POST", "/api/v1/transaction/lookup-contract", params);
|
|
13
|
+
}
|
|
14
|
+
decodeCalldata(params) {
|
|
15
|
+
return this.request("POST", "/api/v1/transaction/decode-calldata", params);
|
|
16
|
+
}
|
|
17
|
+
listProtocols(chainId) {
|
|
18
|
+
const query = chainId ? `?chainId=${chainId}` : "";
|
|
19
|
+
return this.request("GET", `/api/v1/transaction/protocols${query}`);
|
|
20
|
+
}
|
|
21
|
+
registerProtocol(protocol) {
|
|
22
|
+
return this.request("POST", "/api/v1/transaction/protocols", protocol);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* TTS 资源 — 文本转语音(源自 aiops-saas @aiops/sdk TtsApi)。
|
|
5
|
+
* 端点走 Server API(/api/tts/*),与社媒域 MCP 工具同源。
|
|
6
|
+
*/
|
|
7
|
+
export declare class TtsResource {
|
|
8
|
+
private request;
|
|
9
|
+
constructor(request: RequestFn);
|
|
10
|
+
/** 文本转语音 */
|
|
11
|
+
synthesize(text: string, voice?: string, opts?: Record<string, unknown>): Promise<any>;
|
|
12
|
+
/** 可用语音列表 */
|
|
13
|
+
voices(language?: string): Promise<any>;
|
|
14
|
+
/** TTS 历史(分页) */
|
|
15
|
+
history(params?: Record<string, unknown>): Promise<any>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TTS 资源 — 文本转语音(源自 aiops-saas @aiops/sdk TtsApi)。
|
|
3
|
+
* 端点走 Server API(/api/tts/*),与社媒域 MCP 工具同源。
|
|
4
|
+
*/
|
|
5
|
+
export class TtsResource {
|
|
6
|
+
constructor(request) {
|
|
7
|
+
this.request = request;
|
|
8
|
+
}
|
|
9
|
+
/** 文本转语音 */
|
|
10
|
+
synthesize(text, voice = "zh-CN-XiaoxiaoNeural", opts = {}) {
|
|
11
|
+
return this.request("POST", "/api/tts/synthesize", { text, voice, ...opts });
|
|
12
|
+
}
|
|
13
|
+
/** 可用语音列表 */
|
|
14
|
+
voices(language = "") {
|
|
15
|
+
return this.request("GET", `/api/tts/voices${language ? `?language=${language}` : ""}`);
|
|
16
|
+
}
|
|
17
|
+
/** TTS 历史(分页) */
|
|
18
|
+
history(params = {}) {
|
|
19
|
+
const qs = new URLSearchParams(params).toString();
|
|
20
|
+
return this.request("GET", `/api/tts/history${qs ? `?${qs}` : ""}`);
|
|
21
|
+
}
|
|
22
|
+
}
|