@downcity/agent 1.1.199 → 1.1.202
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 -7
- package/bin/agent/local/Agent.d.ts.map +1 -1
- package/bin/agent/local/Agent.js +14 -19
- package/bin/agent/local/Agent.js.map +1 -1
- package/bin/agent/local/services/{AgentSessionManager.d.ts → AgentSessions.d.ts} +12 -17
- package/bin/agent/local/services/AgentSessions.d.ts.map +1 -0
- package/bin/agent/local/services/{AgentSessionManager.js → AgentSessions.js} +11 -26
- package/bin/agent/local/services/AgentSessions.js.map +1 -0
- package/bin/agent/remote/RemoteAgent.d.ts +2 -9
- package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
- package/bin/agent/remote/RemoteAgent.js +40 -22
- package/bin/agent/remote/RemoteAgent.js.map +1 -1
- package/bin/agent/remote/RemoteSession.d.ts +5 -5
- package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
- package/bin/agent/remote/RemoteSession.js +5 -3
- package/bin/agent/remote/RemoteSession.js.map +1 -1
- package/bin/agent/remote/RemoteTransport.d.ts +2 -2
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +2 -2
- package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +5 -5
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +2 -2
- package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +2 -2
- package/bin/executor/Executor.d.ts +7 -7
- package/bin/executor/Executor.d.ts.map +1 -1
- package/bin/executor/Executor.js +41 -33
- package/bin/executor/Executor.js.map +1 -1
- package/bin/executor/SessionRunScope.d.ts +1 -1
- package/bin/executor/SessionRunScope.d.ts.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 +4 -5
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +73 -40
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts +27 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts.map +1 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js +181 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js.map +1 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts +45 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts.map +1 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js +144 -0
- package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js.map +1 -0
- package/bin/executor/composer/context/LocalSessionContextComposer.d.ts +3 -3
- package/bin/executor/composer/context/LocalSessionContextComposer.d.ts.map +1 -1
- package/bin/executor/composer/context/SessionContextComposer.d.ts +3 -3
- package/bin/executor/composer/context/SessionContextComposer.d.ts.map +1 -1
- package/bin/executor/composer/history/SessionHistoryComposer.d.ts +2 -2
- package/bin/executor/composer/history/SessionHistoryComposer.d.ts.map +1 -1
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts +5 -5
- package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
- package/bin/executor/composer/history/SessionHistoryWriter.js +6 -6
- package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +2 -2
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +5 -4
- package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts +5 -5
- package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.d.ts +4 -4
- package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +3 -3
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -1
- package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +1 -1
- package/bin/executor/messages/AssistantResultPersistence.d.ts +5 -5
- package/bin/executor/messages/AssistantResultPersistence.d.ts.map +1 -1
- package/bin/executor/messages/AssistantResultPersistence.js +1 -1
- package/bin/executor/messages/AssistantResultPersistence.js.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.d.ts +3 -3
- package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
- package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
- package/bin/executor/messages/SessionMessageCodec.d.ts +4 -4
- package/bin/executor/messages/SessionMessageCodec.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageCodec.js +5 -5
- package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
- package/bin/executor/messages/SessionMessageLog.d.ts +3 -3
- package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
- package/bin/executor/messages/SessionMessageLog.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/messages/UserVisibleText.d.ts +3 -3
- package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
- package/bin/executor/messages/UserVisibleText.js +3 -3
- package/bin/executor/messages/UserVisibleText.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 +11 -7
- package/bin/executor/services/ExecutorInflightService.js.map +1 -1
- package/bin/executor/store/history/SessionHistoryStore.d.ts +30 -27
- package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/SessionHistoryStore.js +3 -3
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +21 -20
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +114 -72
- package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +1 -7
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.d.ts +4 -6
- package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.js +24 -10
- package/bin/executor/tools/plugin/PluginToolSchemas.js.map +1 -1
- package/bin/executor/types/SessionRecords.d.ts +162 -0
- package/bin/executor/types/SessionRecords.d.ts.map +1 -0
- package/bin/executor/types/SessionRecords.js +52 -0
- package/bin/executor/types/SessionRecords.js.map +1 -0
- package/bin/executor/types/SessionRun.d.ts +3 -3
- package/bin/executor/types/SessionRun.d.ts.map +1 -1
- package/bin/index.d.ts +2 -2
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js.map +1 -1
- package/bin/rpc/Client.d.ts +5 -5
- package/bin/rpc/Client.js +4 -4
- package/bin/session/Session.d.ts +6 -6
- package/bin/session/Session.d.ts.map +1 -1
- package/bin/session/Session.js +8 -8
- package/bin/session/Session.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +2 -2
- 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 +12 -12
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +37 -34
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/index.d.ts +1 -1
- package/bin/session/index.js +1 -1
- package/bin/session/runtime/SessionPromptRuntime.d.ts +3 -3
- package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
- package/bin/session/services/SessionStateService.d.ts +11 -12
- package/bin/session/services/SessionStateService.d.ts.map +1 -1
- package/bin/session/services/SessionStateService.js +43 -69
- 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 +4 -4
- package/bin/session/services/SessionViewService.d.ts.map +1 -1
- package/bin/session/services/SessionViewService.js +26 -36
- package/bin/session/services/SessionViewService.js.map +1 -1
- package/bin/session/storage/Persistence.d.ts +4 -4
- package/bin/session/storage/Persistence.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.d.ts +2 -2
- package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
- package/bin/session/storage/RuntimeSessionPort.js +4 -4
- package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
- package/bin/types/agent/AgentTypes.d.ts +2 -2
- package/bin/types/agent/AgentTypes.d.ts.map +1 -1
- package/bin/types/agent/SessionActor.d.ts +11 -11
- package/bin/types/agent/SessionActor.d.ts.map +1 -1
- package/bin/types/agent/SessionTypes.d.ts +22 -22
- package/bin/types/agent/SessionTypes.d.ts.map +1 -1
- package/bin/types/executor/SessionRunContext.d.ts +7 -7
- package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
- package/bin/types/rpc/RpcProtocol.d.ts +6 -6
- package/bin/types/runtime/agent/AgentContext.d.ts +7 -7
- package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
- package/bin/types/sdk/AgentSessionAction.d.ts +26 -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/bin/types/sdk/AgentSessionTurn.d.ts +2 -2
- package/bin/types/sdk/AgentSessionTurn.d.ts.map +1 -1
- package/package.json +3 -3
- package/scripts/agent-ready.test.mjs +1 -1
- package/scripts/city-model-tool-loop.test.mjs +36 -4
- package/scripts/plugin-tool-bridge.test.mjs +13 -0
- package/scripts/session-action-message.test.mjs +199 -0
- package/scripts/session-compaction-prompts.test.mjs +97 -0
- package/scripts/session-history-archive.test.mjs +8 -8
- package/scripts/session-history-inflight.test.mjs +10 -10
- package/scripts/session-list-title.test.mjs +9 -9
- package/scripts/session-title-event.test.mjs +12 -10
- package/src/agent/local/Agent.ts +16 -22
- package/src/agent/local/services/{AgentSessionManager.ts → AgentSessions.ts} +16 -32
- package/src/agent/remote/RemoteAgent.ts +58 -23
- package/src/agent/remote/RemoteSession.ts +10 -8
- package/src/agent/remote/RemoteTransport.ts +5 -5
- package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +10 -10
- package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -6
- package/src/executor/Executor.ts +51 -41
- package/src/executor/SessionRunScope.ts +1 -1
- 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 +91 -52
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.ts +197 -0
- package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.ts +162 -0
- package/src/executor/composer/context/LocalSessionContextComposer.ts +5 -5
- package/src/executor/composer/context/SessionContextComposer.ts +5 -5
- package/src/executor/composer/history/SessionHistoryComposer.ts +2 -2
- package/src/executor/composer/history/SessionHistoryWriter.ts +10 -10
- package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +13 -10
- package/src/executor/core-engine/CoreEngineMessageState.ts +8 -8
- package/src/executor/core-engine/CoreEngineRunner.ts +7 -7
- package/src/executor/core-engine/CoreEngineSignals.ts +7 -7
- package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +5 -5
- package/src/executor/messages/AssistantResultPersistence.ts +8 -8
- package/src/executor/messages/SessionAttachmentMapper.ts +11 -11
- package/src/executor/messages/SessionMessageCodec.ts +10 -10
- package/src/executor/messages/SessionMessageLog.ts +3 -3
- package/src/executor/messages/SessionStepEventMapper.ts +5 -5
- package/src/executor/messages/UserVisibleText.ts +9 -9
- package/src/executor/services/ExecutorInflightService.ts +13 -9
- package/src/executor/store/history/SessionHistoryStore.ts +32 -28
- package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +146 -95
- package/src/executor/tools/plugin/PluginToolSchemas.ts +24 -10
- package/src/executor/types/SessionRecords.ts +217 -0
- package/src/executor/types/SessionRun.ts +5 -5
- package/src/index.ts +9 -10
- package/src/rpc/Client.ts +9 -9
- package/src/session/Session.ts +10 -10
- package/src/session/SessionTitle.ts +7 -4
- package/src/session/browse/Browse.ts +66 -58
- package/src/session/index.ts +1 -1
- package/src/session/runtime/SessionPromptRuntime.ts +6 -6
- package/src/session/services/SessionStateService.ts +61 -86
- package/src/session/services/SessionTurnService.ts +7 -7
- package/src/session/services/SessionViewService.ts +35 -45
- package/src/session/storage/Persistence.ts +6 -6
- package/src/session/storage/RuntimeSessionPort.ts +6 -6
- package/src/types/agent/AgentTypes.ts +4 -4
- package/src/types/agent/SessionActor.ts +12 -12
- package/src/types/agent/SessionTypes.ts +22 -22
- package/src/types/executor/SessionRunContext.ts +12 -12
- package/src/types/rpc/RpcProtocol.ts +6 -6
- package/src/types/runtime/agent/AgentContext.ts +8 -8
- package/src/types/sdk/AgentSessionAction.ts +35 -0
- package/src/types/sdk/AgentSessionEvent.ts +2 -2
- package/src/types/sdk/AgentSessionTurn.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/agent/local/services/AgentSessionManager.d.ts.map +0 -1
- package/bin/agent/local/services/AgentSessionManager.js.map +0 -1
- package/bin/executor/types/SessionMessages.d.ts +0 -118
- package/bin/executor/types/SessionMessages.d.ts.map +0 -1
- package/bin/executor/types/SessionMessages.js +0 -28
- package/bin/executor/types/SessionMessages.js.map +0 -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/scripts/session-operation-message.test.mjs +0 -197
- package/src/executor/types/SessionMessages.ts +0 -148
- package/src/types/sdk/AgentSessionOperation.ts +0 -125
|
@@ -5,25 +5,25 @@
|
|
|
5
5
|
* - 这里只描述 session 的可调用能力。
|
|
6
6
|
* - session 的数据结构、history/system payload 放在 `SessionTypes.ts`。
|
|
7
7
|
*/
|
|
8
|
-
import type { AgentCreateSessionInput, AgentArchiveSessionInput, AgentArchiveSessionsInput, AgentArchiveSessionResult, AgentArchiveSessionsResult, AgentCleanArchiveResult, AgentListSessionsInput, AgentSessionConfigSnapshot, AgentSessionForkInput,
|
|
8
|
+
import type { AgentCreateSessionInput, AgentArchiveSessionInput, AgentArchiveSessionsInput, AgentArchiveSessionResult, AgentArchiveSessionsResult, AgentCleanArchiveResult, AgentListSessionsInput, AgentSessionConfigSnapshot, AgentSessionForkInput, AgentSessionRecordsInput, AgentSessionRecordsPage, AgentSessionInfo, AgentSessionSetInput, AgentSessionSummaryPage, AgentSessionSystemSnapshot } from "../../types/agent/SessionTypes.js";
|
|
9
9
|
import type { AgentSessionSubscriber, AgentSessionUnsubscribe } from "../../types/sdk/AgentSessionEvent.js";
|
|
10
10
|
import type { AgentSessionPromptInput } from "../../types/sdk/AgentSessionPrompt.js";
|
|
11
11
|
import type { AgentSessionStopResult } from "../../types/sdk/AgentSessionStop.js";
|
|
12
12
|
import type { AgentSessionTurnHandle } from "../../types/sdk/AgentSessionTurn.js";
|
|
13
13
|
/**
|
|
14
|
-
* SDK Session
|
|
14
|
+
* SDK Session 集合入口。
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface AgentSessions<TSession extends AgentSessionActor = AgentSession> {
|
|
17
17
|
/** 新建一个 session。 */
|
|
18
|
-
|
|
18
|
+
create(input?: AgentCreateSessionInput): Promise<TSession>;
|
|
19
19
|
/** 获取一个已存在的 session。 */
|
|
20
|
-
|
|
20
|
+
get(session_id: string): Promise<TSession>;
|
|
21
21
|
/** 列出当前 agent 的 session 摘要页。 */
|
|
22
|
-
|
|
22
|
+
list(input?: AgentListSessionsInput): Promise<AgentSessionSummaryPage>;
|
|
23
23
|
/** 归档单个 session。 */
|
|
24
|
-
|
|
24
|
+
archive(input: AgentArchiveSessionInput): Promise<AgentArchiveSessionResult>;
|
|
25
25
|
/** 列出已归档的 session 摘要页。 */
|
|
26
|
-
|
|
26
|
+
archived(input?: AgentArchiveSessionsInput): Promise<AgentArchiveSessionsResult>;
|
|
27
27
|
/** 永久清空已归档 session。 */
|
|
28
28
|
clean_archive(): Promise<AgentCleanArchiveResult>;
|
|
29
29
|
}
|
|
@@ -34,15 +34,15 @@ export interface AgentSessionActor {
|
|
|
34
34
|
/** 当前 session 稳定标识。 */
|
|
35
35
|
readonly id: string;
|
|
36
36
|
/** 读取当前 session 详情。 */
|
|
37
|
-
|
|
37
|
+
get_info(): Promise<AgentSessionInfo>;
|
|
38
38
|
/** 追加一条新的 prompt。 */
|
|
39
39
|
prompt(input: AgentSessionPromptInput): Promise<AgentSessionTurnHandle>;
|
|
40
40
|
/** 停止当前 turn,并取消尚未被吸收的排队 prompt。 */
|
|
41
41
|
stop(): Promise<AgentSessionStopResult>;
|
|
42
42
|
/** 订阅当前 session 的未来事件。 */
|
|
43
43
|
subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
|
|
44
|
-
/** 读取当前 session
|
|
45
|
-
|
|
44
|
+
/** 读取当前 session records 分页。 */
|
|
45
|
+
records(input?: AgentSessionRecordsInput): Promise<AgentSessionRecordsPage>;
|
|
46
46
|
/** 读取当前 session 生效的 system 快照。 */
|
|
47
47
|
system(): Promise<AgentSessionSystemSnapshot>;
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionActor.d.ts","sourceRoot":"","sources":["../../../src/types/agent/SessionActor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"SessionActor.d.ts","sourceRoot":"","sources":["../../../src/types/agent/SessionActor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB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C,CAAC;IAEtC,qBAAqB;IACrB,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAExE,oCAAoC;IACpC,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAExC,0BAA0B;IAC1B,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,uBAAuB,CAAC;IAEvE,+BAA+B;IAC/B,OAAO,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE5E,kCAAkC;IAClC,MAAM,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAE5C,yBAAyB;IACzB,GAAG,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD,4BAA4B;IAC5B,IAAI,CAAC,KAAK,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACrE;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,8BAA8B;IAC9B,IAAI,CAAC,KAAK,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC3E"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { LanguageModel } from "ai";
|
|
9
9
|
import type { AgentModel } from "../../model/CityModelAdapter.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type { SessionRecordV1 } from "../../executor/types/SessionRecords.js";
|
|
11
11
|
/**
|
|
12
12
|
* 新建 session 的输入参数。
|
|
13
13
|
*/
|
|
@@ -74,9 +74,9 @@ export interface AgentSessionConfigSnapshot {
|
|
|
74
74
|
modelLabel?: string;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Session
|
|
77
|
+
* Session records视图类型。
|
|
78
78
|
*/
|
|
79
|
-
export type
|
|
79
|
+
export type AgentSessionRecordsView = "message" | "timeline";
|
|
80
80
|
/**
|
|
81
81
|
* Session 时间线事件。
|
|
82
82
|
*/
|
|
@@ -89,7 +89,7 @@ export interface AgentSessionTimelineEvent {
|
|
|
89
89
|
* 说明(中文)
|
|
90
90
|
* - `tool-call` / `tool-result` 用于把 assistant 内部工具过程平铺给 UI。
|
|
91
91
|
*/
|
|
92
|
-
role: "user" | "assistant" | "tool-call" | "tool-result" | "
|
|
92
|
+
role: "user" | "assistant" | "tool-call" | "tool-result" | "action";
|
|
93
93
|
/** 事件时间戳(毫秒)。 */
|
|
94
94
|
ts?: number;
|
|
95
95
|
/** 事件所属消息种类。 */
|
|
@@ -106,26 +106,26 @@ export interface AgentSessionTimelineEvent {
|
|
|
106
106
|
*/
|
|
107
107
|
toolName?: string;
|
|
108
108
|
/**
|
|
109
|
-
* 当前
|
|
109
|
+
* 当前 action 标题。
|
|
110
110
|
*
|
|
111
111
|
* 说明(中文)
|
|
112
|
-
* - 仅 `role=
|
|
112
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
actionTitle?: string;
|
|
115
115
|
/**
|
|
116
|
-
* 当前
|
|
116
|
+
* 当前 action 描述。
|
|
117
117
|
*
|
|
118
118
|
* 说明(中文)
|
|
119
|
-
* - 仅 `role=
|
|
119
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
actionDescription?: string;
|
|
122
122
|
/**
|
|
123
|
-
* 当前
|
|
123
|
+
* 当前 action 状态。
|
|
124
124
|
*
|
|
125
125
|
* 说明(中文)
|
|
126
|
-
* - 仅 `role=
|
|
126
|
+
* - 仅 `role=action` 的事件通常会携带该字段。
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
actionState?: string;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Session system block 来源类型。
|
|
@@ -264,9 +264,9 @@ export interface AgentSessionSummaryPage {
|
|
|
264
264
|
hasMore: boolean;
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
|
-
* Session
|
|
267
|
+
* Session records 读取输入。
|
|
268
268
|
*/
|
|
269
|
-
export interface
|
|
269
|
+
export interface AgentSessionRecordsInput {
|
|
270
270
|
/** 当前页返回上限。 */
|
|
271
271
|
limit?: number;
|
|
272
272
|
/** 分页游标。 */
|
|
@@ -294,24 +294,24 @@ export interface AgentSessionHistoryInput {
|
|
|
294
294
|
* - `message`:原始 session 消息
|
|
295
295
|
* - `timeline`:适合直接渲染 UI 的平铺事件
|
|
296
296
|
*/
|
|
297
|
-
view?:
|
|
297
|
+
view?: AgentSessionRecordsView;
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
|
-
* Session
|
|
300
|
+
* Session records 分页结果。
|
|
301
301
|
*/
|
|
302
|
-
export interface
|
|
302
|
+
export interface AgentSessionRecordsPage {
|
|
303
303
|
/** 当前读取所对应的 session 信息。 */
|
|
304
304
|
session: AgentSessionInfo;
|
|
305
305
|
/** 当前页实际返回视图。 */
|
|
306
|
-
view:
|
|
306
|
+
view: AgentSessionRecordsView;
|
|
307
307
|
/**
|
|
308
308
|
* 当前页数据列表。
|
|
309
309
|
*
|
|
310
310
|
* 说明(中文)
|
|
311
|
-
* - `view=message` 时返回 `
|
|
311
|
+
* - `view=message` 时返回 `SessionRecordV1[]`
|
|
312
312
|
* - `view=timeline` 时返回 `AgentSessionTimelineEvent[]`
|
|
313
313
|
*/
|
|
314
|
-
items:
|
|
314
|
+
items: SessionRecordV1[] | AgentSessionTimelineEvent[];
|
|
315
315
|
/**
|
|
316
316
|
* 过滤前后的总条数。
|
|
317
317
|
*
|
|
@@ -337,7 +337,7 @@ export interface AgentSessionHistoryPage {
|
|
|
337
337
|
*
|
|
338
338
|
* 关键点(中文)
|
|
339
339
|
* - compact summary 不会出现在 `items` 中。
|
|
340
|
-
* - 若当前层包含 compact summary,则这里暴露其 archive ID,供调用方继续 `session.
|
|
340
|
+
* - 若当前层包含 compact summary,则这里暴露其 archive ID,供调用方继续 `session.records({ archive_id })`。
|
|
341
341
|
*/
|
|
342
342
|
previous_archive_id?: string;
|
|
343
343
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionTypes.d.ts","sourceRoot":"","sources":["../../../src/types/agent/SessionTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SessionTypes.d.ts","sourceRoot":"","sources":["../../../src/types/agent/SessionTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CAEpB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;A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AAW,0BAA2B,SAAQ,uBAAuB;CAAG;AAE9E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* - 业务侧上下文优先通过该对象显式传递,避免分散读取隐式全局状态。
|
|
7
7
|
* - tool 深层回调等无法直接传参的场景,才通过 run scope 间接读取这个对象。
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { AgentSessionActionCallback, AgentSessionActionEvent, AgentSessionActionRecord } from "../../types/sdk/AgentSessionAction.js";
|
|
10
10
|
import type { SessionAssistantStepCallback, SessionUiMessageChunkCallback } from "../../executor/types/SessionRun.js";
|
|
11
|
-
import type { SessionUserMessageV1 } from "../../executor/types/
|
|
11
|
+
import type { SessionUserMessageV1 } from "../../executor/types/SessionRecords.js";
|
|
12
12
|
import type { FileUIPart } from "ai";
|
|
13
13
|
/**
|
|
14
14
|
* 单次 session run 的运行上下文。
|
|
@@ -57,13 +57,13 @@ export interface SessionRunContext {
|
|
|
57
57
|
*/
|
|
58
58
|
onUiMessageChunkCallback?: SessionUiMessageChunkCallback;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* action 发布回调。
|
|
61
61
|
*
|
|
62
62
|
* 关键点(中文)
|
|
63
|
-
* - 用于把 compaction
|
|
64
|
-
* -
|
|
63
|
+
* - 用于把 compaction 等辅助动作转成 session event 与 action record。
|
|
64
|
+
* - action 不代表 assistant 正文,也不会进入 LLM 输入。
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
onActionCallback?: AgentSessionActionCallback;
|
|
67
67
|
/**
|
|
68
68
|
* 当前 turn 的取消信号。
|
|
69
69
|
*
|
|
@@ -96,5 +96,5 @@ export interface SessionRunContext {
|
|
|
96
96
|
*/
|
|
97
97
|
pendingAssistantFileParts: FileUIPart[];
|
|
98
98
|
}
|
|
99
|
-
export type {
|
|
99
|
+
export type { AgentSessionActionCallback, AgentSessionActionEvent, AgentSessionActionRecord, };
|
|
100
100
|
//# sourceMappingURL=SessionRunContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionRunContext.d.ts","sourceRoot":"","sources":["../../../src/types/executor/SessionRunContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"SessionRunContext.d.ts","sourceRoot":"","sources":["../../../src/types/executor/SessionRunContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAEvD;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,4BAA4B,CAAC;IAEvD;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,6BAA6B,CAAC;IAEzD;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAE9C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;;;OAMG;IACH,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;IAE7C;;;;;OAKG;IACH,6BAA6B,EAAE,oBAAoB,EAAE,CAAC;IAEtD;;;;;;OAMG;IACH,yBAAyB,EAAE,UAAU,EAAE,CAAC;CACzC;AAED,YAAY,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,GACzB,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - Client 与 Server 共享同一份 request/frame 类型,避免协议两边漂移。
|
|
7
7
|
* - 字段名保持现有协议格式,兼容已发布的 downcity 托管 runtime 调用。
|
|
8
8
|
*/
|
|
9
|
-
import type { AgentCreateSessionInput, AgentListSessionsInput, AgentArchiveSessionsInput,
|
|
9
|
+
import type { AgentCreateSessionInput, AgentListSessionsInput, AgentArchiveSessionsInput, AgentSessionRecordsInput, AgentSessionSystemSnapshot } from "../../types/agent/AgentTypes.js";
|
|
10
10
|
import type { AgentSessionEvent } from "../../types/sdk/AgentSessionEvent.js";
|
|
11
11
|
import type { AgentSessionPromptInput } from "../../types/sdk/AgentSessionPrompt.js";
|
|
12
12
|
import type { JsonValue } from "../../types/common/Json.js";
|
|
@@ -90,14 +90,14 @@ export type RpcRequest = {
|
|
|
90
90
|
} | {
|
|
91
91
|
/** 请求 id,用于匹配响应。 */
|
|
92
92
|
id: string;
|
|
93
|
-
/** 读取 session
|
|
94
|
-
method: "sdk.sessions.
|
|
95
|
-
/**
|
|
93
|
+
/** 读取 session records。 */
|
|
94
|
+
method: "sdk.sessions.records";
|
|
95
|
+
/** records 查询参数。 */
|
|
96
96
|
params: {
|
|
97
97
|
/** 目标 session id。 */
|
|
98
98
|
sessionId: string;
|
|
99
|
-
/**
|
|
100
|
-
input?:
|
|
99
|
+
/** records 分页与视图参数。 */
|
|
100
|
+
input?: AgentSessionRecordsInput;
|
|
101
101
|
};
|
|
102
102
|
} | {
|
|
103
103
|
/** 请求 id,用于匹配响应。 */
|
|
@@ -13,7 +13,7 @@ import type { DowncityConfig } from "../../../types/config/DowncityConfig.js";
|
|
|
13
13
|
import type { JsonValue } from "../../../types/common/Json.js";
|
|
14
14
|
import type { AgentPlugins } from "../../../plugin/types/Plugin.js";
|
|
15
15
|
import type { Plugin } from "../../../types/plugin/PluginDefinition.js";
|
|
16
|
-
import type { SessionMetadataV1,
|
|
16
|
+
import type { SessionMetadataV1, SessionRecordV1 } from "../../../executor/types/SessionRecords.js";
|
|
17
17
|
import type { SessionRunInput, SessionRunResult } from "../../../executor/types/SessionRun.js";
|
|
18
18
|
import type { SessionHistoryStore } from "../../../executor/store/history/SessionHistoryStore.js";
|
|
19
19
|
import type { AgentSessionPromptInput } from "../../../types/sdk/AgentSessionPrompt.js";
|
|
@@ -113,7 +113,7 @@ export interface SessionPort {
|
|
|
113
113
|
*
|
|
114
114
|
* 关键点(中文)
|
|
115
115
|
* - 只广播订阅之后产生的事件。
|
|
116
|
-
* -
|
|
116
|
+
* - session records 仍通过 `getHistoryStore()` / SDK `records()` 读取。
|
|
117
117
|
*/
|
|
118
118
|
subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
|
|
119
119
|
/**
|
|
@@ -121,7 +121,7 @@ export interface SessionPort {
|
|
|
121
121
|
*
|
|
122
122
|
* 关键点(中文)
|
|
123
123
|
* - plugin runtime 用它把审批、外部进度等非模型 chunk 事件推送给订阅方。
|
|
124
|
-
* - 历史消息持久化仍由
|
|
124
|
+
* - 历史消息持久化仍由 append_user_message / append_assistant_message 负责。
|
|
125
125
|
*/
|
|
126
126
|
publishEvent(event: AgentSessionEvent): void;
|
|
127
127
|
/**
|
|
@@ -135,11 +135,11 @@ export interface SessionPort {
|
|
|
135
135
|
/**
|
|
136
136
|
* 追加一条 user 消息。
|
|
137
137
|
*/
|
|
138
|
-
|
|
138
|
+
append_user_message(params: {
|
|
139
139
|
/**
|
|
140
140
|
* 已构造好的完整消息。
|
|
141
141
|
*/
|
|
142
|
-
message?:
|
|
142
|
+
message?: SessionRecordV1 | null;
|
|
143
143
|
/**
|
|
144
144
|
* 兜底文本内容。
|
|
145
145
|
*/
|
|
@@ -152,11 +152,11 @@ export interface SessionPort {
|
|
|
152
152
|
/**
|
|
153
153
|
* 追加一条 assistant 消息。
|
|
154
154
|
*/
|
|
155
|
-
|
|
155
|
+
append_assistant_message(params: {
|
|
156
156
|
/**
|
|
157
157
|
* 已构造好的完整消息。
|
|
158
158
|
*/
|
|
159
|
-
message?:
|
|
159
|
+
message?: SessionRecordV1 | null;
|
|
160
160
|
/**
|
|
161
161
|
* 兜底文本内容。
|
|
162
162
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentContext.d.ts","sourceRoot":"","sources":["../../../../src/types/runtime/agent/AgentContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EACV,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"AgentContext.d.ts","sourceRoot":"","sources":["../../../../src/types/runtime/agent/AgentContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAC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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,yBAAyB;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB;IACnB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,8BAA8B;IAC9B,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;IAChD,0BAA0B;IAC1B,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,mBAAmB;IACnB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;gBAEtB,OAAO,EAAE,mBAAmB;IAiBxC;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAI1C;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE;IAInC;;OAEG;IACH,wBAAwB,IAAI,MAAM;IAIlC;;;;;;OAMG;YACW,oBAAoB;CAmBnC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACtC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Session action 公开类型。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - action 是 session records 中的 `type: "action"` 记录。
|
|
6
|
+
* - 同一份结构同时用于 JSONL 持久化与 `session.subscribe()` 实时事件。
|
|
7
|
+
* - action 不进入 LLM 输入;组装模型消息前必须过滤。
|
|
8
|
+
*/
|
|
9
|
+
import type { SessionActionRecordV1, SessionActionStateV1 } from "../../executor/types/SessionRecords.js";
|
|
10
|
+
/**
|
|
11
|
+
* Session action 当前状态。
|
|
12
|
+
*/
|
|
13
|
+
export type AgentSessionActionState = SessionActionStateV1;
|
|
14
|
+
/**
|
|
15
|
+
* Session action 记录。
|
|
16
|
+
*/
|
|
17
|
+
export type AgentSessionActionRecord = SessionActionRecordV1;
|
|
18
|
+
/**
|
|
19
|
+
* Session action 订阅事件。
|
|
20
|
+
*/
|
|
21
|
+
export type AgentSessionActionEvent = SessionActionRecordV1;
|
|
22
|
+
/**
|
|
23
|
+
* Session action 发布回调。
|
|
24
|
+
*/
|
|
25
|
+
export type AgentSessionActionCallback = (action: AgentSessionActionEvent) => Promise<void>;
|
|
26
|
+
//# sourceMappingURL=AgentSessionAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSessionAction.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionAction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,MAAM,EAAE,uBAAuB,KAC5B,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Session action 公开类型。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - action 是 session records 中的 `type: "action"` 记录。
|
|
6
|
+
* - 同一份结构同时用于 JSONL 持久化与 `session.subscribe()` 实时事件。
|
|
7
|
+
* - action 不进入 LLM 输入;组装模型消息前必须过滤。
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AgentSessionAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSessionAction.js","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionAction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { JsonValue } from "../../types/common/Json.js";
|
|
9
9
|
import type { SessionAssistantStepVisibility } from "../../executor/types/SessionRun.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type { AgentSessionActionEvent } from "../../types/sdk/AgentSessionAction.js";
|
|
11
11
|
/**
|
|
12
12
|
* 单个 turn 开始事件。
|
|
13
13
|
*/
|
|
@@ -290,7 +290,7 @@ export interface AgentSessionErrorEvent {
|
|
|
290
290
|
/**
|
|
291
291
|
* Session 订阅可见事件联合类型。
|
|
292
292
|
*/
|
|
293
|
-
export type AgentSessionEvent = AgentSessionTurnStartEvent | AgentSessionTextDeltaEvent | AgentSessionReasoningDeltaEvent | AgentSessionToolCallEvent | AgentSessionToolResultEvent | AgentSessionToolApprovalRequestEvent | AgentSessionToolApprovalResultEvent | AgentSessionAssistantStepEvent | AgentSessionTitleEvent |
|
|
293
|
+
export type AgentSessionEvent = AgentSessionTurnStartEvent | AgentSessionTextDeltaEvent | AgentSessionReasoningDeltaEvent | AgentSessionToolCallEvent | AgentSessionToolResultEvent | AgentSessionToolApprovalRequestEvent | AgentSessionToolApprovalResultEvent | AgentSessionAssistantStepEvent | AgentSessionTitleEvent | AgentSessionActionEvent | AgentSessionTurnFinishEvent | AgentSessionErrorEvent;
|
|
294
294
|
/**
|
|
295
295
|
* Session 事件订阅回调。
|
|
296
296
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentSessionEvent.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionEvent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AgentSessionEvent.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionEvent.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,IAAI,EAAE,iBAAiB,CAAC;IAExB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,YAAY,GAAG,eAAe,GAAG,aAAa,GAAG,MAAM,CAAC;IAElE;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IAEpB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;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,IAAI,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 同一个 turn 可以吸收多条 prompt,因此多个 prompt 可能返回相同 `id` 的 turn handle。
|
|
7
7
|
* - 增量过程继续通过 `session.subscribe()` 观察;turn handle 只负责等待最终完成结果。
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { SessionMessageRecordV1 } from "../../executor/types/SessionRecords.js";
|
|
10
10
|
/**
|
|
11
11
|
* 单个 Session turn 的最终结果。
|
|
12
12
|
*/
|
|
@@ -30,7 +30,7 @@ export interface AgentSessionTurnResult {
|
|
|
30
30
|
* - `turn.finished` 返回的结果以这条消息作为最终事实源。
|
|
31
31
|
* - transport / runtime service 若需要读取最终结构化输出,应优先消费这里。
|
|
32
32
|
*/
|
|
33
|
-
assistantMessage?:
|
|
33
|
+
assistantMessage?: SessionMessageRecordV1;
|
|
34
34
|
/**
|
|
35
35
|
* 当前 turn 失败时的错误文本。
|
|
36
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentSessionTurn.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"AgentSessionTurn.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;OAMG;IACH,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@downcity/agent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.202",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Downcity Agent 运行时 — 单 Agent 执行壳与本机 RPC 能力",
|
|
6
6
|
"main": "./bin/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@ai-sdk/openai-compatible": "^2.0.48",
|
|
20
|
-
"@downcity/shell": "^0.1.
|
|
21
|
-
"@downcity/type": "0.1.
|
|
20
|
+
"@downcity/shell": "^0.1.71",
|
|
21
|
+
"@downcity/type": "0.1.104",
|
|
22
22
|
"ai": "^6.0.193",
|
|
23
23
|
"commander": "^15.0.0",
|
|
24
24
|
"dotenv": "^17.4.2",
|
|
@@ -144,7 +144,7 @@ test("session.prompt waits for agent background ready before model execution", a
|
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
try {
|
|
147
|
-
const session = await agent.
|
|
147
|
+
const session = await agent.sessions.create({
|
|
148
148
|
sessionId: "ready_session",
|
|
149
149
|
});
|
|
150
150
|
const prompt_promise = session.prompt({
|
|
@@ -14,6 +14,7 @@ import os from "node:os";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import fs from "node:fs/promises";
|
|
16
16
|
import { Agent } from "../bin/index.js";
|
|
17
|
+
import { createAction, createPlugin } from "../bin/plugin/core/PluginActionFactory.js";
|
|
17
18
|
import { City } from "../../city/bin/index.js";
|
|
18
19
|
import { tool } from "ai";
|
|
19
20
|
import { z } from "zod";
|
|
@@ -224,12 +225,13 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
|
|
|
224
225
|
|
|
225
226
|
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
226
227
|
|
|
228
|
+
let agent;
|
|
227
229
|
try {
|
|
228
230
|
const address = server.address();
|
|
229
231
|
assert.ok(address && typeof address === "object");
|
|
230
232
|
const city = new City({
|
|
231
233
|
role: "user",
|
|
232
|
-
|
|
234
|
+
federation_url: `http://127.0.0.1:${String(address.port)}`,
|
|
233
235
|
city_id: "city_demo",
|
|
234
236
|
user_token: "ub_test",
|
|
235
237
|
});
|
|
@@ -240,9 +242,25 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
|
|
|
240
242
|
const agent_path = await fs.mkdtemp(
|
|
241
243
|
path.join(os.tmpdir(), "downcity-agent-city-model-tool-loop-"),
|
|
242
244
|
);
|
|
243
|
-
const
|
|
245
|
+
const skill_plugin = createPlugin({
|
|
246
|
+
name: "skill",
|
|
247
|
+
title: "Skill",
|
|
248
|
+
description: "Test skill plugin",
|
|
249
|
+
actions: {
|
|
250
|
+
lookup: createAction({
|
|
251
|
+
description: "Lookup a skill",
|
|
252
|
+
execute: async ({ input }) => ({
|
|
253
|
+
success: true,
|
|
254
|
+
data: { name: input.name },
|
|
255
|
+
message: "loaded",
|
|
256
|
+
}),
|
|
257
|
+
}),
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
agent = new Agent({
|
|
244
261
|
id: "tool_loop_agent",
|
|
245
262
|
path: agent_path,
|
|
263
|
+
plugins: [skill_plugin],
|
|
246
264
|
tools: {
|
|
247
265
|
ping: tool({
|
|
248
266
|
description: "ping tool",
|
|
@@ -257,7 +275,7 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
|
|
|
257
275
|
},
|
|
258
276
|
});
|
|
259
277
|
|
|
260
|
-
const session = await agent.
|
|
278
|
+
const session = await agent.sessions.create();
|
|
261
279
|
await session.set({ model });
|
|
262
280
|
const turn = await session.prompt({ query: "please use the ping tool" });
|
|
263
281
|
const result = await turn.finished;
|
|
@@ -266,8 +284,19 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
|
|
|
266
284
|
assert.equal(tool_executed, true);
|
|
267
285
|
assert.equal(stream_requests, 0);
|
|
268
286
|
assert.equal(agent_requests.length, 2);
|
|
269
|
-
assert.equal(requests.every((request) => request?.city_id === "city_demo"), true);
|
|
270
287
|
assert.equal(agent_requests[0]?.model, "mock-model");
|
|
288
|
+
const plugin_call_tool = agent_requests[0]?.tools?.find(
|
|
289
|
+
(item) => item?.type === "function" && item?.function?.name === "plugin_call",
|
|
290
|
+
);
|
|
291
|
+
assert.ok(plugin_call_tool);
|
|
292
|
+
const plugin_call_parameters = plugin_call_tool.function.parameters;
|
|
293
|
+
assert.equal(plugin_call_parameters.type, "object");
|
|
294
|
+
assert.deepEqual(plugin_call_parameters.required, ["plugin", "action"]);
|
|
295
|
+
assert.equal(plugin_call_parameters.additionalProperties, false);
|
|
296
|
+
assert.equal(
|
|
297
|
+
plugin_call_parameters.properties.payload.additionalProperties,
|
|
298
|
+
true,
|
|
299
|
+
);
|
|
271
300
|
|
|
272
301
|
const second_request_messages = Array.isArray(agent_requests[1]?.messages)
|
|
273
302
|
? agent_requests[1].messages
|
|
@@ -278,6 +307,9 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
|
|
|
278
307
|
assert.match(serialized_second_messages, /echoed/);
|
|
279
308
|
assert.match(serialized_second_messages, /hello/);
|
|
280
309
|
} finally {
|
|
310
|
+
if (agent) {
|
|
311
|
+
await agent.dispose();
|
|
312
|
+
}
|
|
281
313
|
await new Promise((resolve, reject) => {
|
|
282
314
|
server.close((error) => {
|
|
283
315
|
if (error) {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
invokePluginReadTool,
|
|
18
18
|
} from "../bin/executor/tools/plugin/PluginToolBridge.js";
|
|
19
19
|
import { createPluginTools } from "../bin/executor/tools/plugin/PluginToolDefinition.js";
|
|
20
|
+
import { plugin_call_input_schema } from "../bin/executor/tools/plugin/PluginToolSchemas.js";
|
|
20
21
|
import { withSessionRunScope } from "../bin/executor/SessionRunScope.js";
|
|
21
22
|
import { createAction, createPlugin } from "../bin/plugin/core/PluginActionFactory.js";
|
|
22
23
|
import { createAgentPluginRegistry } from "../bin/agent/local/AgentPluginFactory.js";
|
|
@@ -32,6 +33,18 @@ function create_run_context(project_root) {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
test("plugin_call payload schema allows arbitrary object properties", async () => {
|
|
37
|
+
const plugin_call_schema = await plugin_call_input_schema.jsonSchema;
|
|
38
|
+
const payload_schema = plugin_call_schema.properties.payload;
|
|
39
|
+
|
|
40
|
+
assert.equal(plugin_call_schema.type, "object");
|
|
41
|
+
assert.deepEqual(plugin_call_schema.required, ["plugin", "action"]);
|
|
42
|
+
assert.equal(plugin_call_schema.additionalProperties, false);
|
|
43
|
+
assert.equal(payload_schema.type, "object");
|
|
44
|
+
assert.equal(payload_schema.additionalProperties, true);
|
|
45
|
+
assert.deepEqual(payload_schema.default, {});
|
|
46
|
+
});
|
|
47
|
+
|
|
35
48
|
test("invokePluginCallTool returns absolute paths for materialized file parts", async () => {
|
|
36
49
|
const project_root = await fs.mkdtemp(
|
|
37
50
|
path.join(os.tmpdir(), "downcity-agent-plugin-tool-files-"),
|