agentshire 1.0.0

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 (406) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +437 -0
  4. package/README.zh-CN.md +441 -0
  5. package/ROADMAP.md +207 -0
  6. package/THIRD_PARTY_NOTICES.md +49 -0
  7. package/VISION.md +101 -0
  8. package/index.ts +386 -0
  9. package/openclaw.plugin.json +27 -0
  10. package/package.json +100 -0
  11. package/src/bridge/AGENTS.md +136 -0
  12. package/src/bridge/ActivityStream.ts +184 -0
  13. package/src/bridge/CitizenManager.ts +280 -0
  14. package/src/bridge/DirectorBridge.ts +1076 -0
  15. package/src/bridge/EventTranslator.ts +142 -0
  16. package/src/bridge/NpcEventQueue.ts +61 -0
  17. package/src/bridge/ReconnectManager.ts +42 -0
  18. package/src/bridge/RouteManager.ts +270 -0
  19. package/src/bridge/StateTracker.ts +100 -0
  20. package/src/bridge/ToolVfxMapper.ts +94 -0
  21. package/src/bridge/__tests__/ActivityStream.test.ts +156 -0
  22. package/src/bridge/__tests__/CitizenManager.test.ts +174 -0
  23. package/src/bridge/__tests__/EventTranslator.test.ts +292 -0
  24. package/src/bridge/__tests__/NpcEventQueue.test.ts +92 -0
  25. package/src/bridge/__tests__/RouteManager.test.ts +106 -0
  26. package/src/bridge/data/route-config.json +36 -0
  27. package/src/bridge/data/route-config.ts +19 -0
  28. package/src/bridge/implicit-chat.ts +192 -0
  29. package/src/bridge/index.ts +12 -0
  30. package/src/contracts/agent-state.ts +87 -0
  31. package/src/contracts/agui.ts +212 -0
  32. package/src/contracts/chat.ts +67 -0
  33. package/src/contracts/events.ts +170 -0
  34. package/src/contracts/index.ts +71 -0
  35. package/src/contracts/media.ts +77 -0
  36. package/src/contracts/registry.ts +32 -0
  37. package/src/plugin/AGENTS.md +192 -0
  38. package/src/plugin/__tests__/editor-serve-megapack.test.ts +150 -0
  39. package/src/plugin/__tests__/hook-translator.test.ts +197 -0
  40. package/src/plugin/auto-config.ts +131 -0
  41. package/src/plugin/channel.ts +399 -0
  42. package/src/plugin/chat-asset-resolver.ts +75 -0
  43. package/src/plugin/chat-session-watcher.ts +98 -0
  44. package/src/plugin/citizen-agent-manager.ts +178 -0
  45. package/src/plugin/citizen-chat-router.ts +83 -0
  46. package/src/plugin/citizen-workshop-manager.ts +96 -0
  47. package/src/plugin/custom-asset-manager.ts +250 -0
  48. package/src/plugin/editor-serve.ts +1368 -0
  49. package/src/plugin/group-discussion.ts +223 -0
  50. package/src/plugin/hook-translator.ts +202 -0
  51. package/src/plugin/llm-agent-proxy.ts +193 -0
  52. package/src/plugin/outbound-adapter.ts +187 -0
  53. package/src/plugin/paths.ts +33 -0
  54. package/src/plugin/plan-manager.ts +594 -0
  55. package/src/plugin/runtime.ts +9 -0
  56. package/src/plugin/session-history.ts +838 -0
  57. package/src/plugin/session-log-watcher.ts +221 -0
  58. package/src/plugin/soul-prompt-template.ts +290 -0
  59. package/src/plugin/subagent-tracker.ts +205 -0
  60. package/src/plugin/tools.ts +493 -0
  61. package/src/plugin/town-session.ts +40 -0
  62. package/src/plugin/ws-server.ts +680 -0
  63. package/src/town-souls.ts +134 -0
  64. package/town-frontend/dist/assets/CustomAssetStore-oi8aIurt.js +2 -0
  65. package/town-frontend/dist/assets/GLTFLoader-BA5RqSME.js +3804 -0
  66. package/town-frontend/dist/assets/OrbitControls-ZmySp9sQ.js +2 -0
  67. package/town-frontend/dist/assets/SettingsPanel-BO52reJe.js +2 -0
  68. package/town-frontend/dist/assets/SkeletonUtils-BCVmgslc.js +2 -0
  69. package/town-frontend/dist/assets/SkillLearnCard-Dk38iDpy.js +6 -0
  70. package/town-frontend/dist/assets/TopicSetupPanel-DLaLHB_Z.js +2 -0
  71. package/town-frontend/dist/assets/Trap-Bold-CT0JBE39.woff2 +0 -0
  72. package/town-frontend/dist/assets/Trap-SemiBold-R4_-Ld0j.woff2 +0 -0
  73. package/town-frontend/dist/assets/WeatherSystem-Cb3BvHes.js +550 -0
  74. package/town-frontend/dist/assets/avatars/char-female-a.webp +0 -0
  75. package/town-frontend/dist/assets/avatars/char-female-b.webp +0 -0
  76. package/town-frontend/dist/assets/avatars/char-female-c.webp +0 -0
  77. package/town-frontend/dist/assets/avatars/char-female-d.webp +0 -0
  78. package/town-frontend/dist/assets/avatars/char-female-e.webp +0 -0
  79. package/town-frontend/dist/assets/avatars/char-female-f.webp +0 -0
  80. package/town-frontend/dist/assets/avatars/char-male-a.webp +0 -0
  81. package/town-frontend/dist/assets/avatars/char-male-b.webp +0 -0
  82. package/town-frontend/dist/assets/avatars/char-male-c.webp +0 -0
  83. package/town-frontend/dist/assets/avatars/char-male-d.webp +0 -0
  84. package/town-frontend/dist/assets/avatars/char-male-e.webp +0 -0
  85. package/town-frontend/dist/assets/avatars/char-male-f.webp +0 -0
  86. package/town-frontend/dist/assets/avatars/char-pet-beaver.webp +0 -0
  87. package/town-frontend/dist/assets/avatars/char-pet-bee.webp +0 -0
  88. package/town-frontend/dist/assets/avatars/char-pet-bunny.webp +0 -0
  89. package/town-frontend/dist/assets/avatars/char-pet-cat.webp +0 -0
  90. package/town-frontend/dist/assets/avatars/char-pet-caterpillar.webp +0 -0
  91. package/town-frontend/dist/assets/avatars/char-pet-chick.webp +0 -0
  92. package/town-frontend/dist/assets/avatars/char-pet-cow.webp +0 -0
  93. package/town-frontend/dist/assets/avatars/char-pet-crab.webp +0 -0
  94. package/town-frontend/dist/assets/avatars/char-pet-deer.webp +0 -0
  95. package/town-frontend/dist/assets/avatars/char-pet-dog.webp +0 -0
  96. package/town-frontend/dist/assets/avatars/char-pet-elephant.webp +0 -0
  97. package/town-frontend/dist/assets/avatars/char-pet-fish.webp +0 -0
  98. package/town-frontend/dist/assets/avatars/char-pet-fox.webp +0 -0
  99. package/town-frontend/dist/assets/avatars/char-pet-giraffe.webp +0 -0
  100. package/town-frontend/dist/assets/avatars/char-pet-hog.webp +0 -0
  101. package/town-frontend/dist/assets/avatars/char-pet-koala.webp +0 -0
  102. package/town-frontend/dist/assets/avatars/char-pet-lion.webp +0 -0
  103. package/town-frontend/dist/assets/avatars/char-pet-monkey.webp +0 -0
  104. package/town-frontend/dist/assets/avatars/char-pet-panda.webp +0 -0
  105. package/town-frontend/dist/assets/avatars/char-pet-parrot.webp +0 -0
  106. package/town-frontend/dist/assets/avatars/char-pet-penguin.webp +0 -0
  107. package/town-frontend/dist/assets/avatars/char-pet-pig.webp +0 -0
  108. package/town-frontend/dist/assets/avatars/char-pet-polar.webp +0 -0
  109. package/town-frontend/dist/assets/avatars/char-pet-tiger.webp +0 -0
  110. package/town-frontend/dist/assets/character-catalog-DSmLtlNC.js +2 -0
  111. package/town-frontend/dist/assets/citizenEditor-DubGSJOQ.js +296 -0
  112. package/town-frontend/dist/assets/command-parser-BUd15Bmv.js +12 -0
  113. package/town-frontend/dist/assets/editor-B5QO0OtX.js +258 -0
  114. package/town-frontend/dist/assets/editor-Bk8g1NCD.css +1 -0
  115. package/town-frontend/dist/assets/index-BWfrufil.js +2 -0
  116. package/town-frontend/dist/assets/index-faS20RJk.js +6 -0
  117. package/town-frontend/dist/assets/logo-DJI6EtST.png +0 -0
  118. package/town-frontend/dist/assets/logo-title-AdKPZX5E.png +0 -0
  119. package/town-frontend/dist/assets/main-CqsN43aT.js +224 -0
  120. package/town-frontend/dist/assets/main-D7neuy3w.css +1 -0
  121. package/town-frontend/dist/assets/models/buildings/base.bin +0 -0
  122. package/town-frontend/dist/assets/models/buildings/base.gltf +136 -0
  123. package/town-frontend/dist/assets/models/buildings/bench.bin +0 -0
  124. package/town-frontend/dist/assets/models/buildings/bench.gltf +136 -0
  125. package/town-frontend/dist/assets/models/buildings/box_A.bin +0 -0
  126. package/town-frontend/dist/assets/models/buildings/box_A.gltf +136 -0
  127. package/town-frontend/dist/assets/models/buildings/box_B.bin +0 -0
  128. package/town-frontend/dist/assets/models/buildings/box_B.gltf +136 -0
  129. package/town-frontend/dist/assets/models/buildings/building_A.bin +0 -0
  130. package/town-frontend/dist/assets/models/buildings/building_A.gltf +136 -0
  131. package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.bin +0 -0
  132. package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.gltf +136 -0
  133. package/town-frontend/dist/assets/models/buildings/building_B.bin +0 -0
  134. package/town-frontend/dist/assets/models/buildings/building_B.gltf +136 -0
  135. package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.bin +0 -0
  136. package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.gltf +136 -0
  137. package/town-frontend/dist/assets/models/buildings/building_C.bin +0 -0
  138. package/town-frontend/dist/assets/models/buildings/building_C.gltf +136 -0
  139. package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.bin +0 -0
  140. package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.gltf +136 -0
  141. package/town-frontend/dist/assets/models/buildings/building_D.bin +0 -0
  142. package/town-frontend/dist/assets/models/buildings/building_D.gltf +136 -0
  143. package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.bin +0 -0
  144. package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.gltf +136 -0
  145. package/town-frontend/dist/assets/models/buildings/building_E.bin +0 -0
  146. package/town-frontend/dist/assets/models/buildings/building_E.gltf +136 -0
  147. package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.bin +0 -0
  148. package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.gltf +136 -0
  149. package/town-frontend/dist/assets/models/buildings/building_F.bin +0 -0
  150. package/town-frontend/dist/assets/models/buildings/building_F.gltf +136 -0
  151. package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.bin +0 -0
  152. package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.gltf +136 -0
  153. package/town-frontend/dist/assets/models/buildings/building_G.bin +0 -0
  154. package/town-frontend/dist/assets/models/buildings/building_G.gltf +136 -0
  155. package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.bin +0 -0
  156. package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.gltf +136 -0
  157. package/town-frontend/dist/assets/models/buildings/building_H.bin +0 -0
  158. package/town-frontend/dist/assets/models/buildings/building_H.gltf +136 -0
  159. package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.bin +0 -0
  160. package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.gltf +136 -0
  161. package/town-frontend/dist/assets/models/buildings/bush.bin +0 -0
  162. package/town-frontend/dist/assets/models/buildings/bush.gltf +136 -0
  163. package/town-frontend/dist/assets/models/buildings/car_hatchback.bin +0 -0
  164. package/town-frontend/dist/assets/models/buildings/car_hatchback.gltf +442 -0
  165. package/town-frontend/dist/assets/models/buildings/car_police.bin +0 -0
  166. package/town-frontend/dist/assets/models/buildings/car_police.gltf +442 -0
  167. package/town-frontend/dist/assets/models/buildings/car_sedan.bin +0 -0
  168. package/town-frontend/dist/assets/models/buildings/car_sedan.gltf +442 -0
  169. package/town-frontend/dist/assets/models/buildings/car_stationwagon.bin +0 -0
  170. package/town-frontend/dist/assets/models/buildings/car_stationwagon.gltf +442 -0
  171. package/town-frontend/dist/assets/models/buildings/car_taxi.bin +0 -0
  172. package/town-frontend/dist/assets/models/buildings/car_taxi.gltf +442 -0
  173. package/town-frontend/dist/assets/models/buildings/citybits_texture.png +0 -0
  174. package/town-frontend/dist/assets/models/buildings/dumpster.bin +0 -0
  175. package/town-frontend/dist/assets/models/buildings/dumpster.gltf +136 -0
  176. package/town-frontend/dist/assets/models/buildings/firehydrant.bin +0 -0
  177. package/town-frontend/dist/assets/models/buildings/firehydrant.gltf +136 -0
  178. package/town-frontend/dist/assets/models/buildings/road_corner.bin +0 -0
  179. package/town-frontend/dist/assets/models/buildings/road_corner.gltf +136 -0
  180. package/town-frontend/dist/assets/models/buildings/road_corner_curved.bin +0 -0
  181. package/town-frontend/dist/assets/models/buildings/road_corner_curved.gltf +136 -0
  182. package/town-frontend/dist/assets/models/buildings/road_junction.bin +0 -0
  183. package/town-frontend/dist/assets/models/buildings/road_junction.gltf +136 -0
  184. package/town-frontend/dist/assets/models/buildings/road_straight.bin +0 -0
  185. package/town-frontend/dist/assets/models/buildings/road_straight.gltf +136 -0
  186. package/town-frontend/dist/assets/models/buildings/road_straight_crossing.bin +0 -0
  187. package/town-frontend/dist/assets/models/buildings/road_straight_crossing.gltf +136 -0
  188. package/town-frontend/dist/assets/models/buildings/road_tsplit.bin +0 -0
  189. package/town-frontend/dist/assets/models/buildings/road_tsplit.gltf +136 -0
  190. package/town-frontend/dist/assets/models/buildings/streetlight.bin +0 -0
  191. package/town-frontend/dist/assets/models/buildings/streetlight.gltf +136 -0
  192. package/town-frontend/dist/assets/models/buildings/trafficlight_A.bin +0 -0
  193. package/town-frontend/dist/assets/models/buildings/trafficlight_A.gltf +136 -0
  194. package/town-frontend/dist/assets/models/buildings/trafficlight_B.bin +0 -0
  195. package/town-frontend/dist/assets/models/buildings/trafficlight_B.gltf +136 -0
  196. package/town-frontend/dist/assets/models/buildings/trafficlight_C.bin +0 -0
  197. package/town-frontend/dist/assets/models/buildings/trafficlight_C.gltf +136 -0
  198. package/town-frontend/dist/assets/models/buildings/trash_A.bin +0 -0
  199. package/town-frontend/dist/assets/models/buildings/trash_A.gltf +136 -0
  200. package/town-frontend/dist/assets/models/buildings/trash_B.bin +0 -0
  201. package/town-frontend/dist/assets/models/buildings/trash_B.gltf +136 -0
  202. package/town-frontend/dist/assets/models/buildings/watertower.bin +0 -0
  203. package/town-frontend/dist/assets/models/buildings/watertower.gltf +136 -0
  204. package/town-frontend/dist/assets/models/characters/Textures/colormap.png +0 -0
  205. package/town-frontend/dist/assets/models/characters/character-female-a.glb +0 -0
  206. package/town-frontend/dist/assets/models/characters/character-female-b.glb +0 -0
  207. package/town-frontend/dist/assets/models/characters/character-female-c.glb +0 -0
  208. package/town-frontend/dist/assets/models/characters/character-female-d.glb +0 -0
  209. package/town-frontend/dist/assets/models/characters/character-female-e.glb +0 -0
  210. package/town-frontend/dist/assets/models/characters/character-female-f.glb +0 -0
  211. package/town-frontend/dist/assets/models/characters/character-male-a.glb +0 -0
  212. package/town-frontend/dist/assets/models/characters/character-male-b.glb +0 -0
  213. package/town-frontend/dist/assets/models/characters/character-male-c.glb +0 -0
  214. package/town-frontend/dist/assets/models/characters/character-male-d.glb +0 -0
  215. package/town-frontend/dist/assets/models/characters/character-male-e.glb +0 -0
  216. package/town-frontend/dist/assets/models/characters/character-male-f.glb +0 -0
  217. package/town-frontend/dist/assets/models/characters/character-pet-beaver.glb +0 -0
  218. package/town-frontend/dist/assets/models/characters/character-pet-bee.glb +0 -0
  219. package/town-frontend/dist/assets/models/characters/character-pet-bunny.glb +0 -0
  220. package/town-frontend/dist/assets/models/characters/character-pet-cat.glb +0 -0
  221. package/town-frontend/dist/assets/models/characters/character-pet-caterpillar.glb +0 -0
  222. package/town-frontend/dist/assets/models/characters/character-pet-chick.glb +0 -0
  223. package/town-frontend/dist/assets/models/characters/character-pet-cow.glb +0 -0
  224. package/town-frontend/dist/assets/models/characters/character-pet-crab.glb +0 -0
  225. package/town-frontend/dist/assets/models/characters/character-pet-deer.glb +0 -0
  226. package/town-frontend/dist/assets/models/characters/character-pet-dog.glb +0 -0
  227. package/town-frontend/dist/assets/models/characters/character-pet-elephant.glb +0 -0
  228. package/town-frontend/dist/assets/models/characters/character-pet-fish.glb +0 -0
  229. package/town-frontend/dist/assets/models/characters/character-pet-fox.glb +0 -0
  230. package/town-frontend/dist/assets/models/characters/character-pet-giraffe.glb +0 -0
  231. package/town-frontend/dist/assets/models/characters/character-pet-hog.glb +0 -0
  232. package/town-frontend/dist/assets/models/characters/character-pet-koala.glb +0 -0
  233. package/town-frontend/dist/assets/models/characters/character-pet-lion.glb +0 -0
  234. package/town-frontend/dist/assets/models/characters/character-pet-monkey.glb +0 -0
  235. package/town-frontend/dist/assets/models/characters/character-pet-panda.glb +0 -0
  236. package/town-frontend/dist/assets/models/characters/character-pet-parrot.glb +0 -0
  237. package/town-frontend/dist/assets/models/characters/character-pet-penguin.glb +0 -0
  238. package/town-frontend/dist/assets/models/characters/character-pet-pig.glb +0 -0
  239. package/town-frontend/dist/assets/models/characters/character-pet-polar.glb +0 -0
  240. package/town-frontend/dist/assets/models/characters/character-pet-tiger.glb +0 -0
  241. package/town-frontend/dist/assets/models/characters/colormap.png +0 -0
  242. package/town-frontend/dist/assets/models/furniture/armchair.bin +0 -0
  243. package/town-frontend/dist/assets/models/furniture/armchair.gltf +136 -0
  244. package/town-frontend/dist/assets/models/furniture/armchair_pillows.bin +0 -0
  245. package/town-frontend/dist/assets/models/furniture/armchair_pillows.gltf +136 -0
  246. package/town-frontend/dist/assets/models/furniture/bed_double_A.bin +0 -0
  247. package/town-frontend/dist/assets/models/furniture/bed_double_A.gltf +136 -0
  248. package/town-frontend/dist/assets/models/furniture/bed_double_B.bin +0 -0
  249. package/town-frontend/dist/assets/models/furniture/bed_double_B.gltf +136 -0
  250. package/town-frontend/dist/assets/models/furniture/bed_single_A.bin +0 -0
  251. package/town-frontend/dist/assets/models/furniture/bed_single_A.gltf +136 -0
  252. package/town-frontend/dist/assets/models/furniture/bed_single_B.bin +0 -0
  253. package/town-frontend/dist/assets/models/furniture/bed_single_B.gltf +136 -0
  254. package/town-frontend/dist/assets/models/furniture/book_set.bin +0 -0
  255. package/town-frontend/dist/assets/models/furniture/book_set.gltf +136 -0
  256. package/town-frontend/dist/assets/models/furniture/book_single.bin +0 -0
  257. package/town-frontend/dist/assets/models/furniture/book_single.gltf +136 -0
  258. package/town-frontend/dist/assets/models/furniture/cabinet_medium.bin +0 -0
  259. package/town-frontend/dist/assets/models/furniture/cabinet_medium.gltf +136 -0
  260. package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.bin +0 -0
  261. package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.gltf +136 -0
  262. package/town-frontend/dist/assets/models/furniture/cabinet_small.bin +0 -0
  263. package/town-frontend/dist/assets/models/furniture/cabinet_small.gltf +136 -0
  264. package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.bin +0 -0
  265. package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.gltf +136 -0
  266. package/town-frontend/dist/assets/models/furniture/cactus_medium_A.bin +0 -0
  267. package/town-frontend/dist/assets/models/furniture/cactus_medium_A.gltf +136 -0
  268. package/town-frontend/dist/assets/models/furniture/cactus_medium_B.bin +0 -0
  269. package/town-frontend/dist/assets/models/furniture/cactus_medium_B.gltf +136 -0
  270. package/town-frontend/dist/assets/models/furniture/cactus_small_A.bin +0 -0
  271. package/town-frontend/dist/assets/models/furniture/cactus_small_A.gltf +136 -0
  272. package/town-frontend/dist/assets/models/furniture/cactus_small_B.bin +0 -0
  273. package/town-frontend/dist/assets/models/furniture/cactus_small_B.gltf +136 -0
  274. package/town-frontend/dist/assets/models/furniture/chair_A.bin +0 -0
  275. package/town-frontend/dist/assets/models/furniture/chair_A.gltf +136 -0
  276. package/town-frontend/dist/assets/models/furniture/chair_A_wood.bin +0 -0
  277. package/town-frontend/dist/assets/models/furniture/chair_A_wood.gltf +136 -0
  278. package/town-frontend/dist/assets/models/furniture/chair_B.bin +0 -0
  279. package/town-frontend/dist/assets/models/furniture/chair_B.gltf +136 -0
  280. package/town-frontend/dist/assets/models/furniture/chair_B_wood.bin +0 -0
  281. package/town-frontend/dist/assets/models/furniture/chair_B_wood.gltf +136 -0
  282. package/town-frontend/dist/assets/models/furniture/chair_C.bin +0 -0
  283. package/town-frontend/dist/assets/models/furniture/chair_C.gltf +136 -0
  284. package/town-frontend/dist/assets/models/furniture/chair_stool.bin +0 -0
  285. package/town-frontend/dist/assets/models/furniture/chair_stool.gltf +136 -0
  286. package/town-frontend/dist/assets/models/furniture/chair_stool_wood.bin +0 -0
  287. package/town-frontend/dist/assets/models/furniture/chair_stool_wood.gltf +136 -0
  288. package/town-frontend/dist/assets/models/furniture/couch.bin +0 -0
  289. package/town-frontend/dist/assets/models/furniture/couch.gltf +136 -0
  290. package/town-frontend/dist/assets/models/furniture/couch_pillows.bin +0 -0
  291. package/town-frontend/dist/assets/models/furniture/couch_pillows.gltf +136 -0
  292. package/town-frontend/dist/assets/models/furniture/furniturebits_texture.png +0 -0
  293. package/town-frontend/dist/assets/models/furniture/lamp_standing.bin +0 -0
  294. package/town-frontend/dist/assets/models/furniture/lamp_standing.gltf +136 -0
  295. package/town-frontend/dist/assets/models/furniture/lamp_table.bin +0 -0
  296. package/town-frontend/dist/assets/models/furniture/lamp_table.gltf +136 -0
  297. package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.bin +0 -0
  298. package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.gltf +136 -0
  299. package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.bin +0 -0
  300. package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.gltf +136 -0
  301. package/town-frontend/dist/assets/models/furniture/pictureframe_medium.bin +0 -0
  302. package/town-frontend/dist/assets/models/furniture/pictureframe_medium.gltf +136 -0
  303. package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.bin +0 -0
  304. package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.gltf +136 -0
  305. package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.bin +0 -0
  306. package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.gltf +136 -0
  307. package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.bin +0 -0
  308. package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.gltf +136 -0
  309. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.bin +0 -0
  310. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.gltf +136 -0
  311. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.bin +0 -0
  312. package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.gltf +136 -0
  313. package/town-frontend/dist/assets/models/furniture/pillow_A.bin +0 -0
  314. package/town-frontend/dist/assets/models/furniture/pillow_A.gltf +136 -0
  315. package/town-frontend/dist/assets/models/furniture/pillow_B.bin +0 -0
  316. package/town-frontend/dist/assets/models/furniture/pillow_B.gltf +136 -0
  317. package/town-frontend/dist/assets/models/furniture/rug_oval_A.bin +0 -0
  318. package/town-frontend/dist/assets/models/furniture/rug_oval_A.gltf +136 -0
  319. package/town-frontend/dist/assets/models/furniture/rug_oval_B.bin +0 -0
  320. package/town-frontend/dist/assets/models/furniture/rug_oval_B.gltf +136 -0
  321. package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.bin +0 -0
  322. package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.gltf +136 -0
  323. package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.bin +0 -0
  324. package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.gltf +136 -0
  325. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.bin +0 -0
  326. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.gltf +136 -0
  327. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.bin +0 -0
  328. package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.gltf +136 -0
  329. package/town-frontend/dist/assets/models/furniture/shelf_A_big.bin +0 -0
  330. package/town-frontend/dist/assets/models/furniture/shelf_A_big.gltf +136 -0
  331. package/town-frontend/dist/assets/models/furniture/shelf_A_small.bin +0 -0
  332. package/town-frontend/dist/assets/models/furniture/shelf_A_small.gltf +136 -0
  333. package/town-frontend/dist/assets/models/furniture/shelf_B_large.bin +0 -0
  334. package/town-frontend/dist/assets/models/furniture/shelf_B_large.gltf +136 -0
  335. package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.bin +0 -0
  336. package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.gltf +136 -0
  337. package/town-frontend/dist/assets/models/furniture/shelf_B_small.bin +0 -0
  338. package/town-frontend/dist/assets/models/furniture/shelf_B_small.gltf +136 -0
  339. package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.bin +0 -0
  340. package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.gltf +136 -0
  341. package/town-frontend/dist/assets/models/furniture/table_low.bin +0 -0
  342. package/town-frontend/dist/assets/models/furniture/table_low.gltf +136 -0
  343. package/town-frontend/dist/assets/models/furniture/table_medium.bin +0 -0
  344. package/town-frontend/dist/assets/models/furniture/table_medium.gltf +136 -0
  345. package/town-frontend/dist/assets/models/furniture/table_medium_long.bin +0 -0
  346. package/town-frontend/dist/assets/models/furniture/table_medium_long.gltf +136 -0
  347. package/town-frontend/dist/assets/models/furniture/table_small.bin +0 -0
  348. package/town-frontend/dist/assets/models/furniture/table_small.gltf +136 -0
  349. package/town-frontend/dist/assets/models/props/bench.bin +0 -0
  350. package/town-frontend/dist/assets/models/props/bench.gltf +136 -0
  351. package/town-frontend/dist/assets/models/props/bush.bin +0 -0
  352. package/town-frontend/dist/assets/models/props/bush.gltf +136 -0
  353. package/town-frontend/dist/assets/models/props/capybara.glb +0 -0
  354. package/town-frontend/dist/assets/models/props/car_hatchback.bin +0 -0
  355. package/town-frontend/dist/assets/models/props/car_hatchback.gltf +442 -0
  356. package/town-frontend/dist/assets/models/props/car_sedan.bin +0 -0
  357. package/town-frontend/dist/assets/models/props/car_sedan.gltf +442 -0
  358. package/town-frontend/dist/assets/models/props/car_taxi.bin +0 -0
  359. package/town-frontend/dist/assets/models/props/car_taxi.gltf +442 -0
  360. package/town-frontend/dist/assets/models/props/citybits_texture.png +0 -0
  361. package/town-frontend/dist/assets/models/props/dumpster.bin +0 -0
  362. package/town-frontend/dist/assets/models/props/dumpster.gltf +136 -0
  363. package/town-frontend/dist/assets/models/props/firehydrant.bin +0 -0
  364. package/town-frontend/dist/assets/models/props/firehydrant.gltf +136 -0
  365. package/town-frontend/dist/assets/models/props/streetlight.bin +0 -0
  366. package/town-frontend/dist/assets/models/props/streetlight.gltf +136 -0
  367. package/town-frontend/dist/assets/models/props/trafficlight_A.bin +0 -0
  368. package/town-frontend/dist/assets/models/props/trafficlight_A.gltf +136 -0
  369. package/town-frontend/dist/assets/models/props/trash_A.bin +0 -0
  370. package/town-frontend/dist/assets/models/props/trash_A.gltf +136 -0
  371. package/town-frontend/dist/assets/models/props/watertower.bin +0 -0
  372. package/town-frontend/dist/assets/models/props/watertower.gltf +136 -0
  373. package/town-frontend/dist/assets/models/stage-deco/Flowers_1_D.glb +0 -0
  374. package/town-frontend/dist/assets/models/stage-deco/Flowers_2_B.glb +0 -0
  375. package/town-frontend/dist/assets/models/stage-deco/Grass_A_1.glb +0 -0
  376. package/town-frontend/dist/assets/models/stage-deco/Park_GrassHill_A.glb +0 -0
  377. package/town-frontend/dist/assets/models/stage-deco/Pebles_1_A_2.glb +0 -0
  378. package/town-frontend/dist/assets/music/bgm_day.mp3 +0 -0
  379. package/town-frontend/dist/assets/music/bgm_dusk.mp3 +0 -0
  380. package/town-frontend/dist/assets/music/bgm_night.mp3 +0 -0
  381. package/town-frontend/dist/assets/music/bgm_work.mp3 +0 -0
  382. package/town-frontend/dist/assets/office-whiteboard-idle-CyEwBrq_.webp +0 -0
  383. package/town-frontend/dist/assets/preview-B6hYEQij.js +2 -0
  384. package/town-frontend/dist/assets/town-BKesnERP.js +8888 -0
  385. package/town-frontend/dist/assets/town-BnswKsjF.css +1 -0
  386. package/town-frontend/dist/citizen-editor.html +166 -0
  387. package/town-frontend/dist/editor.html +227 -0
  388. package/town-frontend/dist/index.html +22 -0
  389. package/town-frontend/dist/preview.html +56 -0
  390. package/town-frontend/dist/town.html +165 -0
  391. package/town-frontend/dist/viewer.html +91 -0
  392. package/town-souls/CHEN.md +130 -0
  393. package/town-souls/CHENGZI.md +92 -0
  394. package/town-souls/CITIZEN_tpl.md +16 -0
  395. package/town-souls/DIANDIAN.md +92 -0
  396. package/town-souls/HAITANG.md +94 -0
  397. package/town-souls/QIQI.md +119 -0
  398. package/town-souls/SOUL.md +141 -0
  399. package/town-souls/SOUL_tpl.md +135 -0
  400. package/town-souls/XIAOLIE.md +107 -0
  401. package/town-souls/YAN.md +107 -0
  402. package/town-workspace/IDENTITY.md +5 -0
  403. package/town-workspace/SOUL.md +141 -0
  404. package/town-workspace/project-workflow.md +81 -0
  405. package/town-workspace/town-defaults.json +92 -0
  406. package/town-workspace/town-guide.md +45 -0
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Unified LLM call layer for implicit NPC behavior.
3
+ * Uses dependency injection for the actual chat function so it works
4
+ * in both Node.js (direct provider) and browser (WS proxy) environments.
5
+ */
6
+
7
+ export type ImplicitScene =
8
+ | 'daily_plan' | 'tactical_decision' | 'daily_reflection'
9
+ | 'encounter_init' | 'encounter_reply' | 'dialogue_summary'
10
+ | 'town_journal'
11
+ | 'task_assign' | 'work_thought' | 'supervision_comment'
12
+
13
+ export interface ImplicitChatRequest {
14
+ scene: ImplicitScene
15
+ system: string
16
+ user: string
17
+ /** Override per-scene maxTokens */
18
+ maxTokens?: number
19
+ /** Override default temperature */
20
+ temperature?: number
21
+ /** Extra stop sequences appended to defaults */
22
+ extraStop?: string[]
23
+ }
24
+
25
+ export interface ImplicitChatResult {
26
+ text: string
27
+ latencyMs: number
28
+ tokenUsage?: { input: number; output: number }
29
+ fallback: boolean
30
+ }
31
+
32
+ export interface ImplicitChatFn {
33
+ (req: {
34
+ model: string
35
+ system: string
36
+ user: string
37
+ maxTokens: number
38
+ temperature: number
39
+ stop: string[]
40
+ }): Promise<{
41
+ text: string
42
+ usage?: { input: number; output: number }
43
+ }>
44
+ }
45
+
46
+ const SCENE_MAX_TOKENS: Record<ImplicitScene, number> = {
47
+ daily_plan: 200,
48
+ tactical_decision: 80,
49
+ daily_reflection: 60,
50
+ encounter_init: 80,
51
+ encounter_reply: 80,
52
+ dialogue_summary: 60,
53
+ town_journal: 300,
54
+ task_assign: 100,
55
+ work_thought: 60,
56
+ supervision_comment: 80,
57
+ }
58
+
59
+ const DEFAULT_STOP = ['\n\n']
60
+
61
+ const FALLBACK: Partial<Record<ImplicitScene, string[]>> = {
62
+ encounter_init: ['嗨,好久不见!', '哟,你也在这啊', '今天天气不错呢', '嘿!在干嘛呢?'],
63
+ encounter_reply: ['是呀!', '哈哈对', '嗯嗯', '说得也是', '确实如此'],
64
+ dialogue_summary: ['闲聊了几句'],
65
+ daily_reflection: ['今天过得还不错', '充实的一天', '平淡但安心'],
66
+ daily_plan: [],
67
+ tactical_decision: [],
68
+ }
69
+
70
+ function pickFallback(scene: ImplicitScene): string {
71
+ const pool = FALLBACK[scene]
72
+ if (!pool || pool.length === 0) return ''
73
+ return pool[Math.floor(Math.random() * pool.length)]
74
+ }
75
+
76
+ export interface ImplicitChatConfig {
77
+ model: string
78
+ temperature: number
79
+ timeoutMs: number
80
+ }
81
+
82
+ const DEFAULT_CONFIG: ImplicitChatConfig = {
83
+ model: 'qwen-turbo',
84
+ temperature: 0.85,
85
+ timeoutMs: 8000,
86
+ }
87
+
88
+ let _chatFn: ImplicitChatFn | null = null
89
+ let _config: ImplicitChatConfig = { ...DEFAULT_CONFIG }
90
+
91
+ let _totalCalls = 0
92
+ let _totalTokensIn = 0
93
+ let _totalTokensOut = 0
94
+ let _totalLatencyMs = 0
95
+ let _fallbackCount = 0
96
+
97
+ export function setImplicitChatFn(fn: ImplicitChatFn): void {
98
+ _chatFn = fn
99
+ }
100
+
101
+ export function setImplicitChatConfig(config: Partial<ImplicitChatConfig>): void {
102
+ _config = { ..._config, ...config }
103
+ }
104
+
105
+ export function getImplicitChatStats() {
106
+ return {
107
+ totalCalls: _totalCalls,
108
+ totalTokensIn: _totalTokensIn,
109
+ totalTokensOut: _totalTokensOut,
110
+ totalLatencyMs: _totalLatencyMs,
111
+ fallbackCount: _fallbackCount,
112
+ avgLatencyMs: _totalCalls > 0 ? Math.round(_totalLatencyMs / _totalCalls) : 0,
113
+ }
114
+ }
115
+
116
+ export function resetImplicitChatStats(): void {
117
+ _totalCalls = 0
118
+ _totalTokensIn = 0
119
+ _totalTokensOut = 0
120
+ _totalLatencyMs = 0
121
+ _fallbackCount = 0
122
+ }
123
+
124
+ export async function implicitChat(req: ImplicitChatRequest): Promise<ImplicitChatResult> {
125
+ _totalCalls++
126
+
127
+ if (!_chatFn) {
128
+ _fallbackCount++
129
+ return {
130
+ text: pickFallback(req.scene),
131
+ latencyMs: 0,
132
+ fallback: true,
133
+ }
134
+ }
135
+
136
+ const maxTokens = req.maxTokens ?? SCENE_MAX_TOKENS[req.scene]
137
+ const temperature = req.temperature ?? _config.temperature
138
+ const stop = [...DEFAULT_STOP, ...(req.extraStop ?? [])]
139
+
140
+ const start = performance.now()
141
+
142
+ try {
143
+ const result = await Promise.race([
144
+ _chatFn({
145
+ model: _config.model,
146
+ system: req.system,
147
+ user: req.user,
148
+ maxTokens,
149
+ temperature,
150
+ stop,
151
+ }),
152
+ new Promise<never>((_, reject) =>
153
+ setTimeout(() => reject(new Error('implicit_chat_timeout')), _config.timeoutMs)
154
+ ),
155
+ ])
156
+
157
+ const latencyMs = Math.round(performance.now() - start)
158
+ _totalLatencyMs += latencyMs
159
+
160
+ const text = (result.text ?? '').trim()
161
+
162
+ if (!text) {
163
+ _fallbackCount++
164
+ return { text: pickFallback(req.scene), latencyMs, fallback: true }
165
+ }
166
+
167
+ if (result.usage) {
168
+ _totalTokensIn += result.usage.input
169
+ _totalTokensOut += result.usage.output
170
+ }
171
+
172
+ return {
173
+ text,
174
+ latencyMs,
175
+ tokenUsage: result.usage,
176
+ fallback: false,
177
+ }
178
+ } catch (err) {
179
+ const latencyMs = Math.round(performance.now() - start)
180
+ _totalLatencyMs += latencyMs
181
+ _fallbackCount++
182
+
183
+ const tag = err instanceof Error && err.message === 'implicit_chat_timeout' ? '[timeout]' : '[error]'
184
+ console.warn(`implicitChat ${tag} scene=${req.scene} ${latencyMs}ms`, err)
185
+
186
+ return {
187
+ text: pickFallback(req.scene),
188
+ latencyMs,
189
+ fallback: true,
190
+ }
191
+ }
192
+ }
@@ -0,0 +1,12 @@
1
+ // @desc Bridge layer barrel export — re-exports all bridge modules
2
+ export { EventTranslator } from './EventTranslator.js'
3
+ export { StateTracker } from './StateTracker.js'
4
+ export { ReconnectManager } from './ReconnectManager.js'
5
+ export { DirectorBridge } from './DirectorBridge.js'
6
+ export { NpcEventQueue } from './NpcEventQueue.js'
7
+ export { RouteManager } from './RouteManager.js'
8
+ export { ActivityStream } from './ActivityStream.js'
9
+ export { CitizenManager } from './CitizenManager.js'
10
+ export * from './ToolVfxMapper.js'
11
+ export { implicitChat, setImplicitChatFn, setImplicitChatConfig, getImplicitChatStats, resetImplicitChatStats } from './implicit-chat.js'
12
+ export type { ImplicitScene, ImplicitChatRequest, ImplicitChatResult, ImplicitChatFn, ImplicitChatConfig } from './implicit-chat.js'
@@ -0,0 +1,87 @@
1
+ // @desc Agent state machine and structured state snapshots
2
+ //
3
+ // AgentStateSnapshot 是递归结构, children 字段形成子代理树
4
+ // 前端可据此渲染实时代理状态面板 (phase → UI 状态, activity → 当前动作)
5
+ //
6
+ // 迁移注意:
7
+ // - ws-handler 尚未发送 SessionState, 仍用旧的扁平 { sessionId, status }
8
+ // - state_snapshot AgentEvent 尚未在 OpenClaw 核心中发射
9
+ // - CLI 的 App.tsx 目前自行拼装子代理树, 未来应改用 AgentStateSnapshot
10
+
11
+ export type AgentPhase =
12
+ | 'initializing'
13
+ | 'idle'
14
+ | 'thinking'
15
+ | 'tool_calling'
16
+ | 'streaming'
17
+ | 'waiting_input'
18
+ | 'done'
19
+ | 'error';
20
+
21
+ export interface AgentActivity {
22
+ type: 'llm_call' | 'tool_execution' | 'sub_agent_wait';
23
+ toolName?: string;
24
+ toolUseId?: string;
25
+ description?: string;
26
+ startedAt: number;
27
+ progress?: number;
28
+ }
29
+
30
+ export type HookIcon = '🛡️' | '🔧' | '🛑' | '🗜️' | '🚀' | '🏁' | '🔔';
31
+
32
+ export interface HookActivity {
33
+ event: 'PreToolUse' | 'PostToolUse' | 'Stop' | 'PreCompact' | 'SessionStart' | 'SessionEnd' | 'Notification';
34
+ status: 'running' | 'success' | 'error' | 'blocked';
35
+ icon: HookIcon;
36
+ toolName?: string;
37
+ detail?: string;
38
+ durationMs?: number;
39
+ }
40
+
41
+ export const HOOK_ICONS: Record<string, HookIcon> = {
42
+ PreToolUse: '🛡️',
43
+ PostToolUse: '🔧',
44
+ Stop: '🛑',
45
+ PreCompact: '🗜️',
46
+ SessionStart: '🚀',
47
+ SessionEnd: '🏁',
48
+ Notification: '🔔',
49
+ };
50
+
51
+ export interface AgentResources {
52
+ tokens: { used: number; limit: number; percent: number };
53
+ iteration: { current: number; max: number };
54
+ durationMs: number;
55
+ }
56
+
57
+ export interface AgentSnapStats {
58
+ toolCalls: number;
59
+ agentSpawns: number;
60
+ tokensIn: number;
61
+ tokensOut: number;
62
+ }
63
+
64
+ export interface AgentStateSnapshot {
65
+ agentId: string;
66
+ displayName?: string;
67
+ phase: AgentPhase;
68
+ model: string;
69
+ persona?: string;
70
+ activity?: AgentActivity;
71
+ hookActivity?: HookActivity;
72
+ resources: AgentResources;
73
+ stats: AgentSnapStats;
74
+ children: AgentStateSnapshot[];
75
+ }
76
+
77
+ export type SessionStatus = 'active' | 'suspended' | 'completed' | 'error';
78
+
79
+ export interface SessionState {
80
+ sessionId: string;
81
+ status: SessionStatus;
82
+ rootAgent: AgentStateSnapshot;
83
+ createdAt: number;
84
+ lastActiveAt: number;
85
+ persona?: string;
86
+ metadata?: Record<string, unknown>;
87
+ }
@@ -0,0 +1,212 @@
1
+ // @desc AGUI (AG-UI Protocol) event types for OpenClaw
2
+ // Based on AG-UI Protocol: https://docs.ag-ui.com/concepts/events
3
+ //
4
+ // These types mirror the AGUI definitions in packages/agentstudio/backend/src/engines/types.ts
5
+ // but live within OpenClaw's contract layer so the package is self-contained.
6
+
7
+ // ── Event Type Enum ──
8
+
9
+ export enum AGUIEventType {
10
+ // Lifecycle
11
+ RUN_STARTED = 'RUN_STARTED',
12
+ RUN_FINISHED = 'RUN_FINISHED',
13
+ RUN_ERROR = 'RUN_ERROR',
14
+ STEP_STARTED = 'STEP_STARTED',
15
+ STEP_FINISHED = 'STEP_FINISHED',
16
+
17
+ // Text Message
18
+ TEXT_MESSAGE_START = 'TEXT_MESSAGE_START',
19
+ TEXT_MESSAGE_CONTENT = 'TEXT_MESSAGE_CONTENT',
20
+ TEXT_MESSAGE_END = 'TEXT_MESSAGE_END',
21
+
22
+ // Thinking (extended)
23
+ THINKING_START = 'THINKING_START',
24
+ THINKING_CONTENT = 'THINKING_CONTENT',
25
+ THINKING_END = 'THINKING_END',
26
+
27
+ // Tool Call
28
+ TOOL_CALL_START = 'TOOL_CALL_START',
29
+ TOOL_CALL_ARGS = 'TOOL_CALL_ARGS',
30
+ TOOL_CALL_END = 'TOOL_CALL_END',
31
+ TOOL_CALL_RESULT = 'TOOL_CALL_RESULT',
32
+
33
+ // State Management
34
+ STATE_SNAPSHOT = 'STATE_SNAPSHOT',
35
+ STATE_DELTA = 'STATE_DELTA',
36
+ MESSAGES_SNAPSHOT = 'MESSAGES_SNAPSHOT',
37
+
38
+ // Special
39
+ RAW = 'RAW',
40
+ CUSTOM = 'CUSTOM',
41
+ }
42
+
43
+ // ── Base Event ──
44
+
45
+ export interface AGUIBaseEvent {
46
+ type: AGUIEventType;
47
+ timestamp: number;
48
+ threadId?: string;
49
+ runId?: string;
50
+ }
51
+
52
+ // ── Lifecycle Events ──
53
+
54
+ export interface AGUIRunStartedEvent extends AGUIBaseEvent {
55
+ type: AGUIEventType.RUN_STARTED;
56
+ threadId: string;
57
+ runId: string;
58
+ input?: unknown;
59
+ }
60
+
61
+ export interface AGUIRunFinishedEvent extends AGUIBaseEvent {
62
+ type: AGUIEventType.RUN_FINISHED;
63
+ threadId: string;
64
+ runId: string;
65
+ result?: unknown;
66
+ }
67
+
68
+ export interface AGUIRunErrorEvent extends AGUIBaseEvent {
69
+ type: AGUIEventType.RUN_ERROR;
70
+ error: string;
71
+ code?: string;
72
+ message?: string;
73
+ }
74
+
75
+ export interface AGUIStepStartedEvent extends AGUIBaseEvent {
76
+ type: AGUIEventType.STEP_STARTED;
77
+ stepName?: string;
78
+ }
79
+
80
+ export interface AGUIStepFinishedEvent extends AGUIBaseEvent {
81
+ type: AGUIEventType.STEP_FINISHED;
82
+ stepName?: string;
83
+ }
84
+
85
+ // ── Text Message Events ──
86
+
87
+ export interface AGUITextMessageStartEvent extends AGUIBaseEvent {
88
+ type: AGUIEventType.TEXT_MESSAGE_START;
89
+ messageId: string;
90
+ role?: 'assistant' | 'user' | 'system';
91
+ }
92
+
93
+ export interface AGUITextMessageContentEvent extends AGUIBaseEvent {
94
+ type: AGUIEventType.TEXT_MESSAGE_CONTENT;
95
+ messageId: string;
96
+ content: string;
97
+ }
98
+
99
+ export interface AGUITextMessageEndEvent extends AGUIBaseEvent {
100
+ type: AGUIEventType.TEXT_MESSAGE_END;
101
+ messageId: string;
102
+ }
103
+
104
+ // ── Thinking Events ──
105
+
106
+ export interface AGUIThinkingStartEvent extends AGUIBaseEvent {
107
+ type: AGUIEventType.THINKING_START;
108
+ messageId: string;
109
+ }
110
+
111
+ export interface AGUIThinkingContentEvent extends AGUIBaseEvent {
112
+ type: AGUIEventType.THINKING_CONTENT;
113
+ messageId: string;
114
+ content: string;
115
+ }
116
+
117
+ export interface AGUIThinkingEndEvent extends AGUIBaseEvent {
118
+ type: AGUIEventType.THINKING_END;
119
+ messageId: string;
120
+ }
121
+
122
+ // ── Tool Call Events ──
123
+
124
+ export interface AGUIToolCallStartEvent extends AGUIBaseEvent {
125
+ type: AGUIEventType.TOOL_CALL_START;
126
+ toolCallId: string;
127
+ toolName: string;
128
+ parentMessageId?: string;
129
+ }
130
+
131
+ export interface AGUIToolCallArgsEvent extends AGUIBaseEvent {
132
+ type: AGUIEventType.TOOL_CALL_ARGS;
133
+ toolCallId: string;
134
+ args: string;
135
+ }
136
+
137
+ export interface AGUIToolCallEndEvent extends AGUIBaseEvent {
138
+ type: AGUIEventType.TOOL_CALL_END;
139
+ toolCallId: string;
140
+ }
141
+
142
+ export interface AGUIToolCallResultEvent extends AGUIBaseEvent {
143
+ type: AGUIEventType.TOOL_CALL_RESULT;
144
+ toolCallId: string;
145
+ result: string;
146
+ isError?: boolean;
147
+ }
148
+
149
+ // ── State Management Events ──
150
+
151
+ export interface AGUIStateSnapshotEvent extends AGUIBaseEvent {
152
+ type: AGUIEventType.STATE_SNAPSHOT;
153
+ snapshot: unknown;
154
+ }
155
+
156
+ export interface AGUIStateDeltaEvent extends AGUIBaseEvent {
157
+ type: AGUIEventType.STATE_DELTA;
158
+ delta: unknown;
159
+ }
160
+
161
+ export interface AGUIMessagesSnapshotEvent extends AGUIBaseEvent {
162
+ type: AGUIEventType.MESSAGES_SNAPSHOT;
163
+ messages: unknown[];
164
+ }
165
+
166
+ // ── Special Events ──
167
+
168
+ export interface AGUIRawEvent extends AGUIBaseEvent {
169
+ type: AGUIEventType.RAW;
170
+ source: string;
171
+ event: unknown;
172
+ }
173
+
174
+ export interface AGUICustomEvent extends AGUIBaseEvent {
175
+ type: AGUIEventType.CUSTOM;
176
+ name: string;
177
+ data: unknown;
178
+ }
179
+
180
+ // ── Union Type ──
181
+
182
+ export type AGUIEvent =
183
+ | AGUIRunStartedEvent
184
+ | AGUIRunFinishedEvent
185
+ | AGUIRunErrorEvent
186
+ | AGUIStepStartedEvent
187
+ | AGUIStepFinishedEvent
188
+ | AGUITextMessageStartEvent
189
+ | AGUITextMessageContentEvent
190
+ | AGUITextMessageEndEvent
191
+ | AGUIThinkingStartEvent
192
+ | AGUIThinkingContentEvent
193
+ | AGUIThinkingEndEvent
194
+ | AGUIToolCallStartEvent
195
+ | AGUIToolCallArgsEvent
196
+ | AGUIToolCallEndEvent
197
+ | AGUIToolCallResultEvent
198
+ | AGUIStateSnapshotEvent
199
+ | AGUIStateDeltaEvent
200
+ | AGUIMessagesSnapshotEvent
201
+ | AGUIRawEvent
202
+ | AGUICustomEvent;
203
+
204
+ // ── Utility Functions ──
205
+
206
+ export function formatAguiEventAsSSE(event: AGUIEvent): string {
207
+ return `event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`;
208
+ }
209
+
210
+ export function createTimestamp(): number {
211
+ return Date.now();
212
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ChatItem — Chat 视图的统一消息模型。
3
+ *
4
+ * 设计原则:
5
+ * 1. 唯一事实源是 OpenClaw session transcript(.jsonl)。
6
+ * 2. 历史恢复和实时增量共用同一套模型。
7
+ * 3. 不依赖 Town 的 AgentEvent 语义。
8
+ * 4. 每个 item 有稳定 id,支持跨 history/delta/reload 去重。
9
+ */
10
+
11
+ export type ChatMediaType = "image" | "video" | "audio" | "file";
12
+
13
+ export type ChatItemKind = "text" | "media" | "tool" | "status";
14
+
15
+ export interface ChatItemBase {
16
+ id: string;
17
+ agentId: string;
18
+ timestamp: number;
19
+ }
20
+
21
+ export interface ChatTextItem extends ChatItemBase {
22
+ kind: "text";
23
+ role: "user" | "assistant";
24
+ text: string;
25
+ source?: "user_input" | "llm" | "system";
26
+ }
27
+
28
+ export interface ChatMediaItem extends ChatItemBase {
29
+ kind: "media";
30
+ role: "user" | "assistant";
31
+ mediaType: ChatMediaType;
32
+ filePath?: string;
33
+ fileUrl: string;
34
+ fileName?: string;
35
+ mimeType?: string;
36
+ fileSize?: number;
37
+ caption?: string;
38
+ imageData?: string;
39
+ }
40
+
41
+ export interface ChatToolItem extends ChatItemBase {
42
+ kind: "tool";
43
+ phase: "start" | "end";
44
+ toolUseId: string;
45
+ toolName: string;
46
+ input?: Record<string, unknown>;
47
+ outputText?: string;
48
+ isError?: boolean;
49
+ }
50
+
51
+ export interface ChatStatusItem extends ChatItemBase {
52
+ kind: "status";
53
+ status: "yielded" | "error" | "system";
54
+ text: string;
55
+ }
56
+
57
+ export type ChatItem =
58
+ | ChatTextItem
59
+ | ChatMediaItem
60
+ | ChatToolItem
61
+ | ChatStatusItem;
62
+
63
+ export interface ChatItemHistoryResult {
64
+ items: ChatItem[];
65
+ hasMore: boolean;
66
+ cursor: string;
67
+ }