@blade-hq/agent-client 2612.0.0-beta.85 → 2612.0.0-beta.86
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 +14 -0
- package/dist/browser-capability.d.ts +19 -0
- package/dist/{chunk-AKYL4RUF.js → chunk-HOTA22G7.js} +30 -2
- package/dist/chunk-HOTA22G7.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -1
- package/dist/internal.js +9 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/public-api.md +40 -1
- package/dist/chunk-AKYL4RUF.js.map +0 -1
package/README.md
CHANGED
|
@@ -1114,6 +1114,20 @@ BA 默认提供内置定时任务。应用自行管理定时安排时,可在
|
|
|
1114
1114
|
|
|
1115
1115
|
`ProfileResource` 与 `PacksResource` 分别提供上述清单和包操作;`PackProfile`、`ProfileComponent` 描述最终界面,`PackManifest`、`PackLayoutOperation` 和 `InstalledPack` 描述保存/安装的数据形状。完整字段见同目录生成的 `public-api.md` 与 `src/resources/profile.ts`。
|
|
1116
1116
|
|
|
1117
|
+
|
|
1118
|
+
### 沙盒浏览器能力策略
|
|
1119
|
+
|
|
1120
|
+
`BrowserCapability` 区分管理员允许使用浏览器与 Chrome 当前是否运行。`getBrowserCapability(client, sessionId)` 仅读取 BSS 的最终策略,不创建或唤醒沙盒;`enabled=false` 时应隐藏浏览器入口、卸载活动面板并停止健康/标签查询及画面重连。
|
|
1121
|
+
|
|
1122
|
+
```ts
|
|
1123
|
+
import { getBrowserCapability, BrowserDisabledError, isBrowserDisabledError, BROWSER_DISABLED_CODE } from "@blade-hq/agent-client"
|
|
1124
|
+
|
|
1125
|
+
const capability = await getBrowserCapability(client, sessionId)
|
|
1126
|
+
if (!capability.enabled) throw new BrowserDisabledError(capability.source)
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
`BrowserDisabledError.code` 为 `BROWSER_DISABLED_CODE`(`BROWSER_DISABLED`),`retryable=false`。`isBrowserDisabledError(error)` 也识别 BA 透传的终端禁用消息;它不是登录失败,不应触发 token 修复、浏览器唤醒、安装或重复重试。能力重新允许后只恢复入口,实际使用时才启动 Chrome。该策略不限制独立 HTTP 搜索、文件或终端功能。
|
|
1130
|
+
|
|
1117
1131
|
### 平台能力快照
|
|
1118
1132
|
|
|
1119
1133
|
`client.capabilities` 是 `CapabilitiesResource`。`await client.capabilities.get({ signal })` 返回 `CapabilitySnapshot`:`status` 为 `known` 或 `unknown`,`capabilities` 为能力 key 列表,`expires_at` 为绝对有效期。空的 known 列表表示未开通,unknown 表示暂时无法确认;不能把过期的 allow 当作当前授权。资源服务在实际调用时仍会校验资格。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Managed BSS browser policy, independent of whether Chrome is running. */
|
|
2
|
+
export interface BrowserCapability {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
source: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
revision: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const BROWSER_DISABLED_CODE = "BROWSER_DISABLED";
|
|
9
|
+
export declare class BrowserDisabledError extends Error {
|
|
10
|
+
readonly source: string;
|
|
11
|
+
readonly code = "BROWSER_DISABLED";
|
|
12
|
+
readonly retryable = false;
|
|
13
|
+
constructor(source: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function isBrowserDisabledError(error: unknown): boolean;
|
|
16
|
+
/** A capability query never creates or wakes a sandbox. */
|
|
17
|
+
export declare function getBrowserCapability(client: {
|
|
18
|
+
json<T>(method: string, path: string): Promise<T>;
|
|
19
|
+
}, sessionId: string): Promise<BrowserCapability>;
|
|
@@ -9,6 +9,27 @@ var SandboxResource = class {
|
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/browser-capability.ts
|
|
13
|
+
var BROWSER_DISABLED_CODE = "BROWSER_DISABLED";
|
|
14
|
+
var BrowserDisabledError = class extends Error {
|
|
15
|
+
constructor(source) {
|
|
16
|
+
super("BROWSER_DISABLED: \u6D4F\u89C8\u5668\u5DF2\u7981\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u5F00\u542F\uFF1B\u4E0D\u8981\u91CD\u8BD5\u6216\u81EA\u884C\u542F\u52A8\u6D4F\u89C8\u5668");
|
|
17
|
+
this.source = source;
|
|
18
|
+
this.name = "BrowserDisabledError";
|
|
19
|
+
}
|
|
20
|
+
source;
|
|
21
|
+
code = BROWSER_DISABLED_CODE;
|
|
22
|
+
retryable = false;
|
|
23
|
+
};
|
|
24
|
+
function isBrowserDisabledError(error) {
|
|
25
|
+
if (!error || typeof error !== "object") return false;
|
|
26
|
+
const value = error;
|
|
27
|
+
return value.code === BROWSER_DISABLED_CODE || typeof value.message === "string" && value.message.includes(`${BROWSER_DISABLED_CODE}:`);
|
|
28
|
+
}
|
|
29
|
+
function getBrowserCapability(client, sessionId) {
|
|
30
|
+
return client.json("GET", `/api/sessions/${encodeURIComponent(sessionId)}/browser/capability`);
|
|
31
|
+
}
|
|
32
|
+
|
|
12
33
|
// src/rest.ts
|
|
13
34
|
var DOCS_URL = "https://blade-hq.github.io/public-skills/";
|
|
14
35
|
var BladeApiError = class extends Error {
|
|
@@ -45,6 +66,7 @@ async function extractErrorDetail(response) {
|
|
|
45
66
|
}
|
|
46
67
|
function decorateAuthError(error) {
|
|
47
68
|
if (!(error instanceof BladeApiError)) return error;
|
|
69
|
+
if (isBrowserDisabledError(error)) return error;
|
|
48
70
|
if (error.status === 401) {
|
|
49
71
|
error.message = `${error.message}\uFF08\u672A\u767B\u5F55\u6216\u51ED\u8BC1\u5DF2\u5931\u6548\u3002\u6D4F\u89C8\u5668\u573A\u666F\u8C03\u7528 client.auth.login() \u5F39\u7A97\u767B\u5F55\uFF0C\u81EA\u52A8\u5316\u573A\u666F\u5728 new BladeClient({ token }) \u4F20\u5165 PAT\u3002\u63A5\u5165\u6307\u5357\uFF1A${DOCS_URL}\uFF09`;
|
|
50
72
|
} else if (error.status === 403) {
|
|
@@ -227,7 +249,7 @@ var ToolProvider = class {
|
|
|
227
249
|
|
|
228
250
|
// src/version.ts
|
|
229
251
|
var SDK_NAME = "agent-client";
|
|
230
|
-
var SDK_VERSION = true ? "2612.0.0-beta.
|
|
252
|
+
var SDK_VERSION = true ? "2612.0.0-beta.86" : "1.1.1";
|
|
231
253
|
|
|
232
254
|
// src/auth-login.ts
|
|
233
255
|
function isAuthCallbackMessage(value) {
|
|
@@ -3665,6 +3687,8 @@ var ConnectorsResource = class {
|
|
|
3665
3687
|
intent: `\u8FDE\u63A5 ${view.display_name || "\u4E1A\u52A1\u7CFB\u7EDF"}`,
|
|
3666
3688
|
memory_enabled: false
|
|
3667
3689
|
})).session_id;
|
|
3690
|
+
const capability = await getBrowserCapability(this.client, id);
|
|
3691
|
+
if (!capability.enabled) throw new BrowserDisabledError(capability.source);
|
|
3668
3692
|
await this.client.json("POST", `/api/sessions/${encodeURIComponent(id)}/browser/wake`, {});
|
|
3669
3693
|
const tabs = await this.client.json("GET", `/api/sessions/${encodeURIComponent(id)}/browser/tabs`);
|
|
3670
3694
|
const hasBusinessTab = tabs.data?.some(({ url }) => url && url !== "about:blank" && !/^http:\/\/(?:127\.0\.0\.1|localhost):9223\/home(?:[/?#]|$)/.test(url));
|
|
@@ -9707,6 +9731,10 @@ function attachPackPageBridge(options) {
|
|
|
9707
9731
|
|
|
9708
9732
|
export {
|
|
9709
9733
|
SandboxResource,
|
|
9734
|
+
BROWSER_DISABLED_CODE,
|
|
9735
|
+
BrowserDisabledError,
|
|
9736
|
+
isBrowserDisabledError,
|
|
9737
|
+
getBrowserCapability,
|
|
9710
9738
|
BladeApiError,
|
|
9711
9739
|
ToolProvider,
|
|
9712
9740
|
SDK_NAME,
|
|
@@ -9810,4 +9838,4 @@ export {
|
|
|
9810
9838
|
formatAskUserAnswer,
|
|
9811
9839
|
attachPackPageBridge
|
|
9812
9840
|
};
|
|
9813
|
-
//# sourceMappingURL=chunk-
|
|
9841
|
+
//# sourceMappingURL=chunk-HOTA22G7.js.map
|