@blade-hq/agent-client 2610.0.0-beta.25 → 2610.0.0-beta.26

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 CHANGED
@@ -82,12 +82,10 @@ new BladeClient({
82
82
  baseUrl: "https://blade.example.com", // 后端地址;同域部署可传 ""
83
83
  token: "sk-blade-xxx", // 可选:PAT。不传则用 cookie 或 login()
84
84
  tokenStorage: "local", // 可选:login() 的令牌存哪("local" 默认 / "memory")
85
+ streamTokens: false, // 可选:只接收完成态内容,不订阅逐 token 增量
85
86
  })
86
87
  ```
87
88
 
88
- SDK 会固定订阅普通聊天所需的完整实时事件。产品内置 Web 的精简/开发者展示模式不属于
89
- 公共 SDK 契约,也没有对应的构造参数或 Socket.IO 字段。
90
-
91
89
  > **`baseUrl` 填哪个地址?** 必须是 Blade Agent 后端的地址(形如 `http://<主机>:8020`),只要域名和端口、不带路径。
92
90
  > 注意别填成你平时打开的 Blade OS 地址(同主机的 `:80`)—— 那是另一套接口,SDK 连不上。
93
91
 
@@ -23,6 +23,8 @@ export interface BladeClientOptions {
23
23
  tokenStorage?: TokenStorageMode;
24
24
  fetchImpl?: typeof fetch;
25
25
  onRefreshSuccess?: () => void | Promise<void>;
26
+ /** 是否订阅逐 token 增量,默认 true。关闭后仍接收完整消息和语义事件。 */
27
+ streamTokens?: boolean;
26
28
  }
27
29
  export declare class BladeClient {
28
30
  private refreshPromise;
package/dist/index.js CHANGED
@@ -352,7 +352,8 @@ var HeadlessResource = class {
352
352
  socket.on("system:error", onSystemError);
353
353
  socket.emit("session:subscribe", {
354
354
  session_id,
355
- event_format: "raw"
355
+ event_format: "raw",
356
+ stream_tokens: this.client.options.streamTokens !== false
356
357
  });
357
358
  socket.emit(
358
359
  "chat:send",
@@ -3539,6 +3540,7 @@ var AgentSession = class _AgentSession {
3539
3540
  const session = new _AgentSession(
3540
3541
  sessionId,
3541
3542
  {
3543
+ streamTokens: false,
3542
3544
  emitEvent: readonlyError,
3543
3545
  emitWithAck: async () => readonlyError(),
3544
3546
  ensureConnected: readonlyError,
@@ -3693,7 +3695,8 @@ var AgentSession = class _AgentSession {
3693
3695
  thinking_override: options.thinkingOverride,
3694
3696
  whatif: options.whatif,
3695
3697
  replay_decision: options.replayDecision,
3696
- app_context: appContext
3698
+ app_context: appContext,
3699
+ kb_ids: options.kbIds && options.kbIds.length > 0 ? options.kbIds : void 0
3697
3700
  };
3698
3701
  try {
3699
3702
  await this.ensureJoined();
@@ -4270,7 +4273,8 @@ var AgentSession = class _AgentSession {
4270
4273
  {
4271
4274
  session_id: this.sessionId,
4272
4275
  event_format: "raw",
4273
- resume: true
4276
+ resume: true,
4277
+ stream_tokens: this.runtime.streamTokens
4274
4278
  },
4275
4279
  5e3
4276
4280
  ).then((response) => {
@@ -4407,6 +4411,7 @@ var SessionHub = class {
4407
4411
  }
4408
4412
  runtimeFor() {
4409
4413
  return {
4414
+ streamTokens: this.client.options?.streamTokens !== false,
4410
4415
  emitEvent: (event, data) => {
4411
4416
  ;
4412
4417
  this.client.socket().emit(event, data);
@@ -4646,7 +4651,7 @@ function resolveAuthToken(options) {
4646
4651
 
4647
4652
  // src/version.ts
4648
4653
  var SDK_NAME = "agent-client";
4649
- var SDK_VERSION = true ? "2610.0.0-beta.25" : "1.1.1";
4654
+ var SDK_VERSION = true ? "2610.0.0-beta.26" : "1.1.1";
4650
4655
 
4651
4656
  // src/socket.ts
4652
4657
  function withSdkIdentity(auth) {