@blade-hq/agent-client 2610.0.0-beta.35 → 2610.0.0-beta.37
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 +21 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/resources/computers.d.ts +24 -2
- package/package.json +1 -1
- package/public-api.md +25 -1
package/README.md
CHANGED
|
@@ -316,13 +316,30 @@ await client.computers.setEnabled(sessionId, computer.id, false) // 停用
|
|
|
316
316
|
做电脑选择器时用这几个纯函数,别自己重算状态:
|
|
317
317
|
|
|
318
318
|
```ts
|
|
319
|
-
import {
|
|
319
|
+
import {
|
|
320
|
+
canToggleComputer, computerState, sortComputers,
|
|
321
|
+
computerOS, computerPlatformLabel, computerDaemonVersion,
|
|
322
|
+
} from "@blade-hq/agent-client"
|
|
323
|
+
|
|
324
|
+
sortComputers(computers) // 按接入时间,顺序稳定不随状态变化
|
|
325
|
+
computerState(computer) // ComputerState: "primary" | "enabled" | "offline" | "idle"
|
|
326
|
+
canToggleComputer(computer) // 主运行时返回 false
|
|
320
327
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
328
|
+
computerOS(computer) // ComputerOS: "macos" | "windows" | "linux" | "unknown"
|
|
329
|
+
computerPlatformLabel(computer) // "darwin/arm64"
|
|
330
|
+
computerDaemonVersion(computer) // "dev (bc3ad71d1)",未知时是空串
|
|
324
331
|
```
|
|
325
332
|
|
|
333
|
+
`sortComputers` **刻意不按在线/可用排序**:那样排看着"手边的在前面",代价是电脑
|
|
334
|
+
上下线、勾选状态一变整个列表就重排,用户正要点的那一项会在手指底下跑掉。改名也
|
|
335
|
+
不会挪位置,新接入的稳定排在末尾。
|
|
336
|
+
|
|
337
|
+
`computerOS` 判定的是 daemon 上报的 `runtime.GOOS`,各处自己 `startsWith` 一遍必然会分叉;
|
|
338
|
+
图标怎么画交给界面,这里只回答"是哪一类系统"。
|
|
339
|
+
|
|
340
|
+
`computerDaemonVersion` 返回的是服务端存的完整串——dev 构建带 commit,
|
|
341
|
+
因为 dev 的版本号全都是 `dev`,光看它分不出是哪次构建的二进制。**不要在前端另拼一套格式。**
|
|
342
|
+
|
|
326
343
|
`ComputersResource` 是 `client.computers` 的类型。
|
|
327
344
|
|
|
328
345
|
## AgentSession
|
package/dist/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export { isCommandEnvelope, isInboundEnvelope } from "./commands/protocol";
|
|
|
22
22
|
export type { AuthResource, ExchangeCodeParams, ExchangeCodeResult, ProvidersResponse, UserInfo, } from "./resources/auth";
|
|
23
23
|
export type { HeadlessResource } from "./resources/headless";
|
|
24
24
|
export { ComputersResource } from "./resources/computers";
|
|
25
|
-
export { canToggleComputer, computerState, sortComputers, } from "./resources/computers";
|
|
26
|
-
export type { ComputerState, SessionComputer, SessionComputerList, } from "./resources/computers";
|
|
25
|
+
export { canToggleComputer, computerDaemonVersion, computerOS, computerPlatformLabel, computerState, sortComputers, } from "./resources/computers";
|
|
26
|
+
export type { ComputerOS, ComputerState, SessionComputer, SessionComputerList, } from "./resources/computers";
|
|
27
27
|
export { ModelsResource } from "./resources/models";
|
|
28
28
|
export type { ModelCatalog, ModelOption } from "./resources/models";
|
|
29
29
|
export type { SessionsResource } from "./resources/sessions";
|
package/dist/index.js
CHANGED
|
@@ -430,13 +430,29 @@ function computerState(computer) {
|
|
|
430
430
|
if (computer.enabled) return "enabled";
|
|
431
431
|
return computer.online ? "idle" : "offline";
|
|
432
432
|
}
|
|
433
|
+
function computerOS(computer) {
|
|
434
|
+
const os = (computer.os ?? "").toLowerCase();
|
|
435
|
+
if (os.startsWith("darwin") || os.startsWith("mac")) return "macos";
|
|
436
|
+
if (os.startsWith("windows")) return "windows";
|
|
437
|
+
if (os.startsWith("linux")) return "linux";
|
|
438
|
+
return "unknown";
|
|
439
|
+
}
|
|
440
|
+
function computerPlatformLabel(computer) {
|
|
441
|
+
const os = (computer.os ?? "").trim();
|
|
442
|
+
const arch = (computer.arch ?? "").trim();
|
|
443
|
+
if (os && arch) return `${os}/${arch}`;
|
|
444
|
+
return os || arch || "";
|
|
445
|
+
}
|
|
446
|
+
function computerDaemonVersion(computer) {
|
|
447
|
+
return (computer.daemon_version ?? "").trim();
|
|
448
|
+
}
|
|
433
449
|
function canToggleComputer(computer) {
|
|
434
450
|
return !computer.is_primary;
|
|
435
451
|
}
|
|
436
452
|
function sortComputers(computers) {
|
|
437
453
|
return [...computers].sort((a, b) => {
|
|
438
|
-
|
|
439
|
-
if (
|
|
454
|
+
const byCreated = (a.created_at ?? "").localeCompare(b.created_at ?? "");
|
|
455
|
+
if (byCreated !== 0) return byCreated;
|
|
440
456
|
return a.label.localeCompare(b.label);
|
|
441
457
|
});
|
|
442
458
|
}
|
|
@@ -2499,7 +2515,6 @@ function toCreateSessionPayload(request) {
|
|
|
2499
2515
|
var builtinSolutionIds = /* @__PURE__ */ new Set([
|
|
2500
2516
|
"app-dev",
|
|
2501
2517
|
"general_chat",
|
|
2502
|
-
"multica",
|
|
2503
2518
|
"night_build",
|
|
2504
2519
|
"skill_editor",
|
|
2505
2520
|
"smart_bid",
|
|
@@ -5404,7 +5419,7 @@ function resolveAuthToken(options) {
|
|
|
5404
5419
|
|
|
5405
5420
|
// src/version.ts
|
|
5406
5421
|
var SDK_NAME = "agent-client";
|
|
5407
|
-
var SDK_VERSION = true ? "2610.0.0-beta.
|
|
5422
|
+
var SDK_VERSION = true ? "2610.0.0-beta.37" : "1.1.1";
|
|
5408
5423
|
|
|
5409
5424
|
// src/socket.ts
|
|
5410
5425
|
function withSdkIdentity(auth) {
|
|
@@ -6003,6 +6018,9 @@ export {
|
|
|
6003
6018
|
buildMessageContent,
|
|
6004
6019
|
canToggleComputer,
|
|
6005
6020
|
chatErrorForDisplay,
|
|
6021
|
+
computerDaemonVersion,
|
|
6022
|
+
computerOS,
|
|
6023
|
+
computerPlatformLabel,
|
|
6006
6024
|
computerState,
|
|
6007
6025
|
connectEmbedded,
|
|
6008
6026
|
contentPreview,
|