@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.
Files changed (247) hide show
  1. package/bin/agent/local/Agent.d.ts +3 -7
  2. package/bin/agent/local/Agent.d.ts.map +1 -1
  3. package/bin/agent/local/Agent.js +14 -19
  4. package/bin/agent/local/Agent.js.map +1 -1
  5. package/bin/agent/local/services/{AgentSessionManager.d.ts → AgentSessions.d.ts} +12 -17
  6. package/bin/agent/local/services/AgentSessions.d.ts.map +1 -0
  7. package/bin/agent/local/services/{AgentSessionManager.js → AgentSessions.js} +11 -26
  8. package/bin/agent/local/services/AgentSessions.js.map +1 -0
  9. package/bin/agent/remote/RemoteAgent.d.ts +2 -9
  10. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
  11. package/bin/agent/remote/RemoteAgent.js +40 -22
  12. package/bin/agent/remote/RemoteAgent.js.map +1 -1
  13. package/bin/agent/remote/RemoteSession.d.ts +5 -5
  14. package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
  15. package/bin/agent/remote/RemoteSession.js +5 -3
  16. package/bin/agent/remote/RemoteSession.js.map +1 -1
  17. package/bin/agent/remote/RemoteTransport.d.ts +2 -2
  18. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +2 -2
  19. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +5 -5
  20. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +2 -2
  21. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +2 -2
  22. package/bin/executor/Executor.d.ts +7 -7
  23. package/bin/executor/Executor.d.ts.map +1 -1
  24. package/bin/executor/Executor.js +41 -33
  25. package/bin/executor/Executor.js.map +1 -1
  26. package/bin/executor/SessionRunScope.d.ts +1 -1
  27. package/bin/executor/SessionRunScope.d.ts.map +1 -1
  28. package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts +5 -5
  29. package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
  30. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +1 -1
  31. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +1 -1
  32. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +4 -5
  33. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  34. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +73 -40
  35. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  36. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts +27 -0
  37. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts.map +1 -0
  38. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js +181 -0
  39. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js.map +1 -0
  40. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts +45 -0
  41. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts.map +1 -0
  42. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js +144 -0
  43. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js.map +1 -0
  44. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts +3 -3
  45. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts.map +1 -1
  46. package/bin/executor/composer/context/SessionContextComposer.d.ts +3 -3
  47. package/bin/executor/composer/context/SessionContextComposer.d.ts.map +1 -1
  48. package/bin/executor/composer/history/SessionHistoryComposer.d.ts +2 -2
  49. package/bin/executor/composer/history/SessionHistoryComposer.d.ts.map +1 -1
  50. package/bin/executor/composer/history/SessionHistoryWriter.d.ts +5 -5
  51. package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
  52. package/bin/executor/composer/history/SessionHistoryWriter.js +6 -6
  53. package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
  54. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +2 -2
  55. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
  56. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +5 -4
  57. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
  58. package/bin/executor/core-engine/CoreEngineMessageState.d.ts +5 -5
  59. package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
  60. package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
  61. package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
  62. package/bin/executor/core-engine/CoreEngineSignals.d.ts +4 -4
  63. package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
  64. package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
  65. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +3 -3
  66. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -1
  67. package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +1 -1
  68. package/bin/executor/messages/AssistantResultPersistence.d.ts +5 -5
  69. package/bin/executor/messages/AssistantResultPersistence.d.ts.map +1 -1
  70. package/bin/executor/messages/AssistantResultPersistence.js +1 -1
  71. package/bin/executor/messages/AssistantResultPersistence.js.map +1 -1
  72. package/bin/executor/messages/SessionAttachmentMapper.d.ts +3 -3
  73. package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
  74. package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
  75. package/bin/executor/messages/SessionMessageCodec.d.ts +4 -4
  76. package/bin/executor/messages/SessionMessageCodec.d.ts.map +1 -1
  77. package/bin/executor/messages/SessionMessageCodec.js +5 -5
  78. package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
  79. package/bin/executor/messages/SessionMessageLog.d.ts +3 -3
  80. package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
  81. package/bin/executor/messages/SessionMessageLog.js.map +1 -1
  82. package/bin/executor/messages/SessionStepEventMapper.d.ts +2 -2
  83. package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
  84. package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
  85. package/bin/executor/messages/UserVisibleText.d.ts +3 -3
  86. package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
  87. package/bin/executor/messages/UserVisibleText.js +3 -3
  88. package/bin/executor/messages/UserVisibleText.js.map +1 -1
  89. package/bin/executor/services/ExecutorInflightService.d.ts +2 -2
  90. package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
  91. package/bin/executor/services/ExecutorInflightService.js +11 -7
  92. package/bin/executor/services/ExecutorInflightService.js.map +1 -1
  93. package/bin/executor/store/history/SessionHistoryStore.d.ts +30 -27
  94. package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
  95. package/bin/executor/store/history/SessionHistoryStore.js +3 -3
  96. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +21 -20
  97. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  98. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +114 -72
  99. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  100. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +1 -7
  101. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
  102. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts +4 -6
  103. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +1 -1
  104. package/bin/executor/tools/plugin/PluginToolSchemas.js +24 -10
  105. package/bin/executor/tools/plugin/PluginToolSchemas.js.map +1 -1
  106. package/bin/executor/types/SessionRecords.d.ts +162 -0
  107. package/bin/executor/types/SessionRecords.d.ts.map +1 -0
  108. package/bin/executor/types/SessionRecords.js +52 -0
  109. package/bin/executor/types/SessionRecords.js.map +1 -0
  110. package/bin/executor/types/SessionRun.d.ts +3 -3
  111. package/bin/executor/types/SessionRun.d.ts.map +1 -1
  112. package/bin/index.d.ts +2 -2
  113. package/bin/index.d.ts.map +1 -1
  114. package/bin/index.js.map +1 -1
  115. package/bin/rpc/Client.d.ts +5 -5
  116. package/bin/rpc/Client.js +4 -4
  117. package/bin/session/Session.d.ts +6 -6
  118. package/bin/session/Session.d.ts.map +1 -1
  119. package/bin/session/Session.js +8 -8
  120. package/bin/session/Session.js.map +1 -1
  121. package/bin/session/SessionTitle.d.ts +2 -2
  122. package/bin/session/SessionTitle.d.ts.map +1 -1
  123. package/bin/session/SessionTitle.js +5 -0
  124. package/bin/session/SessionTitle.js.map +1 -1
  125. package/bin/session/browse/Browse.d.ts +12 -12
  126. package/bin/session/browse/Browse.d.ts.map +1 -1
  127. package/bin/session/browse/Browse.js +37 -34
  128. package/bin/session/browse/Browse.js.map +1 -1
  129. package/bin/session/index.d.ts +1 -1
  130. package/bin/session/index.js +1 -1
  131. package/bin/session/runtime/SessionPromptRuntime.d.ts +3 -3
  132. package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
  133. package/bin/session/services/SessionStateService.d.ts +11 -12
  134. package/bin/session/services/SessionStateService.d.ts.map +1 -1
  135. package/bin/session/services/SessionStateService.js +43 -69
  136. package/bin/session/services/SessionStateService.js.map +1 -1
  137. package/bin/session/services/SessionTurnService.js +3 -3
  138. package/bin/session/services/SessionTurnService.js.map +1 -1
  139. package/bin/session/services/SessionViewService.d.ts +4 -4
  140. package/bin/session/services/SessionViewService.d.ts.map +1 -1
  141. package/bin/session/services/SessionViewService.js +26 -36
  142. package/bin/session/services/SessionViewService.js.map +1 -1
  143. package/bin/session/storage/Persistence.d.ts +4 -4
  144. package/bin/session/storage/Persistence.d.ts.map +1 -1
  145. package/bin/session/storage/RuntimeSessionPort.d.ts +2 -2
  146. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  147. package/bin/session/storage/RuntimeSessionPort.js +4 -4
  148. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  149. package/bin/types/agent/AgentTypes.d.ts +2 -2
  150. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  151. package/bin/types/agent/SessionActor.d.ts +11 -11
  152. package/bin/types/agent/SessionActor.d.ts.map +1 -1
  153. package/bin/types/agent/SessionTypes.d.ts +22 -22
  154. package/bin/types/agent/SessionTypes.d.ts.map +1 -1
  155. package/bin/types/executor/SessionRunContext.d.ts +7 -7
  156. package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
  157. package/bin/types/rpc/RpcProtocol.d.ts +6 -6
  158. package/bin/types/runtime/agent/AgentContext.d.ts +7 -7
  159. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  160. package/bin/types/sdk/AgentSessionAction.d.ts +26 -0
  161. package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -0
  162. package/bin/types/sdk/AgentSessionAction.js +10 -0
  163. package/bin/types/sdk/AgentSessionAction.js.map +1 -0
  164. package/bin/types/sdk/AgentSessionEvent.d.ts +2 -2
  165. package/bin/types/sdk/AgentSessionEvent.d.ts.map +1 -1
  166. package/bin/types/sdk/AgentSessionTurn.d.ts +2 -2
  167. package/bin/types/sdk/AgentSessionTurn.d.ts.map +1 -1
  168. package/package.json +3 -3
  169. package/scripts/agent-ready.test.mjs +1 -1
  170. package/scripts/city-model-tool-loop.test.mjs +36 -4
  171. package/scripts/plugin-tool-bridge.test.mjs +13 -0
  172. package/scripts/session-action-message.test.mjs +199 -0
  173. package/scripts/session-compaction-prompts.test.mjs +97 -0
  174. package/scripts/session-history-archive.test.mjs +8 -8
  175. package/scripts/session-history-inflight.test.mjs +10 -10
  176. package/scripts/session-list-title.test.mjs +9 -9
  177. package/scripts/session-title-event.test.mjs +12 -10
  178. package/src/agent/local/Agent.ts +16 -22
  179. package/src/agent/local/services/{AgentSessionManager.ts → AgentSessions.ts} +16 -32
  180. package/src/agent/remote/RemoteAgent.ts +58 -23
  181. package/src/agent/remote/RemoteSession.ts +10 -8
  182. package/src/agent/remote/RemoteTransport.ts +5 -5
  183. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +10 -10
  184. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -6
  185. package/src/executor/Executor.ts +51 -41
  186. package/src/executor/SessionRunScope.ts +1 -1
  187. package/src/executor/composer/compaction/SessionCompactionComposer.ts +5 -5
  188. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +1 -1
  189. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +91 -52
  190. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.ts +197 -0
  191. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.ts +162 -0
  192. package/src/executor/composer/context/LocalSessionContextComposer.ts +5 -5
  193. package/src/executor/composer/context/SessionContextComposer.ts +5 -5
  194. package/src/executor/composer/history/SessionHistoryComposer.ts +2 -2
  195. package/src/executor/composer/history/SessionHistoryWriter.ts +10 -10
  196. package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +13 -10
  197. package/src/executor/core-engine/CoreEngineMessageState.ts +8 -8
  198. package/src/executor/core-engine/CoreEngineRunner.ts +7 -7
  199. package/src/executor/core-engine/CoreEngineSignals.ts +7 -7
  200. package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +5 -5
  201. package/src/executor/messages/AssistantResultPersistence.ts +8 -8
  202. package/src/executor/messages/SessionAttachmentMapper.ts +11 -11
  203. package/src/executor/messages/SessionMessageCodec.ts +10 -10
  204. package/src/executor/messages/SessionMessageLog.ts +3 -3
  205. package/src/executor/messages/SessionStepEventMapper.ts +5 -5
  206. package/src/executor/messages/UserVisibleText.ts +9 -9
  207. package/src/executor/services/ExecutorInflightService.ts +13 -9
  208. package/src/executor/store/history/SessionHistoryStore.ts +32 -28
  209. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +146 -95
  210. package/src/executor/tools/plugin/PluginToolSchemas.ts +24 -10
  211. package/src/executor/types/SessionRecords.ts +217 -0
  212. package/src/executor/types/SessionRun.ts +5 -5
  213. package/src/index.ts +9 -10
  214. package/src/rpc/Client.ts +9 -9
  215. package/src/session/Session.ts +10 -10
  216. package/src/session/SessionTitle.ts +7 -4
  217. package/src/session/browse/Browse.ts +66 -58
  218. package/src/session/index.ts +1 -1
  219. package/src/session/runtime/SessionPromptRuntime.ts +6 -6
  220. package/src/session/services/SessionStateService.ts +61 -86
  221. package/src/session/services/SessionTurnService.ts +7 -7
  222. package/src/session/services/SessionViewService.ts +35 -45
  223. package/src/session/storage/Persistence.ts +6 -6
  224. package/src/session/storage/RuntimeSessionPort.ts +6 -6
  225. package/src/types/agent/AgentTypes.ts +4 -4
  226. package/src/types/agent/SessionActor.ts +12 -12
  227. package/src/types/agent/SessionTypes.ts +22 -22
  228. package/src/types/executor/SessionRunContext.ts +12 -12
  229. package/src/types/rpc/RpcProtocol.ts +6 -6
  230. package/src/types/runtime/agent/AgentContext.ts +8 -8
  231. package/src/types/sdk/AgentSessionAction.ts +35 -0
  232. package/src/types/sdk/AgentSessionEvent.ts +2 -2
  233. package/src/types/sdk/AgentSessionTurn.ts +2 -2
  234. package/tsconfig.tsbuildinfo +1 -1
  235. package/bin/agent/local/services/AgentSessionManager.d.ts.map +0 -1
  236. package/bin/agent/local/services/AgentSessionManager.js.map +0 -1
  237. package/bin/executor/types/SessionMessages.d.ts +0 -118
  238. package/bin/executor/types/SessionMessages.d.ts.map +0 -1
  239. package/bin/executor/types/SessionMessages.js +0 -28
  240. package/bin/executor/types/SessionMessages.js.map +0 -1
  241. package/bin/types/sdk/AgentSessionOperation.d.ts +0 -99
  242. package/bin/types/sdk/AgentSessionOperation.d.ts.map +0 -1
  243. package/bin/types/sdk/AgentSessionOperation.js +0 -10
  244. package/bin/types/sdk/AgentSessionOperation.js.map +0 -1
  245. package/scripts/session-operation-message.test.mjs +0 -197
  246. package/src/executor/types/SessionMessages.ts +0 -148
  247. package/src/types/sdk/AgentSessionOperation.ts +0 -125
@@ -1,125 +0,0 @@
1
- /**
2
- * Agent Session operation 类型定义。
3
- *
4
- * 关键点(中文)
5
- * - operation 描述 session 内部正在发生的辅助操作,不代表 assistant 正文。
6
- * - operation 可以同时作为订阅事件发布,也可以作为 UIMessage 持久化到 JSONL。
7
- * - operation message 只用于前端时间线与调试,不应进入 LLM 输入。
8
- */
9
-
10
- import type { JsonValue } from "@/types/common/Json.js";
11
-
12
- /**
13
- * Session operation 当前状态。
14
- */
15
- export type AgentSessionOperationStatus =
16
- | "started"
17
- | "progress"
18
- | "finished"
19
- | "skipped"
20
- | "failed";
21
-
22
- /**
23
- * Session operation 名称。
24
- *
25
- * 说明(中文)
26
- * - 内置名称用于 SDK 与前端约定常见辅助操作。
27
- * - 字符串扩展允许 plugin 或宿主运行时声明自己的 operation。
28
- */
29
- export type AgentSessionOperationName =
30
- | "compacting"
31
- | "model-switching"
32
- | "history-forking"
33
- | (string & {});
34
-
35
- /**
36
- * Session operation 记录。
37
- */
38
- export interface AgentSessionOperationRecord {
39
- /**
40
- * 同一个 operation 生命周期内稳定复用的 ID。
41
- */
42
- operationId: string;
43
-
44
- /**
45
- * 当前 operation 名称。
46
- */
47
- name: AgentSessionOperationName;
48
-
49
- /**
50
- * 当前 operation 状态。
51
- */
52
- status: AgentSessionOperationStatus;
53
-
54
- /**
55
- * 当前 operation 关联的 turn 标识。
56
- *
57
- * 说明(中文)
58
- * - turn 内触发的 operation 应写入该字段。
59
- * - session 级 operation 可以省略。
60
- */
61
- turnId?: string;
62
-
63
- /**
64
- * 面向用户展示的短文本。
65
- */
66
- label?: string;
67
-
68
- /**
69
- * 机器可读原因。
70
- *
71
- * 示例(中文)
72
- * - `under_budget`:未达到压缩阈值。
73
- * - `summary_fallback`:摘要生成失败后使用降级摘要。
74
- */
75
- reason?: string;
76
-
77
- /**
78
- * 当前 operation 进度,范围 0 到 1。
79
- *
80
- * 说明(中文)
81
- * - 无法估算进度时省略。
82
- */
83
- progress?: number;
84
-
85
- /**
86
- * operation 完成后产生的轻量结果。
87
- */
88
- result?: JsonValue;
89
-
90
- /**
91
- * operation 失败时的错误文本。
92
- */
93
- error?: string;
94
-
95
- /**
96
- * 是否建议前端展示。
97
- *
98
- * 说明(中文)
99
- * - 默认视为 `true`。
100
- * - 调试或审计类辅助事件可显式写入 `false`。
101
- */
102
- visible?: boolean;
103
- }
104
-
105
- /**
106
- * Session operation 订阅事件。
107
- */
108
- export interface AgentSessionOperationEvent extends AgentSessionOperationRecord {
109
- /**
110
- * 当前事件类型。
111
- */
112
- type: "operation";
113
-
114
- /**
115
- * 当前 session 唯一标识。
116
- */
117
- sessionId: string;
118
- }
119
-
120
- /**
121
- * Session operation 发布回调。
122
- */
123
- export type AgentSessionOperationCallback = (
124
- operation: AgentSessionOperationEvent,
125
- ) => Promise<void>;