@blade-hq/agent-client 2612.0.0-beta.81 → 2612.0.0-beta.83
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 +20 -0
- package/dist/blade-client.d.ts +4 -0
- package/dist/{chunk-EEX6KL6X.js → chunk-J5HK3PPV.js} +124 -14
- package/dist/chunk-J5HK3PPV.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/internal.js +5 -1
- package/dist/internal.js.map +1 -1
- package/dist/resources/capabilities.d.ts +14 -0
- package/dist/resources/feishu-bots.d.ts +273 -0
- package/dist/resources/sessions.d.ts +0 -12
- package/package.json +1 -1
- package/public-api.md +315 -6
- package/dist/chunk-EEX6KL6X.js.map +0 -1
package/README.md
CHANGED
|
@@ -822,6 +822,22 @@ chat.renderers = {
|
|
|
822
822
|
|
|
823
823
|
相关类型:`ConnectorsResource`、`AccountConnector`、`ConnectorConnection`、`ConnectorConnectionView`。
|
|
824
824
|
|
|
825
|
+
### 独立飞书机器人
|
|
826
|
+
|
|
827
|
+
`BladeClient.feishuBots`(`FeishuBotsResource`)按当前用户访问独立机器人,不更新 `connectors` 的默认办公绑定。`list()` 仅列出 purpose 为 bot 的实例;`create(requestId)` 使用持久请求编号,重试复用原值。`get(id)`、`authorize(id, action, options?)`、`bind(id, pushUrl)`、`pause(id)`、`resume(id)` 返回 `FeishuBotConnection`,`disconnect(id)` 返回 `{disconnected:true}`。扫码步骤用 `FeishuBotAuthorizationAction` 和 `FeishuBotAuthorizationOptions`,只展示 SW 返回的授权链接。扫码成功不代表订阅已启用,应检查 `subscription_state`。
|
|
828
|
+
|
|
829
|
+
`getMessage`、`getHistory`、`resolveNames`、`getChatInfo`、`listChatMembers`、`listChatBots` 与 `downloadResource` 都要求原始 `FeishuBotReferenceScope`。`getDocument` 用调用方明确提供的 owner 办公连接及其来源,机器人不能借用本人的文档授权。接口保留 SW 的 `FeishuBotOperationResult<T>`,消息查询的 `data` 是 `FeishuBotPlatformResult<FeishuBotMessagePage>`,其中包含原生 `FeishuBotRawMessage`;名字查询是 `FeishuBotNames`,群成员是 `FeishuBotMember`。请求类型分别为 `FeishuBotScopedRequest`、`FeishuBotMessageRequest`、`FeishuBotHistoryRequest`、`FeishuBotResourceRequest`,不提供任意 URL 或 operation 调用。
|
|
830
|
+
|
|
831
|
+
`sendMessage(id, FeishuBotSendRequest)` 和 `replyMessage(id, FeishuBotReplyRequest)` 要求固定 `idempotency_key`(最多 50 字节)。保存 `FeishuBotReceipt.operation_id`;`unknown` 表示结果未知,应使用 `getReceipt(id, {operation_id, reference_scope})` 查询,不能改编号再发送。文件发送先用 `uploadArtifact(id, blob, filename, requestId)` 暂存,再用 `uploadFile(id, FeishuBotUploadFileRequest)` 或 `uploadImage` 上传平台,最后 `createMessage(id, FeishuBotCreateMessageRequest)`。上传和创建均保留各自原 `request_id`,平台文件标识在回执的 `result.data` 中。
|
|
832
|
+
|
|
833
|
+
`FeishuBotArtifact` 含临时产物的大小、摘要、来源与下载路径。`downloadArtifact(id, artifactId)` 返回鉴权后的 `Response`,BA 在返回字节前验证大小和 SHA256。路径只用于 BA 同源下载,不是可分享 URL,也不是沙盒内路径;宿主须将字节登记到自己的持久附件链路后供沙盒使用。
|
|
834
|
+
|
|
835
|
+
`getUserInfo` 返回当前机器人可见的 `FeishuBotUser`。`getForwardedMessages` 保留平台消息列表和 `upper_message_id`,由宿主转换库处理合并转发。`getDocumentMetadata` 使用明确指定的办公连接,按 `FeishuDocumentType` 查询 `FeishuDocumentMetadata`;机器人名称直接用连接的 `label`。`getReceipt` 的 `FeishuBotReceiptQuery` 允许三种原身份之一:`operation_id`、文本发送的 `idempotency_key`、文件上传/创建的 `request_id`。HTTP 断连后可用原 key 查回执,无需先取得 operation_id;查询不自动重发。
|
|
836
|
+
|
|
837
|
+
`replyTypedMessage(id, FeishuBotReplyTypedMessageRequest)` 用固定 `request_id` 回复原消息,参数为 `{params:{message_id},data:{msg_type,content},reference_scope,request_id}`,支持图片、文件等与 `createMessage` 相同的消息类型。文件 key 放在 JSON 编码的 `content` 中;响应丢失后仍通过原 `request_id` 查询回执。
|
|
838
|
+
|
|
839
|
+
回执查询仅在 HTTP 200 且 `ok:false`、`error.code:"NOT_FOUND"` 并保留原 `reference_scope` 时表示该连接没有持久回执,可以复用原 key 重试。网络错误、数据库错误及 `unknown` 均不代表未执行。`replyTypedMessage` 还支持 `data.reply_in_thread` 指定在线程内回复。
|
|
840
|
+
|
|
825
841
|
## 第一方内部入口
|
|
826
842
|
|
|
827
843
|
`@blade-hq/agent-client/internal` 是内置 Web、浏览器插件与 `@blade-hq/agent-react` 共用的内部件(状态机细节、判定逻辑、低层通道)。它随包发布,但**不属于公开面**:不写进本文档与 `public-api.md`,版本之间可以随时改动或删除。接入方只用主入口。
|
|
@@ -1094,3 +1110,7 @@ BA 默认提供内置定时任务。应用自行管理定时安排时,可在
|
|
|
1094
1110
|
|
|
1095
1111
|
|
|
1096
1112
|
`ProfileResource` 与 `PacksResource` 分别提供上述清单和包操作;`PackProfile`、`ProfileComponent` 描述最终界面,`PackManifest`、`PackLayoutOperation` 和 `InstalledPack` 描述保存/安装的数据形状。完整字段见同目录生成的 `public-api.md` 与 `src/resources/profile.ts`。
|
|
1113
|
+
|
|
1114
|
+
### 平台能力快照
|
|
1115
|
+
|
|
1116
|
+
`client.capabilities` 是 `CapabilitiesResource`。`await client.capabilities.get({ signal })` 返回 `CapabilitySnapshot`:`status` 为 `known` 或 `unknown`,`capabilities` 为能力 key 列表,`expires_at` 为绝对有效期。空的 known 列表表示未开通,unknown 表示暂时无法确认;不能把过期的 allow 当作当前授权。资源服务在实际调用时仍会校验资格。
|
package/dist/blade-client.d.ts
CHANGED
|
@@ -9,10 +9,12 @@ import { HeadlessResource } from "./resources/headless";
|
|
|
9
9
|
import { ComputersResource } from "./resources/computers";
|
|
10
10
|
import { PhonesResource } from "./resources/phones";
|
|
11
11
|
import { LlmResource } from "./resources/llm";
|
|
12
|
+
import { CapabilitiesResource } from "./resources/capabilities";
|
|
12
13
|
import { ModelsResource } from "./resources/models";
|
|
13
14
|
import { SessionsResource } from "./resources/sessions";
|
|
14
15
|
import { PluginsResource } from "./resources/plugins";
|
|
15
16
|
import { ConnectorsResource } from "./resources/connectors";
|
|
17
|
+
import { FeishuBotsResource } from "./resources/feishu-bots";
|
|
16
18
|
import { ChatGroupsResource } from "./resources/chat-groups";
|
|
17
19
|
import { SiteVisitsResource } from "./resources/site-visits";
|
|
18
20
|
import { SessionHub } from "./session/hub";
|
|
@@ -61,11 +63,13 @@ export declare class BladeClient {
|
|
|
61
63
|
/** 用户接进来的手机:账号级清单、会话启用、画面信令。 */
|
|
62
64
|
readonly phones: PhonesResource;
|
|
63
65
|
readonly llm: LlmResource;
|
|
66
|
+
readonly capabilities: CapabilitiesResource;
|
|
64
67
|
readonly models: ModelsResource;
|
|
65
68
|
readonly sessions: SessionsResource;
|
|
66
69
|
/** 按用户读取的插件目录与图标;没有会话时也能用。 */
|
|
67
70
|
readonly plugins: PluginsResource;
|
|
68
71
|
readonly connectors: ConnectorsResource;
|
|
72
|
+
readonly feishuBots: FeishuBotsResource;
|
|
69
73
|
readonly chatGroups: ChatGroupsResource;
|
|
70
74
|
/**
|
|
71
75
|
* 全站访问统计:匿名读写,不带 bearer 也不触发登录刷新。
|
|
@@ -227,7 +227,7 @@ var ToolProvider = class {
|
|
|
227
227
|
|
|
228
228
|
// src/version.ts
|
|
229
229
|
var SDK_NAME = "agent-client";
|
|
230
|
-
var SDK_VERSION = true ? "2612.0.0-beta.
|
|
230
|
+
var SDK_VERSION = true ? "2612.0.0-beta.83" : "1.1.1";
|
|
231
231
|
|
|
232
232
|
// src/auth-login.ts
|
|
233
233
|
function isAuthCallbackMessage(value) {
|
|
@@ -3505,6 +3505,17 @@ var LlmResource = class {
|
|
|
3505
3505
|
chat = { completions: { create: (body, options = {}) => this.client.jsonFromInit("/api/llm/chat/completions", { method: "POST", body: JSON.stringify(body), signal: options.signal }) } };
|
|
3506
3506
|
};
|
|
3507
3507
|
|
|
3508
|
+
// src/resources/capabilities.ts
|
|
3509
|
+
var CapabilitiesResource = class {
|
|
3510
|
+
constructor(client) {
|
|
3511
|
+
this.client = client;
|
|
3512
|
+
}
|
|
3513
|
+
client;
|
|
3514
|
+
get(options = {}) {
|
|
3515
|
+
return this.client.jsonFromInit("/api/config/capabilities", options);
|
|
3516
|
+
}
|
|
3517
|
+
};
|
|
3518
|
+
|
|
3508
3519
|
// src/resources/models.ts
|
|
3509
3520
|
var ModelsResource = class {
|
|
3510
3521
|
constructor(client) {
|
|
@@ -4188,18 +4199,6 @@ var SessionsResource = class {
|
|
|
4188
4199
|
getSessionHistory(sessionId, init) {
|
|
4189
4200
|
return this.client.jsonFromInit(`/api/sessions/${sessionId}/history`, init);
|
|
4190
4201
|
}
|
|
4191
|
-
tokenizePrompt(prompt, model) {
|
|
4192
|
-
return this.client.json("POST", "/api/sessions/tokenize/prompt", { prompt, model });
|
|
4193
|
-
}
|
|
4194
|
-
tokenizeMessages(messages, options) {
|
|
4195
|
-
return this.client.json("POST", "/api/sessions/tokenize/messages", {
|
|
4196
|
-
messages,
|
|
4197
|
-
model: options?.model,
|
|
4198
|
-
add_generation_prompt: options?.add_generation_prompt ?? true,
|
|
4199
|
-
enable_thinking: options?.enable_thinking ?? null,
|
|
4200
|
-
tools: options?.tools ?? null
|
|
4201
|
-
});
|
|
4202
|
-
}
|
|
4203
4202
|
getSessionCheckpoints(sessionId, init) {
|
|
4204
4203
|
return this.client.jsonFromInit(`/api/sessions/${sessionId}/checkpoints`, init);
|
|
4205
4204
|
}
|
|
@@ -4503,6 +4502,111 @@ var PluginsResource = class {
|
|
|
4503
4502
|
}
|
|
4504
4503
|
};
|
|
4505
4504
|
|
|
4505
|
+
// src/resources/feishu-bots.ts
|
|
4506
|
+
var FeishuBotsResource = class {
|
|
4507
|
+
constructor(client) {
|
|
4508
|
+
this.client = client;
|
|
4509
|
+
}
|
|
4510
|
+
client;
|
|
4511
|
+
path(id) {
|
|
4512
|
+
return `/api/feishu/bots/${encodeURIComponent(id)}`;
|
|
4513
|
+
}
|
|
4514
|
+
operation(id, name, args, init) {
|
|
4515
|
+
return this.client.jsonFromInit(`${this.path(id)}/operations/${name}`, { ...init, method: "POST", body: JSON.stringify(args) });
|
|
4516
|
+
}
|
|
4517
|
+
list(init) {
|
|
4518
|
+
return this.client.jsonFromInit("/api/feishu/bots", { ...init, method: "GET" });
|
|
4519
|
+
}
|
|
4520
|
+
create(requestId, init) {
|
|
4521
|
+
return this.client.jsonFromInit("/api/feishu/bots", { ...init, method: "POST", body: JSON.stringify({ request_id: requestId }) });
|
|
4522
|
+
}
|
|
4523
|
+
get(id, init) {
|
|
4524
|
+
return this.client.jsonFromInit(this.path(id), { ...init, method: "GET" });
|
|
4525
|
+
}
|
|
4526
|
+
authorize(id, action, options = {}, init) {
|
|
4527
|
+
return this.client.jsonFromInit(`${this.path(id)}/actions`, { ...init, method: "POST", body: JSON.stringify({ ...options, action }) });
|
|
4528
|
+
}
|
|
4529
|
+
bind(id, pushUrl, init) {
|
|
4530
|
+
return this.client.jsonFromInit(`${this.path(id)}/subscription`, { ...init, method: "POST", body: JSON.stringify({ push_url: pushUrl }) });
|
|
4531
|
+
}
|
|
4532
|
+
pause(id, init) {
|
|
4533
|
+
return this.subscription(id, false, init);
|
|
4534
|
+
}
|
|
4535
|
+
resume(id, init) {
|
|
4536
|
+
return this.subscription(id, true, init);
|
|
4537
|
+
}
|
|
4538
|
+
subscription(id, enabled, init) {
|
|
4539
|
+
return this.client.jsonFromInit(`${this.path(id)}/subscription`, { ...init, method: "PATCH", body: JSON.stringify({ enabled }) });
|
|
4540
|
+
}
|
|
4541
|
+
disconnect(id, init) {
|
|
4542
|
+
return this.client.jsonFromInit(`${this.path(id)}/disconnect`, { ...init, method: "POST", body: "{}" });
|
|
4543
|
+
}
|
|
4544
|
+
getMessage(id, request, init) {
|
|
4545
|
+
return this.operation(id, "messages_get", { ...request, identity: "bot" }, init);
|
|
4546
|
+
}
|
|
4547
|
+
getHistory(id, request, init) {
|
|
4548
|
+
return this.operation(id, "messages_list", { ...request, identity: "bot" }, init);
|
|
4549
|
+
}
|
|
4550
|
+
getForwardedMessages(id, request, init) {
|
|
4551
|
+
return this.getMessage(id, request, init);
|
|
4552
|
+
}
|
|
4553
|
+
getUserInfo(id, request, init) {
|
|
4554
|
+
return this.operation(id, "users_get", request, init);
|
|
4555
|
+
}
|
|
4556
|
+
resolveNames(id, request, init) {
|
|
4557
|
+
return this.operation(id, "message_names", request, init);
|
|
4558
|
+
}
|
|
4559
|
+
downloadResource(id, request, init) {
|
|
4560
|
+
return this.operation(id, "message_resource_download", { ...request, identity: "bot" }, init);
|
|
4561
|
+
}
|
|
4562
|
+
sendMessage(id, request, init) {
|
|
4563
|
+
return this.operation(id, "message_send", request, init);
|
|
4564
|
+
}
|
|
4565
|
+
replyMessage(id, request, init) {
|
|
4566
|
+
return this.operation(id, "message_reply", request, init);
|
|
4567
|
+
}
|
|
4568
|
+
getReceipt(id, request, init) {
|
|
4569
|
+
return this.operation(id, "operations_get", request, init);
|
|
4570
|
+
}
|
|
4571
|
+
getDocumentMetadata(id, request, init) {
|
|
4572
|
+
return this.operation(id, "document_metadata", request, init);
|
|
4573
|
+
}
|
|
4574
|
+
getDocument(id, request, init) {
|
|
4575
|
+
return this.operation(id, "docs_documents_get", { reference_scope: request.reference_scope, params: { document_id: request.document_id } }, init);
|
|
4576
|
+
}
|
|
4577
|
+
getChatInfo(id, request, init) {
|
|
4578
|
+
return this.operation(id, "im_chats_get", { reference_scope: request.reference_scope, params: { chat_id: request.chat_id } }, init);
|
|
4579
|
+
}
|
|
4580
|
+
listChatMembers(id, request, init) {
|
|
4581
|
+
const { reference_scope, ...params } = request;
|
|
4582
|
+
return this.operation(id, "im_chat_members_get", { reference_scope, params: { ...params, member_id_type: "open_id" } }, init);
|
|
4583
|
+
}
|
|
4584
|
+
listChatBots(id, request, init) {
|
|
4585
|
+
return this.operation(id, "im_chat_members_bots", { reference_scope: request.reference_scope, params: { chat_id: request.chat_id } }, init);
|
|
4586
|
+
}
|
|
4587
|
+
uploadFile(id, request, init) {
|
|
4588
|
+
return this.operation(id, "im_files_upload", request, init);
|
|
4589
|
+
}
|
|
4590
|
+
uploadImage(id, request, init) {
|
|
4591
|
+
return this.operation(id, "im_images_upload", request, init);
|
|
4592
|
+
}
|
|
4593
|
+
createMessage(id, request, init) {
|
|
4594
|
+
return this.operation(id, "im_messages_create", request, init);
|
|
4595
|
+
}
|
|
4596
|
+
replyTypedMessage(id, request, init) {
|
|
4597
|
+
return this.operation(id, "im_messages_reply", request, init);
|
|
4598
|
+
}
|
|
4599
|
+
uploadArtifact(id, file, filename, requestId, init) {
|
|
4600
|
+
const body = new FormData();
|
|
4601
|
+
body.set("file", file, filename);
|
|
4602
|
+
body.set("request_id", requestId);
|
|
4603
|
+
return this.client.jsonFromInit(`${this.path(id)}/files`, { ...init, method: "POST", body });
|
|
4604
|
+
}
|
|
4605
|
+
downloadArtifact(id, artifactId, init) {
|
|
4606
|
+
return this.client.responseFromInit(`${this.path(id)}/files/${encodeURIComponent(artifactId)}`, { ...init, method: "GET" });
|
|
4607
|
+
}
|
|
4608
|
+
};
|
|
4609
|
+
|
|
4506
4610
|
// src/resources/chat-groups.ts
|
|
4507
4611
|
var ChatGroupsResource = class {
|
|
4508
4612
|
constructor(client) {
|
|
@@ -8420,11 +8524,13 @@ var BladeClient = class _BladeClient {
|
|
|
8420
8524
|
/** 用户接进来的手机:账号级清单、会话启用、画面信令。 */
|
|
8421
8525
|
phones;
|
|
8422
8526
|
llm;
|
|
8527
|
+
capabilities;
|
|
8423
8528
|
models;
|
|
8424
8529
|
sessions;
|
|
8425
8530
|
/** 按用户读取的插件目录与图标;没有会话时也能用。 */
|
|
8426
8531
|
plugins;
|
|
8427
8532
|
connectors;
|
|
8533
|
+
feishuBots;
|
|
8428
8534
|
chatGroups;
|
|
8429
8535
|
/**
|
|
8430
8536
|
* 全站访问统计:匿名读写,不带 bearer 也不触发登录刷新。
|
|
@@ -8450,9 +8556,11 @@ var BladeClient = class _BladeClient {
|
|
|
8450
8556
|
this.phones = new PhonesResource(this);
|
|
8451
8557
|
this.llm = new LlmResource(this);
|
|
8452
8558
|
this.models = new ModelsResource(this);
|
|
8559
|
+
this.capabilities = new CapabilitiesResource(this);
|
|
8453
8560
|
this.sessions = new SessionsResource(this);
|
|
8454
8561
|
this.plugins = new PluginsResource(this);
|
|
8455
8562
|
this.connectors = new ConnectorsResource(this);
|
|
8563
|
+
this.feishuBots = new FeishuBotsResource(this);
|
|
8456
8564
|
this.chatGroups = new ChatGroupsResource(this);
|
|
8457
8565
|
this.siteVisits = new SiteVisitsResource(this);
|
|
8458
8566
|
this.hub = new SessionHub(this);
|
|
@@ -9629,6 +9737,7 @@ export {
|
|
|
9629
9737
|
phoneState,
|
|
9630
9738
|
sortPhones,
|
|
9631
9739
|
phoneSerialLabel,
|
|
9740
|
+
CapabilitiesResource,
|
|
9632
9741
|
ModelsResource,
|
|
9633
9742
|
isLocalConnectorName,
|
|
9634
9743
|
ConnectorsResource,
|
|
@@ -9638,6 +9747,7 @@ export {
|
|
|
9638
9747
|
SessionSetupError,
|
|
9639
9748
|
isEntryGoneError,
|
|
9640
9749
|
PluginsResource,
|
|
9750
|
+
FeishuBotsResource,
|
|
9641
9751
|
ChatGroupsResource,
|
|
9642
9752
|
syncServerTime,
|
|
9643
9753
|
getServerTime,
|
|
@@ -9692,4 +9802,4 @@ export {
|
|
|
9692
9802
|
formatAskUserAnswer,
|
|
9693
9803
|
attachPackPageBridge
|
|
9694
9804
|
};
|
|
9695
|
-
//# sourceMappingURL=chunk-
|
|
9805
|
+
//# sourceMappingURL=chunk-J5HK3PPV.js.map
|