@downcity/agent 1.1.199 → 1.1.200
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/bin/executor/Executor.d.ts +2 -2
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +23 -24
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts +5 -5
- package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +2 -2
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +23 -30
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +4 -3
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
- package/bin/executor/messages/SessionMessageCodec.d.ts +1 -1
- package/bin/executor/messages/SessionMessageCodec.js +3 -3
- package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
- package/bin/executor/messages/SessionStepEventMapper.d.ts +2 -2
- package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
- package/bin/executor/services/ExecutorInflightService.d.ts +2 -2
- package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
- package/bin/executor/services/ExecutorInflightService.js +9 -5
- package/bin/executor/services/ExecutorInflightService.js.map +1 -1
- package/bin/executor/store/history/SessionHistoryStore.d.ts +11 -11
- package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +9 -7
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +97 -52
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
- package/bin/executor/types/SessionMessages.d.ts +41 -22
- package/bin/executor/types/SessionMessages.d.ts.map +1 -1
- package/bin/executor/types/SessionMessages.js +25 -7
- package/bin/executor/types/SessionMessages.js.map +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js.map +1 -1
- package/bin/session/SessionTitle.d.ts.map +1 -1
- package/bin/session/SessionTitle.js +5 -0
- package/bin/session/SessionTitle.js.map +1 -1
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +35 -32
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/services/SessionStateService.d.ts +8 -8
- package/bin/session/services/SessionStateService.d.ts.map +1 -1
- package/bin/session/services/SessionStateService.js +44 -54
- package/bin/session/services/SessionStateService.js.map +1 -1
- package/bin/session/services/SessionTurnService.js +3 -3
- package/bin/session/services/SessionTurnService.js.map +1 -1
- package/bin/session/services/SessionViewService.d.ts.map +1 -1
- package/bin/session/services/SessionViewService.js +17 -27
- package/bin/session/services/SessionViewService.js.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +10 -10
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/executor/SessionRunContext.d.ts +6 -6
- package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.d.ts +67 -0
- package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -0
- package/bin/types/sdk/AgentSessionAction.js +10 -0
- package/bin/types/sdk/AgentSessionAction.js.map +1 -0
- package/bin/types/sdk/AgentSessionEvent.d.ts +2 -2
- package/bin/types/sdk/AgentSessionEvent.d.ts.map +1 -1
- package/package.json +3 -3
- package/scripts/{session-operation-message.test.mjs → session-action-message.test.mjs} +57 -55
- package/src/executor/Executor.ts +28 -29
- package/src/executor/composer/compaction/SessionCompactionComposer.ts +5 -5
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +1 -1
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +32 -37
- package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +7 -4
- package/src/executor/messages/SessionAttachmentMapper.ts +2 -2
- package/src/executor/messages/SessionMessageCodec.ts +3 -3
- package/src/executor/messages/SessionStepEventMapper.ts +5 -5
- package/src/executor/services/ExecutorInflightService.ts +11 -7
- package/src/executor/store/history/SessionHistoryStore.ts +11 -10
- package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +118 -63
- package/src/executor/types/SessionMessages.ts +69 -31
- package/src/index.ts +5 -6
- package/src/session/SessionTitle.ts +3 -0
- package/src/session/browse/Browse.ts +42 -34
- package/src/session/services/SessionStateService.ts +54 -64
- package/src/session/services/SessionTurnService.ts +3 -3
- package/src/session/services/SessionViewService.ts +17 -27
- package/src/types/agent/SessionTypes.ts +10 -10
- package/src/types/executor/SessionRunContext.ts +11 -11
- package/src/types/sdk/AgentSessionAction.ts +79 -0
- package/src/types/sdk/AgentSessionEvent.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/types/sdk/AgentSessionOperation.d.ts +0 -99
- package/bin/types/sdk/AgentSessionOperation.d.ts.map +0 -1
- package/bin/types/sdk/AgentSessionOperation.js +0 -10
- package/bin/types/sdk/AgentSessionOperation.js.map +0 -1
- package/src/types/sdk/AgentSessionOperation.ts +0 -125
|
@@ -31,9 +31,9 @@ import type {
|
|
|
31
31
|
AgentSessionEvent,
|
|
32
32
|
} from "@/types/sdk/AgentSessionEvent.js";
|
|
33
33
|
import type {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from "@/types/sdk/
|
|
34
|
+
AgentSessionActionEvent,
|
|
35
|
+
AgentSessionActionRecord,
|
|
36
|
+
} from "@/types/sdk/AgentSessionAction.js";
|
|
37
37
|
import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
|
|
38
38
|
import type {
|
|
39
39
|
SessionMessageV1,
|
|
@@ -87,17 +87,17 @@ type SessionStateServiceOptions = {
|
|
|
87
87
|
|
|
88
88
|
type SessionSetOptions = {
|
|
89
89
|
/**
|
|
90
|
-
* 是否写入并发布 model-switching
|
|
90
|
+
* 是否写入并发布 model-switching action。
|
|
91
91
|
*
|
|
92
92
|
* 说明(中文)
|
|
93
93
|
* - 公开 `session.set()` 应保持默认开启。
|
|
94
94
|
* - fork 内部复制模型配置时关闭,避免污染 forked session 历史。
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
emit_action?: boolean;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
type
|
|
100
|
-
Partial<Pick<
|
|
99
|
+
type EmitActionInput = Omit<AgentSessionActionRecord, "id"> &
|
|
100
|
+
Partial<Pick<AgentSessionActionRecord, "id">>;
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* 本地 Session 状态与持久化服务。
|
|
@@ -223,23 +223,21 @@ export class SessionStateService {
|
|
|
223
223
|
* 写入当前 session 配置。
|
|
224
224
|
*/
|
|
225
225
|
async set(input: AgentSessionSetInput, options?: SessionSetOptions): Promise<void> {
|
|
226
|
-
const
|
|
226
|
+
const should_emit_action = options?.emit_action !== false;
|
|
227
227
|
const previous_model_label = this.state.sessionConfig.modelLabel;
|
|
228
228
|
const next_model_label = input.model
|
|
229
229
|
? inferAgentModelLabel(input.model)
|
|
230
230
|
: undefined;
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
if (input.model &&
|
|
234
|
-
await this.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
...(next_model_label ? { modelLabel: next_model_label } : {}),
|
|
242
|
-
},
|
|
231
|
+
const action_id = `model-switching:${this.session_id}:${Date.now()}:${generateId()}`;
|
|
232
|
+
|
|
233
|
+
if (input.model && should_emit_action) {
|
|
234
|
+
await this.emit_action_event({
|
|
235
|
+
id: action_id,
|
|
236
|
+
title: "Switching session model",
|
|
237
|
+
description: next_model_label
|
|
238
|
+
? `Switching to ${next_model_label}.`
|
|
239
|
+
: undefined,
|
|
240
|
+
state: "running",
|
|
243
241
|
});
|
|
244
242
|
}
|
|
245
243
|
|
|
@@ -256,30 +254,25 @@ export class SessionStateService {
|
|
|
256
254
|
model: this.state.sessionConfig.model,
|
|
257
255
|
});
|
|
258
256
|
} catch (error) {
|
|
259
|
-
if (input.model &&
|
|
260
|
-
await this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
error: error instanceof Error ? error.message : String(error),
|
|
257
|
+
if (input.model && should_emit_action) {
|
|
258
|
+
await this.emit_action_event({
|
|
259
|
+
id: action_id,
|
|
260
|
+
title: "Session model switch failed",
|
|
261
|
+
description: error instanceof Error ? error.message : String(error),
|
|
262
|
+
state: "failed",
|
|
266
263
|
});
|
|
267
264
|
}
|
|
268
265
|
throw error;
|
|
269
266
|
}
|
|
270
267
|
|
|
271
|
-
if (input.model &&
|
|
272
|
-
await this.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
...(this.state.sessionConfig.modelLabel
|
|
280
|
-
? { modelLabel: this.state.sessionConfig.modelLabel }
|
|
281
|
-
: {}),
|
|
282
|
-
},
|
|
268
|
+
if (input.model && should_emit_action) {
|
|
269
|
+
await this.emit_action_event({
|
|
270
|
+
id: action_id,
|
|
271
|
+
title: "Session model switched",
|
|
272
|
+
description: this.state.sessionConfig.modelLabel
|
|
273
|
+
? `Using ${this.state.sessionConfig.modelLabel}.`
|
|
274
|
+
: undefined,
|
|
275
|
+
state: "completed",
|
|
283
276
|
});
|
|
284
277
|
}
|
|
285
278
|
}
|
|
@@ -369,23 +362,18 @@ export class SessionStateService {
|
|
|
369
362
|
}
|
|
370
363
|
|
|
371
364
|
/**
|
|
372
|
-
* 持久化一条
|
|
365
|
+
* 持久化一条 action message。
|
|
373
366
|
*/
|
|
374
|
-
async
|
|
375
|
-
event:
|
|
367
|
+
async persist_action_event(
|
|
368
|
+
event: AgentSessionActionEvent,
|
|
376
369
|
): Promise<void> {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
370
|
+
const message = this.history_store.action({
|
|
371
|
+
action: {
|
|
372
|
+
id: event.id,
|
|
373
|
+
title: event.title,
|
|
374
|
+
state: event.state,
|
|
375
|
+
...(event.description ? { description: event.description } : {}),
|
|
383
376
|
...(event.turnId ? { turnId: event.turnId } : {}),
|
|
384
|
-
...(event.label ? { label: event.label } : {}),
|
|
385
|
-
...(event.reason ? { reason: event.reason } : {}),
|
|
386
|
-
...(typeof event.progress === "number" ? { progress: event.progress } : {}),
|
|
387
|
-
...(event.result !== undefined ? { result: event.result } : {}),
|
|
388
|
-
...(event.error ? { error: event.error } : {}),
|
|
389
377
|
},
|
|
390
378
|
metadata: {
|
|
391
379
|
sessionId: this.session_id,
|
|
@@ -396,22 +384,24 @@ export class SessionStateService {
|
|
|
396
384
|
}
|
|
397
385
|
|
|
398
386
|
/**
|
|
399
|
-
* 写入并发布一条
|
|
387
|
+
* 写入并发布一条 action。
|
|
400
388
|
*/
|
|
401
|
-
async
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
389
|
+
async emit_action_event(input: EmitActionInput): Promise<void> {
|
|
390
|
+
if (input.visible === false) return;
|
|
391
|
+
const action_id =
|
|
392
|
+
String(input.id || "").trim() ||
|
|
393
|
+
`action:${this.session_id}:${Date.now()}:${generateId()}`;
|
|
394
|
+
const { visible: _visible, ...public_input } = input;
|
|
395
|
+
const event: AgentSessionActionEvent = {
|
|
396
|
+
type: "action",
|
|
407
397
|
sessionId: this.session_id,
|
|
408
|
-
...
|
|
409
|
-
|
|
398
|
+
...public_input,
|
|
399
|
+
id: action_id,
|
|
410
400
|
};
|
|
411
401
|
try {
|
|
412
|
-
await this.
|
|
402
|
+
await this.persist_action_event(event);
|
|
413
403
|
} catch {
|
|
414
|
-
//
|
|
404
|
+
// action 持久化失败不应阻断宿主操作。
|
|
415
405
|
}
|
|
416
406
|
this.publish_event(event);
|
|
417
407
|
}
|
|
@@ -199,11 +199,11 @@ export class SessionTurnService {
|
|
|
199
199
|
this.publish_event(session_event);
|
|
200
200
|
}
|
|
201
201
|
},
|
|
202
|
-
|
|
202
|
+
onActionCallback: async (event) => {
|
|
203
203
|
try {
|
|
204
|
-
await this.state_service.
|
|
204
|
+
await this.state_service.persist_action_event(event);
|
|
205
205
|
} catch {
|
|
206
|
-
//
|
|
206
|
+
// action 持久化失败不应阻断当前 turn。
|
|
207
207
|
}
|
|
208
208
|
this.publish_event(event);
|
|
209
209
|
},
|
|
@@ -278,17 +278,13 @@ export class SessionViewService<TSession extends Pick<AgentSession, "set">> {
|
|
|
278
278
|
!message_id
|
|
279
279
|
? messages
|
|
280
280
|
: this.resolve_fork_messages(messages, message_id);
|
|
281
|
-
const
|
|
281
|
+
const action_id = `history-forking:${this.session_id}:${Date.now()}:${nanoid(8)}`;
|
|
282
282
|
|
|
283
|
-
await this.state_service.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
result: {
|
|
289
|
-
messageCount: fork_messages.length,
|
|
290
|
-
...(message_id ? { messageId: message_id } : {}),
|
|
291
|
-
},
|
|
283
|
+
await this.state_service.emit_action_event({
|
|
284
|
+
id: action_id,
|
|
285
|
+
title: "Forking session history",
|
|
286
|
+
description: `Preparing ${String(fork_messages.length)} messages for the new session.`,
|
|
287
|
+
state: "running",
|
|
292
288
|
});
|
|
293
289
|
|
|
294
290
|
try {
|
|
@@ -302,29 +298,23 @@ export class SessionViewService<TSession extends Pick<AgentSession, "set">> {
|
|
|
302
298
|
{
|
|
303
299
|
model: session_config.model,
|
|
304
300
|
},
|
|
305
|
-
{
|
|
301
|
+
{ emit_action: false },
|
|
306
302
|
);
|
|
307
303
|
}
|
|
308
304
|
await this.append_fork_messages(forked_bundle, fork_messages);
|
|
309
|
-
await this.state_service.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
result: {
|
|
315
|
-
forkedSessionId: String((forked as { id?: unknown }).id || ""),
|
|
316
|
-
messageCount: fork_messages.length,
|
|
317
|
-
...(message_id ? { messageId: message_id } : {}),
|
|
318
|
-
},
|
|
305
|
+
await this.state_service.emit_action_event({
|
|
306
|
+
id: action_id,
|
|
307
|
+
title: "Session history forked",
|
|
308
|
+
description: `Created ${String((forked as { id?: unknown }).id || "")} with ${String(fork_messages.length)} messages.`,
|
|
309
|
+
state: "completed",
|
|
319
310
|
});
|
|
320
311
|
return forked;
|
|
321
312
|
} catch (error) {
|
|
322
|
-
await this.state_service.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
error: error instanceof Error ? error.message : String(error),
|
|
313
|
+
await this.state_service.emit_action_event({
|
|
314
|
+
id: action_id,
|
|
315
|
+
title: "Session history fork failed",
|
|
316
|
+
description: error instanceof Error ? error.message : String(error),
|
|
317
|
+
state: "failed",
|
|
328
318
|
});
|
|
329
319
|
throw error;
|
|
330
320
|
}
|
|
@@ -99,7 +99,7 @@ export interface AgentSessionTimelineEvent {
|
|
|
99
99
|
* 说明(中文)
|
|
100
100
|
* - `tool-call` / `tool-result` 用于把 assistant 内部工具过程平铺给 UI。
|
|
101
101
|
*/
|
|
102
|
-
role: "user" | "assistant" | "tool-call" | "tool-result" | "
|
|
102
|
+
role: "user" | "assistant" | "tool-call" | "tool-result" | "action";
|
|
103
103
|
/** 事件时间戳(毫秒)。 */
|
|
104
104
|
ts?: number;
|
|
105
105
|
/** 事件所属消息种类。 */
|
|
@@ -116,26 +116,26 @@ export interface AgentSessionTimelineEvent {
|
|
|
116
116
|
*/
|
|
117
117
|
toolName?: string;
|
|
118
118
|
/**
|
|
119
|
-
* 当前
|
|
119
|
+
* 当前 action 标题。
|
|
120
120
|
*
|
|
121
121
|
* 说明(中文)
|
|
122
|
-
* - 仅 `role=
|
|
122
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
actionTitle?: string;
|
|
125
125
|
/**
|
|
126
|
-
* 当前
|
|
126
|
+
* 当前 action 描述。
|
|
127
127
|
*
|
|
128
128
|
* 说明(中文)
|
|
129
|
-
* - 仅 `role=
|
|
129
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
130
130
|
*/
|
|
131
|
-
|
|
131
|
+
actionDescription?: string;
|
|
132
132
|
/**
|
|
133
|
-
* 当前
|
|
133
|
+
* 当前 action 状态。
|
|
134
134
|
*
|
|
135
135
|
* 说明(中文)
|
|
136
|
-
* - 仅 `role=
|
|
136
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
137
137
|
*/
|
|
138
|
-
|
|
138
|
+
actionState?: string;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/**
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "@/types/sdk/
|
|
11
|
+
AgentSessionActionCallback,
|
|
12
|
+
AgentSessionActionEvent,
|
|
13
|
+
AgentSessionActionRecord,
|
|
14
|
+
} from "@/types/sdk/AgentSessionAction.js";
|
|
15
15
|
import type {
|
|
16
16
|
SessionAssistantStepCallback,
|
|
17
17
|
SessionUiMessageChunkCallback,
|
|
@@ -72,13 +72,13 @@ export interface SessionRunContext {
|
|
|
72
72
|
onUiMessageChunkCallback?: SessionUiMessageChunkCallback;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* action 发布回调。
|
|
76
76
|
*
|
|
77
77
|
* 关键点(中文)
|
|
78
|
-
* - 用于把 compaction
|
|
79
|
-
* -
|
|
78
|
+
* - 用于把 compaction 等辅助动作转成 session event 与 action message。
|
|
79
|
+
* - action 不代表 assistant 正文,也不会进入 LLM 输入。
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
onActionCallback?: AgentSessionActionCallback;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* 当前 turn 的取消信号。
|
|
@@ -117,7 +117,7 @@ export interface SessionRunContext {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export type {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
AgentSessionActionCallback,
|
|
121
|
+
AgentSessionActionEvent,
|
|
122
|
+
AgentSessionActionRecord,
|
|
123
123
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Session action 类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - action 描述 session 内部正在发生的辅助动作,不代表 assistant 正文。
|
|
6
|
+
* - action 同时用于 `session.subscribe()` 实时事件与 JSONL history item。
|
|
7
|
+
* - action 只服务前端状态展示与历史回放,不进入 LLM 输入。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Session action 当前状态。
|
|
12
|
+
*/
|
|
13
|
+
export type AgentSessionActionState = "running" | "completed" | "failed";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Session action 记录。
|
|
17
|
+
*/
|
|
18
|
+
export interface AgentSessionActionRecord {
|
|
19
|
+
/**
|
|
20
|
+
* 同一个 action 生命周期内稳定复用的 ID。
|
|
21
|
+
*
|
|
22
|
+
* 说明(中文)
|
|
23
|
+
* - 这是 history item envelope 字段,用于把同一个动作更新为一条记录。
|
|
24
|
+
* - 前端展示语义只依赖 `type/title/description/state`。
|
|
25
|
+
*/
|
|
26
|
+
id: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 当前 action 标题。
|
|
30
|
+
*/
|
|
31
|
+
title: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 当前 action 描述。
|
|
35
|
+
*/
|
|
36
|
+
description?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 当前 action 状态。
|
|
40
|
+
*/
|
|
41
|
+
state: AgentSessionActionState;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 当前 action 关联的 turn 标识。
|
|
45
|
+
*/
|
|
46
|
+
turnId?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 是否建议前端展示。
|
|
50
|
+
*
|
|
51
|
+
* 说明(中文)
|
|
52
|
+
* - 默认视为 `true`。
|
|
53
|
+
* - 调试或审计类辅助事件可显式写入 `false`。
|
|
54
|
+
*/
|
|
55
|
+
visible?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Session action 订阅事件。
|
|
60
|
+
*/
|
|
61
|
+
export interface AgentSessionActionEvent
|
|
62
|
+
extends Omit<AgentSessionActionRecord, "visible"> {
|
|
63
|
+
/**
|
|
64
|
+
* 当前事件类型。
|
|
65
|
+
*/
|
|
66
|
+
type: "action";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 当前 session 唯一标识。
|
|
70
|
+
*/
|
|
71
|
+
sessionId: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Session action 发布回调。
|
|
76
|
+
*/
|
|
77
|
+
export type AgentSessionActionCallback = (
|
|
78
|
+
action: AgentSessionActionEvent,
|
|
79
|
+
) => Promise<void>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { JsonValue } from "@/types/common/Json.js";
|
|
10
10
|
import type { SessionAssistantStepVisibility } from "@/executor/types/SessionRun.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { AgentSessionActionEvent } from "@/types/sdk/AgentSessionAction.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* 单个 turn 开始事件。
|
|
@@ -355,7 +355,7 @@ export type AgentSessionEvent =
|
|
|
355
355
|
| AgentSessionToolApprovalResultEvent
|
|
356
356
|
| AgentSessionAssistantStepEvent
|
|
357
357
|
| AgentSessionTitleEvent
|
|
358
|
-
|
|
|
358
|
+
| AgentSessionActionEvent
|
|
359
359
|
| AgentSessionTurnFinishEvent
|
|
360
360
|
| AgentSessionErrorEvent;
|
|
361
361
|
|