@blade-hq/agent-client 2610.0.0-beta.89 → 2610.0.0-beta.90
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 +11 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +125 -99
- package/dist/index.js.map +1 -1
- package/dist/resources/chat-groups.d.ts +2 -0
- package/dist/schemas/message-utils.d.ts +2 -0
- package/dist/session/definition.d.ts +6 -1
- package/dist/session/events.d.ts +3 -1
- package/dist/shared/tool-ui-card.d.ts +5 -3
- package/package.json +1 -1
- package/public-api.md +24 -6
package/README.md
CHANGED
|
@@ -157,6 +157,8 @@ const chat = await client.sessions.create({
|
|
|
157
157
|
|
|
158
158
|
Solution 和 Skill 都声明为 `{ path, content }[]` 文本文件;SDK 负责准备资源、创建会话和安装 Skill,成功返回时 `chat` 已可使用。已有 Solution 改传 `solution: { id, role }`。模型值是 Server 模型目录中的 ID,LLM 地址与密钥应由 Server 管理。
|
|
159
159
|
|
|
160
|
+
`SkillDefinition.files` 使用 `SkillFile[]`:文本文件仍填写 `path` 和 `content`;二进制文件将内容编码为 base64,并设置 `encoding: "base64"`。自带可执行文件另设 `executable: true`。这两个可选字段适用于沙盒会话,不扩展 Solution 的 `TextFile` 格式。
|
|
161
|
+
|
|
160
162
|
> **`sessionId` 从哪来?** 三种,按需选:
|
|
161
163
|
> 1. **不用管它** —— 首次接入最省事:`client.sessions.create()` 直接建一个新会话,用不着 ID。React 的 `<ChatView />` 不传 `sessionId` 也一样。
|
|
162
164
|
> 2. **自己建、自己存**:`const { session_id } = await client.sessions.createSessionWithRequest({ intent: "季度报表分析" })`。把返回的 `session_id`(后端是蛇形命名)存进你的数据库或 URL,用户下次进来传给 `connect(sessionId)`(前端参数是驼峰),就能接着上次的对话。
|
|
@@ -715,12 +717,15 @@ const previewCards = collectPreviewToolUiCards(messages) // [{ key, toolCall, ca
|
|
|
715
717
|
|
|
716
718
|
// 渲染前解析实际内容;archived 留档卡片只用留档 HTML,绝不回退 resourceUri
|
|
717
719
|
// (历史恢复/刷新不会因此重放一次 MCP 资源读取)
|
|
718
|
-
const resolved = resolveToolUiCardContent(card) // { type: "resource-html" | "resource-uri", content } | null
|
|
720
|
+
const resolved = resolveToolUiCardContent(card) // { type: "resource-html" | "resource-uri" | "resource-file", content } | null
|
|
719
721
|
|
|
720
|
-
//
|
|
721
|
-
|
|
722
|
+
// 文件卡片按 sourcePath、URI 按地址、无来源 HTML 按 toolCallId 去重。
|
|
723
|
+
// 宿主可先按会话 workspace 将 sourcePath 归一,和文件树中的身份对齐。
|
|
724
|
+
const key = buildToolUiCardKey(toolCallId, resolved.type, resolved.content, card.sourcePath)
|
|
722
725
|
```
|
|
723
726
|
|
|
727
|
+
`resource-file` 来自 `blade ui --html 文件 --preview`:`content`/`sourcePath` 是文件路径,不是 HTML。打开时通过带鉴权的会话文件接口读取当前文件;历史引用也读取最新文件。每次新工具调用都会发 `toolPreview` 通知文件有更新,宿主仍按路径复用一个页签;同次调用的重复事件不重复发送。已打开的 HTML 应保留当前页面和交互状态,提供醒目的“刷新”按钮,让用户决定何时读取最新内容。内联卡片继续使用 HTML 快照。
|
|
728
|
+
|
|
724
729
|
单个 block 判有效用 `isToolUiCard`(严格守卫:`target`/`height` 缺失、archived 无留档
|
|
725
730
|
HTML 一律判无效);`isInternalStatusToolUiCard` 识别内部「阶段进度」卡片(不对用户展示),
|
|
726
731
|
`isAppDevToolUiCard` 识别应用开发会话的预览卡。相关类型:`ToolUiCard`、
|
|
@@ -744,7 +749,7 @@ HTML 一律判无效);`isInternalStatusToolUiCard` 识别内部「阶段进
|
|
|
744
749
|
|
|
745
750
|
- **客户端与登录**:`BladeClientOptions`、`LoginOptions`、`LoginResult`、`TokenStorageMode`、`UploadProgress`、`BladeApiError`、`AuthResource`、`ProvidersResponse`、`UserInfo`
|
|
746
751
|
- **SDK 身份**:`SDK_NAME`、`SDK_VERSION`
|
|
747
|
-
- **声明式会话**:`SessionDefinition`、`SolutionDefinition`、`SkillDefinition`、`SessionConfig`、`TextFile`、`SessionSetupError`、`SessionSetupStage`
|
|
752
|
+
- **声明式会话**:`SessionDefinition`、`SolutionDefinition`、`SkillDefinition`、`SkillFile`、`SessionConfig`、`TextFile`、`SessionSetupError`、`SessionSetupStage`
|
|
748
753
|
- **会话错误**:`AgentSessionError`(`code` 是服务端路由失败原因,供调用方决定是否重试)
|
|
749
754
|
- **模型目录**:`ModelsResource`、`ModelCatalog`、`ModelOption`
|
|
750
755
|
- **聊天分组资源(REST)**:`ChatGroupsResource`、`ChatGroup`(含 `delete` 永久删除);`client.chatGroups`。旧名 `ChatProjectsResource`、`ChatProject`、`client.chatProjects` 与 `chat_project_id` 字段已随分组改名一并移除,接入方请改用 `chatGroups` 与 `chat_group_id`
|
|
@@ -772,3 +777,5 @@ HTML 一律判无效);`isInternalStatusToolUiCard` 识别内部「阶段进
|
|
|
772
777
|
最新调用失败或完成状态未知时,归档同时提供 `previousToolInput` / `previousToolResult`,用于先恢复最后成功的界面再展示错误。读取这些留档不会重新执行工具。
|
|
773
778
|
|
|
774
779
|
会话列表和详情的 `SessionInfo.initiator` 表示首次发起来源:`ui` 为界面,`sdk` 为 SDK;旧会话缺少可靠记录时为 `unknown`,尚未发起会话时为 `null` 或未提供。它不等同于后台运行标记 `is_headless`,后续继续会话不会改变来源。
|
|
780
|
+
|
|
781
|
+
后台唤醒输入可用 `isBackgroundWakeMessage(message)` 识别,它读取消息的结构化通知 block。自定义 UI 应为这类输入显示说明卡片;`isHiddenInternalMessage` 仍将其视为内部输入,避免作为用户发言或回溯导航点。
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type { AgentSessionEvents, AgentSessionEventName } from "./session/events
|
|
|
16
16
|
export { isMcpAppData } from "./schemas/mcp-app";
|
|
17
17
|
export type { McpAppArchive, McpAppContextState, McpAppContextUpdate, McpAppData, } from "./schemas/mcp-app";
|
|
18
18
|
export { SessionSetupError } from "./session/definition";
|
|
19
|
-
export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, TextFile, SolutionDefinition, } from "./session/definition";
|
|
19
|
+
export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, SkillFile, TextFile, SolutionDefinition, } from "./session/definition";
|
|
20
20
|
export { createInitialSessionState, reconcileHistoricalUserTurns, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
|
|
21
21
|
export type { AskUserAnswerData, AgentLoopInfo, ActiveCompactionState, ConnectionStatus, ReplaySnapshot, SessionState, } from "./session/state";
|
|
22
22
|
export { EMPTY_SESSION_QUEUE, canCancelQueuedMessage, canDeliverQueuedMessage, canEditQueuedMessage, isSessionQueueSnapshot, parseQueueAck, queuePauseReasonLabel, queuedMessageStatusLabel, shouldApplySnapshot, } from "./session/queue";
|
|
@@ -46,7 +46,7 @@ export type { CreateSessionRequest, AppCliAttachment, AppCliDefinition, FileEntr
|
|
|
46
46
|
export type { ArchivedFileInfo, ArchivedToolCallInfo, ChatMessage, CompactionInfo, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolBridgeContent, ToolCallInfo, } from "./schemas/message";
|
|
47
47
|
export { inferToolStatus } from "./schemas/message";
|
|
48
48
|
export type { ChatEnd, ContentDelta, LlmResponseDone, SessionStatusEvent, SystemError, ToolCallArgumentsDelta, ToolCallCreated, ToolResultDelta, ToolResultDone, } from "./schemas/event";
|
|
49
|
-
export { buildMessageContent, chatErrorForDisplay, contentPreview, extractTextAttachments, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, isHiddenInternalMessage, normalizeMessageContent, transformSlashCommand, } from "./schemas/message-utils";
|
|
49
|
+
export { buildMessageContent, chatErrorForDisplay, contentPreview, extractTextAttachments, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, isHiddenInternalMessage, isBackgroundWakeMessage, normalizeMessageContent, transformSlashCommand, } from "./schemas/message-utils";
|
|
50
50
|
export { contextProjectionData, getContextDisplayState, getContextGroupDisplayState, groupAdjacentContextRuns, } from "./schemas/context";
|
|
51
51
|
export type { ContextAction, ContextDisplayState, ContextGroupDisplayState, ContextProjectionData, ContextProjectionFields, ContextSourceInfo, } from "./schemas/context";
|
|
52
52
|
export type { ParsedTextAttachment, ParsedTextContext, SkillMentionAvailability, } from "./schemas/message-utils";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// src/version.ts
|
|
2
|
+
var SDK_NAME = "agent-client";
|
|
3
|
+
var SDK_VERSION = true ? "2610.0.0-beta.90" : "1.1.1";
|
|
4
|
+
|
|
1
5
|
// src/auth-login.ts
|
|
2
6
|
function isAuthCallbackMessage(value) {
|
|
3
7
|
return typeof value === "object" && value !== null && value.type === "blade-agent:sdk-auth";
|
|
@@ -1738,6 +1742,9 @@ var ClientProjectionBuilder = class {
|
|
|
1738
1742
|
duration_ms: 0,
|
|
1739
1743
|
client_request_id: typeof payload.client_request_id === "string" ? payload.client_request_id : null
|
|
1740
1744
|
};
|
|
1745
|
+
if (payload.start_reason === "background-completion") {
|
|
1746
|
+
turn.blocks.push({ type: "system_notification", content: { notification_type: "bg:wakeup" } });
|
|
1747
|
+
}
|
|
1741
1748
|
this.latestTurns.set("root", turn);
|
|
1742
1749
|
return [{ kind: "upsert", turn }];
|
|
1743
1750
|
}
|
|
@@ -2178,6 +2185,101 @@ function toolArgsFromPayload(payload) {
|
|
|
2178
2185
|
return "";
|
|
2179
2186
|
}
|
|
2180
2187
|
|
|
2188
|
+
// src/schemas/mcp-app.ts
|
|
2189
|
+
function isMcpAppData(value) {
|
|
2190
|
+
return isRecord(value) && typeof value.sourceId === "string" && value.sourceId.length > 0 && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && typeof value.mimeType === "string" && isRecord(value.resourceMeta) && isRecord(value.toolInput) && isRecord(value.toolResult);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
// src/shared/tool-ui-card.ts
|
|
2194
|
+
function isNonEmptyString(value) {
|
|
2195
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
2196
|
+
}
|
|
2197
|
+
function isPositiveNumber(value) {
|
|
2198
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
2199
|
+
}
|
|
2200
|
+
function isToolUiCard(value) {
|
|
2201
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
2202
|
+
return false;
|
|
2203
|
+
}
|
|
2204
|
+
const raw = value;
|
|
2205
|
+
if (raw.target !== "inline" && raw.target !== "preview") {
|
|
2206
|
+
return false;
|
|
2207
|
+
}
|
|
2208
|
+
if (!isPositiveNumber(raw.height)) {
|
|
2209
|
+
return false;
|
|
2210
|
+
}
|
|
2211
|
+
if (raw.archived === true && !isNonEmptyString(raw.resourceHTML)) {
|
|
2212
|
+
return false;
|
|
2213
|
+
}
|
|
2214
|
+
if (!isNonEmptyString(raw.resourceHTML) && !isNonEmptyString(raw.resourceUri) && !isNonEmptyString(raw.resourceURI) && !(raw.target === "preview" && isNonEmptyString(raw.sourcePath))) {
|
|
2215
|
+
return false;
|
|
2216
|
+
}
|
|
2217
|
+
if (raw.title != null && !isNonEmptyString(raw.title)) {
|
|
2218
|
+
return false;
|
|
2219
|
+
}
|
|
2220
|
+
if (raw.sourcePath != null && !isNonEmptyString(raw.sourcePath)) return false;
|
|
2221
|
+
if (raw.mcpApp !== void 0 && !isMcpAppData(raw.mcpApp)) {
|
|
2222
|
+
return false;
|
|
2223
|
+
}
|
|
2224
|
+
return true;
|
|
2225
|
+
}
|
|
2226
|
+
function resolveToolUiCardContent(card) {
|
|
2227
|
+
if (isNonEmptyString(card.resourceHTML)) {
|
|
2228
|
+
return { type: "resource-html", content: card.resourceHTML };
|
|
2229
|
+
}
|
|
2230
|
+
if (card.archived) return null;
|
|
2231
|
+
const uri = isNonEmptyString(card.resourceUri) ? card.resourceUri : card.resourceURI;
|
|
2232
|
+
if (isNonEmptyString(uri)) return { type: "resource-uri", content: uri };
|
|
2233
|
+
return card.target === "preview" && isNonEmptyString(card.sourcePath) ? { type: "resource-file", content: card.sourcePath } : null;
|
|
2234
|
+
}
|
|
2235
|
+
function buildToolUiCardKey(toolCallId, type3, content, sourcePath) {
|
|
2236
|
+
if (type3 === "resource-uri") {
|
|
2237
|
+
return `tool-preview-uri:${content}`;
|
|
2238
|
+
}
|
|
2239
|
+
if (sourcePath?.trim()) return sourcePath.trim();
|
|
2240
|
+
if (type3 === "resource-file") return content;
|
|
2241
|
+
return `tool-preview:${toolCallId}`;
|
|
2242
|
+
}
|
|
2243
|
+
function isInternalStatusToolUiCard(card) {
|
|
2244
|
+
return card?.title?.trim() === "\u9636\u6BB5\u8FDB\u5EA6";
|
|
2245
|
+
}
|
|
2246
|
+
function isAppDevToolUiCard(card, isAppDev) {
|
|
2247
|
+
return isAppDev && card.target === "preview" && !card.resourceHTML && Boolean(card.resourceUri || card.resourceURI);
|
|
2248
|
+
}
|
|
2249
|
+
function collectInlineToolUiCards(messages) {
|
|
2250
|
+
return messages.flatMap(
|
|
2251
|
+
(message) => (message.blocks ?? []).flatMap(
|
|
2252
|
+
(block, index) => block.type === "tool_ui" && block.tool_call_id && isToolUiCard(block.content) && block.content.target === "inline" ? [
|
|
2253
|
+
{
|
|
2254
|
+
key: `${message.entry_id ?? message.timestamp ?? "message"}-${block.tool_call_id}-${index}`,
|
|
2255
|
+
toolCallId: block.tool_call_id,
|
|
2256
|
+
card: block.content
|
|
2257
|
+
}
|
|
2258
|
+
] : []
|
|
2259
|
+
)
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
function collectPreviewToolUiCards(messages) {
|
|
2263
|
+
return messages.flatMap(
|
|
2264
|
+
(message) => (message.blocks ?? []).flatMap((block, index) => {
|
|
2265
|
+
if (block.type !== "tool_ui" || !block.tool_call_id || !isToolUiCard(block.content) || block.content.target !== "preview") {
|
|
2266
|
+
return [];
|
|
2267
|
+
}
|
|
2268
|
+
const toolCall = (message.tool_calls ?? []).find(
|
|
2269
|
+
(candidate) => candidate.id === block.tool_call_id
|
|
2270
|
+
);
|
|
2271
|
+
return toolCall ? [
|
|
2272
|
+
{
|
|
2273
|
+
key: `${message.entry_id ?? message.timestamp ?? "message"}-${block.tool_call_id}-${index}`,
|
|
2274
|
+
toolCall,
|
|
2275
|
+
card: block.content,
|
|
2276
|
+
blocks: message.blocks ?? []
|
|
2277
|
+
}
|
|
2278
|
+
] : [];
|
|
2279
|
+
})
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2181
2283
|
// src/shared/projection/history.ts
|
|
2182
2284
|
function projectHistory(entries) {
|
|
2183
2285
|
const turns = [];
|
|
@@ -2270,6 +2372,9 @@ function projectHistory(entries) {
|
|
|
2270
2372
|
if (role !== "user" && role !== "assistant" && role !== "system") continue;
|
|
2271
2373
|
const toolCalls = role === "assistant" && !message._error ? buildToolCalls(message.tool_calls) : [];
|
|
2272
2374
|
const blocks = buildBlocks(message, toolCalls);
|
|
2375
|
+
if (role === "user" && message._start_reason === "background-completion") {
|
|
2376
|
+
blocks.push({ type: "system_notification", content: { notification_type: "bg:wakeup" } });
|
|
2377
|
+
}
|
|
2273
2378
|
const turn = {
|
|
2274
2379
|
id,
|
|
2275
2380
|
sequence: ++sequence,
|
|
@@ -2384,7 +2489,8 @@ function projectHistory(entries) {
|
|
|
2384
2489
|
const toolCallId = String(data.tool_call_id ?? "");
|
|
2385
2490
|
const owner = kind === "tool_bridge" ? toolCallId ? toolOwners.get(toolCallId) : void 0 : toolOwners.get(toolCallId) ?? findLatestAssistant(turns, loopId);
|
|
2386
2491
|
const rawContent = kind === "tool_ui" ? data.ui : data.bridge;
|
|
2387
|
-
const
|
|
2492
|
+
const fileReference = isToolUiCard(rawContent) && resolveToolUiCardContent(rawContent)?.type === "resource-file";
|
|
2493
|
+
const content = kind === "tool_ui" && isRecord(rawContent) ? { ...rawContent, ...!fileReference ? { archived: true } : {} } : rawContent;
|
|
2388
2494
|
if (owner && content !== void 0) {
|
|
2389
2495
|
owner.blocks.push({
|
|
2390
2496
|
type: kind,
|
|
@@ -3671,97 +3777,6 @@ function queuePauseReasonLabel(reason) {
|
|
|
3671
3777
|
return QUEUE_PAUSE_REASON_LABELS[reason] ?? reason;
|
|
3672
3778
|
}
|
|
3673
3779
|
|
|
3674
|
-
// src/schemas/mcp-app.ts
|
|
3675
|
-
function isMcpAppData(value) {
|
|
3676
|
-
return isRecord(value) && typeof value.sourceId === "string" && value.sourceId.length > 0 && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && typeof value.mimeType === "string" && isRecord(value.resourceMeta) && isRecord(value.toolInput) && isRecord(value.toolResult);
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3679
|
-
// src/shared/tool-ui-card.ts
|
|
3680
|
-
function isNonEmptyString(value) {
|
|
3681
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
3682
|
-
}
|
|
3683
|
-
function isPositiveNumber(value) {
|
|
3684
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
3685
|
-
}
|
|
3686
|
-
function isToolUiCard(value) {
|
|
3687
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
3688
|
-
return false;
|
|
3689
|
-
}
|
|
3690
|
-
const raw = value;
|
|
3691
|
-
if (raw.target !== "inline" && raw.target !== "preview") {
|
|
3692
|
-
return false;
|
|
3693
|
-
}
|
|
3694
|
-
if (!isPositiveNumber(raw.height)) {
|
|
3695
|
-
return false;
|
|
3696
|
-
}
|
|
3697
|
-
if (raw.archived === true && !isNonEmptyString(raw.resourceHTML)) {
|
|
3698
|
-
return false;
|
|
3699
|
-
}
|
|
3700
|
-
if (!isNonEmptyString(raw.resourceHTML) && !isNonEmptyString(raw.resourceUri) && !isNonEmptyString(raw.resourceURI)) {
|
|
3701
|
-
return false;
|
|
3702
|
-
}
|
|
3703
|
-
if (raw.title != null && !isNonEmptyString(raw.title)) {
|
|
3704
|
-
return false;
|
|
3705
|
-
}
|
|
3706
|
-
if (raw.mcpApp !== void 0 && !isMcpAppData(raw.mcpApp)) {
|
|
3707
|
-
return false;
|
|
3708
|
-
}
|
|
3709
|
-
return true;
|
|
3710
|
-
}
|
|
3711
|
-
function resolveToolUiCardContent(card) {
|
|
3712
|
-
if (isNonEmptyString(card.resourceHTML)) {
|
|
3713
|
-
return { type: "resource-html", content: card.resourceHTML };
|
|
3714
|
-
}
|
|
3715
|
-
if (card.archived) return null;
|
|
3716
|
-
const uri = isNonEmptyString(card.resourceUri) ? card.resourceUri : card.resourceURI;
|
|
3717
|
-
return isNonEmptyString(uri) ? { type: "resource-uri", content: uri } : null;
|
|
3718
|
-
}
|
|
3719
|
-
function buildToolUiCardKey(toolCallId, type3, content) {
|
|
3720
|
-
if (type3 === "resource-uri") {
|
|
3721
|
-
return `tool-preview-uri:${content}`;
|
|
3722
|
-
}
|
|
3723
|
-
return `tool-preview:${toolCallId}`;
|
|
3724
|
-
}
|
|
3725
|
-
function isInternalStatusToolUiCard(card) {
|
|
3726
|
-
return card?.title?.trim() === "\u9636\u6BB5\u8FDB\u5EA6";
|
|
3727
|
-
}
|
|
3728
|
-
function isAppDevToolUiCard(card, isAppDev) {
|
|
3729
|
-
return isAppDev && card.target === "preview" && !card.resourceHTML && Boolean(card.resourceUri || card.resourceURI);
|
|
3730
|
-
}
|
|
3731
|
-
function collectInlineToolUiCards(messages) {
|
|
3732
|
-
return messages.flatMap(
|
|
3733
|
-
(message) => (message.blocks ?? []).flatMap(
|
|
3734
|
-
(block, index) => block.type === "tool_ui" && block.tool_call_id && isToolUiCard(block.content) && block.content.target === "inline" ? [
|
|
3735
|
-
{
|
|
3736
|
-
key: `${message.entry_id ?? message.timestamp ?? "message"}-${block.tool_call_id}-${index}`,
|
|
3737
|
-
toolCallId: block.tool_call_id,
|
|
3738
|
-
card: block.content
|
|
3739
|
-
}
|
|
3740
|
-
] : []
|
|
3741
|
-
)
|
|
3742
|
-
);
|
|
3743
|
-
}
|
|
3744
|
-
function collectPreviewToolUiCards(messages) {
|
|
3745
|
-
return messages.flatMap(
|
|
3746
|
-
(message) => (message.blocks ?? []).flatMap((block, index) => {
|
|
3747
|
-
if (block.type !== "tool_ui" || !block.tool_call_id || !isToolUiCard(block.content) || block.content.target !== "preview") {
|
|
3748
|
-
return [];
|
|
3749
|
-
}
|
|
3750
|
-
const toolCall = (message.tool_calls ?? []).find(
|
|
3751
|
-
(candidate) => candidate.id === block.tool_call_id
|
|
3752
|
-
);
|
|
3753
|
-
return toolCall ? [
|
|
3754
|
-
{
|
|
3755
|
-
key: `${message.entry_id ?? message.timestamp ?? "message"}-${block.tool_call_id}-${index}`,
|
|
3756
|
-
toolCall,
|
|
3757
|
-
card: block.content,
|
|
3758
|
-
blocks: message.blocks ?? []
|
|
3759
|
-
}
|
|
3760
|
-
] : [];
|
|
3761
|
-
})
|
|
3762
|
-
);
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3765
3780
|
// src/schemas/message-utils.ts
|
|
3766
3781
|
var SYSTEM_REMINDER_PATTERN = /^<system-reminder>\s*[\s\S]*?\s*<\/system-reminder>$/i;
|
|
3767
3782
|
var SYSTEM_NOTIFICATION_PATTERN = /^<system-notification>\s*[\s\S]*?\s*<\/system-notification>$/i;
|
|
@@ -3945,6 +3960,12 @@ function groupMessagesByLoop(messages) {
|
|
|
3945
3960
|
}
|
|
3946
3961
|
return groups;
|
|
3947
3962
|
}
|
|
3963
|
+
function isBackgroundWakeMessage(message) {
|
|
3964
|
+
return message.blocks?.some((block) => {
|
|
3965
|
+
const content = block.content;
|
|
3966
|
+
return block.type === "system_notification" && content !== null && typeof content === "object" && "notification_type" in content && content.notification_type === "bg:wakeup";
|
|
3967
|
+
}) ?? false;
|
|
3968
|
+
}
|
|
3948
3969
|
|
|
3949
3970
|
// src/session/state.ts
|
|
3950
3971
|
function toReplaySnapshot(raw) {
|
|
@@ -5653,8 +5674,12 @@ var AgentSession = class _AgentSession {
|
|
|
5653
5674
|
if (ui.target !== "preview") continue;
|
|
5654
5675
|
const resolved = resolveToolUiCardContent(ui);
|
|
5655
5676
|
if (!resolved) continue;
|
|
5656
|
-
const key = buildToolUiCardKey(block.tool_call_id, resolved.type, resolved.content);
|
|
5657
|
-
const fingerprint = JSON.stringify([
|
|
5677
|
+
const key = buildToolUiCardKey(block.tool_call_id, resolved.type, resolved.content, ui.sourcePath);
|
|
5678
|
+
const fingerprint = JSON.stringify([
|
|
5679
|
+
resolved.content,
|
|
5680
|
+
ui.mcpApp?.sourceId,
|
|
5681
|
+
resolved.type === "resource-file" ? block.tool_call_id : void 0
|
|
5682
|
+
]);
|
|
5658
5683
|
if (this.deliveredToolPreviews.get(key) === fingerprint) continue;
|
|
5659
5684
|
this.deliveredToolPreviews.set(key, fingerprint);
|
|
5660
5685
|
this.emitter.emit("toolPreview", {
|
|
@@ -5662,6 +5687,7 @@ var AgentSession = class _AgentSession {
|
|
|
5662
5687
|
type: resolved.type,
|
|
5663
5688
|
content: resolved.content,
|
|
5664
5689
|
title: ui.title ?? "\u5DE5\u5177\u9884\u89C8",
|
|
5690
|
+
...ui.sourcePath ? { sourcePath: ui.sourcePath } : {},
|
|
5665
5691
|
...ui.mcpApp ? { mcpApp: ui.mcpApp } : {}
|
|
5666
5692
|
});
|
|
5667
5693
|
}
|
|
@@ -6613,6 +6639,7 @@ var BladeClient = class {
|
|
|
6613
6639
|
if (!this.isSameBackendUrl(url)) {
|
|
6614
6640
|
return result;
|
|
6615
6641
|
}
|
|
6642
|
+
result.set("X-Blade-Client", `${SDK_NAME}/${SDK_VERSION}`);
|
|
6616
6643
|
const token = this.resolveRestToken();
|
|
6617
6644
|
if (token) {
|
|
6618
6645
|
result.set("Authorization", `Bearer ${token}`);
|
|
@@ -6674,7 +6701,9 @@ var BladeClient = class {
|
|
|
6674
6701
|
this.buildUrl(REFRESH_PATH).toString(),
|
|
6675
6702
|
{
|
|
6676
6703
|
method: "POST",
|
|
6677
|
-
credentials: "include"
|
|
6704
|
+
credentials: "include",
|
|
6705
|
+
// Refresh remains cookie-only; do not attach the REST bearer.
|
|
6706
|
+
headers: { "X-Blade-Client": `${SDK_NAME}/${SDK_VERSION}` }
|
|
6678
6707
|
}
|
|
6679
6708
|
);
|
|
6680
6709
|
if (!response.ok) {
|
|
@@ -6917,10 +6946,6 @@ function resolveServiceUrl(endpoints, name, path = "") {
|
|
|
6917
6946
|
return target.toString();
|
|
6918
6947
|
}
|
|
6919
6948
|
|
|
6920
|
-
// src/version.ts
|
|
6921
|
-
var SDK_NAME = "agent-client";
|
|
6922
|
-
var SDK_VERSION = true ? "2610.0.0-beta.89" : "1.1.1";
|
|
6923
|
-
|
|
6924
6949
|
// src/commands/protocol.ts
|
|
6925
6950
|
function isCommandEnvelope(value) {
|
|
6926
6951
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -7075,6 +7100,7 @@ export {
|
|
|
7075
7100
|
hasChatRunEvent,
|
|
7076
7101
|
inferToolStatus,
|
|
7077
7102
|
isAppDevToolUiCard,
|
|
7103
|
+
isBackgroundWakeMessage,
|
|
7078
7104
|
isCommandEnvelope,
|
|
7079
7105
|
isEntryGoneError,
|
|
7080
7106
|
isHiddenInternalMessage,
|