@downcity/agent 1.1.43 → 1.1.62

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 (256) hide show
  1. package/README.md +11 -12
  2. package/bin/agent/Agent.d.ts +31 -16
  3. package/bin/agent/Agent.d.ts.map +1 -1
  4. package/bin/agent/Agent.js +47 -63
  5. package/bin/agent/Agent.js.map +1 -1
  6. package/bin/agent/RemoteAgent.d.ts +6 -6
  7. package/bin/agent/RemoteAgent.d.ts.map +1 -1
  8. package/bin/agent/RemoteAgent.js +377 -267
  9. package/bin/agent/RemoteAgent.js.map +1 -1
  10. package/bin/config/AgentInitializer.d.ts +5 -5
  11. package/bin/config/AgentInitializer.d.ts.map +1 -1
  12. package/bin/config/AgentInitializer.js +15 -13
  13. package/bin/config/AgentInitializer.js.map +1 -1
  14. package/bin/config/Config.d.ts +9 -30
  15. package/bin/config/Config.d.ts.map +1 -1
  16. package/bin/config/Config.js +23 -70
  17. package/bin/config/Config.js.map +1 -1
  18. package/bin/config/Defaults.d.ts.map +1 -1
  19. package/bin/config/Defaults.js +1 -9
  20. package/bin/config/Defaults.js.map +1 -1
  21. package/bin/config/DowncitySchema.d.ts.map +1 -1
  22. package/bin/config/DowncitySchema.js +4 -112
  23. package/bin/config/DowncitySchema.js.map +1 -1
  24. package/bin/config/ExecutionBinding.d.ts +1 -16
  25. package/bin/config/ExecutionBinding.d.ts.map +1 -1
  26. package/bin/config/ExecutionBinding.js +2 -22
  27. package/bin/config/ExecutionBinding.js.map +1 -1
  28. package/bin/config/Paths.d.ts +4 -43
  29. package/bin/config/Paths.d.ts.map +1 -1
  30. package/bin/config/Paths.js +10 -30
  31. package/bin/config/Paths.js.map +1 -1
  32. package/bin/config/PlatformPaths.d.ts +0 -4
  33. package/bin/config/PlatformPaths.d.ts.map +1 -1
  34. package/bin/config/PlatformPaths.js +5 -1
  35. package/bin/config/PlatformPaths.js.map +1 -1
  36. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  37. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +0 -4
  38. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  39. package/bin/executor/composer/system/default/InitPrompts.d.ts +1 -1
  40. package/bin/executor/composer/system/default/InitPrompts.js +1 -1
  41. package/bin/executor/composer/system/default/SystemDomain.js +1 -1
  42. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  43. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  44. package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts +1 -1
  45. package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts.map +1 -1
  46. package/bin/executor/composer/system/default/assets/init/PROFILE.md.js +1 -1
  47. package/bin/executor/composer/system/default/assets/init/PROFILE.md.js.map +1 -1
  48. package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts +1 -1
  49. package/bin/executor/composer/system/default/assets/plugin.prompt.js +1 -1
  50. package/bin/executor/composer/system/default/assets/task.prompt.d.ts +1 -1
  51. package/bin/executor/composer/system/default/assets/task.prompt.js +1 -1
  52. package/bin/executor/messages/ChatMessageMarkupTypes.d.ts +1 -1
  53. package/bin/executor/messages/ChatMessageMarkupTypes.js +1 -1
  54. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +1 -2
  55. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  56. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +17 -56
  57. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  58. package/bin/executor/tools/shell/ShellToolBridge.js +1 -1
  59. package/bin/executor/tools/shell/ShellToolBridge.js.map +1 -1
  60. package/bin/executor/tools/shell/ShellToolDefinition.d.ts +2 -2
  61. package/bin/executor/tools/shell/ShellToolFormatting.d.ts +1 -1
  62. package/bin/executor/tools/shell/ShellToolFormatting.js +9 -9
  63. package/bin/executor/tools/shell/ShellToolFormatting.js.map +1 -1
  64. package/bin/executor/tools/shell/ShellToolSchemas.d.ts +7 -75
  65. package/bin/executor/tools/shell/ShellToolSchemas.d.ts.map +1 -1
  66. package/bin/executor/types/SessionHistoryMeta.d.ts +5 -24
  67. package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
  68. package/bin/executor/types/SessionHistoryMeta.js +1 -1
  69. package/bin/executor/types/SessionRun.d.ts +1 -1
  70. package/bin/index.d.ts +5 -6
  71. package/bin/index.d.ts.map +1 -1
  72. package/bin/index.js +6 -5
  73. package/bin/index.js.map +1 -1
  74. package/bin/model/CityModelAdapter.d.ts +23 -0
  75. package/bin/model/CityModelAdapter.d.ts.map +1 -0
  76. package/bin/model/CityModelAdapter.js +338 -0
  77. package/bin/model/CityModelAdapter.js.map +1 -0
  78. package/bin/plugin/core/PluginCommandRequest.d.ts +1 -1
  79. package/bin/plugin/core/PluginCommandRequest.js +1 -1
  80. package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
  81. package/bin/plugin/core/PluginLocalExecution.js +4 -8
  82. package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
  83. package/bin/plugin/types/PluginApi.d.ts +1 -1
  84. package/bin/rpc/Client.d.ts +104 -0
  85. package/bin/rpc/Client.d.ts.map +1 -0
  86. package/bin/rpc/Client.js +300 -0
  87. package/bin/rpc/Client.js.map +1 -0
  88. package/bin/rpc/Server.d.ts +41 -0
  89. package/bin/rpc/Server.d.ts.map +1 -0
  90. package/bin/rpc/Server.js +164 -0
  91. package/bin/rpc/Server.js.map +1 -0
  92. package/bin/runtime/host/daemon/Api.d.ts +1 -1
  93. package/bin/runtime/host/daemon/Client.d.ts +1 -1
  94. package/bin/runtime/host/daemon/Client.d.ts.map +1 -1
  95. package/bin/runtime/host/daemon/Client.js +30 -20
  96. package/bin/runtime/host/daemon/Client.js.map +1 -1
  97. package/bin/runtime/host/daemon/Paths.d.ts +1 -1
  98. package/bin/runtime/host/daemon/Paths.js +1 -1
  99. package/bin/runtime/host/daemon/ProjectSetup.js +2 -2
  100. package/bin/runtime/server/http/control/OverviewRoutes.js +1 -1
  101. package/bin/runtime/server/http/control/OverviewRoutes.js.map +1 -1
  102. package/bin/session/Session.d.ts +1 -0
  103. package/bin/session/Session.d.ts.map +1 -1
  104. package/bin/session/Session.js +32 -6
  105. package/bin/session/Session.js.map +1 -1
  106. package/bin/session/SessionTitle.d.ts +49 -0
  107. package/bin/session/SessionTitle.d.ts.map +1 -0
  108. package/bin/session/SessionTitle.js +130 -0
  109. package/bin/session/SessionTitle.js.map +1 -0
  110. package/bin/session/browse/Browse.d.ts +2 -1
  111. package/bin/session/browse/Browse.d.ts.map +1 -1
  112. package/bin/session/browse/Browse.js +18 -15
  113. package/bin/session/browse/Browse.js.map +1 -1
  114. package/bin/session/index.d.ts +3 -2
  115. package/bin/session/index.d.ts.map +1 -1
  116. package/bin/session/index.js +3 -2
  117. package/bin/session/index.js.map +1 -1
  118. package/bin/session/storage/Metadata.d.ts +4 -0
  119. package/bin/session/storage/Metadata.d.ts.map +1 -1
  120. package/bin/session/storage/Metadata.js +12 -25
  121. package/bin/session/storage/Metadata.js.map +1 -1
  122. package/bin/session/storage/Paths.d.ts +0 -4
  123. package/bin/session/storage/Paths.d.ts.map +1 -1
  124. package/bin/session/storage/Paths.js +0 -6
  125. package/bin/session/storage/Paths.js.map +1 -1
  126. package/bin/session/storage/Persistence.d.ts.map +1 -1
  127. package/bin/session/storage/Persistence.js +1 -4
  128. package/bin/session/storage/Persistence.js.map +1 -1
  129. package/bin/types/agent/AgentTypes.d.ts +32 -57
  130. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  131. package/bin/types/config/AgentProject.d.ts +7 -6
  132. package/bin/types/config/AgentProject.d.ts.map +1 -1
  133. package/bin/types/config/DowncityConfig.d.ts +11 -69
  134. package/bin/types/config/DowncityConfig.d.ts.map +1 -1
  135. package/bin/types/config/ExecutionBinding.d.ts +4 -4
  136. package/bin/types/config/ExecutionBinding.js +1 -1
  137. package/bin/types/config/LlmConfig.d.ts +1 -1
  138. package/bin/types/config/Start.d.ts +3 -0
  139. package/bin/types/config/Start.d.ts.map +1 -1
  140. package/bin/types/config/Start.js +2 -0
  141. package/bin/types/config/Start.js.map +1 -1
  142. package/bin/types/runtime/auth/AuthPermission.js +2 -2
  143. package/bin/types/runtime/auth/AuthPermission.js.map +1 -1
  144. package/bin/types/runtime/host/Store.d.ts +10 -227
  145. package/bin/types/runtime/host/Store.d.ts.map +1 -1
  146. package/bin/types/runtime/host/Store.js +7 -0
  147. package/bin/types/runtime/host/Store.js.map +1 -1
  148. package/bin/types/runtime/http/InlineInstant.d.ts +1 -1
  149. package/bin/types/runtime/platform/Platform.d.ts +7 -7
  150. package/bin/types/runtime/platform/Platform.d.ts.map +1 -1
  151. package/bin/types/runtime/platform/PlatformGateway.d.ts +2 -2
  152. package/bin/types/runtime/platform/PlatformGateway.d.ts.map +1 -1
  153. package/bin/utils/Time.d.ts +0 -1
  154. package/bin/utils/Time.d.ts.map +1 -1
  155. package/bin/utils/Time.js +0 -7
  156. package/bin/utils/Time.js.map +1 -1
  157. package/bin/utils/storage/index.d.ts +0 -1
  158. package/bin/utils/storage/index.d.ts.map +1 -1
  159. package/bin/utils/storage/index.js +0 -6
  160. package/bin/utils/storage/index.js.map +1 -1
  161. package/package.json +22 -23
  162. package/src/agent/Agent.ts +57 -73
  163. package/src/agent/RemoteAgent.ts +515 -345
  164. package/src/config/AgentInitializer.ts +15 -13
  165. package/src/config/Config.ts +28 -85
  166. package/src/config/Defaults.ts +1 -9
  167. package/src/config/DowncitySchema.ts +4 -114
  168. package/src/config/ExecutionBinding.ts +2 -24
  169. package/src/config/Paths.ts +10 -43
  170. package/src/config/PlatformPaths.ts +5 -1
  171. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +0 -4
  172. package/src/executor/composer/system/default/InitPrompts.ts +1 -1
  173. package/src/executor/composer/system/default/SystemDomain.ts +1 -1
  174. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  175. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +1 -1
  176. package/src/executor/composer/system/default/assets/init/PROFILE.md.ts +1 -1
  177. package/src/executor/composer/system/default/assets/init/PROFILE.md.ts.txt +1 -2
  178. package/src/executor/composer/system/default/assets/plugin.prompt.ts +1 -1
  179. package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +18 -18
  180. package/src/executor/composer/system/default/assets/task.prompt.ts +1 -1
  181. package/src/executor/composer/system/default/assets/task.prompt.ts.txt +1 -1
  182. package/src/executor/messages/ChatMessageMarkupTypes.ts +1 -1
  183. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +17 -57
  184. package/src/executor/tools/shell/ShellToolBridge.ts +1 -1
  185. package/src/executor/tools/shell/ShellToolFormatting.ts +9 -9
  186. package/src/executor/types/SessionHistoryMeta.ts +5 -25
  187. package/src/executor/types/SessionRun.ts +1 -1
  188. package/src/index.ts +12 -19
  189. package/src/model/CityModelAdapter.ts +384 -0
  190. package/src/plugin/core/PluginCommandRequest.ts +1 -1
  191. package/src/plugin/core/PluginLocalExecution.ts +4 -8
  192. package/src/plugin/types/PluginApi.ts +1 -1
  193. package/src/rpc/Client.ts +467 -0
  194. package/src/rpc/Server.ts +302 -0
  195. package/src/runtime/host/daemon/Api.ts +1 -1
  196. package/src/runtime/host/daemon/Client.ts +44 -22
  197. package/src/runtime/host/daemon/Paths.ts +1 -1
  198. package/src/runtime/host/daemon/ProjectSetup.ts +2 -2
  199. package/src/runtime/server/http/control/OverviewRoutes.ts +1 -1
  200. package/src/session/Session.ts +40 -6
  201. package/src/session/SessionTitle.ts +192 -0
  202. package/src/session/browse/Browse.ts +22 -13
  203. package/src/session/index.ts +5 -1
  204. package/src/session/storage/Metadata.ts +14 -29
  205. package/src/session/storage/Paths.ts +0 -10
  206. package/src/session/storage/Persistence.ts +1 -4
  207. package/src/types/agent/AgentTypes.ts +33 -62
  208. package/src/types/config/AgentProject.ts +7 -6
  209. package/src/types/config/DowncityConfig.ts +11 -70
  210. package/src/types/config/ExecutionBinding.ts +4 -4
  211. package/src/types/config/LlmConfig.ts +1 -1
  212. package/src/types/config/Start.ts +3 -0
  213. package/src/types/runtime/auth/AuthPermission.ts +2 -2
  214. package/src/types/runtime/host/Store.ts +10 -235
  215. package/src/types/runtime/http/InlineInstant.ts +1 -1
  216. package/src/types/runtime/platform/Platform.ts +7 -7
  217. package/src/types/runtime/platform/PlatformGateway.ts +2 -2
  218. package/src/utils/Time.ts +0 -6
  219. package/src/utils/storage/index.ts +0 -7
  220. package/tsconfig.json +1 -0
  221. package/tsconfig.tsbuildinfo +1 -1
  222. package/bin/config/ConfigEnvResolver.d.ts +0 -22
  223. package/bin/config/ConfigEnvResolver.d.ts.map +0 -1
  224. package/bin/config/ConfigEnvResolver.js +0 -41
  225. package/bin/config/ConfigEnvResolver.js.map +0 -1
  226. package/bin/runtime/server/rpc/Server.d.ts +0 -18
  227. package/bin/runtime/server/rpc/Server.d.ts.map +0 -1
  228. package/bin/runtime/server/rpc/Server.js +0 -315
  229. package/bin/runtime/server/rpc/Server.js.map +0 -1
  230. package/bin/runtime/transport/rpc/Client.d.ts +0 -13
  231. package/bin/runtime/transport/rpc/Client.d.ts.map +0 -1
  232. package/bin/runtime/transport/rpc/Client.js +0 -98
  233. package/bin/runtime/transport/rpc/Client.js.map +0 -1
  234. package/bin/runtime/transport/rpc/Paths.d.ts +0 -14
  235. package/bin/runtime/transport/rpc/Paths.d.ts.map +0 -1
  236. package/bin/runtime/transport/rpc/Paths.js +0 -42
  237. package/bin/runtime/transport/rpc/Paths.js.map +0 -1
  238. package/bin/runtime/transport/rpc/Transport.d.ts +0 -21
  239. package/bin/runtime/transport/rpc/Transport.d.ts.map +0 -1
  240. package/bin/runtime/transport/rpc/Transport.js +0 -30
  241. package/bin/runtime/transport/rpc/Transport.js.map +0 -1
  242. package/bin/types/common/ResolvedConfigValue.d.ts +0 -12
  243. package/bin/types/common/ResolvedConfigValue.d.ts.map +0 -1
  244. package/bin/types/common/ResolvedConfigValue.js +0 -2
  245. package/bin/types/common/ResolvedConfigValue.js.map +0 -1
  246. package/bin/types/runtime/rpc/LocalRpc.d.ts +0 -69
  247. package/bin/types/runtime/rpc/LocalRpc.d.ts.map +0 -1
  248. package/bin/types/runtime/rpc/LocalRpc.js +0 -9
  249. package/bin/types/runtime/rpc/LocalRpc.js.map +0 -1
  250. package/src/config/ConfigEnvResolver.ts +0 -52
  251. package/src/runtime/server/rpc/Server.ts +0 -408
  252. package/src/runtime/transport/rpc/Client.ts +0 -113
  253. package/src/runtime/transport/rpc/Paths.ts +0 -50
  254. package/src/runtime/transport/rpc/Transport.ts +0 -43
  255. package/src/types/common/ResolvedConfigValue.ts +0 -16
  256. package/src/types/runtime/rpc/LocalRpc.ts +0 -72
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 基本信息
4
4
 
5
- - 名字:`{{agent_name}}`
5
+ - ID:`{{agent_id}}`
6
6
  - 身份:长期协作型助手
7
7
  - 关系:用户的合作者,不是用户的替身
8
8
 
@@ -15,4 +15,3 @@
15
15
  - 可访问的信息不等于可传播的信息,隐私默认保密。
16
16
  - 坚持真实与可验证,不伪造结论、不编造事实。
17
17
 
18
-
@@ -4,6 +4,6 @@
4
4
  */
5
5
 
6
6
  // Source: src/executor/composer/system/default/assets/plugin.prompt.ts.txt
7
- const TEXT_MODULE_CONTENT = "# Plugin State\n\n你正在一个基于 plugin 的执行环境中工作。\n\n## 可用命令总览\n- plugin 状态管理(统一使用 `city plugin`):\n - `city plugin list`\n - `city plugin status <pluginName>`\n - `city plugin start <pluginName>`\n - `city plugin stop <pluginName>`\n - `city plugin restart <pluginName>`\n - `city plugin command <pluginName> <command> [--payload '<json>']`\n - `city plugin schedule list`\n - `city plugin schedule info <jobId>`\n - `city plugin schedule cancel <jobId>`\n- ActionSchedule 管理命令用于查看/取消延迟执行的 plugin action,不是独立 plugin。\n- 当前内建托管 plugin:`shell` / `chat` / `task` / `memory` / `contact`。\n- 当前内建本地 plugin:`auth` / `skill` / `asr` / `tts`。\n- 模块级 action 命令:\n - `city shell <action> ...`\n - `city chat <action> ...`\n - `city task <action> ...`\n - `city memory <action> ...`\n - `city plugin action <plugin> <action> ...`\n - `city skill <action> ...`\n - `city asr <action> ...`\n - `city tts <action> ...`\n\n具体 plugin 的执行参考对应文档。\n";
7
+ const TEXT_MODULE_CONTENT = "# Plugin State\n\n你正在一个基于 plugin 的执行环境中工作。\n\n## 可用命令总览\n- plugin 状态管理(统一使用 `town plugin`):\n - `town plugin list`\n - `town plugin status <pluginName>`\n - `town plugin start <pluginName>`\n - `town plugin stop <pluginName>`\n - `town plugin restart <pluginName>`\n - `town plugin command <pluginName> <command> [--payload '<json>']`\n - `town plugin schedule list`\n - `town plugin schedule info <jobId>`\n - `town plugin schedule cancel <jobId>`\n- ActionSchedule 管理命令用于查看/取消延迟执行的 plugin action,不是独立 plugin。\n- 当前内建托管 plugin:`shell` / `chat` / `task` / `memory` / `contact`。\n- 当前内建本地 plugin:`auth` / `skill` / `asr` / `tts`。\n- 模块级 action 命令:\n - `town shell <action> ...`\n - `town chat <action> ...`\n - `town task <action> ...`\n - `town memory <action> ...`\n - `town plugin action <plugin> <action> ...`\n - `town skill <action> ...`\n - `town asr <action> ...`\n - `town tts <action> ...`\n\n具体 plugin 的执行参考对应文档。\n";
8
8
 
9
9
  export default TEXT_MODULE_CONTENT;
@@ -3,27 +3,27 @@
3
3
  你正在一个基于 plugin 的执行环境中工作。
4
4
 
5
5
  ## 可用命令总览
6
- - plugin 状态管理(统一使用 `city plugin`):
7
- - `city plugin list`
8
- - `city plugin status <pluginName>`
9
- - `city plugin start <pluginName>`
10
- - `city plugin stop <pluginName>`
11
- - `city plugin restart <pluginName>`
12
- - `city plugin command <pluginName> <command> [--payload '<json>']`
13
- - `city plugin schedule list`
14
- - `city plugin schedule info <jobId>`
15
- - `city plugin schedule cancel <jobId>`
6
+ - plugin 状态管理(统一使用 `town plugin`):
7
+ - `town plugin list`
8
+ - `town plugin status <pluginName>`
9
+ - `town plugin start <pluginName>`
10
+ - `town plugin stop <pluginName>`
11
+ - `town plugin restart <pluginName>`
12
+ - `town plugin command <pluginName> <command> [--payload '<json>']`
13
+ - `town plugin schedule list`
14
+ - `town plugin schedule info <jobId>`
15
+ - `town plugin schedule cancel <jobId>`
16
16
  - ActionSchedule 管理命令用于查看/取消延迟执行的 plugin action,不是独立 plugin。
17
17
  - 当前内建托管 plugin:`shell` / `chat` / `task` / `memory` / `contact`。
18
18
  - 当前内建本地 plugin:`auth` / `skill` / `asr` / `tts`。
19
19
  - 模块级 action 命令:
20
- - `city shell <action> ...`
21
- - `city chat <action> ...`
22
- - `city task <action> ...`
23
- - `city memory <action> ...`
24
- - `city plugin action <plugin> <action> ...`
25
- - `city skill <action> ...`
26
- - `city asr <action> ...`
27
- - `city tts <action> ...`
20
+ - `town shell <action> ...`
21
+ - `town chat <action> ...`
22
+ - `town task <action> ...`
23
+ - `town memory <action> ...`
24
+ - `town plugin action <plugin> <action> ...`
25
+ - `town skill <action> ...`
26
+ - `town asr <action> ...`
27
+ - `town tts <action> ...`
28
28
 
29
29
  具体 plugin 的执行参考对应文档。
@@ -4,6 +4,6 @@
4
4
  */
5
5
 
6
6
  // Source: src/executor/composer/system/default/assets/task.prompt.ts.txt
7
- const TEXT_MODULE_CONTENT = "你正在执行 Task 系统内部任务(非聊天会话)。\n\n运行约束(关键):\n- 当前上下文用于任务执行与审计,不是用户聊天回合。\n- 除非任务正文明确要求,否则不要调用 `city chat send` 或任何外部渠道发送动作。\n- 不要把自己当作“即时对话客服”;优先完成任务目标并输出可审计结果。\n- 允许在执行过程中产生必要的中间说明,但你**最后一条 assistant 返回**会被系统直接当作 `output.md` 与最终发送内容。\n\n输出原则:\n- 你的最后一条 assistant 返回必须是“任务交付物本身”。\n- 最后一条 assistant 返回不要包含过程汇报、状态说明、任务管理说明或发送说明。\n- 优先返回可复用、结构化、简洁的结果内容。\n- 不要回显冗长原始日志;必要时给摘要与关键结论。\n- 如任务输入要求固定格式(例如 JSON),严格遵守该格式。\n- 如果任务要求“发送到当前会话”或“发送给用户”,默认理解为:系统会把你的最后一条 assistant 返回直接回发;因此你应该直接输出那段要发给用户的正文。\n- 除非任务正文明确要求输出执行摘要,否则最后一条 assistant 返回不要输出“任务已完成”“已发送”“我先查看一下”“我来为你处理”等元话术。\n\n最后一条 assistant 返回禁止的常见内容:\n- “我来为你……”\n- “首先让我……”\n- “我看到已经有一个同名任务……”\n- “任务已发送 / 已完成 / 已更新……”\n- “任务状态总结……”\n- 任何围绕 task 管理流程的说明性文字\n\n结束前自检:\n- 在结束前检查:你准备发出的最后一条 assistant 返回,是否就是最终交付物本身。\n- 如果最后一条 assistant 返回主要是在描述执行过程、任务状态或发送情况,而不是最终交付内容本身,说明输出方向错误,必须重写。\n- 如果删掉“我来”“首先”“已发送”“任务状态”这类句子后几乎没有剩余内容,说明这不是合格的 task 输出。\n\n上下文原则:\n- 该任务上下文是独立执行上下文,不继承聊天对话目标。\n- 如与系统其他提示冲突,以“任务执行上下文规则”为准。\n";
7
+ const TEXT_MODULE_CONTENT = "你正在执行 Task 系统内部任务(非聊天会话)。\n\n运行约束(关键):\n- 当前上下文用于任务执行与审计,不是用户聊天回合。\n- 除非任务正文明确要求,否则不要调用 `town chat send` 或任何外部渠道发送动作。\n- 不要把自己当作“即时对话客服”;优先完成任务目标并输出可审计结果。\n- 允许在执行过程中产生必要的中间说明,但你**最后一条 assistant 返回**会被系统直接当作 `output.md` 与最终发送内容。\n\n输出原则:\n- 你的最后一条 assistant 返回必须是“任务交付物本身”。\n- 最后一条 assistant 返回不要包含过程汇报、状态说明、任务管理说明或发送说明。\n- 优先返回可复用、结构化、简洁的结果内容。\n- 不要回显冗长原始日志;必要时给摘要与关键结论。\n- 如任务输入要求固定格式(例如 JSON),严格遵守该格式。\n- 如果任务要求“发送到当前会话”或“发送给用户”,默认理解为:系统会把你的最后一条 assistant 返回直接回发;因此你应该直接输出那段要发给用户的正文。\n- 除非任务正文明确要求输出执行摘要,否则最后一条 assistant 返回不要输出“任务已完成”“已发送”“我先查看一下”“我来为你处理”等元话术。\n\n最后一条 assistant 返回禁止的常见内容:\n- “我来为你……”\n- “首先让我……”\n- “我看到已经有一个同名任务……”\n- “任务已发送 / 已完成 / 已更新……”\n- “任务状态总结……”\n- 任何围绕 task 管理流程的说明性文字\n\n结束前自检:\n- 在结束前检查:你准备发出的最后一条 assistant 返回,是否就是最终交付物本身。\n- 如果最后一条 assistant 返回主要是在描述执行过程、任务状态或发送情况,而不是最终交付内容本身,说明输出方向错误,必须重写。\n- 如果删掉“我来”“首先”“已发送”“任务状态”这类句子后几乎没有剩余内容,说明这不是合格的 task 输出。\n\n上下文原则:\n- 该任务上下文是独立执行上下文,不继承聊天对话目标。\n- 如与系统其他提示冲突,以“任务执行上下文规则”为准。\n";
8
8
 
9
9
  export default TEXT_MODULE_CONTENT;
@@ -2,7 +2,7 @@
2
2
 
3
3
  运行约束(关键):
4
4
  - 当前上下文用于任务执行与审计,不是用户聊天回合。
5
- - 除非任务正文明确要求,否则不要调用 `city chat send` 或任何外部渠道发送动作。
5
+ - 除非任务正文明确要求,否则不要调用 `town chat send` 或任何外部渠道发送动作。
6
6
  - 不要把自己当作“即时对话客服”;优先完成任务目标并输出可审计结果。
7
7
  - 允许在执行过程中产生必要的中间说明,但你**最后一条 assistant 返回**会被系统直接当作 `output.md` 与最终发送内容。
8
8
 
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 统一描述 chat plugin runtime 中可见的消息协议:frontmatter metadata + `<file>` 标签。
6
- * - direct 模式、`city chat send`、入站附件注入、渠道出站解析都应复用本类型。
6
+ * - direct 模式、`town chat send`、入站附件注入、渠道出站解析都应复用本类型。
7
7
  */
8
8
 
9
9
  /**
@@ -194,29 +194,9 @@ export class JsonlSessionHistoryStore implements SessionHistoryStore {
194
194
  await fs.ensureFile(this.getMessagesFilePath());
195
195
  }
196
196
 
197
- private normalizePinnedSkillIds(input: string[] | undefined): string[] {
198
- if (!Array.isArray(input)) return [];
199
- const out: string[] = [];
200
- for (const raw of input) {
201
- const id = typeof raw === "string" ? raw.trim() : "";
202
- if (!id) continue;
203
- out.push(id);
204
- }
205
- return Array.from(new Set(out)).slice(0, 2000);
206
- }
207
-
208
- private normalizeSdkConfig(
209
- input: SessionHistoryMetaV1["sdkConfig"],
210
- ): SessionHistoryMetaV1["sdkConfig"] {
211
- if (!input || typeof input !== "object" || Array.isArray(input)) {
212
- return undefined;
213
- }
214
- const modelLabel =
215
- typeof input.modelLabel === "string" ? input.modelLabel.trim() : "";
216
- if (!modelLabel) return undefined;
217
- return {
218
- modelLabel,
219
- };
197
+ private normalizeText(input: unknown): string | undefined {
198
+ const value = typeof input === "string" ? input.trim() : "";
199
+ return value || undefined;
220
200
  }
221
201
 
222
202
  private async readMetaUnsafe(): Promise<SessionHistoryMetaV1> {
@@ -235,24 +215,15 @@ export class JsonlSessionHistoryStore implements SessionHistoryStore {
235
215
  ...(typeof raw.createdAt === "number" && Number.isFinite(raw.createdAt)
236
216
  ? { createdAt: raw.createdAt }
237
217
  : {}),
238
- updatedAt: typeof raw.updatedAt === "number" ? raw.updatedAt : 0,
239
- pinnedSkillIds: this.normalizePinnedSkillIds(raw.pinnedSkillIds),
240
- ...(typeof raw.lastArchiveId === "string" && raw.lastArchiveId.trim()
241
- ? { lastArchiveId: raw.lastArchiveId.trim() }
242
- : {}),
243
- ...(typeof raw.keepLastMessages === "number" &&
244
- Number.isFinite(raw.keepLastMessages)
245
- ? { keepLastMessages: raw.keepLastMessages }
246
- : {}),
247
- ...(typeof raw.maxInputTokensApprox === "number" &&
248
- Number.isFinite(raw.maxInputTokensApprox)
249
- ? { maxInputTokensApprox: raw.maxInputTokensApprox }
218
+ ...(this.normalizeText(raw.timezone)
219
+ ? { timezone: this.normalizeText(raw.timezone) }
250
220
  : {}),
251
- ...(typeof raw.compactRatio === "number" && Number.isFinite(raw.compactRatio)
252
- ? { compactRatio: raw.compactRatio }
221
+ updatedAt: typeof raw.updatedAt === "number" ? raw.updatedAt : 0,
222
+ ...(this.normalizeText(raw.title)
223
+ ? { title: this.normalizeText(raw.title) }
253
224
  : {}),
254
- ...(this.normalizeSdkConfig(raw.sdkConfig)
255
- ? { sdkConfig: this.normalizeSdkConfig(raw.sdkConfig) }
225
+ ...(this.normalizeText(raw.modelLabel)
226
+ ? { modelLabel: this.normalizeText(raw.modelLabel) }
256
227
  : {}),
257
228
  };
258
229
  } catch {
@@ -261,7 +232,6 @@ export class JsonlSessionHistoryStore implements SessionHistoryStore {
261
232
  sessionId: this.sessionId,
262
233
  createdAt: Date.now(),
263
234
  updatedAt: 0,
264
- pinnedSkillIds: [],
265
235
  };
266
236
  }
267
237
  }
@@ -276,26 +246,16 @@ export class JsonlSessionHistoryStore implements SessionHistoryStore {
276
246
  ...(typeof next.createdAt === "number" && Number.isFinite(next.createdAt)
277
247
  ? { createdAt: next.createdAt }
278
248
  : {}),
249
+ ...(this.normalizeText(next.timezone)
250
+ ? { timezone: this.normalizeText(next.timezone) }
251
+ : {}),
279
252
  updatedAt:
280
253
  typeof next.updatedAt === "number" ? next.updatedAt : Date.now(),
281
- pinnedSkillIds: this.normalizePinnedSkillIds(next.pinnedSkillIds),
282
- ...(typeof next.lastArchiveId === "string" && next.lastArchiveId.trim()
283
- ? { lastArchiveId: next.lastArchiveId.trim() }
284
- : {}),
285
- ...(typeof next.keepLastMessages === "number" &&
286
- Number.isFinite(next.keepLastMessages)
287
- ? { keepLastMessages: next.keepLastMessages }
288
- : {}),
289
- ...(typeof next.maxInputTokensApprox === "number" &&
290
- Number.isFinite(next.maxInputTokensApprox)
291
- ? { maxInputTokensApprox: next.maxInputTokensApprox }
292
- : {}),
293
- ...(typeof next.compactRatio === "number" &&
294
- Number.isFinite(next.compactRatio)
295
- ? { compactRatio: next.compactRatio }
254
+ ...(this.normalizeText(next.title)
255
+ ? { title: this.normalizeText(next.title) }
296
256
  : {}),
297
- ...(this.normalizeSdkConfig(next.sdkConfig)
298
- ? { sdkConfig: this.normalizeSdkConfig(next.sdkConfig) }
257
+ ...(this.normalizeText(next.modelLabel)
258
+ ? { modelLabel: this.normalizeText(next.modelLabel) }
299
259
  : {}),
300
260
  };
301
261
  await fs.writeJson(this.getMetaFilePath(), normalized, { spaces: 2 });
@@ -75,7 +75,7 @@ function tryParseJsonObject(raw: string): JsonObject | null {
75
75
  function shouldEnableCommandBridge(command: string): boolean {
76
76
  const raw = String(command || "").trim();
77
77
  if (!raw) return false;
78
- return /(?:^|\s)(?:city|downcity)(?:\s|$)/i.test(raw);
78
+ return /(?:^|\s)(?:city|town)(?:\s|$)/i.test(raw);
79
79
  }
80
80
 
81
81
  async function injectUserTextMessage(params: {
@@ -33,7 +33,7 @@ function applyEnvMap(
33
33
  }
34
34
 
35
35
  /**
36
- * 对 `city chat send` 命令做前置安全校验。
36
+ * 对 `town chat send` 命令做前置安全校验。
37
37
  *
38
38
  * 关键点(中文)
39
39
  * - 历史上模型会把长文本直接拼进多行 shell 命令,导致后续行被 zsh 当作独立命令解析。
@@ -42,20 +42,20 @@ function applyEnvMap(
42
42
  */
43
43
  export function validateChatSendCommand(cmd: string): string | null {
44
44
  const source = String(cmd ?? "");
45
- if (!/\b(?:city|downcity)\s+chat\s+send\b/.test(source)) return null;
45
+ if (!/\bbay\s+chat\s+send\b/.test(source)) return null;
46
46
  if (!/[\r\n]/.test(source)) return null;
47
- if (/\b(?:city|downcity)\s+chat\s+send\b[\s\S]*\s--stdin(?:\s|$)/.test(source)) {
47
+ if (/\bbay\s+chat\s+send\b[\s\S]*\s--stdin(?:\s|$)/.test(source)) {
48
48
  return null;
49
49
  }
50
- if (/\b(?:city|downcity)\s+chat\s+send\b[\s\S]*\s--text(?:\s|$)/.test(source)) {
50
+ if (/\bbay\s+chat\s+send\b[\s\S]*\s--text(?:\s|$)/.test(source)) {
51
51
  return null;
52
52
  }
53
- if (/\b(?:city|downcity)\s+chat\s+send\b[\s\S]*\s--text-file(?:\s|$)/.test(source)) {
53
+ if (/\bbay\s+chat\s+send\b[\s\S]*\s--text-file(?:\s|$)/.test(source)) {
54
54
  return null;
55
55
  }
56
56
  return [
57
- "Unsafe `city chat send` command: real newlines are not allowed.",
58
- "If your message is multi-line, use `city chat send --stdin` (with heredoc/pipe), `--text-file`, or explicit `--text`.",
57
+ "Unsafe `town chat send` command: real newlines are not allowed.",
58
+ "If your message is multi-line, use `town chat send --stdin` (with heredoc/pipe), `--text-file`, or explicit `--text`.",
59
59
  ].join(" ");
60
60
  }
61
61
 
@@ -75,8 +75,8 @@ export function buildShellContextEnv(
75
75
 
76
76
  applyEnvMap(env, injected);
77
77
  setEnvString(env, "DC_SESSION_ID", contextCtx?.sessionId);
78
- setEnvString(env, "DC_CTX_SERVER_HOST", process.env.DC_SERVER_HOST);
79
- setEnvString(env, "DC_CTX_SERVER_PORT", process.env.DC_SERVER_PORT);
78
+ setEnvString(env, "DC_CITY_HOST", process.env.DC_CITY_HOST);
79
+ setEnvString(env, "DC_CITY_PORT", process.env.DC_CITY_PORT);
80
80
  stripInvocationAuthEnv(env);
81
81
 
82
82
  return env;
@@ -3,21 +3,9 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 存储位置:`.downcity/agents/<encodedAgentId>/sessions/<encodedSessionId>/messages/meta.json`
6
- * - 用于保存 compact 元数据与固定注入的 skills 信息
6
+ * - 用于保存 session 列表、详情和索引所需的轻量元信息
7
7
  */
8
8
 
9
- /**
10
- * SDK Session 配置摘要。
11
- *
12
- * 关键点(中文)
13
- * - 这里只存可稳定序列化、仅用于回显/索引的轻量配置摘要。
14
- * - 例如本地注入的 `LanguageModel` 实例本身不可序列化,因此仅记录其可读标签。
15
- */
16
- export type SessionHistorySdkConfigV1 = {
17
- /** 当前 session 绑定模型的可读标签。 */
18
- modelLabel?: string;
19
- };
20
-
21
9
  export type SessionHistoryMetaV1 = {
22
10
  /** schema 版本。 */
23
11
  v: 1;
@@ -31,16 +19,8 @@ export type SessionHistoryMetaV1 = {
31
19
  timezone?: string;
32
20
  /** 最近一次更新元信息的时间戳(ms)。 */
33
21
  updatedAt: number;
34
- /** 固定注入到 Session 上下文的 skill id 列表。 */
35
- pinnedSkillIds: string[];
36
- /** 最近一次归档生成的 archive id。 */
37
- lastArchiveId?: string;
38
- /** 最近一次 compact 生效的保留消息数。 */
39
- keepLastMessages?: number;
40
- /** 最近一次 compact 生效的输入 token 近似上限。 */
41
- maxInputTokensApprox?: number;
42
- /** 最近一次 compact 生效的前段压缩比例。 */
43
- compactRatio?: number;
44
- /** SDK 侧的轻量配置摘要。 */
45
- sdkConfig?: SessionHistorySdkConfigV1;
22
+ /** 当前 session 持久化标题。 */
23
+ title?: string;
24
+ /** 当前 session 绑定模型的可读标签。 */
25
+ modelLabel?: string;
46
26
  };
@@ -65,7 +65,7 @@ export type SessionAssistantStepCallback = (
65
65
  *
66
66
  * 关键点(中文)
67
67
  * - 这里直接复用 AI SDK 的 `UIMessageChunk` 结构,避免在 session 内核层再复制一套协议。
68
- * - SDK / HTTP / RPC 若需要自己的事件模型,应在更上层做映射。
68
+ * - SDK / HTTP 若需要自己的事件模型,应在更上层做映射。
69
69
  */
70
70
  export type SessionUiMessageChunk = UIMessageChunk;
71
71
 
package/src/index.ts CHANGED
@@ -10,16 +10,20 @@
10
10
  // Agent 入口
11
11
  export { Agent } from "./agent/Agent.js";
12
12
  export { RemoteAgent } from "./agent/RemoteAgent.js";
13
+ export {
14
+ inferAgentModelLabel,
15
+ normalizeAgentModel,
16
+ } from "./model/CityModelAdapter.js";
13
17
  export type {
14
18
  AgentSessionCollection,
19
+ AgentModel,
15
20
  AgentSessionActor,
16
21
  AgentSession,
17
22
  AgentCreateSessionInput,
18
23
  AgentListSessionsInput,
19
24
  AgentOptions,
20
- AgentHttpBinding,
21
- AgentHttpStartOptions,
22
25
  AgentRpcBinding,
26
+ AgentRpcStartOptions,
23
27
  AgentStartOptions,
24
28
  AgentStartResult,
25
29
  AgentStopResult,
@@ -103,10 +107,11 @@ export {
103
107
  registerPluginActionCommandsForCli,
104
108
  } from "./plugin/core/PluginCommand.js";
105
109
 
106
- // Agent server 与 transport 集成
110
+ // Agent RPC 集成
111
+ export { startRpcServer } from "./rpc/Server.js";
112
+
113
+ // 宿主 HTTP gateway 集成
107
114
  export { startServer } from "./runtime/server/http/Server.js";
108
- export { startLocalRpcServer } from "./runtime/server/rpc/Server.js";
109
- export { callAgentTransport } from "./runtime/transport/rpc/Transport.js";
110
115
 
111
116
  // Runtime plugin 运行集成
112
117
  export {
@@ -127,7 +132,7 @@ export { persistProjectPluginConfig } from "./plugin/core/ProjectConfigStore.js"
127
132
  export {
128
133
  initializeAgentProject,
129
134
  isAgentProjectInitialized,
130
- normalizeDefaultAgentName,
135
+ normalizeDefaultAgentId,
131
136
  } from "./config/AgentInitializer.js";
132
137
  export { loadDowncityConfig } from "./config/Config.js";
133
138
  export {
@@ -193,7 +198,7 @@ export type {
193
198
  PlatformAgentShipStartConfig,
194
199
  } from "./types/runtime/platform/PlatformGateway.js";
195
200
 
196
- // Daemon / RPC 协议类型
201
+ // Daemon 协议类型
197
202
  export {
198
203
  DAEMON_LOG_FILENAME,
199
204
  DAEMON_META_FILENAME,
@@ -203,10 +208,6 @@ export type {
203
208
  DaemonMeta,
204
209
  DaemonStaleReason,
205
210
  } from "./types/runtime/daemon/Daemon.js";
206
- export type {
207
- LocalRpcRequest,
208
- LocalRpcResponse,
209
- } from "./types/runtime/rpc/LocalRpc.js";
210
211
 
211
212
  // Inline instant 协议类型
212
213
  export type {
@@ -281,21 +282,13 @@ export type {
281
282
 
282
283
  // Platform store 类型
283
284
  export type {
284
- StoredAgentEnvEntry,
285
285
  StoredChannelAccount,
286
286
  StoredChannelAccountChannel,
287
287
  StoredEnvEntry,
288
- StoredEnvScope,
289
288
  StoredGlobalEnvEntry,
290
- StoredModel,
291
- StoredModelProvider,
292
- StoredProviderMeta,
293
- UpsertAgentEnvEntryInput,
294
289
  UpsertChannelAccountInput,
295
290
  UpsertEnvEntryInput,
296
291
  UpsertGlobalEnvEntryInput,
297
- UpsertModelInput,
298
- UpsertModelProviderInput,
299
292
  } from "./types/runtime/host/Store.js";
300
293
 
301
294
  // HTTP auth 协议类型