@blade-hq/agent-client 2610.0.0-beta.34 → 2610.0.0-beta.35
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 +7 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +604 -109
- package/dist/index.js.map +1 -1
- package/dist/resources/sessions.d.ts +16 -0
- package/dist/schemas/projection.d.ts +8 -0
- package/dist/session/agent-session.d.ts +43 -14
- package/dist/session/history-page.d.ts +9 -0
- package/dist/session/state.d.ts +7 -1
- package/dist/shared/projection/builder.d.ts +7 -0
- package/dist/shared/projection/helpers.d.ts +1 -1
- package/dist/shared/projection/index.d.ts +1 -1
- package/dist/shared/projection/state.d.ts +3 -0
- package/dist/types/socket-events.d.ts +17 -0
- package/package.json +1 -1
- package/public-api.md +69 -1
package/README.md
CHANGED
|
@@ -167,6 +167,8 @@ await client.sessions.getSession(id) // 会话详情
|
|
|
167
167
|
await client.sessions.updateSession(id, { intent: "新标题" })
|
|
168
168
|
await client.sessions.deleteSession(id)
|
|
169
169
|
await client.sessions.getSessionTurns(id) // 历史消息(投影格式,与实时流同构)
|
|
170
|
+
const page = await client.sessions.getSessionTurnsPage(id) // 聊天首屏 recent page
|
|
171
|
+
await client.sessions.getSessionTurnsPage(id, { before: page.nextBefore! })
|
|
170
172
|
```
|
|
171
173
|
|
|
172
174
|
### 会话回放(演示 / 彩排)
|
|
@@ -341,6 +343,7 @@ chat.getState()
|
|
|
341
343
|
// errorMessage, 最近一次运行错误
|
|
342
344
|
// replay, 回放状态:{ isReplay, speed, sourceSessionId } | null
|
|
343
345
|
// viewerRole, "owner" | "viewer" | null(只读身份改不动会话)
|
|
346
|
+
// nextBefore, loadingOlder, 历史分页游标与加载状态
|
|
344
347
|
// turns, askAnswers, agentLoops, activeCompaction 进阶字段
|
|
345
348
|
// }
|
|
346
349
|
|
|
@@ -357,6 +360,7 @@ await chat.send("换个方案", { mode: "planning" }) // 指定模式/模型等
|
|
|
357
360
|
chat.append("补充:预算不超过 5 万") // 智能体运行中追加说明
|
|
358
361
|
await chat.stop() // 停止当前回复
|
|
359
362
|
await chat.compact() // 手动压缩上下文
|
|
363
|
+
if (chat.hasOlderHistory) await chat.loadOlderHistory()
|
|
360
364
|
chat.dispose() // 彻底释放(什么时候该调见下方说明)
|
|
361
365
|
```
|
|
362
366
|
|
|
@@ -433,6 +437,8 @@ chat.on("error", (e) => console.error(e.message))
|
|
|
433
437
|
|
|
434
438
|
完整事件表见 `AgentSessionEvents` 类型定义(含 `modeChange` / `workspaceChanged` / `artifact` / `notification` / `backgroundTask` / `taskListUpdated` / `rewind` / `replayMismatch` 等)。`toolResult.source` 区分实时结果、首次连接回放和断线重连回放;`on()` 返回取消函数,handler 抛异常只告警、不影响会话。
|
|
435
439
|
|
|
440
|
+
分页响应是 `SessionTurnsPage`,其中 `nextBefore: string | null` 是唯一的“还有更早历史”真值。历史页面指令通过独立的 `HistoricalCommand` 日志恢复,不混进展示页。自定义状态容器可复用 `prependOlder`、`replaceWindow` 与 `LiveRevisionState`,但一般直接使用 `AgentSession` 即可。
|
|
441
|
+
|
|
436
442
|
## iframe 嵌入形态:connectEmbedded
|
|
437
443
|
|
|
438
444
|
如果你不是嵌组件,而是把 **Blade 的聊天页面整个用 iframe 嵌进自己系统**,宿主页面用 `connectEmbedded` 拿到同构的协作 API:
|
|
@@ -588,4 +594,4 @@ transformSlashCommand(skillId, prompt, { local: false, installed: false })
|
|
|
588
594
|
- **消息与投影协议**:`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
595
|
- **Solution / 任务协议**:`Solution`、`SolutionAppField`、`SolutionAppState`、`SolutionAppUiConfig`、`SolutionRef`、`PublishedSolutionRef`、`ExistingSolutionRef`、`PreparedSolution`、`PreparedSolutionAsset`、`LayoutType`、`BizRole`、`TaskStatus`、`BackgroundTask`、`BackgroundTaskStopResult`
|
|
590
596
|
- **Headless**:`HeadlessResource`、`RunOptions`、`RunResult`、`RunTrace`
|
|
591
|
-
- **低层通道(apps/web 等高级集成)**:`createSocket`、`CreateSocketOptions`、`TypedSocket`、`AsrAudioPayload`、`ClientProjectionBuilder`、`RawEvent`、`acceptedPostChatFollowupCompletesLatestRun`、`reconcileOptimisticUserTurns`
|
|
597
|
+
- **低层通道(apps/web 等高级集成)**:`createSocket`、`CreateSocketOptions`、`TypedSocket`、`AsrAudioPayload`、`ClientProjectionBuilder`、`RawEvent`、`acknowledgeTurnEvents`、`hasChatRunEvent`、`acceptedPostChatFollowupCompletesLatestRun`、`reconcileOptimisticUserTurns`、`reconcileHistoricalUserTurns`
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { SessionConnectOptions } from "./session/hub";
|
|
|
12
12
|
export type { AgentSessionEvents, AgentSessionEventName } from "./session/events";
|
|
13
13
|
export { SessionSetupError } from "./session/definition";
|
|
14
14
|
export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, TextFile, SolutionDefinition, } from "./session/definition";
|
|
15
|
-
export { createInitialSessionState, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
|
|
15
|
+
export { createInitialSessionState, reconcileHistoricalUserTurns, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
|
|
16
16
|
export type { AskUserAnswerData, AgentLoopInfo, ActiveCompactionState, ConnectionStatus, ReplaySnapshot, SessionState, } from "./session/state";
|
|
17
17
|
export { connectEmbedded } from "./commands/embedded";
|
|
18
18
|
export type { EmbeddedChat, EmbeddedChatOptions } from "./commands/embedded";
|
|
@@ -27,7 +27,8 @@ export type { ComputerState, SessionComputer, SessionComputerList, } from "./res
|
|
|
27
27
|
export { ModelsResource } from "./resources/models";
|
|
28
28
|
export type { ModelCatalog, ModelOption } from "./resources/models";
|
|
29
29
|
export type { SessionsResource } from "./resources/sessions";
|
|
30
|
-
export
|
|
30
|
+
export { hasChatRunEvent } from "./shared/projection";
|
|
31
|
+
export type { CreateSessionRequest, AppCliAttachment, AppCliDefinition, FileEntry, ImportSessionOptions, PaginatedSessionsResult, GlobalSearchConversationResult, GlobalSearchFileResult, GlobalSearchResult, GlobalSearchResultItem, ResultFeedback, ResultFeedbackReason, HistoricalCommand, SessionContextStats, SessionHistory, SessionTurnsPage, ShareLinkResult, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
|
|
31
32
|
export type { ArchivedFileInfo, ArchivedToolCallInfo, ChatMessage, CompactionInfo, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolBridgeContent, ToolCallInfo, } from "./schemas/message";
|
|
32
33
|
export { buildMessageContent, chatErrorForDisplay, contentPreview, extractTextAttachments, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, isHiddenInternalMessage, normalizeMessageContent, transformSlashCommand, } from "./schemas/message-utils";
|
|
33
34
|
export { contextProjectionData, getContextDisplayState, getContextGroupDisplayState, groupAdjacentContextRuns, } from "./schemas/context";
|
|
@@ -35,6 +36,8 @@ export type { ContextAction, ContextDisplayState, ContextGroupDisplayState, Cont
|
|
|
35
36
|
export type { ParsedTextAttachment, ParsedTextContext, SkillMentionAvailability, } from "./schemas/message-utils";
|
|
36
37
|
export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PostChatFollowup, TurnProjection, } from "./schemas/projection";
|
|
37
38
|
export { latestPostChatFollowup } from "./schemas/projection-utils";
|
|
39
|
+
export { prependOlder, replaceWindow } from "./session/history-page";
|
|
40
|
+
export type { LiveRevisionState } from "./session/history-page";
|
|
38
41
|
export { DEFAULT_REPLAY_SPEED } from "./schemas/session";
|
|
39
42
|
export { SessionInfo, SessionStatus } from "./schemas/session";
|
|
40
43
|
export type { ModeId, PrimarySkillParallelMode, PrimarySkillSnapshot, ReplayPreview, ReplaySpeed, ReplayState, SessionDetail, SessionPortMapping, PublishedSolutionRef, TemplateId, } from "./schemas/session";
|
|
@@ -42,7 +45,7 @@ export { LayoutType } from "./schemas/solution";
|
|
|
42
45
|
export type { BizRole, Solution, SolutionAppField, SolutionAppState, SolutionAppUiConfig, } from "./schemas/solution";
|
|
43
46
|
export { Task, TaskStatus } from "./schemas/task";
|
|
44
47
|
export type { BackgroundTask, BackgroundTaskStopResult } from "./schemas/background";
|
|
45
|
-
export { acceptedPostChatFollowupCompletesLatestRun, ClientProjectionBuilder } from "./shared/projection";
|
|
48
|
+
export { acceptedPostChatFollowupCompletesLatestRun, acknowledgeTurnEvents, ClientProjectionBuilder, } from "./shared/projection";
|
|
46
49
|
export type { RawEvent } from "./shared/projection";
|
|
47
50
|
export { createSocket } from "./socket";
|
|
48
51
|
export type { CreateSocketOptions, TypedSocket } from "./socket";
|