@blade-hq/agent-client 2612.0.0-beta.41 → 2612.0.0-beta.43

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
@@ -739,6 +739,8 @@ chat.renderers = {
739
739
 
740
740
  ## 附录:公开类型索引
741
741
 
742
+ 已有会话可调用 `await session.selectModel("模型标识")` 立即切换模型,无须额外发送消息。父子任务后续模型调用沿用会话当前选择;正在调用的旧模型会取消,正在执行的业务工具保留。返回 `false` 表示选择失败,并通过会话的错误事件反馈原因。因模型调用失败停止的任务会接续执行;主动停止或等待用户回答的任务保持原状态。
743
+
742
744
  完整签名见 [public-api.md](./public-api.md)(由 `scripts/public-api-report.mjs` 生成并在 CI 校验)。
743
745
 
744
746
  - **客户端与登录**:`BladeClient`、`BladeClientOptions`、`UploadProgress`、`BladeApiError`、`LoginOptions`、`LoginResult`、`TokenStorageMode`、`AuthResource`、`ExchangeCodeParams`、`ExchangeCodeResult`、`ProvidersResponse`、`UserInfo`
@@ -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.41" : "1.1.1";
227
+ var SDK_VERSION = true ? "2612.0.0-beta.43" : "1.1.1";
228
228
 
229
229
  // src/auth-login.ts
230
230
  function isAuthCallbackMessage(value) {
@@ -6010,6 +6010,20 @@ var AgentSession = class _AgentSession {
6010
6010
  this.getAppContext = options.getContext;
6011
6011
  return attachment;
6012
6012
  }
6013
+ /** 立即为整个会话切换模型,并接续因模型故障停下的任务。 */
6014
+ async selectModel(model) {
6015
+ try {
6016
+ await this.ensureJoined();
6017
+ const response = await this.runtime.emitWithAck("chat:model", { session_id: this.sessionId, model }, 3e4);
6018
+ if (response?.status !== "ok") throw new Error(typeof response?.message === "string" ? response.message : "\u6A21\u578B\u5207\u6362\u5931\u8D25");
6019
+ return true;
6020
+ } catch (error) {
6021
+ const failure = describeSessionError(error, "\u6A21\u578B\u5207\u6362\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
6022
+ this.update((state) => addErrorMessage(state, failure.message));
6023
+ this.emitter.emit("error", { message: failure.message });
6024
+ return false;
6025
+ }
6026
+ }
6013
6027
  /** Prepare a durable text input without sending any network request. */
6014
6028
  prepareSend(content, options = {}) {
6015
6029
  if (!content.trim()) throw new Error("\u6D88\u606F\u4E0D\u80FD\u4E3A\u7A7A");
@@ -9117,4 +9131,4 @@ export {
9117
9131
  BladeClient,
9118
9132
  BladeApplicationClient
9119
9133
  };
9120
- //# sourceMappingURL=chunk-X4LEN2SS.js.map
9134
+ //# sourceMappingURL=chunk-XAXUPUD2.js.map