@blade-hq/agent-client 2610.0.0-beta.0 → 2610.0.0-beta.2
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 +17 -3
- package/dist/blade-client.d.ts +2 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +117 -14
- package/dist/index.js.map +1 -1
- package/dist/resources/sessions.d.ts +40 -0
- package/dist/schemas/projection-utils.d.ts +3 -0
- package/dist/schemas/projection.d.ts +14 -0
- package/dist/session/agent-session.d.ts +2 -0
- package/dist/shared/projection/builder.d.ts +5 -0
- package/dist/shared/projection/helpers.d.ts +2 -0
- package/dist/shared/projection/index.d.ts +1 -1
- package/dist/types/socket-events.d.ts +6 -0
- package/package.json +4 -2
- package/public-api.md +98 -1
|
@@ -90,6 +90,26 @@ export interface PaginatedSessionsResult {
|
|
|
90
90
|
offset: number;
|
|
91
91
|
content_match_truncated?: boolean;
|
|
92
92
|
}
|
|
93
|
+
export interface GlobalSearchConversationResult {
|
|
94
|
+
type: "conversation";
|
|
95
|
+
session: SessionInfo;
|
|
96
|
+
snippet: string;
|
|
97
|
+
matched: "title" | "content";
|
|
98
|
+
}
|
|
99
|
+
export interface GlobalSearchFileResult {
|
|
100
|
+
type: "file";
|
|
101
|
+
session: SessionInfo;
|
|
102
|
+
path: string;
|
|
103
|
+
name: string;
|
|
104
|
+
snippet: string;
|
|
105
|
+
matched: "name" | "path";
|
|
106
|
+
}
|
|
107
|
+
export type GlobalSearchResultItem = GlobalSearchConversationResult | GlobalSearchFileResult;
|
|
108
|
+
export interface GlobalSearchResult {
|
|
109
|
+
items: GlobalSearchResultItem[];
|
|
110
|
+
truncated: boolean;
|
|
111
|
+
indexing: boolean;
|
|
112
|
+
}
|
|
93
113
|
export interface SkillDevSession {
|
|
94
114
|
session: SessionInfo;
|
|
95
115
|
skill_id: string;
|
|
@@ -106,6 +126,17 @@ export interface SessionContextStats {
|
|
|
106
126
|
context_window: number;
|
|
107
127
|
compaction_ratio: number;
|
|
108
128
|
}
|
|
129
|
+
export type ResultFeedbackReason = "not_solved" | "inaccurate" | "incomplete" | "needs_major_changes" | "too_slow" | "other";
|
|
130
|
+
export interface ResultFeedback {
|
|
131
|
+
session_id: string;
|
|
132
|
+
assistant_entry_id: string;
|
|
133
|
+
surface: "chat" | "software_factory" | "unknown";
|
|
134
|
+
project_id: string | null;
|
|
135
|
+
helpful: boolean;
|
|
136
|
+
reason: ResultFeedbackReason | null;
|
|
137
|
+
created_at: string;
|
|
138
|
+
updated_at: string;
|
|
139
|
+
}
|
|
109
140
|
export interface FileEntry {
|
|
110
141
|
name: string;
|
|
111
142
|
path: string;
|
|
@@ -185,6 +216,10 @@ export declare class SessionsResource {
|
|
|
185
216
|
q?: string;
|
|
186
217
|
}): Promise<PaginatedSessionsResult>;
|
|
187
218
|
listSessionsWithSkillData(): Promise<SkillDevSession[]>;
|
|
219
|
+
searchOwnedContent(params: {
|
|
220
|
+
q: string;
|
|
221
|
+
limit?: number;
|
|
222
|
+
}): Promise<GlobalSearchResult>;
|
|
188
223
|
createSession(intent?: string, template_id?: TemplateId, primary_skill_id?: string | null): Promise<{
|
|
189
224
|
session_id: string;
|
|
190
225
|
}>;
|
|
@@ -227,6 +262,11 @@ export declare class SessionsResource {
|
|
|
227
262
|
getSharedSession(token: string): Promise<TurnProjection[]>;
|
|
228
263
|
getSessionTasks(sessionId: string): Promise<Task[]>;
|
|
229
264
|
getSessionTurns(sessionId: string): Promise<TurnProjection[]>;
|
|
265
|
+
listResultFeedback(sessionId: string): Promise<ResultFeedback[]>;
|
|
266
|
+
putResultFeedback(sessionId: string, assistantEntryId: string, feedback: {
|
|
267
|
+
helpful: boolean;
|
|
268
|
+
reason?: ResultFeedbackReason | null;
|
|
269
|
+
}): Promise<ResultFeedback>;
|
|
230
270
|
getSessionContextStats(sessionId: string, init?: RequestInit): Promise<SessionContextStats>;
|
|
231
271
|
getSessionHistory(sessionId: string, init?: RequestInit): Promise<SessionHistory>;
|
|
232
272
|
tokenizePrompt(prompt: string, model?: string): Promise<TokenizeResult>;
|
|
@@ -29,6 +29,19 @@ export interface MemoryRef {
|
|
|
29
29
|
content_preview: string;
|
|
30
30
|
skill_name?: string | null;
|
|
31
31
|
}
|
|
32
|
+
export interface FinalArtifact {
|
|
33
|
+
kind: "file" | "link";
|
|
34
|
+
target: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PostChatFollowup {
|
|
38
|
+
assistant_entry_id: string;
|
|
39
|
+
recaption?: string;
|
|
40
|
+
suggestions: string[];
|
|
41
|
+
final_artifacts?: FinalArtifact[];
|
|
42
|
+
feedback_eligible: boolean;
|
|
43
|
+
feedback_scope: "latest_result";
|
|
44
|
+
}
|
|
32
45
|
export interface TurnProjection {
|
|
33
46
|
id: string;
|
|
34
47
|
sequence: number;
|
|
@@ -58,6 +71,7 @@ export interface TurnProjection {
|
|
|
58
71
|
trigger?: "auto" | "manual" | "forced_retry" | null;
|
|
59
72
|
failure_reason?: string | null;
|
|
60
73
|
fallback_applied?: boolean | null;
|
|
74
|
+
post_chat_followup?: PostChatFollowup | null;
|
|
61
75
|
}
|
|
62
76
|
export interface ArchivedFileInfo {
|
|
63
77
|
tool_name?: string | null;
|
|
@@ -8,6 +8,7 @@ import type { AppCliAttachment, AppCliDefinition, FileEntry } from "../resources
|
|
|
8
8
|
import { type ConnectionStatus, type SessionState } from "./state";
|
|
9
9
|
/** SessionHub 注入给 AgentSession 的运行时依赖(socket 收发 + REST 补数)。 */
|
|
10
10
|
export interface SessionRuntime {
|
|
11
|
+
streamTokens: boolean;
|
|
11
12
|
emitEvent(event: string, data: unknown): void;
|
|
12
13
|
emitWithAck(event: string, data: unknown, timeoutMs: number): Promise<Record<string, unknown> | undefined>;
|
|
13
14
|
ensureConnected(): void;
|
|
@@ -202,6 +203,7 @@ export declare class AgentSession {
|
|
|
202
203
|
_applyRunningState(isRunning: boolean): void;
|
|
203
204
|
private markRunningIfIdle;
|
|
204
205
|
private finishStreaming;
|
|
206
|
+
private completeChat;
|
|
205
207
|
private applyTurn;
|
|
206
208
|
private schedulePatchFlush;
|
|
207
209
|
private cancelPatchFlush;
|
|
@@ -13,6 +13,11 @@ export type ProjectionUpdate = {
|
|
|
13
13
|
toolName?: string;
|
|
14
14
|
workspacePath?: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* 缺失 chat:end 时的终态兜底。只有被投影接受到当前 assistant turn 的 followup
|
|
18
|
+
* 才能结束流式态;陈旧 followup 或其后已有新轮事件时均返回 false。
|
|
19
|
+
*/
|
|
20
|
+
export declare function acceptedPostChatFollowupCompletesLatestRun(events: RawEvent[], updates: ProjectionUpdate[]): boolean;
|
|
16
21
|
export declare class ClientProjectionBuilder {
|
|
17
22
|
private activeTurns;
|
|
18
23
|
private lastTurnIds;
|
|
@@ -42,6 +42,8 @@ export declare function normalizePostChatFollowup(data: Record<string, unknown>,
|
|
|
42
42
|
recaption: string;
|
|
43
43
|
suggestions: string[];
|
|
44
44
|
final_artifacts: FinalArtifact[];
|
|
45
|
+
feedback_eligible: boolean;
|
|
46
|
+
feedback_scope: "latest_result";
|
|
45
47
|
} | null;
|
|
46
48
|
export declare function normalizeChildPause(pausePayload: Record<string, unknown>): {
|
|
47
49
|
pauseToolData: Record<string, unknown>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ClientProjectionBuilder, type RawEvent, type ProjectionUpdate } from "./builder";
|
|
1
|
+
export { acceptedPostChatFollowupCompletesLatestRun, ClientProjectionBuilder, type RawEvent, type ProjectionUpdate, } from "./builder";
|
|
2
2
|
export { type TurnState, createTurnState, snapshot, PAUSE_TOOL_NAMES } from "./state";
|
|
3
3
|
export { projectHistory, type RawHistoryEntry } from "./history";
|
|
@@ -93,12 +93,14 @@ export declare namespace SessionSubscribePayloadSchema {
|
|
|
93
93
|
type EventFormat = "raw";
|
|
94
94
|
type AfterSequence = number;
|
|
95
95
|
type Resume = boolean;
|
|
96
|
+
type StreamTokens = boolean;
|
|
96
97
|
interface SessionSubscribePayload {
|
|
97
98
|
session_id: SessionId;
|
|
98
99
|
mode?: Mode;
|
|
99
100
|
event_format?: EventFormat;
|
|
100
101
|
after_sequence?: AfterSequence;
|
|
101
102
|
resume?: Resume;
|
|
103
|
+
stream_tokens?: StreamTokens;
|
|
102
104
|
[k: string]: unknown;
|
|
103
105
|
}
|
|
104
106
|
}
|
|
@@ -114,6 +116,7 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
|
|
|
114
116
|
type EventFormat = "raw";
|
|
115
117
|
type AfterSequence = number;
|
|
116
118
|
type Resume = boolean;
|
|
119
|
+
type StreamTokens = boolean;
|
|
117
120
|
interface SessionSubscribeBatchPayload {
|
|
118
121
|
sessions: Sessions;
|
|
119
122
|
[k: string]: unknown;
|
|
@@ -124,6 +127,7 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
|
|
|
124
127
|
event_format?: EventFormat;
|
|
125
128
|
after_sequence?: AfterSequence;
|
|
126
129
|
resume?: Resume;
|
|
130
|
+
stream_tokens?: StreamTokens;
|
|
127
131
|
[k: string]: unknown;
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -154,8 +158,10 @@ export declare namespace AgentBoardProjectUnsubscribePayloadSchema {
|
|
|
154
158
|
export type AgentBoardProjectUnsubscribePayload = AgentBoardProjectUnsubscribePayloadSchema.AgentBoardProjectUnsubscribePayload;
|
|
155
159
|
export declare namespace ChatStartPayloadSchema {
|
|
156
160
|
type SessionId = (string | null);
|
|
161
|
+
type ChatRunId = (string | null);
|
|
157
162
|
interface ChatStartPayload {
|
|
158
163
|
session_id?: SessionId;
|
|
164
|
+
chat_run_id?: ChatRunId;
|
|
159
165
|
[k: string]: unknown;
|
|
160
166
|
}
|
|
161
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blade-hq/agent-client",
|
|
3
|
-
"version": "2610.0.0-beta.
|
|
3
|
+
"version": "2610.0.0-beta.2",
|
|
4
4
|
"description": "Blade Agent 框架无关客户端:会话实时状态机、REST 通道、弹窗登录、页面协作。浏览器与 Node.js 通用。",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
20
|
"README.md",
|
|
21
|
-
"public-api.md"
|
|
21
|
+
"public-api.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"THIRD_PARTY_NOTICES.md"
|
|
22
24
|
],
|
|
23
25
|
"sideEffects": [
|
|
24
26
|
"**/*.css"
|
package/public-api.md
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
> 本文件由 `scripts/public-api-report.mjs` 生成,请勿手改。
|
|
4
4
|
> 公共面变更时重新生成本报告,并同步更新 README 对应章节——CI 会校验两者。
|
|
5
5
|
|
|
6
|
-
共
|
|
6
|
+
共 136 个公开声明。
|
|
7
|
+
|
|
8
|
+
## `acceptedPostChatFollowupCompletesLatestRun` (function)
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
acceptedPostChatFollowupCompletesLatestRun: (events: RawEvent[], updates: ProjectionUpdate[]) => boolean
|
|
12
|
+
```
|
|
7
13
|
|
|
8
14
|
## `ActiveCompactionState` (interface)
|
|
9
15
|
|
|
@@ -240,6 +246,7 @@ baseUrl: string
|
|
|
240
246
|
fetchImpl: { (input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined
|
|
241
247
|
onRefreshSuccess: (() => void | Promise<void>) | undefined
|
|
242
248
|
socketToken: string | (() => string | null | undefined) | undefined
|
|
249
|
+
streamTokens: boolean | undefined
|
|
243
250
|
token: string | (() => string | null | undefined) | undefined
|
|
244
251
|
tokenStorage: TokenStorageMode | undefined
|
|
245
252
|
```
|
|
@@ -450,6 +457,14 @@ path: string
|
|
|
450
457
|
tags: string[] | undefined
|
|
451
458
|
```
|
|
452
459
|
|
|
460
|
+
## `FinalArtifact` (interface)
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
kind: "link" | "file"
|
|
464
|
+
label: string
|
|
465
|
+
target: string
|
|
466
|
+
```
|
|
467
|
+
|
|
453
468
|
## `getFileParts` (function)
|
|
454
469
|
|
|
455
470
|
```ts
|
|
@@ -468,6 +483,42 @@ getImageParts: (content: MessageContent) => ImageUrlContentPart[]
|
|
|
468
483
|
getTextContent: (content: MessageContent) => string
|
|
469
484
|
```
|
|
470
485
|
|
|
486
|
+
## `GlobalSearchConversationResult` (interface)
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
matched: "title" | "content"
|
|
490
|
+
session: SessionInfo
|
|
491
|
+
snippet: string
|
|
492
|
+
type: "conversation"
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## `GlobalSearchFileResult` (interface)
|
|
496
|
+
|
|
497
|
+
```ts
|
|
498
|
+
matched: "name" | "path"
|
|
499
|
+
name: string
|
|
500
|
+
path: string
|
|
501
|
+
session: SessionInfo
|
|
502
|
+
snippet: string
|
|
503
|
+
type: "file"
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## `GlobalSearchResult` (interface)
|
|
507
|
+
|
|
508
|
+
```ts
|
|
509
|
+
indexing: boolean
|
|
510
|
+
items: GlobalSearchResultItem[]
|
|
511
|
+
truncated: boolean
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
## `GlobalSearchResultItem` (type)
|
|
515
|
+
|
|
516
|
+
```ts
|
|
517
|
+
export type GlobalSearchResultItem =
|
|
518
|
+
| GlobalSearchConversationResult
|
|
519
|
+
| GlobalSearchFileResult
|
|
520
|
+
```
|
|
521
|
+
|
|
471
522
|
## `groupMessagesByLoop` (function)
|
|
472
523
|
|
|
473
524
|
```ts
|
|
@@ -528,6 +579,12 @@ isHiddenInternalMessage: (message: Pick<ChatMessage, "role" | "content">) => boo
|
|
|
528
579
|
isInboundEnvelope: (value: unknown) => value is InboundEnvelope
|
|
529
580
|
```
|
|
530
581
|
|
|
582
|
+
## `latestPostChatFollowup` (function)
|
|
583
|
+
|
|
584
|
+
```ts
|
|
585
|
+
latestPostChatFollowup: (turns: TurnProjection[]) => PostChatFollowup | null
|
|
586
|
+
```
|
|
587
|
+
|
|
531
588
|
## `LayoutType` (enum)
|
|
532
589
|
|
|
533
590
|
```ts
|
|
@@ -656,6 +713,17 @@ sequence: number
|
|
|
656
713
|
turn_id: string
|
|
657
714
|
```
|
|
658
715
|
|
|
716
|
+
## `PostChatFollowup` (interface)
|
|
717
|
+
|
|
718
|
+
```ts
|
|
719
|
+
assistant_entry_id: string
|
|
720
|
+
feedback_eligible: boolean
|
|
721
|
+
feedback_scope: "latest_result"
|
|
722
|
+
final_artifacts: FinalArtifact[] | undefined
|
|
723
|
+
recaption: string | undefined
|
|
724
|
+
suggestions: string[]
|
|
725
|
+
```
|
|
726
|
+
|
|
659
727
|
## `PreparedSolution` (interface)
|
|
660
728
|
|
|
661
729
|
```ts
|
|
@@ -751,6 +819,31 @@ speed: ReplaySpeed | undefined
|
|
|
751
819
|
status: "replay" | "autonomous" | undefined
|
|
752
820
|
```
|
|
753
821
|
|
|
822
|
+
## `ResultFeedback` (interface)
|
|
823
|
+
|
|
824
|
+
```ts
|
|
825
|
+
assistant_entry_id: string
|
|
826
|
+
created_at: string
|
|
827
|
+
helpful: boolean
|
|
828
|
+
project_id: string | null
|
|
829
|
+
reason: ResultFeedbackReason | null
|
|
830
|
+
session_id: string
|
|
831
|
+
surface: "unknown" | "chat" | "software_factory"
|
|
832
|
+
updated_at: string
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
## `ResultFeedbackReason` (type)
|
|
836
|
+
|
|
837
|
+
```ts
|
|
838
|
+
export type ResultFeedbackReason =
|
|
839
|
+
| "not_solved"
|
|
840
|
+
| "inaccurate"
|
|
841
|
+
| "incomplete"
|
|
842
|
+
| "needs_major_changes"
|
|
843
|
+
| "too_slow"
|
|
844
|
+
| "other"
|
|
845
|
+
```
|
|
846
|
+
|
|
754
847
|
## `RunOptions` (interface)
|
|
755
848
|
|
|
756
849
|
```ts
|
|
@@ -998,15 +1091,18 @@ getSharedSession: (token: string) => Promise<TurnProjection[]>
|
|
|
998
1091
|
importSession: (file: File, name?: string, solutionOverride?: string | null | ImportSessionOptions) => Promise<{ session_id: string; }>
|
|
999
1092
|
listBackgroundTasks: (sessionId: string, init?: RequestInit) => Promise<BackgroundTask[]>
|
|
1000
1093
|
listDir: (sessionId: string, dirPath: string) => Promise<FileEntry[]>
|
|
1094
|
+
listResultFeedback: (sessionId: string) => Promise<ResultFeedback[]>
|
|
1001
1095
|
listSessions: (template_id_prefix?: string, solution_id?: string) => Promise<SessionInfo[]>
|
|
1002
1096
|
listSessionsPaginated: (params: { limit: number; offset: number; template_id_prefix?: string; solution_id?: string; solution_registry_id?: string; q?: string; }) => Promise<PaginatedSessionsResult>
|
|
1003
1097
|
listSessionsWithSkillData: () => Promise<SkillDevSession[]>
|
|
1004
1098
|
pinSession: (sessionId: string, pinned: boolean) => Promise<SessionInfo>
|
|
1005
1099
|
previewImport: (file: File) => Promise<ImportPreview>
|
|
1006
1100
|
probeSessionUrl: (sessionId: string, url: string) => Promise<{ reachable: boolean; requires_proxy: boolean; }>
|
|
1101
|
+
putResultFeedback: (sessionId: string, assistantEntryId: string, feedback: { helpful: boolean; reason?: ResultFeedbackReason | null; }) => Promise<ResultFeedback>
|
|
1007
1102
|
renameFile: (sessionId: string, filePath: string, newName: string) => Promise<{ path: string; }>
|
|
1008
1103
|
revokeShare: (sessionId: string, token: string) => Promise<{ revoked: boolean; }>
|
|
1009
1104
|
rewindSession: (sessionId: string, checkpointId: string) => Promise<{ id: string; content: string; }>
|
|
1105
|
+
searchOwnedContent: (params: { q: string; limit?: number; }) => Promise<GlobalSearchResult>
|
|
1010
1106
|
setSessionEnv: (sessionId: string, env: Record<string, string>) => Promise<SessionDetail>
|
|
1011
1107
|
shareFile: (sessionId: string, sourcePath: string, linkName?: string, shareFolder?: string) => Promise<{ path: string; target: string; }>
|
|
1012
1108
|
startReplaySession: (sourceSessionId: string, speed?: ReplaySpeed) => Promise<{ session_id: string; }>
|
|
@@ -1243,6 +1339,7 @@ loop_id: string
|
|
|
1243
1339
|
memory_refs: MemoryRef[] | null | undefined
|
|
1244
1340
|
model: string | null | undefined
|
|
1245
1341
|
parent_fork_tool_call_id: string | null | undefined
|
|
1342
|
+
post_chat_followup: PostChatFollowup | null | undefined
|
|
1246
1343
|
role: "user" | "assistant" | "system"
|
|
1247
1344
|
saved_ratio: number | null | undefined
|
|
1248
1345
|
sequence: number
|