@myclaw163/clawclaw-cli 0.10.11 → 0.10.13

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 (409) hide show
  1. package/bin/clawclaw-cli.mjs +15 -6
  2. package/bin/startup-trace.d.mts +9 -0
  3. package/bin/startup-trace.mjs +100 -0
  4. package/cli-runtime/assets/clawclaw-map.json +1782 -0
  5. package/cli-runtime/assets/clawclaw-spatial-facts.json +1383 -0
  6. package/cli-runtime/assets/clawclaw-spatial-model.txt +142 -0
  7. package/cli-runtime/channel/claude-channel-ipc-server.js +220 -0
  8. package/cli-runtime/channel/claude-channel-ipc.js +135 -0
  9. package/cli-runtime/channel/claude-channel-server.js +209 -0
  10. package/cli-runtime/cli.js +81 -0
  11. package/cli-runtime/commands/_schema.js +60 -0
  12. package/cli-runtime/commands/account.js +577 -0
  13. package/cli-runtime/commands/auth.js +140 -0
  14. package/cli-runtime/commands/behavior.js +422 -0
  15. package/cli-runtime/commands/capability.js +327 -0
  16. package/cli-runtime/commands/communication.js +339 -0
  17. package/cli-runtime/commands/competition.js +55 -0
  18. package/cli-runtime/commands/config.js +28 -0
  19. package/cli-runtime/commands/data.js +78 -0
  20. package/cli-runtime/commands/events.js +339 -0
  21. package/cli-runtime/commands/game/index.js +646 -0
  22. package/cli-runtime/commands/hub.js +152 -0
  23. package/cli-runtime/commands/load.js +22 -0
  24. package/cli-runtime/commands/memory.js +30 -0
  25. package/cli-runtime/commands/module-runtime-control.js +110 -0
  26. package/cli-runtime/commands/peek.js +38 -0
  27. package/cli-runtime/commands/perception.js +146 -0
  28. package/cli-runtime/commands/persona.js +165 -0
  29. package/cli-runtime/commands/prepare.js +878 -0
  30. package/cli-runtime/commands/setup/codex.js +244 -0
  31. package/cli-runtime/commands/setup/hermes.js +55 -0
  32. package/cli-runtime/commands/setup/index.js +15 -0
  33. package/cli-runtime/commands/setup/openclaw.js +103 -0
  34. package/cli-runtime/commands/skill.js +76 -0
  35. package/cli-runtime/commands/strategy.js +4 -0
  36. package/cli-runtime/commands/trigger.js +271 -0
  37. package/cli-runtime/commands/upgrade.js +112 -0
  38. package/cli-runtime/lib/account-guidance.js +97 -0
  39. package/cli-runtime/lib/agent-workspace-client.js +66 -0
  40. package/cli-runtime/lib/agent-workspace-runtime.js +174 -0
  41. package/cli-runtime/lib/agent-workspace-skills.js +453 -0
  42. package/cli-runtime/lib/agent-workspace-sync.js +812 -0
  43. package/cli-runtime/lib/auth.js +210 -0
  44. package/cli-runtime/lib/capability-cloud-presence.js +134 -0
  45. package/cli-runtime/lib/capability-cloud-refresh.js +263 -0
  46. package/cli-runtime/lib/capability-cloud-sync.js +385 -0
  47. package/cli-runtime/lib/capability-discovery.js +94 -0
  48. package/cli-runtime/lib/capability-load-diagnostics.js +121 -0
  49. package/cli-runtime/lib/capability-operation-name.js +24 -0
  50. package/cli-runtime/lib/capability-operation-rename.js +120 -0
  51. package/cli-runtime/lib/capability-selection.js +69 -0
  52. package/cli-runtime/lib/capability-workspace.js +214 -0
  53. package/cli-runtime/lib/command-error.js +25 -0
  54. package/cli-runtime/lib/command-meta.js +13 -0
  55. package/cli-runtime/lib/competition.js +77 -0
  56. package/cli-runtime/lib/custom-tts.js +363 -0
  57. package/cli-runtime/lib/desktop-auth.js +44 -0
  58. package/cli-runtime/lib/desktop-mode.js +12 -0
  59. package/cli-runtime/lib/diagnostics-config.js +82 -0
  60. package/cli-runtime/lib/game-client.js +602 -0
  61. package/cli-runtime/lib/game-context.js +117 -0
  62. package/cli-runtime/lib/gameplay-config.js +232 -0
  63. package/cli-runtime/lib/host-config-patcher.js +101 -0
  64. package/cli-runtime/lib/http-keepalive.js +15 -0
  65. package/cli-runtime/lib/http-transport.js +163 -0
  66. package/cli-runtime/lib/hub-client.js +292 -0
  67. package/cli-runtime/lib/hub-errors.js +51 -0
  68. package/cli-runtime/lib/hub-reminder.js +65 -0
  69. package/cli-runtime/lib/hub-unzip.js +52 -0
  70. package/cli-runtime/lib/init-command.js +160 -0
  71. package/cli-runtime/lib/load-context.js +97 -0
  72. package/cli-runtime/lib/load-startup-context.js +59 -0
  73. package/cli-runtime/lib/load-startup.js +23 -0
  74. package/cli-runtime/lib/lobby-host-context.js +70 -0
  75. package/cli-runtime/lib/match-state.js +61 -0
  76. package/cli-runtime/lib/normalize.js +28 -0
  77. package/cli-runtime/lib/package-skills.js +15 -0
  78. package/cli-runtime/lib/participation-leave.js +54 -0
  79. package/cli-runtime/lib/participation-status.js +73 -0
  80. package/cli-runtime/lib/perception-config.js +85 -0
  81. package/cli-runtime/lib/persona.js +157 -0
  82. package/cli-runtime/lib/room.js +108 -0
  83. package/cli-runtime/lib/runtime-cadence-config.js +18 -0
  84. package/cli-runtime/lib/server-registry.js +155 -0
  85. package/cli-runtime/lib/server-status.js +44 -0
  86. package/cli-runtime/lib/service-status.js +88 -0
  87. package/cli-runtime/lib/skill-host.js +246 -0
  88. package/cli-runtime/lib/skill-name-conflicts.js +89 -0
  89. package/cli-runtime/lib/skill-version.js +20 -0
  90. package/cli-runtime/lib/training-role.js +23 -0
  91. package/cli-runtime/lib/trigger-config.js +138 -0
  92. package/cli-runtime/lib/user-data.js +336 -0
  93. package/cli-runtime/lib/workspace-argv.js +35 -0
  94. package/cli-runtime/lib/workspace-runtime-lock.js +6 -0
  95. package/cli-runtime/lib/zip-store.js +78 -0
  96. package/cli-runtime/pipeline/canonical-event-presentation.js +32 -0
  97. package/cli-runtime/pipeline/event-format.js +921 -0
  98. package/cli-runtime/pipeline/event-hints.js +235 -0
  99. package/cli-runtime/pipeline/game-sync-event-normalization.js +228 -0
  100. package/cli-runtime/pipeline/player-projection.js +272 -0
  101. package/cli-runtime/pipeline/role-display.js +22 -0
  102. package/cli-runtime/runtime/auto-upgrade.js +30 -0
  103. package/cli-runtime/runtime/canonical-event-emitter.js +58 -0
  104. package/cli-runtime/runtime/canonical-monitor.js +332 -0
  105. package/cli-runtime/runtime/clawclaw/agent-ability-state.js +41 -0
  106. package/cli-runtime/runtime/clawclaw/agent-event-policy.js +58 -0
  107. package/cli-runtime/runtime/clawclaw/behavior-decision.js +84 -0
  108. package/cli-runtime/runtime/clawclaw/behavior-input-fields.js +212 -0
  109. package/cli-runtime/runtime/clawclaw/behavior-input.js +54 -0
  110. package/cli-runtime/runtime/clawclaw/behavior-observation-memory.js +106 -0
  111. package/cli-runtime/runtime/clawclaw/behavior-read-api.js +110 -0
  112. package/cli-runtime/runtime/clawclaw/behavior-reflex-control.js +97 -0
  113. package/cli-runtime/runtime/clawclaw/behavior-start-control.js +159 -0
  114. package/cli-runtime/runtime/clawclaw/index.js +3 -0
  115. package/cli-runtime/runtime/clawclaw/navigation/astar-path.js +244 -0
  116. package/cli-runtime/runtime/clawclaw/navigation/clawclaw-walkable.bin +0 -0
  117. package/cli-runtime/runtime/clawclaw/navigation/distance-field.js +136 -0
  118. package/cli-runtime/runtime/clawclaw/navigation/escape-planner.js +273 -0
  119. package/cli-runtime/runtime/clawclaw/navigation/hide-spots.js +31 -0
  120. package/cli-runtime/runtime/clawclaw/navigation/off-route-points.js +64 -0
  121. package/cli-runtime/runtime/clawclaw/navigation/walkable-grid.js +85 -0
  122. package/cli-runtime/runtime/clawclaw/notification-policy.js +59 -0
  123. package/cli-runtime/runtime/clawclaw/notification-turn.js +28 -0
  124. package/cli-runtime/runtime/clawclaw/notifications.js +65 -0
  125. package/cli-runtime/runtime/clawclaw/observation-frame-projector.js +94 -0
  126. package/cli-runtime/runtime/clawclaw/owner-lock-error.js +17 -0
  127. package/cli-runtime/runtime/clawclaw/owner-lock.js +219 -0
  128. package/cli-runtime/runtime/clawclaw/owner.js +1257 -0
  129. package/cli-runtime/runtime/clawclaw/perception-module-manifest.js +67 -0
  130. package/cli-runtime/runtime/clawclaw/perception-strategy-names.js +12 -0
  131. package/cli-runtime/runtime/clawclaw/persistence-compatibility.js +38 -0
  132. package/cli-runtime/runtime/clawclaw/plugins/action/action-plugin.js +604 -0
  133. package/cli-runtime/runtime/clawclaw/plugins/action/automated-action-normalization.js +67 -0
  134. package/cli-runtime/runtime/clawclaw/plugins/action/index.js +1 -0
  135. package/cli-runtime/runtime/clawclaw/plugins/assembly.js +134 -0
  136. package/cli-runtime/runtime/clawclaw/plugins/behavior/activation-manager.js +1 -0
  137. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-action.js +26 -0
  138. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.js +21 -0
  139. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +25 -0
  140. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-catalog.js +90 -0
  141. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-decision-history.js +60 -0
  142. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.js +1 -0
  143. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-manifest.js +136 -0
  144. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-module-loader.js +230 -0
  145. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-normalization.js +92 -0
  146. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-plugin.js +162 -0
  147. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-runner.js +20 -0
  148. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-source.js +493 -0
  149. package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.js +28 -0
  150. package/cli-runtime/runtime/clawclaw/plugins/behavior/control-driver.js +5 -0
  151. package/cli-runtime/runtime/clawclaw/plugins/behavior/index.js +11 -0
  152. package/cli-runtime/runtime/clawclaw/plugins/behavior/thread-behavior-executor.js +18 -0
  153. package/cli-runtime/runtime/clawclaw/plugins/behavior-input-source.js +233 -0
  154. package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-plugin.js +25 -0
  155. package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-rules.js +289 -0
  156. package/cli-runtime/runtime/clawclaw/plugins/derived-event/index.js +2 -0
  157. package/cli-runtime/runtime/clawclaw/plugins/derived-event/player-change-tracker.js +162 -0
  158. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-plugin.js +182 -0
  159. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-rules.js +1 -0
  160. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-runner.js +83 -0
  161. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.js +35 -0
  162. package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.ts +33 -0
  163. package/cli-runtime/runtime/clawclaw/plugins/derived-event/state-change-rules.js +111 -0
  164. package/cli-runtime/runtime/clawclaw/plugins/derived-event/task-change-tracker.js +1 -0
  165. package/cli-runtime/runtime/clawclaw/plugins/game-query/context-capabilities.js +10 -0
  166. package/cli-runtime/runtime/clawclaw/plugins/game-query/game-query-plugin.js +196 -0
  167. package/cli-runtime/runtime/clawclaw/plugins/game-query/index.js +2 -0
  168. package/cli-runtime/runtime/clawclaw/plugins/index.js +9 -0
  169. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.js +24 -0
  170. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.js +21 -0
  171. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.js +84 -0
  172. package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.js +54 -0
  173. package/cli-runtime/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.js +61 -0
  174. package/cli-runtime/runtime/clawclaw/plugins/mailbox/consumer-ids.js +10 -0
  175. package/cli-runtime/runtime/clawclaw/plugins/mailbox/desktop-event-socket.js +45 -0
  176. package/cli-runtime/runtime/clawclaw/plugins/mailbox/index.js +11 -0
  177. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.js +1 -0
  178. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-plugin.js +13 -0
  179. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-presentation.js +99 -0
  180. package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-service.js +84 -0
  181. package/cli-runtime/runtime/clawclaw/plugins/perception/contracts.js +14 -0
  182. package/cli-runtime/runtime/clawclaw/plugins/perception/index.js +11 -0
  183. package/cli-runtime/runtime/clawclaw/plugins/perception/map-concurrent.js +1 -0
  184. package/cli-runtime/runtime/clawclaw/plugins/perception/module-input-boundary.js +64 -0
  185. package/cli-runtime/runtime/clawclaw/plugins/perception/module-runner.js +182 -0
  186. package/cli-runtime/runtime/clawclaw/plugins/perception/notification-content.js +47 -0
  187. package/cli-runtime/runtime/clawclaw/plugins/perception/official-module-ids.js +13 -0
  188. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.js +684 -0
  189. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.js +145 -0
  190. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +252 -0
  191. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-loader.js +78 -0
  192. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-output.js +15 -0
  193. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-plugin.js +144 -0
  194. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-runner.js +22 -0
  195. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.js +18 -0
  196. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.ts +19 -0
  197. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-plugin.js +1343 -0
  198. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-pool.js +522 -0
  199. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.js +161 -0
  200. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.ts +262 -0
  201. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-source.js +489 -0
  202. package/cli-runtime/runtime/clawclaw/plugins/perception/perception-test-fixtures.js +31 -0
  203. package/cli-runtime/runtime/clawclaw/plugins/perception/replay.js +56 -0
  204. package/cli-runtime/runtime/clawclaw/plugins/perception/report-content.js +39 -0
  205. package/cli-runtime/runtime/clawclaw/plugins/perception/shared/math.js +1 -0
  206. package/cli-runtime/runtime/clawclaw/plugins/perception/spatial-facts.js +103 -0
  207. package/cli-runtime/runtime/clawclaw/plugins/perception/task-baseline.js +29 -0
  208. package/cli-runtime/runtime/clawclaw/plugins/plugin-api-version.js +89 -0
  209. package/cli-runtime/runtime/clawclaw/plugins/source/game-transport.js +204 -0
  210. package/cli-runtime/runtime/clawclaw/plugins/source/index.js +5 -0
  211. package/cli-runtime/runtime/clawclaw/plugins/source/room-transport.js +399 -0
  212. package/cli-runtime/runtime/clawclaw/plugins/source/source-plugin.js +2003 -0
  213. package/cli-runtime/runtime/clawclaw/plugins/source/source-transports.js +26 -0
  214. package/cli-runtime/runtime/clawclaw/plugins/source/types.js +0 -0
  215. package/cli-runtime/runtime/clawclaw/plugins/system-perception/rule-runner.js +90 -0
  216. package/cli-runtime/runtime/clawclaw/plugins/system-perception/sabotage-availability-rule.js +59 -0
  217. package/cli-runtime/runtime/clawclaw/plugins/system-perception/system-perceptions.js +241 -0
  218. package/cli-runtime/runtime/clawclaw/plugins/trigger/contracts.js +12 -0
  219. package/cli-runtime/runtime/clawclaw/plugins/trigger/index.js +4 -0
  220. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-module-loader.js +105 -0
  221. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-plugin.js +741 -0
  222. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-source.js +372 -0
  223. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-pool.js +378 -0
  224. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.js +118 -0
  225. package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +168 -0
  226. package/cli-runtime/runtime/clawclaw/reaction-behavior-resolution.js +1 -0
  227. package/cli-runtime/runtime/clawclaw/reaction-manifest.js +62 -0
  228. package/cli-runtime/runtime/clawclaw/reminder-manifest.js +39 -0
  229. package/cli-runtime/runtime/clawclaw/runtime-cadence.js +28 -0
  230. package/cli-runtime/runtime/clawclaw/runtime-data-export.js +321 -0
  231. package/cli-runtime/runtime/clawclaw/runtime-state.js +51 -0
  232. package/cli-runtime/runtime/clawclaw/runtime.js +132 -0
  233. package/cli-runtime/runtime/clawclaw/spatial-api.js +48 -0
  234. package/cli-runtime/runtime/clawclaw/starting-owner-control.js +24 -0
  235. package/cli-runtime/runtime/clawclaw/strategy-memory-rpc.js +1 -0
  236. package/cli-runtime/runtime/clawclaw/strategy-memory.js +6 -0
  237. package/cli-runtime/runtime/clawclaw/task-choice-projection.js +72 -0
  238. package/cli-runtime/runtime/clawclaw-event-catalog.js +284 -0
  239. package/cli-runtime/runtime/clawclaw-position.js +0 -0
  240. package/cli-runtime/runtime/clawclaw-room-state.js +38 -0
  241. package/cli-runtime/runtime/framework/action-diagnostics.js +69 -0
  242. package/cli-runtime/runtime/framework/capability-registry.js +1 -0
  243. package/cli-runtime/runtime/framework/contracts.js +1 -0
  244. package/cli-runtime/runtime/framework/control/control-scheduler.js +1 -0
  245. package/cli-runtime/runtime/framework/control/domain-set.js +1 -0
  246. package/cli-runtime/runtime/framework/control/index.js +1 -0
  247. package/cli-runtime/runtime/framework/control/types.js +1 -0
  248. package/cli-runtime/runtime/framework/control-coordinator.js +1 -0
  249. package/cli-runtime/runtime/framework/events/event-catalog.js +1 -0
  250. package/cli-runtime/runtime/framework/events/event-delivery-service.js +1 -0
  251. package/cli-runtime/runtime/framework/events/event-ingress.js +1 -0
  252. package/cli-runtime/runtime/framework/events/event-repository.js +1 -0
  253. package/cli-runtime/runtime/framework/events/index.js +5 -0
  254. package/cli-runtime/runtime/framework/events/memory-event-repository.js +1 -0
  255. package/cli-runtime/runtime/framework/events/runtime-resume.js +1 -0
  256. package/cli-runtime/runtime/framework/events/sqlite-event-repository.js +6 -0
  257. package/cli-runtime/runtime/framework/events/test-helpers.js +56 -0
  258. package/cli-runtime/runtime/framework/events/types.js +1 -0
  259. package/cli-runtime/runtime/framework/index.js +7 -0
  260. package/cli-runtime/runtime/framework/load-node-sqlite.js +1 -0
  261. package/cli-runtime/runtime/framework/mailbox/coalescer.js +1 -0
  262. package/cli-runtime/runtime/framework/mailbox/host-notification-sink.js +1 -0
  263. package/cli-runtime/runtime/framework/mailbox/identity.js +1 -0
  264. package/cli-runtime/runtime/framework/mailbox/index.js +1 -0
  265. package/cli-runtime/runtime/framework/mailbox/mailbox-dispatcher.js +1 -0
  266. package/cli-runtime/runtime/framework/mailbox/mailbox-repository.js +1 -0
  267. package/cli-runtime/runtime/framework/mailbox/notification-projector.js +1 -0
  268. package/cli-runtime/runtime/framework/mailbox/types.js +1 -0
  269. package/cli-runtime/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -0
  270. package/cli-runtime/runtime/framework/modules/runtime-module-loader.js +31 -0
  271. package/cli-runtime/runtime/framework/modules/runtime-module-output.js +1 -0
  272. package/cli-runtime/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -0
  273. package/cli-runtime/runtime/framework/participation-manager.js +1 -0
  274. package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.js +1 -0
  275. package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -0
  276. package/cli-runtime/runtime/framework/persistence/memory-first-persistence.js +9 -0
  277. package/cli-runtime/runtime/framework/plugins/contracts.js +1 -0
  278. package/cli-runtime/runtime/framework/plugins/index.js +1 -0
  279. package/cli-runtime/runtime/framework/plugins/runtime-event-identity.js +1 -0
  280. package/cli-runtime/runtime/framework/plugins/runtime-input-journal.js +1 -0
  281. package/cli-runtime/runtime/framework/plugins/runtime-plugin-scheduler.js +1 -0
  282. package/cli-runtime/runtime/framework/runtime.js +12 -0
  283. package/cli-runtime/runtime/framework/serial-task-queue.js +1 -0
  284. package/cli-runtime/runtime/framework/state/contracts.js +1 -0
  285. package/cli-runtime/runtime/framework/state/current-state-store.js +1 -0
  286. package/cli-runtime/runtime/framework/state/durable-agent-state-snapshot.js +1 -0
  287. package/cli-runtime/runtime/framework/state/freshness.js +1 -0
  288. package/cli-runtime/runtime/framework/state/history/contracts.js +1 -0
  289. package/cli-runtime/runtime/framework/state/history/history-writer.js +1 -0
  290. package/cli-runtime/runtime/framework/state/history/memory-state-history-repository.js +1 -0
  291. package/cli-runtime/runtime/framework/state/history/sqlite-state-history-repository.js +1 -0
  292. package/cli-runtime/runtime/framework/state/history/trajectory-projector.js +1 -0
  293. package/cli-runtime/runtime/framework/state/index.js +1 -0
  294. package/cli-runtime/runtime/framework/state/state-ingress.js +1 -0
  295. package/cli-runtime/runtime/framework/state/state-provider.js +1 -0
  296. package/cli-runtime/runtime/framework/state/types.js +1 -0
  297. package/cli-runtime/runtime/game-sync-ingress-protocol.js +0 -0
  298. package/cli-runtime/runtime/game-sync-ingress-worker.js +310 -0
  299. package/cli-runtime/runtime/game-sync-ingress-worker.ts +274 -0
  300. package/cli-runtime/runtime/game-sync-protocol.js +278 -0
  301. package/cli-runtime/runtime/host-monitor-rate-gate.js +1 -0
  302. package/cli-runtime/runtime/mailbox-host-relay.js +1 -0
  303. package/cli-runtime/runtime/observability/detail-capture.js +35 -0
  304. package/cli-runtime/runtime/observability/factory.js +137 -0
  305. package/cli-runtime/runtime/observability/index.js +6 -0
  306. package/cli-runtime/runtime/observability/process-timing.js +1 -0
  307. package/cli-runtime/runtime/observability/recorder.js +1 -0
  308. package/cli-runtime/runtime/observability/redaction.js +1 -0
  309. package/cli-runtime/runtime/observability/reporter.js +1 -0
  310. package/cli-runtime/runtime/observability/sinks.js +1 -0
  311. package/cli-runtime/runtime/observability/types.js +1 -0
  312. package/cli-runtime/runtime/owner-control.js +59 -0
  313. package/cli-runtime/runtime/parent-process-watch.js +1 -0
  314. package/cli-runtime/runtime/pending-event-handoff.js +48 -0
  315. package/cli-runtime/runtime/process-identity.js +45 -0
  316. package/cli-runtime/runtime/raw-ws-log.js +181 -0
  317. package/cli-runtime/runtime/runtime-logger.js +79 -0
  318. package/cli-runtime/runtime/threaded-ws-client.js +263 -0
  319. package/cli-runtime/runtime/ws-client.js +563 -0
  320. package/cli-runtime/sdk/action.js +133 -0
  321. package/cli-runtime/sdk/action.ts +160 -0
  322. package/cli-runtime/sdk/behavior-plugin/index.js +23 -0
  323. package/cli-runtime/sdk/behavior-plugin/index.ts +341 -0
  324. package/cli-runtime/sdk/behavior-toolkit/corpse-search.js +56 -0
  325. package/cli-runtime/sdk/behavior-toolkit/corpse-search.ts +87 -0
  326. package/cli-runtime/sdk/behavior-toolkit/escape.js +25 -0
  327. package/cli-runtime/sdk/behavior-toolkit/escape.ts +40 -0
  328. package/cli-runtime/sdk/behavior-toolkit/index.js +7 -0
  329. package/cli-runtime/sdk/behavior-toolkit/index.ts +7 -0
  330. package/cli-runtime/sdk/behavior-toolkit/kill-flow.js +239 -0
  331. package/cli-runtime/sdk/behavior-toolkit/kill-flow.ts +299 -0
  332. package/cli-runtime/sdk/behavior-toolkit/model.js +183 -0
  333. package/cli-runtime/sdk/behavior-toolkit/model.ts +265 -0
  334. package/cli-runtime/sdk/behavior-toolkit/move-gate.js +30 -0
  335. package/cli-runtime/sdk/behavior-toolkit/move-gate.ts +52 -0
  336. package/cli-runtime/sdk/behavior-toolkit/patrol.js +39 -0
  337. package/cli-runtime/sdk/behavior-toolkit/patrol.ts +53 -0
  338. package/cli-runtime/sdk/behavior-toolkit/search.js +81 -0
  339. package/cli-runtime/sdk/behavior-toolkit/search.ts +102 -0
  340. package/cli-runtime/sdk/index.js +78 -0
  341. package/cli-runtime/sdk/index.ts +136 -0
  342. package/cli-runtime/sdk/module-input/index.js +0 -0
  343. package/cli-runtime/sdk/module-input/index.ts +310 -0
  344. package/cli-runtime/sdk/perception-plugin/index.js +79 -0
  345. package/cli-runtime/sdk/perception-plugin/index.ts +251 -0
  346. package/cli-runtime/sdk/perception-plugin/lifecycle.js +18 -0
  347. package/cli-runtime/sdk/perception-plugin/lifecycle.ts +15 -0
  348. package/cli-runtime/sdk/perception-plugin/math.js +99 -0
  349. package/cli-runtime/sdk/perception-plugin/math.ts +107 -0
  350. package/cli-runtime/sdk/perception-plugin/module.js +4 -0
  351. package/cli-runtime/sdk/perception-plugin/module.ts +80 -0
  352. package/cli-runtime/sdk/perception-plugin/reaction.js +6 -0
  353. package/cli-runtime/sdk/perception-plugin/reaction.ts +79 -0
  354. package/cli-runtime/sdk/perception-plugin/reminder-rules.js +131 -0
  355. package/cli-runtime/sdk/perception-plugin/reminder-rules.ts +89 -0
  356. package/cli-runtime/sdk/perception-plugin/reminder.js +8 -0
  357. package/cli-runtime/sdk/perception-plugin/reminder.ts +68 -0
  358. package/cli-runtime/sdk/perception-plugin/task-change-tracker.js +150 -0
  359. package/cli-runtime/sdk/perception-plugin/task-change-tracker.ts +258 -0
  360. package/cli-runtime/sdk/resource-metadata.js +27 -0
  361. package/cli-runtime/sdk/resource-metadata.ts +66 -0
  362. package/cli-runtime/sdk/strategy-memory.js +1 -0
  363. package/cli-runtime/sdk/strategy-memory.ts +1 -0
  364. package/cli-runtime/sdk/strategy-plugin/index.js +6 -0
  365. package/cli-runtime/sdk/strategy-plugin/index.ts +36 -0
  366. package/cli-runtime/sdk/task-availability.js +56 -0
  367. package/cli-runtime/sdk/task-availability.ts +70 -0
  368. package/cli-runtime/sdk/trigger-plugin/index.js +16 -0
  369. package/cli-runtime/sdk/trigger-plugin/index.ts +130 -0
  370. package/cli-runtime/sdk/types.js +25 -0
  371. package/cli-runtime/sdk/types.ts +165 -0
  372. package/cli-runtime/short-command/classifier.js +129 -0
  373. package/cli-runtime/short-command/index.js +7 -0
  374. package/cli-runtime/short-command/presenter.js +225 -0
  375. package/cli-runtime/short-command/process-io.js +13 -0
  376. package/cli-runtime/short-command/response-contract.js +24 -0
  377. package/cli-runtime/short-command/runner.js +94 -0
  378. package/cli-runtime/short-command/sensitive-data-filter.js +92 -0
  379. package/cli-runtime/short-command/transport-response.js +57 -0
  380. package/cli-runtime/short-command/types.js +0 -0
  381. package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/host.js +21 -29
  382. package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/sdk-sdk.js +76 -6
  383. package/docs/configuration.md +13 -0
  384. package/package.json +7 -4
  385. package/scripts/build-cli.mjs +34 -0
  386. package/skills/clawclaw/SKILL.md +1 -1
  387. package/skills/clawclaw/references/STREAM.md +1 -0
  388. package/skills/clawclaw-start/SKILL.md +1 -0
  389. package/skills/clawclaw-start/references/STARTUP.md +1 -0
  390. package/src/cli.ts +75 -77
  391. package/src/commands/auth.ts +3 -2
  392. package/src/commands/game/index.ts +33 -9
  393. package/src/commands/prepare.ts +34 -18
  394. package/src/lib/agent-workspace-client.ts +12 -9
  395. package/src/lib/game-client.ts +1 -1
  396. package/src/lib/http-transport.ts +17 -2
  397. package/src/lib/hub-client.ts +10 -7
  398. package/src/pipeline/event-format.ts +2 -0
  399. package/src/pipeline/event-hints.ts +6 -0
  400. package/src/runtime/clawclaw/notification-policy.ts +1 -1
  401. package/src/runtime/clawclaw/owner-lock.ts +3 -2
  402. package/src/runtime/clawclaw/owner.ts +36 -10
  403. package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +1 -1
  404. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +19 -0
  405. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +1 -0
  406. package/src/runtime/clawclaw/plugins/source/source-plugin.ts +33 -9
  407. package/src/runtime/clawclaw-event-catalog.ts +1 -0
  408. package/src/runtime/framework/modules/runtime-module-loader.ts +24 -29
  409. package/src/runtime/process-identity.ts +44 -0
@@ -0,0 +1,310 @@
1
+ /** Shared authoring data boundaries for player-defined ClawClaw modules. */
2
+
3
+ export interface Position {
4
+ readonly x: number;
5
+ readonly y: number;
6
+ }
7
+
8
+ export interface PlayerRef {
9
+ readonly seat: number;
10
+ readonly name: string;
11
+ }
12
+
13
+ export interface GamePlayerActivity {
14
+ readonly kind: 'idle' | 'moving' | 'task';
15
+ readonly task_name?: string;
16
+ readonly remaining_secs?: number;
17
+ readonly target_x?: number;
18
+ readonly target_y?: number;
19
+ }
20
+
21
+ export type GameTaskKind = 'ordinary' | 'fake_shrimp' | 'sabotage' | 'emergency';
22
+
23
+ export interface GameTaskAvailability {
24
+ readonly state: 'ready' | 'cooldown' | 'blocked' | 'in_progress' | 'completed' | 'unknown';
25
+ readonly reason?: 'sabotage_cooldown' | 'emergency_active' | 'sabotage_state_unavailable'
26
+ | 'task_state_unavailable' | 'player_state_unavailable' | 'not_assigned' | 'not_alive'
27
+ | 'not_wandering' | 'emergency_inactive' | 'task_in_progress' | 'task_completed';
28
+ /** Authoritative shared cooldown, not an SDK wall-clock estimate. */
29
+ readonly remaining_secs?: number;
30
+ }
31
+
32
+ export interface GameTask {
33
+ /** Stable task identity when the backend provides one. */
34
+ readonly task_id?: string;
35
+ /** Player-facing task name accepted by the task Action. */
36
+ readonly name: string;
37
+ readonly room: string;
38
+ readonly x: number;
39
+ readonly y: number;
40
+ readonly is_fake_shrimp: boolean;
41
+ readonly status?: 'normal' | 'in_progress' | 'completed';
42
+ readonly task_note?: string;
43
+ /** CCL read projection; does not change the underlying assignment or execution status. */
44
+ readonly kind?: GameTaskKind;
45
+ readonly availability?: Readonly<GameTaskAvailability>;
46
+ }
47
+
48
+ export interface GameSelf {
49
+ readonly player?: Readonly<PlayerRef>;
50
+ readonly x?: number;
51
+ readonly y?: number;
52
+ readonly room?: string;
53
+ readonly role?: string;
54
+ readonly faction?: string;
55
+ readonly is_alive?: boolean;
56
+ readonly completed_task_count?: number;
57
+ readonly kill_cooldown_secs?: number;
58
+ readonly kills_remaining?: number | null;
59
+ readonly activity?: Readonly<GamePlayerActivity>;
60
+ readonly crab_teammates?: readonly Readonly<PlayerRef>[];
61
+ /** Complete current assignments, including cooldown/blocked tasks and execution/completion facts. */
62
+ readonly tasks?: readonly Readonly<GameTask>[];
63
+ }
64
+
65
+ export interface VisiblePlayer extends Position {
66
+ readonly player: Readonly<PlayerRef>;
67
+ readonly room: string;
68
+ readonly distance?: number;
69
+ readonly is_alive?: boolean;
70
+ }
71
+
72
+ export interface VisibleCorpse extends Position {
73
+ /** Stable corpse identity. A corpse may not yet be identifiable as a player. */
74
+ readonly corpse_id: string;
75
+ readonly player?: Readonly<PlayerRef>;
76
+ readonly room: string;
77
+ readonly distance?: number;
78
+ }
79
+
80
+ export type GameKiller =
81
+ | Readonly<{ readonly kind: 'player'; readonly player: Readonly<PlayerRef> }>
82
+ | Readonly<{ readonly kind: 'system'; readonly name: string }>;
83
+
84
+ export interface KnownPlayer extends PlayerRef {
85
+ readonly known_status: Readonly<{
86
+ readonly is_alive?: boolean;
87
+ readonly death_cause?: 'killed' | 'exiled';
88
+ readonly killer?: GameKiller;
89
+ readonly reported_in_current_meeting?: boolean;
90
+ }>;
91
+ readonly tier?: string;
92
+ readonly tier_display?: string;
93
+ }
94
+
95
+ export interface GameEmergency {
96
+ readonly active: boolean;
97
+ readonly task_name?: string;
98
+ readonly room?: string;
99
+ readonly x?: number;
100
+ readonly y?: number;
101
+ readonly remaining_secs?: number | null;
102
+ }
103
+
104
+ export interface GameCrabSabotage {
105
+ readonly status:
106
+ | 'ready'
107
+ | 'cooldown_charged'
108
+ | 'emergency_active';
109
+ readonly cooldown_remaining_secs?: number;
110
+ }
111
+
112
+ export interface GameMeeting {
113
+ readonly active: boolean;
114
+ readonly sub_phase?: string;
115
+ readonly caller?: Readonly<PlayerRef>;
116
+ readonly speech_order?: readonly Readonly<PlayerRef>[];
117
+ readonly current_speaker?: Readonly<PlayerRef>;
118
+ readonly deadline_at_ms?: number;
119
+ readonly server_time_ms?: number;
120
+ readonly speeches?: Readonly<Record<string, string>>;
121
+ readonly speech_skipped?: readonly number[];
122
+ readonly votes_submitted?: readonly number[];
123
+ }
124
+
125
+ export interface GameOctopusTime {
126
+ readonly active: boolean;
127
+ readonly remaining_secs?: number;
128
+ }
129
+
130
+ export type GameWinner =
131
+ | Readonly<{
132
+ readonly kind: 'faction';
133
+ readonly faction: 'lobster' | 'crab';
134
+ }>
135
+ | Readonly<{
136
+ readonly kind: 'neutral';
137
+ readonly faction: 'neutral';
138
+ readonly player: Readonly<PlayerRef>;
139
+ readonly role: 'neutral_octopus' | 'neutral_paradise_fish';
140
+ }>;
141
+
142
+ /**
143
+ * The authoritative, current-player GameSync snapshot.
144
+ *
145
+ * It is the only public business-state schema. It is not the Runtime lifecycle
146
+ * state and it is not an omniscient view of the match.
147
+ */
148
+ export interface GameState {
149
+ readonly game_id: string;
150
+ readonly tick: number;
151
+ /** May be absent only on a degraded frame accepted by the current Runtime. */
152
+ readonly phase?: 'preparing' | 'wandering' | 'meeting' | 'game_over';
153
+ readonly you?: Readonly<GameSelf>;
154
+ readonly players?: readonly Readonly<KnownPlayer>[];
155
+ readonly visible_players?: readonly Readonly<VisiblePlayer>[];
156
+ readonly visible_corpses?: readonly Readonly<VisibleCorpse>[];
157
+ readonly task_progress?: Readonly<{ completed: number; goal: number }>;
158
+ readonly emergency?: Readonly<GameEmergency>;
159
+ readonly crab_sabotage?: Readonly<GameCrabSabotage>;
160
+ readonly meeting?: Readonly<GameMeeting>;
161
+ readonly octopus_time?: Readonly<GameOctopusTime>;
162
+ readonly winner?: Readonly<GameWinner>;
163
+ readonly settlement?: Readonly<Record<string, unknown>>;
164
+ }
165
+
166
+ export interface VisualPosition {
167
+ readonly x: number;
168
+ readonly y: number;
169
+ readonly room: string | null;
170
+ }
171
+
172
+ export interface VisualPlayer extends VisualPosition {
173
+ readonly id: string;
174
+ readonly name?: string;
175
+ readonly seat?: number;
176
+ /** True only for the player whose Agent owns this observation stream. */
177
+ readonly observer: boolean;
178
+ readonly alive?: boolean;
179
+ }
180
+
181
+ export interface VisualCorpse extends VisualPosition {
182
+ readonly id: string;
183
+ readonly playerId?: string;
184
+ readonly name?: string;
185
+ readonly seat?: number;
186
+ }
187
+
188
+ /** Visual facts derived from one player-visible Game State. It is not a second State. */
189
+ export interface VisualObservation {
190
+ /** The observer and every other player currently visible to the observer. */
191
+ readonly players: readonly VisualPlayer[];
192
+ readonly corpses: readonly VisualCorpse[];
193
+ /** False means absence cannot be interpreted as leaving the field of view. */
194
+ readonly visibleSetComplete: boolean;
195
+ }
196
+
197
+ /**
198
+ * One persisted Game State frame plus its visual observation.
199
+ *
200
+ * Perception and Trigger receive this same immutable observation boundary and
201
+ * may compute concurrently. It contains no output from either module family.
202
+ */
203
+ export interface ObservationFrame {
204
+ /** Stable Source identity of the persisted State frame. */
205
+ readonly frameKey: string;
206
+ /** CCL State History sequence. It is not the game tick. */
207
+ readonly frameSeq: number;
208
+ readonly tick: number;
209
+ readonly timeMs: number;
210
+ readonly tickDelta: number | null;
211
+ readonly continuousFromPrevious: boolean;
212
+ /** The authoritative player-visible State for this frame. */
213
+ readonly gameState: Readonly<GameState>;
214
+ /** A derived, visual-only projection of `gameState`; never an independent State. */
215
+ readonly observation: Readonly<VisualObservation>;
216
+ }
217
+
218
+ export interface GameEvent {
219
+ readonly eventId: string;
220
+ readonly epochId?: number;
221
+ readonly type: string;
222
+ readonly occurredAt: string;
223
+ readonly payload: Readonly<Record<string, unknown>>;
224
+ }
225
+
226
+ export interface BehaviorScope {
227
+ readonly sessionId: string;
228
+ readonly segmentId: string;
229
+ }
230
+
231
+ /** Runtime-owned terminal result of a short Behavior delegated by a long Behavior. */
232
+ export interface BehaviorDelegatedBehaviorResult {
233
+ readonly activationId: string;
234
+ readonly behavior: string;
235
+ readonly outcome: 'completed' | 'failed' | 'cancelled' | 'replaced';
236
+ readonly reason: string;
237
+ readonly summary?: string;
238
+ }
239
+
240
+ /** One-shot input delivered when a long Behavior resumes after delegated work. */
241
+ export interface BehaviorContinuation {
242
+ readonly delegatedBehavior: Readonly<BehaviorDelegatedBehaviorResult>;
243
+ }
244
+
245
+ interface BehaviorDecisionActionBase {
246
+ readonly thinking_content?: string;
247
+ }
248
+
249
+ /** One credential-free Action proposed by a Behavior Decision. */
250
+ export type BehaviorDecisionAction =
251
+ | (BehaviorDecisionActionBase & {
252
+ readonly action: 'move';
253
+ readonly target: string;
254
+ readonly target_x?: never;
255
+ readonly target_y?: never;
256
+ readonly stop_on_player?: boolean;
257
+ })
258
+ | (BehaviorDecisionActionBase & {
259
+ readonly action: 'move';
260
+ readonly target?: never;
261
+ readonly target_x: number;
262
+ readonly target_y: number;
263
+ readonly stop_on_player?: boolean;
264
+ })
265
+ | (BehaviorDecisionActionBase & { readonly action: 'kill'; readonly target_seat: number })
266
+ | (BehaviorDecisionActionBase & { readonly action: 'speech'; readonly text: string })
267
+ | (BehaviorDecisionActionBase & { readonly action: 'task'; readonly task_name?: string })
268
+ | (BehaviorDecisionActionBase & { readonly action: 'report' })
269
+ | (BehaviorDecisionActionBase & { readonly action: 'think' });
270
+
271
+ export type BehaviorDecisionFrameStatus = 'pending' | 'completed' | 'not_computed' | 'failed';
272
+
273
+ /**
274
+ * One activation-local Runtime frame and the Decision result known so far.
275
+ * `actions` is an array for a completed Decision (including an empty array)
276
+ * and null when no Decision result exists.
277
+ */
278
+ export interface BehaviorDecisionFrame {
279
+ readonly epochId: number;
280
+ readonly tick: number;
281
+ readonly instanceGeneration: number;
282
+ readonly status: BehaviorDecisionFrameStatus;
283
+ readonly actions: readonly Readonly<BehaviorDecisionAction>[] | null;
284
+ readonly reason?: string;
285
+ }
286
+
287
+ /** The input envelope shared by finite and continuous Behaviors. */
288
+ export interface BehaviorInput<
289
+ TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,
290
+ > {
291
+ /** Local cadence metadata; backend tick and observation age remain authoritative. */
292
+ readonly cycle?: ProcessingCycleInfo;
293
+ readonly epochId: number;
294
+ readonly scope: Readonly<BehaviorScope>;
295
+ /** Runtime-observed time for this accepted input, suitable for deterministic logic. */
296
+ readonly nowMs: number;
297
+ readonly gameState: Readonly<GameState>;
298
+ readonly events: readonly Readonly<GameEvent>[];
299
+ readonly input: Readonly<TInput>;
300
+ /**
301
+ * One immutable snapshot of the current Activation's latest 100 Decision frames.
302
+ * Current Runtime owners always provide it; optional keeps older author test fixtures source-compatible.
303
+ */
304
+ readonly decisionHistory?: readonly Readonly<BehaviorDecisionFrame>[];
305
+ /** Present for the first committed decision after delegated short work ends. */
306
+ readonly continuation?: Readonly<BehaviorContinuation>;
307
+ }
308
+ /** Local call timing and the provenance of the latest backend observation; not a State-history API. */
309
+ export type ProcessingCycleInfo = Readonly<Pick<import('../../runtime/framework/plugins/contracts.js').RuntimeCycleInfo,
310
+ 'id' | 'intervalMs' | 'nowMs' | 'hasNewState' | 'stateVersion' | 'stateReceivedAtMs' | 'stateAgeMs' | 'connectionState'>>;
@@ -0,0 +1,79 @@
1
+ const PERCEPTION_PLUGIN_API_VERSION = 2;
2
+ export * from "./module.js";
3
+ export * from "./lifecycle.js";
4
+ import { Perception } from "@myclaw163/game-agent-runtime/sdk/perception.js";
5
+ import { ClawclawReaction } from "./reaction.js";
6
+ export * from "./reminder.js";
7
+ import { defaultReminder } from "./reminder-rules.js";
8
+ function evaluateReminder(topic, input) {
9
+ return defaultReminder(topic, "events" in input ? { ...input, facts: input.events } : input);
10
+ }
11
+ import {
12
+ hasValidClawclawResourceLocalizations,
13
+ resolveClawclawResourceMetadata
14
+ } from "../resource-metadata.js";
15
+ import {
16
+ MOVE_MIN_PX,
17
+ STEP_MOVE_MIN_PX,
18
+ STILL_STEP_MAX_PX,
19
+ TICK_MS,
20
+ actorLabel,
21
+ actorValue,
22
+ angleDegrees,
23
+ cosine,
24
+ cross,
25
+ direction,
26
+ distance,
27
+ dot,
28
+ headingDirection,
29
+ length,
30
+ positionCopy,
31
+ round1,
32
+ timeRange,
33
+ unit,
34
+ vector
35
+ } from "./math.js";
36
+ class ClawclawPerception extends Perception {
37
+ static manifest;
38
+ /** API v3 combines observation, notification and fixed Behavior activation. */
39
+ evaluate(_input, _api) {
40
+ throw new Error("PERCEPTION_EVALUATE_NOT_IMPLEMENTED");
41
+ }
42
+ /** @deprecated API v2 compatibility; new modules implement evaluate(). */
43
+ update(frame, api) {
44
+ throw new Error("PERCEPTION_UPDATE_NOT_IMPLEMENTED");
45
+ }
46
+ }
47
+ class ClawclawParallelPerception extends ClawclawPerception {
48
+ update() {
49
+ throw new Error("parallel_perception_uses_analyze_and_commit");
50
+ }
51
+ }
52
+ export {
53
+ ClawclawParallelPerception,
54
+ ClawclawPerception,
55
+ ClawclawReaction,
56
+ MOVE_MIN_PX,
57
+ PERCEPTION_PLUGIN_API_VERSION,
58
+ STEP_MOVE_MIN_PX,
59
+ STILL_STEP_MAX_PX,
60
+ TICK_MS,
61
+ actorLabel,
62
+ actorValue,
63
+ angleDegrees,
64
+ cosine,
65
+ cross,
66
+ direction,
67
+ distance,
68
+ dot,
69
+ evaluateReminder,
70
+ hasValidClawclawResourceLocalizations,
71
+ headingDirection,
72
+ length,
73
+ positionCopy,
74
+ resolveClawclawResourceMetadata,
75
+ round1,
76
+ timeRange,
77
+ unit,
78
+ vector
79
+ };
@@ -0,0 +1,251 @@
1
+ /** Frozen API v2 compatibility version; new modules use PERCEPTION_MODULE_API_VERSION (3). */
2
+ export const PERCEPTION_PLUGIN_API_VERSION = 2 as const;
3
+ export * from './module.js';
4
+ export * from './lifecycle.js';
5
+ import { Perception } from '@myclaw163/game-agent-runtime/sdk/perception.js';
6
+ import type { PerceptionModuleManifest, PerceptionModuleInput, PerceptionModuleResult, PerceptionModuleApi } from './module.js';
7
+ export { ClawclawReaction } from './reaction.js';
8
+ export type { ClawclawReactionManifest, ReactionBehaviorBinding, ReactionActivation, ReactionInput, ReactionResult, ReactionEvent, ReactionFact } from './reaction.js';
9
+ export * from './reminder.js';
10
+ import { defaultReminder } from './reminder-rules.js';
11
+ import type { ReminderInput, ReminderResult, ReminderTopic } from './reminder.js';
12
+ /** Optional task/speech helper accepts both the unified input and its v2 compatibility input. */
13
+ export function evaluateReminder(topic: ReminderTopic, input: ReminderInput | PerceptionModuleInput): ReminderResult {
14
+ return defaultReminder(topic, 'events' in input ? { ...input, facts: input.events } : input);
15
+ }
16
+
17
+ export {
18
+ hasValidClawclawResourceLocalizations,
19
+ resolveClawclawResourceMetadata,
20
+ } from '../resource-metadata.js';
21
+ export type {
22
+ ClawclawLocalizedResourceText,
23
+ ClawclawResolvedResourceMetadata,
24
+ ClawclawResourceLocalizations,
25
+ ClawclawResourceMetadata,
26
+ } from '../resource-metadata.js';
27
+
28
+ export {
29
+ MOVE_MIN_PX,
30
+ STEP_MOVE_MIN_PX,
31
+ STILL_STEP_MAX_PX,
32
+ TICK_MS,
33
+ actorLabel,
34
+ actorValue,
35
+ angleDegrees,
36
+ cosine,
37
+ cross,
38
+ direction,
39
+ distance,
40
+ dot,
41
+ headingDirection,
42
+ length,
43
+ positionCopy,
44
+ round1,
45
+ timeRange,
46
+ unit,
47
+ vector,
48
+ } from './math.js';
49
+ export type { Direction, Vec } from './math.js';
50
+
51
+ import type { ClawclawResourceLocalizations } from '../resource-metadata.js';
52
+ import type { ObservationFrame } from '../module-input/index.js';
53
+ import type { SpatialApi, SpatialRoom } from '../behavior-plugin/index.js';
54
+
55
+ export type {
56
+ GameEvent,
57
+ GameState,
58
+ KnownPlayer,
59
+ PlayerRef,
60
+ Position,
61
+ VisibleCorpse,
62
+ VisiblePlayer,
63
+ ObservationFrame,
64
+ VisualCorpse,
65
+ VisualObservation,
66
+ VisualPlayer,
67
+ VisualPosition,
68
+ } from '../module-input/index.js';
69
+
70
+ export type PerceptionSubjectScope =
71
+ | 'others'
72
+ | 'self_and_others'
73
+ | 'visible_pairs'
74
+ | 'corpses';
75
+
76
+ /** Perception's public name for the shared observation-frame boundary. */
77
+ export type PerceptionFrame = ObservationFrame;
78
+
79
+ export type PerceptionMapRoom = SpatialRoom;
80
+
81
+ export type PerceptionSpatialApi = SpatialApi;
82
+
83
+ export interface PerceptionApi {
84
+ readonly spatial: PerceptionSpatialApi;
85
+ }
86
+
87
+ export interface ClawclawPerceptionEventMetadata {
88
+ readonly name: string;
89
+ readonly description: string;
90
+ readonly localizations?: ClawclawResourceLocalizations;
91
+ }
92
+
93
+ /**
94
+ * Immutable, epoch-bound input for one fresh parallel analyzer instance.
95
+ * Frames may be skipped and different inputs may be analyzed concurrently.
96
+ */
97
+ export interface PerceptionAnalysisInput {
98
+ /** Current visual frame. Its continuity fields are resolved against history. */
99
+ readonly frame: Readonly<PerceptionFrame>;
100
+ /** Older visual frames, ascending and excluding `frame`; total window is at most 10. */
101
+ readonly history: readonly Readonly<PerceptionFrame>[];
102
+ /** True only when a prior visual frame exists but continuity into `frame` is not proven. */
103
+ readonly gapBefore: boolean;
104
+ }
105
+
106
+ export type PerceptionBoundaryKind =
107
+ | 'events_requested'
108
+ | 'phase_changed'
109
+ | 'trajectory_gap'
110
+ | 'segment_ending'
111
+ | 'shutdown';
112
+
113
+ export interface PerceptionBoundary {
114
+ readonly kind: PerceptionBoundaryKind;
115
+ /** snapshot reports an open slice and keeps it alive; close ends and resets the slice. */
116
+ readonly mode: 'snapshot' | 'close';
117
+ /** Last visual frame the module may include in this output. */
118
+ readonly through: Readonly<PerceptionFrame> | null;
119
+ /** First frame after a close boundary, when one exists; never part of the closing slice. */
120
+ readonly next?: Readonly<PerceptionFrame> | null;
121
+ }
122
+
123
+ export interface PerceptionEventProposal {
124
+ /** Whether this Event may initiate Agent delivery; omitted means true. */
125
+ readonly wakeAgent?: boolean;
126
+ readonly type: string;
127
+ /** Stable semantic key for replaying the same epoch/output; not cross-frame suppression. */
128
+ readonly dedupeKey: string;
129
+ /** Identity namespace; epoch and output position still participate in event identity. */
130
+ readonly dedupeScope?: 'segment' | 'session';
131
+ readonly payload: Readonly<Record<string, unknown>>;
132
+ readonly occurredAt?: string;
133
+ }
134
+
135
+ /** @deprecated Visual API v2 compatibility; new scripts use PerceptionModuleManifest. */
136
+ export interface ClawclawPerceptionManifest {
137
+ /** Whether this Event may initiate Agent delivery; omitted means true. */
138
+ readonly wakeAgent?: boolean;
139
+ readonly apiVersion: typeof PERCEPTION_PLUGIN_API_VERSION;
140
+ readonly id: string;
141
+ /** Legacy modules may provide a name; human-facing text is managed by the host. */
142
+ readonly name?: string;
143
+ readonly description: string;
144
+ readonly localizations?: ClawclawResourceLocalizations;
145
+ /** Describes Event subjects; every module still receives self as a spatial reference. */
146
+ readonly subjectScope: PerceptionSubjectScope;
147
+ readonly produces: readonly string[];
148
+ /** Optional display metadata for every Event in `produces`. */
149
+ readonly eventMetadata?: Readonly<Record<string, ClawclawPerceptionEventMetadata>>;
150
+ /**
151
+ * Omit for the persistent, ordered `update()` contract.
152
+ * `parallel_analysis` batches every enabled parallel module for one frame on
153
+ * reusable analysis Workers, then applies each persistent reducer in order
154
+ * on its reducer Worker lane.
155
+ */
156
+ readonly execution?: 'parallel_analysis';
157
+ /**
158
+ * The analysis contains a current-frame observation that `commit()` can
159
+ * safely install into a freshly reset reducer without retaining any
160
+ * relationship to `input.history`. CCL suppresses Events from that boundary
161
+ * commit. Omit unless this invariant is guaranteed by the module.
162
+ */
163
+ readonly boundaryBaseline?: 'current_only';
164
+ }
165
+
166
+ /**
167
+ * Canonical authoring surface for one independent perception module.
168
+ *
169
+ * API v3 runs evaluate() in a bounded Worker with a fresh instance per call;
170
+ * return state for the next call and recovery. API v2 update/parallel_analysis
171
+ * retains its original persistent reducer semantics on the compatibility path.
172
+ * A slow call can be terminated without blocking the Runtime Owner.
173
+ */
174
+ export abstract class ClawclawPerception extends Perception<PerceptionModuleInput, PerceptionModuleApi, PerceptionModuleResult> {
175
+ static readonly manifest?: ClawclawPerceptionManifest | PerceptionModuleManifest;
176
+
177
+ /** API v3 combines observation, notification and fixed Behavior activation. */
178
+ evaluate(_input: Readonly<PerceptionModuleInput>, _api?: PerceptionModuleApi): PerceptionModuleResult | Promise<PerceptionModuleResult> {
179
+ throw new Error('PERCEPTION_EVALUATE_NOT_IMPLEMENTED');
180
+ }
181
+
182
+ /** @deprecated API v2 compatibility; new modules implement evaluate(). */
183
+ update(
184
+ frame: Readonly<PerceptionFrame>,
185
+ api: PerceptionApi,
186
+ ): readonly PerceptionEventProposal[] | void | Promise<readonly PerceptionEventProposal[] | void> {
187
+ throw new Error('PERCEPTION_UPDATE_NOT_IMPLEMENTED');
188
+ }
189
+
190
+ /** Called only when CCL requires an open long-running slice to be reported. */
191
+ flush?(
192
+ boundary: Readonly<PerceptionBoundary>,
193
+ api: PerceptionApi,
194
+ ): readonly PerceptionEventProposal[] | void | Promise<readonly PerceptionEventProposal[] | void>;
195
+
196
+ /** Clears private trajectory state after a hard boundary or replay restart. */
197
+ reset?(reason: Exclude<PerceptionBoundaryKind, 'events_requested'> | 'replay'): void | Promise<void>;
198
+
199
+ /** Developer-only state included in diagnostics and offline replay, never in Agent Events. */
200
+ debugSnapshot?(): unknown;
201
+ }
202
+
203
+ /**
204
+ * Opt-in authoring surface for perception work that may exceed one game tick.
205
+ *
206
+ * CCL prewarms two Worker Threads (or the configured maximum when smaller),
207
+ * grows on queued frame pressure up to ten, and retires surplus Workers after
208
+ * 30 seconds of continuous idleness without dropping below current demand.
209
+ * Every ready thread has imported and cached all enabled parallel module classes.
210
+ * One frame is one batch containing all those modules; different frame batches
211
+ * may run concurrently on different threads. CCL constructs a fresh analyzer
212
+ * instance for every module/frame job, so `analyze()` must depend only on its
213
+ * arguments and cannot rely on an earlier instance having run.
214
+ *
215
+ * A separate long-lived reducer instance lives on a memory-bounded Worker lane
216
+ * and receives successful analysis values through `commit()` in frame order.
217
+ * `commit()` is the only place this module may mutate cross-frame state or emit
218
+ * Events and must remain short. A completed analysis is still only a proposal:
219
+ * when the 1-10 frame window is exhausted, CCL may discard it before `commit()`.
220
+ * Old frames may therefore be skipped, and CCL resets ordered trajectory state
221
+ * at that boundary.
222
+ * Aborting an active batch retires and replaces only its occupied pool slot.
223
+ *
224
+ * Analysis values cross the Worker boundary and therefore must be supported by
225
+ * `structuredClone`. CCL rejects a value that cannot be cloned. Worker Threads
226
+ * isolate failures and bound V8 old-generation memory, but are not an
227
+ * operating-system security sandbox; load only trusted code.
228
+ */
229
+ export abstract class ClawclawParallelPerception<TAnalysis = unknown>
230
+ extends ClawclawPerception {
231
+ override update(): never {
232
+ throw new Error('parallel_perception_uses_analyze_and_commit');
233
+ }
234
+
235
+ abstract analyze(
236
+ input: Readonly<PerceptionAnalysisInput>,
237
+ api: PerceptionApi,
238
+ ): TAnalysis | Promise<TAnalysis>;
239
+
240
+ abstract commit(
241
+ frame: Readonly<PerceptionFrame>,
242
+ analysis: Readonly<TAnalysis>,
243
+ api: PerceptionApi,
244
+ ): readonly PerceptionEventProposal[] | void | Promise<readonly PerceptionEventProposal[] | void>;
245
+ }
246
+
247
+ export interface ClawclawPerceptionClass {
248
+ readonly manifest?: ClawclawPerceptionManifest;
249
+ new(): ClawclawPerception;
250
+ }
251
+ export type { ProcessingCycleInfo } from '../module-input/index.js';
@@ -0,0 +1,18 @@
1
+ function hasPerceptionBoundary(input, kind) {
2
+ return input.lifecycle?.some((change) => change.kind === kind) ?? false;
3
+ }
4
+ function enteredPhase(input, phase) {
5
+ return input.lifecycle?.some((change) => change.kind === "phase_changed" && change.to === phase) ?? false;
6
+ }
7
+ function leftPhase(input, phase) {
8
+ return input.lifecycle?.some((change) => change.kind === "phase_changed" && change.from === phase) ?? false;
9
+ }
10
+ function resetPerceptionState(state, replacement) {
11
+ return { ...state, ...replacement };
12
+ }
13
+ export {
14
+ enteredPhase,
15
+ hasPerceptionBoundary,
16
+ leftPhase,
17
+ resetPerceptionState
18
+ };
@@ -0,0 +1,15 @@
1
+ import type { PerceptionModuleInput, PerceptionLifecycleChange } from './module.js';
2
+
3
+ export function hasPerceptionBoundary(input: Pick<PerceptionModuleInput, 'lifecycle'>, kind: PerceptionLifecycleChange['kind']): boolean {
4
+ return input.lifecycle?.some(change => change.kind === kind) ?? false;
5
+ }
6
+ export function enteredPhase(input: Pick<PerceptionModuleInput, 'lifecycle'>, phase: string): boolean {
7
+ return input.lifecycle?.some(change => change.kind === 'phase_changed' && change.to === phase) ?? false;
8
+ }
9
+ export function leftPhase(input: Pick<PerceptionModuleInput, 'lifecycle'>, phase: string): boolean {
10
+ return input.lifecycle?.some(change => change.kind === 'phase_changed' && change.from === phase) ?? false;
11
+ }
12
+ /** Return a new module state; never mutates the read-only input or another module. */
13
+ export function resetPerceptionState<T extends object>(state: Readonly<T>, replacement: Partial<T>): T {
14
+ return { ...state, ...replacement };
15
+ }