@blade-hq/agent-client 2610.0.0-beta.30 → 2610.0.0-beta.31
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 +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/dist/schemas/context.d.ts +15 -0
- package/dist/schemas/message-utils.d.ts +3 -1
- package/package.json +1 -1
- package/public-api.md +22 -2
package/README.md
CHANGED
|
@@ -585,7 +585,7 @@ transformSlashCommand(skillId, prompt, { local: false, installed: false })
|
|
|
585
585
|
- **会话回放**:`ReplayState`、`ReplaySpeed`、`ReplayPreview`、`ReplaySnapshot`、`toReplaySnapshot`、`DEFAULT_REPLAY_SPEED`
|
|
586
586
|
- **会话状态机**:`SessionHub`、`SessionState`、`SendOptions`、`ConnectionStatus`、`AskUserAnswerData`、`AgentLoopInfo`、`ActiveCompactionState`、`createInitialSessionState`、`AgentSessionEventName`
|
|
587
587
|
- **页面协作**:`EmbeddedChat`、`EmbeddedChatOptions`、`CommandHandler`、`CommandEnvelope`、`InboundAction`、`InboundEnvelope`、`isCommandEnvelope`、`isInboundEnvelope`
|
|
588
|
-
- **消息与投影协议**:`MessageContent`、`MessageContentPart`、`TextContentPart`、`ImageUrlContentPart`、`FileContentPart`、`ToolCallInfo`、`ToolBridgeContent`、`CompactionInfo`、`ContextProjectionData`、`ContextProjectionFields`、`ContextDisplayState`、`ContextAction`、`ContextSourceInfo`、`MemoryRefInfo`、`ArchivedFileInfo`、`ArchivedToolCallInfo`、`TurnProjection`、`ContentBlock`、`PatchEnvelope`、`MemoryRef`、`PostChatFollowup`、`FinalArtifact`、`contextProjectionData`、`getContextDisplayState`、`latestPostChatFollowup`、`buildMessageContent`、`normalizeMessageContent`、`isHiddenInternalMessage`、`transformSlashCommand`、`SkillMentionAvailability`、`extractTextAttachments`、`ParsedTextAttachment`、`ParsedTextContext`
|
|
588
|
+
- **消息与投影协议**:`MessageContent`、`MessageContentPart`、`TextContentPart`、`ImageUrlContentPart`、`FileContentPart`、`ToolCallInfo`、`ToolBridgeContent`、`CompactionInfo`、`ContextProjectionData`、`ContextProjectionFields`、`ContextDisplayState`、`ContextGroupDisplayState`、`ContextAction`、`ContextSourceInfo`、`MemoryRefInfo`、`ArchivedFileInfo`、`ArchivedToolCallInfo`、`TurnProjection`、`ContentBlock`、`PatchEnvelope`、`MemoryRef`、`PostChatFollowup`、`FinalArtifact`、`contextProjectionData`、`getContextDisplayState`、`getContextGroupDisplayState`、`groupAdjacentContextRuns`、`latestPostChatFollowup`、`buildMessageContent`、`normalizeMessageContent`、`isHiddenInternalMessage`、`transformSlashCommand`、`SkillMentionAvailability`、`extractTextAttachments`、`ParsedTextAttachment`、`ParsedTextContext`
|
|
589
589
|
- **Solution / 任务协议**:`Solution`、`SolutionAppField`、`SolutionAppState`、`SolutionAppUiConfig`、`SolutionRef`、`PublishedSolutionRef`、`ExistingSolutionRef`、`PreparedSolution`、`PreparedSolutionAsset`、`LayoutType`、`BizRole`、`TaskStatus`、`BackgroundTask`、`BackgroundTaskStopResult`
|
|
590
590
|
- **Headless**:`HeadlessResource`、`RunOptions`、`RunResult`、`RunTrace`
|
|
591
591
|
- **低层通道(apps/web 等高级集成)**:`createSocket`、`CreateSocketOptions`、`TypedSocket`、`AsrAudioPayload`、`ClientProjectionBuilder`、`RawEvent`、`acceptedPostChatFollowupCompletesLatestRun`、`reconcileOptimisticUserTurns`
|
package/dist/index.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export type { SessionsResource } from "./resources/sessions";
|
|
|
29
29
|
export type { CreateSessionRequest, AppCliAttachment, AppCliDefinition, FileEntry, ImportSessionOptions, PaginatedSessionsResult, GlobalSearchConversationResult, GlobalSearchFileResult, GlobalSearchResult, GlobalSearchResultItem, ResultFeedback, ResultFeedbackReason, SessionContextStats, SessionHistory, ShareLinkResult, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
|
|
30
30
|
export type { ArchivedFileInfo, ArchivedToolCallInfo, ChatMessage, CompactionInfo, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolBridgeContent, ToolCallInfo, } from "./schemas/message";
|
|
31
31
|
export { buildMessageContent, chatErrorForDisplay, contentPreview, extractTextAttachments, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, isHiddenInternalMessage, normalizeMessageContent, transformSlashCommand, } from "./schemas/message-utils";
|
|
32
|
-
export { contextProjectionData, getContextDisplayState, } from "./schemas/context";
|
|
33
|
-
export type { ContextAction, ContextDisplayState, ContextProjectionData, ContextProjectionFields, ContextSourceInfo, } from "./schemas/context";
|
|
32
|
+
export { contextProjectionData, getContextDisplayState, getContextGroupDisplayState, groupAdjacentContextRuns, } from "./schemas/context";
|
|
33
|
+
export type { ContextAction, ContextDisplayState, ContextGroupDisplayState, ContextProjectionData, ContextProjectionFields, ContextSourceInfo, } from "./schemas/context";
|
|
34
34
|
export type { ParsedTextAttachment, ParsedTextContext, SkillMentionAvailability, } from "./schemas/message-utils";
|
|
35
35
|
export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PostChatFollowup, TurnProjection, } from "./schemas/projection";
|
|
36
36
|
export { latestPostChatFollowup } from "./schemas/projection-utils";
|
package/dist/index.js
CHANGED
|
@@ -1104,12 +1104,47 @@ function contextProjectionData(fields) {
|
|
|
1104
1104
|
};
|
|
1105
1105
|
}
|
|
1106
1106
|
function getContextDisplayState(context) {
|
|
1107
|
-
const title =
|
|
1107
|
+
const title = nonEmptyString(context.display_title) ?? BUILTIN_CONTEXT_TITLES[context.context_kind] ?? "\u5BF9\u8BDD\u80CC\u666F";
|
|
1108
1108
|
const isRemoved = context.context_action === "removed";
|
|
1109
1109
|
const summary = nonEmptyString(context.display_summary) ?? (isRemoved ? "\u5DF2\u505C\u6B62\u7528\u4E8E\u540E\u7EED\u5BF9\u8BDD" : context.context_action === "retained" ? "\u7EE7\u7EED\u7528\u4E8E\u540E\u7EED\u5BF9\u8BDD" : context.context_kind === "agent-instructions" ? "\u5DF2\u66F4\u65B0\u672C\u6B21\u5BF9\u8BDD\u4F7F\u7528\u7684\u9879\u76EE\u8BF4\u660E" : context.context_kind === "skill-catalog" ? "\u5DF2\u66F4\u65B0\u672C\u6B21\u53EF\u7528\u80FD\u529B" : context.context_kind === "runtime-context" ? "\u5DF2\u66F4\u65B0\u672C\u6B21\u5DE5\u4F5C\u73AF\u5883" : context.context_kind === "workspace-context" ? "\u5DF2\u66F4\u65B0\u672C\u6B21\u5DE5\u4F5C\u533A\u73AF\u5883" : "\u5DF2\u66F4\u65B0\u672C\u6B21\u5BF9\u8BDD\u80CC\u666F");
|
|
1110
1110
|
const detail = isRemoved ? `${title}\u5DF2\u4E0D\u518D\u7528\u4E8E\u540E\u7EED\u5BF9\u8BDD\u3002` : BUILTIN_CONTEXT_DETAILS[context.context_kind] ?? "\u8FD9\u4E9B\u4FE1\u606F\u4F1A\u5E2E\u52A9\u667A\u80FD\u4F53\u7406\u89E3\u5F53\u524D\u4EFB\u52A1\u3002";
|
|
1111
1111
|
return { title, summary, detail, isRemoved };
|
|
1112
1112
|
}
|
|
1113
|
+
function groupAdjacentContextRuns(kinds) {
|
|
1114
|
+
const runs = [];
|
|
1115
|
+
let current = null;
|
|
1116
|
+
kinds.forEach((kind, index) => {
|
|
1117
|
+
if (kind === null) {
|
|
1118
|
+
current = null;
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
if (current === null) {
|
|
1122
|
+
current = [];
|
|
1123
|
+
runs.push(current);
|
|
1124
|
+
}
|
|
1125
|
+
current.push(index);
|
|
1126
|
+
});
|
|
1127
|
+
return runs;
|
|
1128
|
+
}
|
|
1129
|
+
function getContextGroupDisplayState(contexts) {
|
|
1130
|
+
const count = contexts.length;
|
|
1131
|
+
if (count === 1) {
|
|
1132
|
+
const single = getContextDisplayState(contexts[0]);
|
|
1133
|
+
return { title: single.title, summary: single.summary, count };
|
|
1134
|
+
}
|
|
1135
|
+
const removed = contexts.filter(
|
|
1136
|
+
(context) => context.context_action === "removed"
|
|
1137
|
+
).length;
|
|
1138
|
+
const updated = count - removed;
|
|
1139
|
+
const parts = [];
|
|
1140
|
+
if (updated > 0) parts.push(`${updated} \u9879\u5DF2\u66F4\u65B0`);
|
|
1141
|
+
if (removed > 0) parts.push(`${removed} \u9879\u5DF2\u505C\u7528`);
|
|
1142
|
+
return {
|
|
1143
|
+
title: "\u5BF9\u8BDD\u80CC\u666F",
|
|
1144
|
+
summary: parts.join(" \xB7 ") || `${count} \u9879`,
|
|
1145
|
+
count
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1113
1148
|
|
|
1114
1149
|
// src/shared/projection/context.ts
|
|
1115
1150
|
function isRecord2(value) {
|
|
@@ -2015,7 +2050,11 @@ function projectHistory(entries) {
|
|
|
2015
2050
|
model: stringOrNull(message.model),
|
|
2016
2051
|
usage: isRecord4(message._usage) ? { ...message._usage } : null,
|
|
2017
2052
|
duration_ms: numberOrZero(message._duration_ms),
|
|
2018
|
-
started_at: typeof entry.timestamp === "string" ? entry.timestamp : void 0
|
|
2053
|
+
started_at: typeof entry.timestamp === "string" ? entry.timestamp : void 0,
|
|
2054
|
+
// fork 子会话的父锚点:历史里落在消息级 _parent_fork_tool_call_id。丢掉它,
|
|
2055
|
+
// 刷新后工作流步骤 fork 就配不回 workflow:run 工具调用(普通 Agent fork 有
|
|
2056
|
+
// root Agent 工具调用兜底配对,工作流 fork 没有,子智能体卡会整体消失)。
|
|
2057
|
+
parent_fork_tool_call_id: stringOrNull(message._parent_fork_tool_call_id)
|
|
2019
2058
|
};
|
|
2020
2059
|
const isNativeToolEntry = role === "assistant" && Array.isArray(message.tool_calls) && message.tool_calls.some(
|
|
2021
2060
|
(toolCall) => isRecord4(toolCall) && typeof toolCall.provider === "string"
|
|
@@ -2990,10 +3029,10 @@ function isLegacyForkContextText(text) {
|
|
|
2990
3029
|
const normalized = text.trim();
|
|
2991
3030
|
return LEGACY_FORK_CONTEXT_MARKERS.every((marker) => normalized.includes(marker));
|
|
2992
3031
|
}
|
|
2993
|
-
function isHiddenInternalMessage(message) {
|
|
3032
|
+
function isHiddenInternalMessage(message, options = {}) {
|
|
2994
3033
|
if (message.role !== "user") return false;
|
|
2995
3034
|
const text = getTextContent(normalizeMessageContent(message.content));
|
|
2996
|
-
return isSystemReminderText(text) || isSystemNotificationText(text) || isLegacyForkContextText(text);
|
|
3035
|
+
return isSystemReminderText(text) || isSystemNotificationText(text) || (options.includeLegacyForkContext ?? true) && isLegacyForkContextText(text);
|
|
2997
3036
|
}
|
|
2998
3037
|
function buildMessageContent(text, attachments) {
|
|
2999
3038
|
if (attachments.length === 0) return text;
|
|
@@ -4818,7 +4857,7 @@ function resolveAuthToken(options) {
|
|
|
4818
4857
|
|
|
4819
4858
|
// src/version.ts
|
|
4820
4859
|
var SDK_NAME = "agent-client";
|
|
4821
|
-
var SDK_VERSION = true ? "2610.0.0-beta.
|
|
4860
|
+
var SDK_VERSION = true ? "2610.0.0-beta.31" : "1.1.1";
|
|
4822
4861
|
|
|
4823
4862
|
// src/socket.ts
|
|
4824
4863
|
function withSdkIdentity(auth) {
|
|
@@ -5424,9 +5463,11 @@ export {
|
|
|
5424
5463
|
createSocket,
|
|
5425
5464
|
extractTextAttachments,
|
|
5426
5465
|
getContextDisplayState,
|
|
5466
|
+
getContextGroupDisplayState,
|
|
5427
5467
|
getFileParts,
|
|
5428
5468
|
getImageParts,
|
|
5429
5469
|
getTextContent,
|
|
5470
|
+
groupAdjacentContextRuns,
|
|
5430
5471
|
groupMessagesByLoop,
|
|
5431
5472
|
isCommandEnvelope,
|
|
5432
5473
|
isHiddenInternalMessage,
|