@downcity/agent 1.1.208 → 1.1.212
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/agent/local/Agent.d.ts +3 -3
- package/bin/agent/local/Agent.d.ts.map +1 -1
- package/bin/agent/local/Agent.js +0 -3
- package/bin/agent/local/Agent.js.map +1 -1
- package/bin/agent/local/AgentInstructions.d.ts +1 -1
- package/bin/agent/local/AgentInstructions.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.d.ts +3 -8
- package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.js +0 -1
- package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
- package/bin/agent/local/services/AgentSessions.d.ts +5 -7
- package/bin/agent/local/services/AgentSessions.d.ts.map +1 -1
- package/bin/agent/local/services/AgentSessions.js +2 -3
- package/bin/agent/local/services/AgentSessions.js.map +1 -1
- package/bin/agent/remote/RemoteAgent.d.ts +3 -1
- package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
- package/bin/agent/remote/RemoteAgent.js.map +1 -1
- package/bin/agent/remote/RemoteSession.d.ts +10 -1
- package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
- package/bin/agent/remote/RemoteSession.js +18 -0
- package/bin/agent/remote/RemoteSession.js.map +1 -1
- package/bin/agent/remote/RemoteTransport.d.ts +5 -1
- package/bin/agent/remote/RemoteTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +4 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +7 -0
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +4 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +1 -0
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
- package/bin/executor/Executor.d.ts +0 -16
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +0 -16
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +1 -3
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +1 -5
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts +0 -10
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
- package/bin/executor/composer/history/SessionHistoryWriter.js +31 -61
- package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
- package/bin/executor/messages/AssistantFileResource.d.ts.map +1 -1
- package/bin/executor/messages/AssistantFileResource.js +58 -15
- package/bin/executor/messages/AssistantFileResource.js.map +1 -1
- package/bin/executor/services/ExecutorInflightService.d.ts +0 -5
- package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
- package/bin/executor/services/ExecutorInflightService.js +0 -6
- package/bin/executor/services/ExecutorInflightService.js.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +4 -0
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +115 -3
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
- package/bin/executor/types/SessionHistoryMeta.d.ts +6 -0
- package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
- package/bin/index.d.ts +38 -6
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +14 -1
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.js +1 -1
- package/bin/plugin/core/ActionScheduleExecutor.js.map +1 -1
- package/bin/plugin/core/BasePlugin.d.ts +7 -9
- package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
- package/bin/plugin/core/BasePlugin.js +1 -14
- package/bin/plugin/core/BasePlugin.js.map +1 -1
- package/bin/plugin/core/HookRegistry.d.ts +1 -1
- package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionFactory.d.ts +1 -5
- package/bin/plugin/core/PluginActionFactory.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionFactory.js +0 -3
- package/bin/plugin/core/PluginActionFactory.js.map +1 -1
- package/bin/plugin/core/PluginActionRunner.d.ts +6 -4
- package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionRunner.js +2 -2
- package/bin/plugin/core/PluginActionRunner.js.map +1 -1
- package/bin/plugin/core/PluginCatalog.d.ts +2 -1
- package/bin/plugin/core/PluginCatalog.d.ts.map +1 -1
- package/bin/plugin/core/PluginCatalog.js.map +1 -1
- package/bin/plugin/core/PluginCommand.d.ts +1 -1
- package/bin/plugin/core/PluginCommand.d.ts.map +1 -1
- package/bin/plugin/core/PluginCommand.js.map +1 -1
- package/bin/plugin/core/PluginHttpRoutes.d.ts +1 -1
- package/bin/plugin/core/PluginHttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.d.ts +4 -1
- package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.js +0 -1
- package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +4 -2
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js +7 -6
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/core/PluginStateController.d.ts +7 -27
- package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
- package/bin/plugin/core/PluginStateController.js +5 -39
- package/bin/plugin/core/PluginStateController.js.map +1 -1
- package/bin/plugin/types/PluginApi.d.ts +3 -79
- package/bin/plugin/types/PluginApi.d.ts.map +1 -1
- package/bin/rpc/Client.d.ts +11 -6
- package/bin/rpc/Client.d.ts.map +1 -1
- package/bin/rpc/Client.js +2 -0
- package/bin/rpc/Client.js.map +1 -1
- package/bin/session/Session.d.ts +2 -5
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +3 -16
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionSystemBuilder.d.ts +1 -1
- package/bin/session/SessionSystemBuilder.d.ts.map +1 -1
- package/bin/session/browse/Browse.d.ts +4 -6
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +71 -71
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/preview/SessionMessagePreview.d.ts +13 -0
- package/bin/session/preview/SessionMessagePreview.d.ts.map +1 -0
- package/bin/session/preview/SessionMessagePreview.js +61 -0
- package/bin/session/preview/SessionMessagePreview.js.map +1 -0
- package/bin/session/runtime/SessionPromptRuntime.d.ts +14 -0
- package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
- package/bin/session/runtime/SessionPromptRuntime.js +11 -0
- package/bin/session/runtime/SessionPromptRuntime.js.map +1 -1
- package/bin/session/services/SessionStateService.d.ts +1 -1
- package/bin/session/services/SessionStateService.d.ts.map +1 -1
- package/bin/session/services/SessionStateService.js +2 -2
- package/bin/session/services/SessionStateService.js.map +1 -1
- package/bin/session/services/SessionTurnService.d.ts.map +1 -1
- package/bin/session/services/SessionTurnService.js +9 -0
- package/bin/session/services/SessionTurnService.js.map +1 -1
- package/bin/session/services/SessionViewService.d.ts +2 -1
- package/bin/session/services/SessionViewService.d.ts.map +1 -1
- package/bin/session/services/SessionViewService.js +4 -1
- package/bin/session/services/SessionViewService.js.map +1 -1
- package/bin/session/storage/Metadata.d.ts.map +1 -1
- package/bin/session/storage/Metadata.js +23 -0
- package/bin/session/storage/Metadata.js.map +1 -1
- package/bin/session/storage/Persistence.d.ts +1 -1
- package/bin/session/storage/Persistence.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +0 -12
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +0 -8
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/types/plugin/PluginAction.d.ts +0 -10
- package/bin/types/plugin/PluginAction.d.ts.map +1 -1
- package/bin/types/plugin/PluginCommand.d.ts +2 -3
- package/bin/types/plugin/PluginCommand.d.ts.map +1 -1
- package/bin/types/plugin/PluginControl.d.ts +74 -0
- package/bin/types/plugin/PluginControl.d.ts.map +1 -0
- package/bin/types/plugin/PluginControl.js +9 -0
- package/bin/types/plugin/PluginControl.js.map +1 -0
- package/bin/types/plugin/PluginDefinition.d.ts +1 -1
- package/bin/types/plugin/PluginDefinition.d.ts.map +1 -1
- package/bin/types/plugin/PluginRuntime.d.ts +1 -3
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/bin/types/plugin/PluginState.d.ts +3 -16
- package/bin/types/plugin/PluginState.d.ts.map +1 -1
- package/bin/types/rpc/RpcProtocol.d.ts +3 -3
- package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
- package/bin/types/runtime/agent/AgentContext.d.ts +1 -9
- package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
- package/bin/types/runtime/agent/AgentContext.js.map +1 -1
- package/bin/types/session/SessionLocalState.d.ts +1 -1
- package/bin/types/session/SessionLocalState.d.ts.map +1 -1
- package/package.json +4 -7
- package/scripts/agent-ready.test.mjs +38 -0
- package/scripts/assistant-file-resource.test.mjs +39 -0
- package/scripts/city-model-tool-loop.test.mjs +18 -30
- package/scripts/image-plugin-job.test.mjs +13 -13
- package/scripts/plugin-tool-bridge.test.mjs +2 -3
- package/scripts/remote-session-reconnect.test.mjs +67 -0
- package/scripts/session-history-writer-error.test.mjs +57 -0
- package/scripts/session-list-title.test.mjs +114 -23
- package/scripts/session-prompt-runtime.test.mjs +22 -0
- package/src/agent/local/Agent.ts +4 -10
- package/src/agent/local/AgentInstructions.ts +1 -1
- package/src/agent/local/services/AgentAssemblyService.ts +3 -9
- package/src/agent/local/services/AgentSessions.ts +8 -15
- package/src/agent/remote/RemoteAgent.ts +5 -4
- package/src/agent/remote/RemoteSession.ts +21 -2
- package/src/agent/remote/RemoteTransport.ts +6 -2
- package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +13 -3
- package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -2
- package/src/executor/Executor.ts +0 -23
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +2 -8
- package/src/executor/composer/history/SessionHistoryWriter.ts +33 -64
- package/src/executor/messages/AssistantFileResource.ts +61 -17
- package/src/executor/services/ExecutorInflightService.ts +0 -10
- package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +130 -4
- package/src/executor/types/SessionHistoryMeta.ts +6 -0
- package/src/index.ts +100 -29
- package/src/plugin/core/ActionScheduleExecutor.ts +1 -1
- package/src/plugin/core/BasePlugin.ts +8 -22
- package/src/plugin/core/HookRegistry.ts +1 -1
- package/src/plugin/core/PluginActionFactory.ts +1 -8
- package/src/plugin/core/PluginActionRunner.ts +8 -11
- package/src/plugin/core/PluginCatalog.ts +2 -5
- package/src/plugin/core/PluginCommand.ts +2 -1
- package/src/plugin/core/PluginHttpRoutes.ts +1 -1
- package/src/plugin/core/PluginLocalExecution.ts +4 -7
- package/src/plugin/core/PluginRegistry.ts +10 -10
- package/src/plugin/core/PluginStateController.ts +12 -60
- package/src/plugin/types/PluginApi.ts +6 -81
- package/src/rpc/Client.ts +22 -16
- package/src/session/Session.ts +5 -21
- package/src/session/SessionSystemBuilder.ts +1 -1
- package/src/session/browse/Browse.ts +103 -84
- package/src/session/preview/SessionMessagePreview.ts +75 -0
- package/src/session/runtime/SessionPromptRuntime.ts +29 -4
- package/src/session/services/SessionStateService.ts +3 -4
- package/src/session/services/SessionTurnService.ts +9 -0
- package/src/session/services/SessionViewService.ts +6 -6
- package/src/session/storage/Metadata.ts +26 -0
- package/src/session/storage/Persistence.ts +1 -1
- package/src/session/storage/RuntimeSessionPort.ts +0 -20
- package/src/types/plugin/PluginAction.ts +0 -10
- package/src/types/plugin/PluginCommand.ts +2 -3
- package/src/types/plugin/PluginControl.ts +80 -0
- package/src/types/plugin/PluginDefinition.ts +1 -1
- package/src/types/plugin/PluginRuntime.ts +1 -3
- package/src/types/plugin/PluginState.ts +3 -20
- package/src/types/rpc/RpcProtocol.ts +4 -4
- package/src/types/runtime/agent/AgentContext.ts +1 -9
- package/src/types/session/SessionLocalState.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/config/DowncitySchema.d.ts +0 -20
- package/bin/config/DowncitySchema.d.ts.map +0 -1
- package/bin/config/DowncitySchema.js +0 -160
- package/bin/config/DowncitySchema.js.map +0 -1
- package/bin/plugin/core/Activation.d.ts +0 -18
- package/bin/plugin/core/Activation.d.ts.map +0 -1
- package/bin/plugin/core/Activation.js +0 -21
- package/bin/plugin/core/Activation.js.map +0 -1
- package/bin/plugin/core/Manager.d.ts +0 -7
- package/bin/plugin/core/Manager.d.ts.map +0 -1
- package/bin/plugin/core/Manager.js +0 -6
- package/bin/plugin/core/Manager.js.map +0 -1
- package/bin/plugin/types/Plugin.d.ts +0 -15
- package/bin/plugin/types/Plugin.d.ts.map +0 -1
- package/bin/plugin/types/Plugin.js +0 -9
- package/bin/plugin/types/Plugin.js.map +0 -1
- package/bin/plugin/types/PluginLifecycle.d.ts +0 -34
- package/bin/plugin/types/PluginLifecycle.d.ts.map +0 -1
- package/bin/plugin/types/PluginLifecycle.js +0 -9
- package/bin/plugin/types/PluginLifecycle.js.map +0 -1
- package/bin/plugin/types/PluginState.d.ts +0 -5
- package/bin/plugin/types/PluginState.d.ts.map +0 -1
- package/bin/plugin/types/PluginState.js +0 -5
- package/bin/plugin/types/PluginState.js.map +0 -1
- package/bin/plugin/types/Plugins.d.ts +0 -61
- package/bin/plugin/types/Plugins.d.ts.map +0 -1
- package/bin/plugin/types/Plugins.js +0 -5
- package/bin/plugin/types/Plugins.js.map +0 -1
- package/bin/session/index.d.ts +0 -15
- package/bin/session/index.d.ts.map +0 -1
- package/bin/session/index.js +0 -15
- package/bin/session/index.js.map +0 -1
- package/bin/types/agent/AgentTypes.d.ts +0 -18
- package/bin/types/agent/AgentTypes.d.ts.map +0 -1
- package/bin/types/agent/AgentTypes.js +0 -10
- package/bin/types/agent/AgentTypes.js.map +0 -1
- package/bin/utils/logger/Format.d.ts +0 -11
- package/bin/utils/logger/Format.d.ts.map +0 -1
- package/bin/utils/logger/Format.js +0 -10
- package/bin/utils/logger/Format.js.map +0 -1
- package/src/config/DowncitySchema.ts +0 -175
- package/src/plugin/core/Activation.ts +0 -26
- package/src/plugin/core/Manager.ts +0 -17
- package/src/plugin/types/Plugin.ts +0 -63
- package/src/plugin/types/PluginLifecycle.ts +0 -35
- package/src/plugin/types/PluginState.ts +0 -12
- package/src/plugin/types/Plugins.ts +0 -67
- package/src/session/index.ts +0 -57
- package/src/types/agent/AgentTypes.ts +0 -58
- package/src/utils/logger/Format.ts +0 -15
|
@@ -98,6 +98,21 @@ export interface SessionPromptRuntimeOptions {
|
|
|
98
98
|
input: AgentSessionPromptInput,
|
|
99
99
|
) => Promise<SessionUserMessageV1>;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* 在 steer message 成功持久化后发送对应 action。
|
|
103
|
+
*/
|
|
104
|
+
emit_steer_action: (input: {
|
|
105
|
+
/**
|
|
106
|
+
* steer message 所属的当前 turn 标识。
|
|
107
|
+
*/
|
|
108
|
+
turn_id: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 已成功持久化的 steer message。
|
|
112
|
+
*/
|
|
113
|
+
message: SessionUserMessageV1;
|
|
114
|
+
}) => Promise<void>;
|
|
115
|
+
|
|
101
116
|
/**
|
|
102
117
|
* 执行单轮 turn。
|
|
103
118
|
*/
|
|
@@ -126,6 +141,7 @@ export class SessionPromptRuntime {
|
|
|
126
141
|
private readonly sessionId: string;
|
|
127
142
|
private readonly publish: SessionPromptRuntimeOptions["publish"];
|
|
128
143
|
private readonly createAndPersistUserMessage: SessionPromptRuntimeOptions["createAndPersistUserMessage"];
|
|
144
|
+
private readonly emit_steer_action: SessionPromptRuntimeOptions["emit_steer_action"];
|
|
129
145
|
private readonly executeTurn: SessionPromptRuntimeOptions["executeTurn"];
|
|
130
146
|
private readonly stopTurn: SessionPromptRuntimeOptions["stopTurn"];
|
|
131
147
|
private readonly queue: QueuedPrompt[] = [];
|
|
@@ -136,6 +152,7 @@ export class SessionPromptRuntime {
|
|
|
136
152
|
this.sessionId = String(options.sessionId || "").trim();
|
|
137
153
|
this.publish = options.publish;
|
|
138
154
|
this.createAndPersistUserMessage = options.createAndPersistUserMessage;
|
|
155
|
+
this.emit_steer_action = options.emit_steer_action;
|
|
139
156
|
this.executeTurn = options.executeTurn;
|
|
140
157
|
this.stopTurn = options.stopTurn;
|
|
141
158
|
if (!this.sessionId) {
|
|
@@ -329,12 +346,20 @@ export class SessionPromptRuntime {
|
|
|
329
346
|
const merged: SessionUserMessageV1[] = [];
|
|
330
347
|
|
|
331
348
|
for (let index = 0; index < drained.length; index += 1) {
|
|
332
|
-
|
|
349
|
+
const item = drained[index];
|
|
350
|
+
try {
|
|
351
|
+
const message = await this.createAndPersistUserMessage(item.input);
|
|
352
|
+
item.deferredHandle.resolve(createTurnHandle(activeTurn));
|
|
353
|
+
merged.push(message);
|
|
333
354
|
try {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
355
|
+
await this.emit_steer_action({
|
|
356
|
+
turn_id: activeTurn.turnId,
|
|
357
|
+
message,
|
|
358
|
+
});
|
|
337
359
|
} catch {
|
|
360
|
+
// action 发送失败不应阻断已经持久化的 steer message。
|
|
361
|
+
}
|
|
362
|
+
} catch {
|
|
338
363
|
// 关键点(中文):若某条消息持久化失败,把未处理部分重新放回队列头部,避免静默丢失。
|
|
339
364
|
const remaining = drained.slice(index);
|
|
340
365
|
this.queue.unshift(...remaining);
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
patchSessionModelLabel,
|
|
16
16
|
readSessionMetadata,
|
|
17
17
|
resolveSystemTimezone,
|
|
18
|
-
touchSessionMetadata,
|
|
19
18
|
writeSessionMetadata,
|
|
20
|
-
} from "@/session/
|
|
19
|
+
} from "@/session/storage/Metadata.js";
|
|
20
|
+
import { touchSessionMetadata } from "@/session/storage/Persistence.js";
|
|
21
21
|
import { ensureSessionTitle } from "@/session/SessionTitle.js";
|
|
22
22
|
import { persistSdkAssistantResult } from "@/session/storage/Persistence.js";
|
|
23
23
|
import { hydrateUserPromptFileParts } from "@executor/messages/SessionAttachmentMapper.js";
|
|
@@ -26,7 +26,7 @@ import type { JsonlSessionHistoryStore } from "@/executor/store/history/jsonl/Js
|
|
|
26
26
|
import type {
|
|
27
27
|
AgentSessionConfigSnapshot,
|
|
28
28
|
AgentSessionSetInput,
|
|
29
|
-
} from "@/types/agent/
|
|
29
|
+
} from "@/types/agent/SessionTypes.js";
|
|
30
30
|
import type {
|
|
31
31
|
AgentSessionEvent,
|
|
32
32
|
} from "@/types/sdk/AgentSessionEvent.js";
|
|
@@ -259,7 +259,6 @@ export class SessionStateService {
|
|
|
259
259
|
if (input.model) {
|
|
260
260
|
this.state.sessionConfig.model = normalizeAgentModel(input.model);
|
|
261
261
|
this.state.sessionConfig.modelLabel = next_model_label;
|
|
262
|
-
this.executor.clearExecutor();
|
|
263
262
|
}
|
|
264
263
|
await patchSessionModelLabel({
|
|
265
264
|
projectRoot: this.project_root,
|
|
@@ -83,6 +83,15 @@ export class SessionTurnService {
|
|
|
83
83
|
input,
|
|
84
84
|
);
|
|
85
85
|
},
|
|
86
|
+
emit_steer_action: async ({ turn_id, message }) => {
|
|
87
|
+
await this.state_service.emit_action_event({
|
|
88
|
+
id: `steer-message:${message.id}`,
|
|
89
|
+
title: "Session steer message sent",
|
|
90
|
+
description: "Merged a new user message into the active turn.",
|
|
91
|
+
state: "completed",
|
|
92
|
+
turnId: turn_id,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
86
95
|
executeTurn: async ({ turnId, promptInput, onStepMerge, abortSignal }) => {
|
|
87
96
|
return await this.execute_prompt_turn({
|
|
88
97
|
turnId,
|
|
@@ -11,11 +11,11 @@ import { nanoid } from "nanoid";
|
|
|
11
11
|
import {
|
|
12
12
|
buildSessionRecordsPage,
|
|
13
13
|
buildSessionInfo,
|
|
14
|
-
getSdkAgentSessionArchiveFilePath,
|
|
15
|
-
ensureSessionTitle,
|
|
16
14
|
loadSessionArchiveMessagesFromPath,
|
|
17
|
-
|
|
18
|
-
} from "@/session/
|
|
15
|
+
} from "@/session/browse/Browse.js";
|
|
16
|
+
import { getSdkAgentSessionArchiveFilePath } from "@/session/storage/Paths.js";
|
|
17
|
+
import { ensureSessionTitle } from "@/session/SessionTitle.js";
|
|
18
|
+
import { readSessionMetadata } from "@/session/storage/Metadata.js";
|
|
19
19
|
import { buildSessionSystemBlocks } from "@/session/SessionSystemBuilder.js";
|
|
20
20
|
import type { JsonlSessionHistoryStore } from "@/executor/store/history/jsonl/JsonlSessionHistoryStore.js";
|
|
21
21
|
import type { SessionSystemComposer } from "@/executor/composer/system/SessionSystemComposer.js";
|
|
@@ -24,10 +24,10 @@ import type {
|
|
|
24
24
|
AgentSessionRecordsInput,
|
|
25
25
|
AgentSessionRecordsPage,
|
|
26
26
|
AgentSessionInfo,
|
|
27
|
-
AgentSession,
|
|
28
27
|
AgentSessionSystemBlock,
|
|
29
28
|
AgentSessionSystemSnapshot,
|
|
30
|
-
} from "@/types/agent/
|
|
29
|
+
} from "@/types/agent/SessionTypes.js";
|
|
30
|
+
import type { AgentSession } from "@/types/agent/SessionActor.js";
|
|
31
31
|
import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
|
|
32
32
|
import { SessionStateService } from "@/session/services/SessionStateService.js";
|
|
33
33
|
import type { SessionRunContext } from "@/types/executor/SessionRunContext.js";
|
|
@@ -56,6 +56,23 @@ function normalizeTimezone(input: unknown): string | undefined {
|
|
|
56
56
|
return timezone || undefined;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function normalize_message_count(input: unknown): number | undefined {
|
|
60
|
+
return typeof input === "number" && Number.isInteger(input) && input >= 0
|
|
61
|
+
? input
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function normalize_preview_text(input: unknown): string | undefined {
|
|
66
|
+
const preview_text = typeof input === "string" ? input.trim() : "";
|
|
67
|
+
return preview_text || undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalize_history_bytes(input: unknown): number | undefined {
|
|
71
|
+
return typeof input === "number" && Number.isInteger(input) && input >= 0
|
|
72
|
+
? input
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
/**
|
|
60
77
|
* 从模型实例推导轻量可读标签。
|
|
61
78
|
*/
|
|
@@ -136,6 +153,15 @@ export async function readSessionMetadataFromPath(input: {
|
|
|
136
153
|
...(normalizeModelLabel(raw.modelLabel)
|
|
137
154
|
? { modelLabel: normalizeModelLabel(raw.modelLabel) }
|
|
138
155
|
: {}),
|
|
156
|
+
...(normalize_message_count(raw.messageCount) !== undefined
|
|
157
|
+
? { messageCount: normalize_message_count(raw.messageCount) }
|
|
158
|
+
: {}),
|
|
159
|
+
...(normalize_preview_text(raw.previewText)
|
|
160
|
+
? { previewText: normalize_preview_text(raw.previewText) }
|
|
161
|
+
: {}),
|
|
162
|
+
...(normalize_history_bytes(raw.historyBytes) !== undefined
|
|
163
|
+
? { historyBytes: normalize_history_bytes(raw.historyBytes) }
|
|
164
|
+
: {}),
|
|
139
165
|
};
|
|
140
166
|
} catch {
|
|
141
167
|
return {
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
SessionMessageRecordV1,
|
|
14
14
|
} from "@/executor/types/SessionRecords.js";
|
|
15
15
|
import { persistAssistantResult } from "@/executor/messages/AssistantResultPersistence.js";
|
|
16
|
-
import type { AgentSessionConfigSnapshot } from "@/types/agent/
|
|
16
|
+
import type { AgentSessionConfigSnapshot } from "@/types/agent/SessionTypes.js";
|
|
17
17
|
import {
|
|
18
18
|
readSessionMetadata,
|
|
19
19
|
writeSessionMetadata,
|
|
@@ -47,14 +47,6 @@ export interface CreateRuntimeSessionPortParams {
|
|
|
47
47
|
* 发布一条 session runtime 事件。
|
|
48
48
|
*/
|
|
49
49
|
publishEvent: (event: AgentSessionEvent) => void;
|
|
50
|
-
/**
|
|
51
|
-
* 清理当前 session executor 状态。
|
|
52
|
-
*/
|
|
53
|
-
clearExecutor: () => void;
|
|
54
|
-
/**
|
|
55
|
-
* session 更新后的异步通知回调。
|
|
56
|
-
*/
|
|
57
|
-
afterSessionUpdatedAsync: () => Promise<void>;
|
|
58
50
|
/**
|
|
59
51
|
* 追加 user 消息到底层历史。
|
|
60
52
|
*/
|
|
@@ -75,10 +67,6 @@ export interface CreateRuntimeSessionPortParams {
|
|
|
75
67
|
* 在执行前确保当前 session 已完成初始化与宿主级配置。
|
|
76
68
|
*/
|
|
77
69
|
ensureReadyForExecution: () => Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* session 更新后需要同步执行的持久化回调。
|
|
80
|
-
*/
|
|
81
|
-
touchMetadata: () => Promise<void>;
|
|
82
70
|
}
|
|
83
71
|
|
|
84
72
|
/**
|
|
@@ -105,19 +93,11 @@ export function createRuntimeSessionPort(
|
|
|
105
93
|
publishEvent: (event) => {
|
|
106
94
|
params.publishEvent(event);
|
|
107
95
|
},
|
|
108
|
-
clearExecutor: () => {
|
|
109
|
-
params.clearExecutor();
|
|
110
|
-
},
|
|
111
|
-
afterSessionUpdatedAsync: async () => {
|
|
112
|
-
await params.afterSessionUpdatedAsync();
|
|
113
|
-
},
|
|
114
96
|
append_user_message: async (messageParams) => {
|
|
115
97
|
await params.append_user_message(messageParams);
|
|
116
|
-
await params.touchMetadata();
|
|
117
98
|
},
|
|
118
99
|
append_assistant_message: async (messageParams) => {
|
|
119
100
|
await params.append_assistant_message(messageParams);
|
|
120
|
-
await params.touchMetadata();
|
|
121
101
|
},
|
|
122
102
|
isExecuting: () => params.isExecuting(),
|
|
123
103
|
};
|
|
@@ -139,14 +139,6 @@ export interface PluginAction<
|
|
|
139
139
|
P extends JsonValue = JsonValue,
|
|
140
140
|
R extends JsonValue = JsonValue,
|
|
141
141
|
> extends PluginActionMetadata<P> {
|
|
142
|
-
/**
|
|
143
|
-
* disabled 状态下是否仍允许执行。
|
|
144
|
-
*
|
|
145
|
-
* 说明(中文)
|
|
146
|
-
* - 用于 `on` / `status` / `models` / `configure` / `install` 这类 setup 相关 action。
|
|
147
|
-
* - 默认 false,避免 disabled plugin 绕过 registry 保护执行普通业务 action。
|
|
148
|
-
*/
|
|
149
|
-
allowWhenDisabled?: boolean;
|
|
150
142
|
/** CLI 定义(可选)。 */
|
|
151
143
|
command?: PluginActionCommand<P>;
|
|
152
144
|
/** HTTP 定义(可选)。 */
|
|
@@ -155,8 +147,6 @@ export interface PluginAction<
|
|
|
155
147
|
execute: (params: {
|
|
156
148
|
/** 当前执行上下文。 */
|
|
157
149
|
context: AgentContext;
|
|
158
|
-
/** 输入 payload。 */
|
|
159
|
-
payload: P;
|
|
160
150
|
/** 已通过 schema 校验后的输入。 */
|
|
161
151
|
input: P;
|
|
162
152
|
/** 当前插件名称。 */
|
|
@@ -71,11 +71,10 @@ export interface PluginCommandResult {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Plugin
|
|
74
|
+
* Plugin 生命周期定义。
|
|
75
75
|
*
|
|
76
76
|
* 关键点(中文)
|
|
77
|
-
* -
|
|
78
|
-
* - 新代码优先直接实现 `start/stop/command`。
|
|
77
|
+
* - 生命周期只描述 plugin 启动、停止和非 action 命令处理。
|
|
79
78
|
*/
|
|
80
79
|
export interface PluginLifecycle {
|
|
81
80
|
/** plugin 启动钩子。 */
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin 控制面协议类型。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - CLI、HTTP 与 RPC 共用同一套 plugin 控制请求和响应结构。
|
|
6
|
+
* - 状态数据统一复用 `PluginSnapshot`,不再复制字段或保留旧别名。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { JsonValue } from "@/types/common/Json.js";
|
|
10
|
+
import type { PluginControlAction, PluginSnapshot } from "@/types/plugin/PluginState.js";
|
|
11
|
+
|
|
12
|
+
export type { PluginControlAction } from "@/types/plugin/PluginState.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* plugin 状态列表响应。
|
|
16
|
+
*/
|
|
17
|
+
export type PluginStateListResponse = {
|
|
18
|
+
/** 请求是否成功。 */
|
|
19
|
+
success: boolean;
|
|
20
|
+
/** 当前已注册 plugin 快照。 */
|
|
21
|
+
plugins?: PluginSnapshot[];
|
|
22
|
+
/** 失败原因。 */
|
|
23
|
+
error?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 单个 plugin 控制响应。
|
|
28
|
+
*/
|
|
29
|
+
export type PluginControlResponse = {
|
|
30
|
+
/** 请求是否成功。 */
|
|
31
|
+
success: boolean;
|
|
32
|
+
/** 当前 plugin 快照。 */
|
|
33
|
+
plugin?: PluginSnapshot;
|
|
34
|
+
/** 失败原因。 */
|
|
35
|
+
error?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* plugin command/action 执行响应。
|
|
40
|
+
*/
|
|
41
|
+
export type PluginCommandResponse = {
|
|
42
|
+
/** 调用是否成功。 */
|
|
43
|
+
success: boolean;
|
|
44
|
+
/** 当前 plugin 快照。 */
|
|
45
|
+
plugin?: PluginSnapshot;
|
|
46
|
+
/** 人类可读结果。 */
|
|
47
|
+
message?: string;
|
|
48
|
+
/** 结构化结果。 */
|
|
49
|
+
data?: JsonValue;
|
|
50
|
+
/** 失败原因。 */
|
|
51
|
+
error?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* plugin CLI 通用选项。
|
|
56
|
+
*/
|
|
57
|
+
export type PluginCliBaseOptions = {
|
|
58
|
+
/** agent 项目路径。 */
|
|
59
|
+
path?: string;
|
|
60
|
+
/** 目标 agent 标识。 */
|
|
61
|
+
agent?: string;
|
|
62
|
+
/** HTTP 主机。 */
|
|
63
|
+
host?: string;
|
|
64
|
+
/** HTTP 端口。 */
|
|
65
|
+
port?: number;
|
|
66
|
+
/** 控制面认证令牌。 */
|
|
67
|
+
token?: string;
|
|
68
|
+
/** 是否输出 JSON。 */
|
|
69
|
+
json?: boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* plugin 控制请求。
|
|
74
|
+
*/
|
|
75
|
+
export type PluginControlRequest = {
|
|
76
|
+
/** 目标 plugin 名称。 */
|
|
77
|
+
plugin_name: string;
|
|
78
|
+
/** 控制动作。 */
|
|
79
|
+
action: PluginControlAction;
|
|
80
|
+
};
|
|
@@ -63,7 +63,7 @@ export interface Plugin {
|
|
|
63
63
|
resolves?: PluginResolves;
|
|
64
64
|
/** Plugin system 文本构建器(可选)。 */
|
|
65
65
|
system?: (context: AgentContext) => string | Promise<string>;
|
|
66
|
-
/**
|
|
66
|
+
/** Plugin 生命周期定义(可选)。 */
|
|
67
67
|
lifecycle?: PluginLifecycle;
|
|
68
68
|
/** Plugin 可用性检查器(可选)。 */
|
|
69
69
|
availability?: (
|
|
@@ -14,7 +14,7 @@ import type { JsonValue } from "@/types/common/Json.js";
|
|
|
14
14
|
import type { PluginActionResult } from "@/types/plugin/PluginAction.js";
|
|
15
15
|
import type { PluginActionExample } from "@/types/plugin/PluginAction.js";
|
|
16
16
|
import type { Plugin } from "@/types/plugin/PluginDefinition.js";
|
|
17
|
-
import type { AgentSessionSystemBlock } from "@/types/agent/
|
|
17
|
+
import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
|
|
18
18
|
import type { PluginSnapshot } from "@/types/plugin/PluginState.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -57,8 +57,6 @@ export interface PluginActionReadView {
|
|
|
57
57
|
input_schema?: JsonValue;
|
|
58
58
|
/** Action 调用示例。 */
|
|
59
59
|
examples?: PluginActionExample[];
|
|
60
|
-
/** disabled 状态下是否仍允许执行。 */
|
|
61
|
-
allow_when_disabled: boolean;
|
|
62
60
|
/** 是否声明 CLI command。 */
|
|
63
61
|
has_command: boolean;
|
|
64
62
|
/** 是否声明 HTTP API。 */
|
|
@@ -46,40 +46,23 @@ export interface PluginSnapshot {
|
|
|
46
46
|
description: string;
|
|
47
47
|
/** 当前注册后的可用状态。 */
|
|
48
48
|
status: PluginState;
|
|
49
|
-
/** 兼容旧字段的状态别名。 */
|
|
50
|
-
state: PluginState;
|
|
51
49
|
/** 注册时间(毫秒时间戳)。 */
|
|
52
50
|
registered_at: number;
|
|
53
51
|
/** 最近更新时间(毫秒时间戳)。 */
|
|
54
52
|
updated_at: number;
|
|
55
|
-
/** 兼容旧字段的最近更新时间。 */
|
|
56
|
-
updatedAt: number;
|
|
57
53
|
/** 最近错误。 */
|
|
58
54
|
last_error?: string;
|
|
59
|
-
/** 兼容旧字段的最近错误。 */
|
|
60
|
-
lastError?: string;
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
|
-
*
|
|
65
|
-
*/
|
|
66
|
-
export type PluginStateSnapshot = PluginSnapshot;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 兼容旧控制动作类型。
|
|
70
|
-
*
|
|
71
|
-
* 说明(中文)
|
|
72
|
-
* - 控制面只保留状态查询与卸载。
|
|
58
|
+
* Plugin 控制动作。
|
|
73
59
|
*/
|
|
74
|
-
export type
|
|
75
|
-
| "register"
|
|
76
|
-
| "unregister"
|
|
77
|
-
| "status";
|
|
60
|
+
export type PluginControlAction = "unregister" | "status";
|
|
78
61
|
|
|
79
62
|
/**
|
|
80
63
|
* plugin 控制结果。
|
|
81
64
|
*/
|
|
82
|
-
export interface
|
|
65
|
+
export interface PluginControlResult {
|
|
83
66
|
/** 控制动作是否成功。 */
|
|
84
67
|
success: boolean;
|
|
85
68
|
/** 成功或失败后返回的最新 plugin 快照。 */
|
|
@@ -16,13 +16,13 @@ import type {
|
|
|
16
16
|
AgentArchiveSessionsResult,
|
|
17
17
|
AgentCleanArchiveResult,
|
|
18
18
|
AgentSessionRecordsInput,
|
|
19
|
-
AgentSessionStopResult,
|
|
20
19
|
AgentSessionSystemSnapshot,
|
|
21
|
-
} from "@/types/agent/
|
|
20
|
+
} from "@/types/agent/SessionTypes.js";
|
|
22
21
|
import type { AgentSessionEvent } from "@/types/sdk/AgentSessionEvent.js";
|
|
23
22
|
import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
|
|
23
|
+
import type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
|
|
24
24
|
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
25
|
-
import type {
|
|
25
|
+
import type { PluginControlAction } from "@/types/plugin/PluginState.js";
|
|
26
26
|
import type { ShellApprovalMode } from "@downcity/shell";
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -229,7 +229,7 @@ export type RpcRequest =
|
|
|
229
229
|
/** plugin 名称。 */
|
|
230
230
|
pluginName: string;
|
|
231
231
|
/** 控制动作。 */
|
|
232
|
-
action:
|
|
232
|
+
action: PluginControlAction;
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
| {
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
} from "@/types/agent/AgentRuntimeAssembly.js";
|
|
16
16
|
import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
|
|
17
17
|
import type { JsonValue } from "@/types/common/Json.js";
|
|
18
|
-
import type { AgentPlugins } from "@/plugin/
|
|
18
|
+
import type { AgentPlugins } from "@/types/plugin/PluginRuntime.js";
|
|
19
19
|
import type { Plugin } from "@/types/plugin/PluginDefinition.js";
|
|
20
20
|
import type {
|
|
21
21
|
SessionMetadataV1,
|
|
@@ -144,14 +144,6 @@ export interface SessionPort {
|
|
|
144
144
|
* - 历史消息持久化仍由 append_user_message / append_assistant_message 负责。
|
|
145
145
|
*/
|
|
146
146
|
publishEvent(event: AgentSessionEvent): void;
|
|
147
|
-
/**
|
|
148
|
-
* 清理当前 session 的 executor 缓存。
|
|
149
|
-
*/
|
|
150
|
-
clearExecutor(): void;
|
|
151
|
-
/**
|
|
152
|
-
* 当前 session 更新后的异步通知钩子。
|
|
153
|
-
*/
|
|
154
|
-
afterSessionUpdatedAsync(): Promise<void>;
|
|
155
147
|
/**
|
|
156
148
|
* 追加一条 user 消息。
|
|
157
149
|
*/
|