@blade-hq/agent-client 2612.0.0-beta.53 → 2612.0.0-beta.54

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
@@ -113,6 +113,8 @@ const configured = await client.sessions.create({ intent: "数据分析", model:
113
113
 
114
114
  SDK 创建的会话默认归接入应用(`initiator: "sdk"`),运行事件仍由 SDK 交付,提醒展示和点击导航由接入应用自行处理,BA 内置 Web 不弹出这些会话的完成或等待回复提醒。内置 Web 创建入口显式使用 `initiator: "ui"`;此字段表示应用归属,与 headless 执行模式无关。
115
115
 
116
+ 创建请求省略默认的 `sdk` 值,由服务端采用默认归属;显式 `ui` 仍会发送。这样默认创建不会因旧服务端尚未定义 `initiator` 而返回 422。接入时仍须按服务端 `/api/version` 返回的 `version` 安装配套 SDK,其他新功能参数不保证适用于旧服务端。
117
+
116
118
  ### 声明完整会话
117
119
 
118
120
  自定义 Solution、Skill 和模型无需手写上传步骤:
@@ -201,7 +201,7 @@ var ToolProvider = class {
201
201
  const params = message.params;
202
202
  const tool = this.options.tools.find((t) => t.name === params?.name);
203
203
  if (!tool || typeof params?.sessionId !== "string" || !params.sessionId || !params.arguments || typeof params.arguments !== "object" || Array.isArray(params.arguments)) throw new Error("Invalid or unauthorized tool call");
204
- response.result = await tool.handler(params.arguments, { sessionId: params.sessionId, signal: controller.signal });
204
+ response.result = await tool.handler(params.arguments, { sessionId: params.sessionId, signal: controller.signal, ...Object.fromEntries(["executionId", "requestId", "toolCallId"].flatMap((key) => typeof params[key] === "string" && params[key] ? [[key, params[key]]] : [])) });
205
205
  } else {
206
206
  response.error = { code: -32601, message: "Method not found" };
207
207
  }
@@ -224,7 +224,7 @@ var ToolProvider = class {
224
224
 
225
225
  // src/version.ts
226
226
  var SDK_NAME = "agent-client";
227
- var SDK_VERSION = true ? "2612.0.0-beta.53" : "1.1.1";
227
+ var SDK_VERSION = true ? "2612.0.0-beta.54" : "1.1.1";
228
228
 
229
229
  // src/auth-login.ts
230
230
  function isAuthCallbackMessage(value) {
@@ -3525,7 +3525,8 @@ function toCreateSessionPayload(request) {
3525
3525
  const solutionRef = request.solution_ref ?? externalSolutionRef(request.solution_id);
3526
3526
  return {
3527
3527
  intent: request.intent ?? "",
3528
- initiator: request.initiator ?? "sdk",
3528
+ // The server defaults to sdk; older APIs reject even this redundant field.
3529
+ initiator: request.initiator === "sdk" ? void 0 : request.initiator,
3529
3530
  anonymous: request.anonymous,
3530
3531
  solution_id: solutionRef ? void 0 : request.solution_id,
3531
3532
  solution_ref: solutionRef,
@@ -6502,9 +6503,9 @@ var AgentSession = class _AgentSession {
6502
6503
  }
6503
6504
  }
6504
6505
  /** 停止当前回复。 */
6505
- async stop() {
6506
+ async stop(executionId) {
6506
6507
  const request = this.manualCompactionRequest;
6507
- if (request) {
6508
+ if (request && !executionId) {
6508
6509
  const ack = await request.ack;
6509
6510
  if (ack.status !== "accepted") return ack;
6510
6511
  if (this.manualCompactionRequest !== request) return { status: "idle" };
@@ -6513,7 +6514,7 @@ var AgentSession = class _AgentSession {
6513
6514
  chat_run_id: request.runId
6514
6515
  }, 35e3) ?? {};
6515
6516
  }
6516
- const response = await this.runtime.emitWithAck("chat:stop", { session_id: this.sessionId }, 35e3) ?? {};
6517
+ const response = await this.runtime.emitWithAck("chat:stop", { session_id: this.sessionId, ...executionId ? { chat_run_id: executionId } : {} }, 35e3) ?? {};
6517
6518
  const cancelled = response.cancelled_client_request_ids;
6518
6519
  if (response.status === "stopped" && Array.isArray(cancelled) && this.pendingChatRequestId !== null && cancelled.includes(this.pendingChatRequestId)) {
6519
6520
  this.pendingChatRequestId = null;
@@ -9303,4 +9304,4 @@ export {
9303
9304
  parseAskUserQuestion,
9304
9305
  formatAskUserAnswer
9305
9306
  };
9306
- //# sourceMappingURL=chunk-CF6ROLBQ.js.map
9307
+ //# sourceMappingURL=chunk-5NTMW62O.js.map