@blade-hq/agent-react 2610.0.0-beta.23 → 2610.0.0-beta.25

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
@@ -32,7 +32,6 @@ export function App() {
32
32
 
33
33
  - 不传 `sessionId` 自动创建新会话;未登录时 `ChatView` 自己渲染登录按钮(弹窗授权,见 agent-client 的 `client.auth.login()`)。
34
34
  - 同一 `BladeProvider` 下可以放多个 `ChatView`,各自独立会话、互不干扰。
35
- - 宿主只需要完成态消息时,可在 `BladeClient` 构造参数中传 `streamTokens: false`,不订阅逐 token 增量。
36
35
 
37
36
  ## BladeProvider
38
37
 
@@ -137,6 +136,9 @@ await replay.exitToAutonomous() // 退出回放,之后真的运
137
136
 
138
137
  完整聊天界面:消息列表(Markdown、代码高亮、工具调用、提问卡片)+ 输入框 + 连接状态条 + 登录引导。
139
138
 
139
+ `ChatView` 固定使用普通展示模式。产品内置 Web 的精简/开发者模式不属于 SDK 公共能力,
140
+ 因此没有 `renderMode` 等切换属性。
141
+
140
142
  ```tsx
141
143
  <ChatView
142
144
  sessionId={id} // 可选;不传自动建会话
@@ -268,6 +270,27 @@ models.filter((m) => m.serviceModelId)
268
270
  <MarkdownContent sessionId={sessionId}>{markdownText}</MarkdownContent>
269
271
  ```
270
272
 
273
+ ## isAgentComputerCommand / isAgentComputerToolCall / classifyAgentComputerLaunchOutcome
274
+
275
+ 判断智能体是否在沙盒里启动了通用 GUI 应用镜像(`computer launch`)——后端 blade-agent 通过 `computer` CLI 驱动一块虚拟屏幕运行任意 GUI 软件,这些函数用于自行接入方判断要不要展示对应的实时画面入口(比如自建一个类似「电脑镜像」的标签页)。当前 SDK 侧还没有内置这块 UI,只导出判定规则,避免各接入方重新猜一遍匹配逻辑。
276
+
277
+ `isAgentComputerCommand`/`isAgentComputerToolCall` 只回答"这条命令是不是一次 launch 尝试",不回答"这次 launch 最终成不成功"——待处理、已失败的 launch 也会命中。要判断真实结果(比如决定要不要展示画面入口),用 `classifyAgentComputerLaunchOutcome`:它会解析工具调用的 `status`/`result`,返回 `"pending" | "succeeded" | "failed" | "unknown"`。`"unknown"` 表示 `status` 已经是终态但 `result` 字段本身缺失(常见于会话整理/compaction 之后的历史投影,归档时不会重新序列化完整 result),跟"result 回来了、里面确实没有成功标记"的 `"failed"` 是两种不同性质的证据——接入方要按自己的场景决定怎么处理(展示类场景可以偏宽松,当作足够展示;自动跳转/替用户做决定的场景应该偏保守,当作跟 `"failed"` 一样处理)。
278
+
279
+ ```ts
280
+ import {
281
+ isAgentComputerCommand,
282
+ isAgentComputerToolCall,
283
+ classifyAgentComputerLaunchOutcome,
284
+ } from "@blade-hq/agent-react"
285
+
286
+ isAgentComputerCommand("computer launch --exec /opt/apps/foo/bar") // true
287
+ isAgentComputerCommand("computer status") // false(只认 launch,不认查询类子命令)
288
+
289
+ isAgentComputerToolCall(toolCall.arguments) // 工具调用的 JSON 参数版本
290
+
291
+ classifyAgentComputerLaunchOutcome(toolCall) // "pending" | "succeeded" | "failed" | "unknown"
292
+ ```
293
+
271
294
  ## 选择模型
272
295
 
273
296
  SDK 的 ChatView / `<blade-chat>` 不内置模型选择器(默认用后端配置的模型)。指定模型有两种方式:
package/dist/index.d.ts CHANGED
@@ -24,4 +24,6 @@ export type { ReplayMismatchPromptProps } from "./components/ReplayMismatchPromp
24
24
  export type { ToolCallRenderer } from "./components/ToolCallBlock";
25
25
  export { ContextCard } from "./components/ContextCard";
26
26
  export type { ContextCardProps } from "./components/ContextCard";
27
+ export { isAgentComputerCommand, isAgentComputerToolCall, classifyAgentComputerLaunchOutcome, } from "./lib/agent-computer-command";
28
+ export type { AgentComputerLaunchOutcome } from "./lib/agent-computer-command";
27
29
  export * from "@blade-hq/agent-client";