@cydm/happy-elves 0.1.0-beta.31 → 0.1.0-beta.310

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 (342) hide show
  1. package/apps/cli/dist/commands/app.js +10 -0
  2. package/apps/cli/dist/commands/daemon.js +92 -4
  3. package/apps/cli/dist/commands/gateway.d.ts +2 -0
  4. package/apps/cli/dist/commands/gateway.js +429 -0
  5. package/apps/cli/dist/commands/lib/args.js +49 -0
  6. package/apps/cli/dist/commands/lib/bootstrap-daemon.d.ts +2 -2
  7. package/apps/cli/dist/commands/lib/bootstrap-daemon.js +2 -2
  8. package/apps/cli/dist/commands/lib/doctor.d.ts +11 -0
  9. package/apps/cli/dist/commands/lib/doctor.js +276 -11
  10. package/apps/cli/dist/commands/lib/gateway-store.d.ts +38 -0
  11. package/apps/cli/dist/commands/lib/gateway-store.js +33 -0
  12. package/apps/cli/dist/commands/lib/index.d.ts +4 -2
  13. package/apps/cli/dist/commands/lib/index.js +2 -0
  14. package/apps/cli/dist/commands/lib/json.d.ts +2 -2
  15. package/apps/cli/dist/commands/lib/json.js +5 -2
  16. package/apps/cli/dist/commands/lib/local-daemon.d.ts +1 -0
  17. package/apps/cli/dist/commands/lib/local-daemon.js +14 -0
  18. package/apps/cli/dist/commands/lib/paths.d.ts +2 -0
  19. package/apps/cli/dist/commands/lib/paths.js +2 -0
  20. package/apps/cli/dist/commands/lib/relay-db-audit.d.ts +37 -0
  21. package/apps/cli/dist/commands/lib/relay-db-audit.js +300 -0
  22. package/apps/cli/dist/commands/lib/relay-http.d.ts +1 -1
  23. package/apps/cli/dist/commands/lib/scope.d.ts +1 -1
  24. package/apps/cli/dist/commands/lib/session-output.d.ts +15 -1
  25. package/apps/cli/dist/commands/lib/session-output.js +214 -6
  26. package/apps/cli/dist/commands/lib/session-view.d.ts +2 -2
  27. package/apps/cli/dist/commands/lib/status.js +5 -1
  28. package/apps/cli/dist/commands/lib/types.d.ts +4 -2
  29. package/apps/cli/dist/commands/lib/usage.js +123 -10
  30. package/apps/cli/dist/commands/lib/workspace.d.ts +2 -2
  31. package/apps/cli/dist/commands/lib/workspace.js +63 -10
  32. package/apps/cli/dist/commands/machine.js +50 -9
  33. package/apps/cli/dist/commands/memory.d.ts +2 -0
  34. package/apps/cli/dist/commands/memory.js +179 -0
  35. package/apps/cli/dist/commands/relay.js +29 -2
  36. package/apps/cli/dist/commands/release.d.ts +2 -0
  37. package/apps/cli/dist/commands/release.js +197 -0
  38. package/apps/cli/dist/commands/remote.js +10 -2
  39. package/apps/cli/dist/commands/schedule.d.ts +2 -0
  40. package/apps/cli/dist/commands/schedule.js +273 -0
  41. package/apps/cli/dist/commands/session.js +517 -5
  42. package/apps/cli/dist/commands/turn.js +225 -9
  43. package/apps/cli/dist/commands/workspace.d.ts +2 -0
  44. package/apps/cli/dist/commands/workspace.js +68 -0
  45. package/apps/cli/package.json +6 -0
  46. package/apps/daemon/dist/gateway/adapters.d.ts +38 -0
  47. package/apps/daemon/dist/gateway/adapters.js +2 -0
  48. package/apps/daemon/dist/gateway/feishu.d.ts +65 -0
  49. package/apps/daemon/dist/gateway/feishu.js +493 -0
  50. package/apps/daemon/dist/gateway/format.d.ts +2 -0
  51. package/apps/daemon/dist/gateway/format.js +19 -0
  52. package/apps/daemon/dist/gateway/handler.d.ts +7 -0
  53. package/apps/daemon/dist/gateway/handler.js +151 -0
  54. package/apps/daemon/dist/gateway/runtime.d.ts +33 -0
  55. package/apps/daemon/dist/gateway/runtime.js +850 -0
  56. package/apps/daemon/dist/gateway/store.d.ts +92 -0
  57. package/apps/daemon/dist/gateway/store.js +268 -0
  58. package/apps/daemon/dist/memory/handler.d.ts +7 -0
  59. package/apps/daemon/dist/memory/handler.js +105 -0
  60. package/apps/daemon/dist/memory/manager.d.ts +44 -0
  61. package/apps/daemon/dist/memory/manager.js +359 -0
  62. package/apps/daemon/dist/paths.d.ts +3 -0
  63. package/apps/daemon/dist/paths.js +3 -0
  64. package/apps/daemon/dist/relay/admission.d.ts +30 -0
  65. package/apps/daemon/dist/relay/admission.js +31 -0
  66. package/apps/daemon/dist/relay/connection.js +37 -1
  67. package/apps/daemon/dist/relay/devtools.d.ts +1 -1
  68. package/apps/daemon/dist/relay/register.js +2 -0
  69. package/apps/daemon/dist/relay/send.d.ts +2 -2
  70. package/apps/daemon/dist/relay/send.js +2 -0
  71. package/apps/daemon/dist/relay-http.d.ts +1 -1
  72. package/apps/daemon/dist/runtime/external-provider.d.ts +1 -1
  73. package/apps/daemon/dist/runtime/external-provider.js +187 -17
  74. package/apps/daemon/dist/runtime.d.ts +1 -2
  75. package/apps/daemon/dist/runtime.js +0 -3
  76. package/apps/daemon/dist/schedule/handler.d.ts +9 -0
  77. package/apps/daemon/dist/schedule/handler.js +148 -0
  78. package/apps/daemon/dist/schedule/runner.d.ts +21 -0
  79. package/apps/daemon/dist/schedule/runner.js +547 -0
  80. package/apps/daemon/dist/schedule/store.d.ts +9 -0
  81. package/apps/daemon/dist/schedule/store.js +143 -0
  82. package/apps/daemon/dist/session/create-session.d.ts +1 -1
  83. package/apps/daemon/dist/session/directory.d.ts +1 -1
  84. package/apps/daemon/dist/session/events.d.ts +15 -2
  85. package/apps/daemon/dist/session/events.js +76 -24
  86. package/apps/daemon/dist/session/file-preview.d.ts +1 -1
  87. package/apps/daemon/dist/session/lifecycle.d.ts +26 -3
  88. package/apps/daemon/dist/session/lifecycle.js +161 -22
  89. package/apps/daemon/dist/session/metadata.d.ts +2 -2
  90. package/apps/daemon/dist/session/metadata.js +42 -1
  91. package/apps/daemon/dist/session/primitives.d.ts +1 -1
  92. package/apps/daemon/dist/session/primitives.js +37 -6
  93. package/apps/daemon/dist/session/prompt.d.ts +28 -1
  94. package/apps/daemon/dist/session/prompt.js +340 -5
  95. package/apps/daemon/dist/session/reconcile.d.ts +3 -0
  96. package/apps/daemon/dist/session/reconcile.js +235 -0
  97. package/apps/daemon/dist/session/runtime-handle.d.ts +1 -1
  98. package/apps/daemon/dist/start.js +5 -1
  99. package/apps/daemon/dist/state.d.ts +2 -2
  100. package/apps/daemon/dist/turn-coordinator.d.ts +1 -0
  101. package/apps/daemon/dist/turn-coordinator.js +4 -0
  102. package/apps/daemon/dist/types.d.ts +16 -1
  103. package/apps/daemon/package.json +3 -25
  104. package/apps/relay/dist/connections.d.ts +2 -0
  105. package/apps/relay/dist/controller-handlers.d.ts +42 -2
  106. package/apps/relay/dist/controller-handlers.js +349 -37
  107. package/apps/relay/dist/db.js +296 -2
  108. package/apps/relay/dist/errors.d.ts +2 -1
  109. package/apps/relay/dist/errors.js +3 -1
  110. package/apps/relay/dist/http-routes.js +659 -33
  111. package/apps/relay/dist/http-schemas.d.ts +156 -0
  112. package/apps/relay/dist/http-schemas.js +85 -0
  113. package/apps/relay/dist/index.js +31 -1
  114. package/apps/relay/dist/machine-handlers.d.ts +15 -7
  115. package/apps/relay/dist/machine-handlers.js +567 -27
  116. package/apps/relay/dist/projections.d.ts +1 -1
  117. package/apps/relay/dist/projections.js +13 -0
  118. package/apps/relay/dist/relay-context.d.ts +41 -3
  119. package/apps/relay/dist/relay-context.js +244 -19
  120. package/apps/relay/dist/repositories.d.ts +2 -2
  121. package/apps/relay/dist/repositories.js +28 -1
  122. package/apps/relay/dist/runtime-bindings.d.ts +25 -0
  123. package/apps/relay/dist/runtime-bindings.js +49 -0
  124. package/apps/relay/dist/scope.d.ts +1 -1
  125. package/apps/relay/dist/types.d.ts +71 -1
  126. package/apps/relay/dist/websocket.js +2 -0
  127. package/package.json +5 -11
  128. package/packages/agent-sdk/dist/index.d.ts +80 -0
  129. package/packages/agent-sdk/dist/index.js +16 -0
  130. package/packages/client/dist/account.d.ts +35 -2
  131. package/packages/client/dist/account.js +98 -1
  132. package/packages/client/dist/client.d.ts +59 -6
  133. package/packages/client/dist/client.js +312 -58
  134. package/packages/client/dist/index.d.ts +1 -1
  135. package/packages/client/dist/parsers.d.ts +28 -2
  136. package/packages/client/dist/parsers.js +167 -0
  137. package/packages/client/dist/transport.d.ts +21 -1
  138. package/packages/client/dist/transport.js +69 -6
  139. package/packages/client/dist/types.d.ts +177 -1
  140. package/packages/client/dist/validation.d.ts +1 -1
  141. package/packages/runtime/dist/index.d.ts +66 -0
  142. package/packages/runtime-acpx/dist/index.d.ts +1 -1
  143. package/packages/runtime-acpx/dist/index.js +8 -0
  144. package/packages/runtime-cli/dist/claude-history.d.ts +1 -2
  145. package/packages/runtime-cli/dist/claude-history.js +0 -3
  146. package/packages/runtime-cli/dist/claude-session-store.d.ts +0 -1
  147. package/packages/runtime-cli/dist/claude-session-store.js +1 -1
  148. package/packages/runtime-cli/dist/claude-turn.d.ts +2 -1
  149. package/packages/runtime-cli/dist/claude-turn.js +29 -9
  150. package/packages/runtime-cli/dist/codex-app-server.d.ts +8 -3
  151. package/packages/runtime-cli/dist/codex-app-server.js +122 -25
  152. package/packages/runtime-cli/dist/codex-history.d.ts +1 -2
  153. package/packages/runtime-cli/dist/codex-history.js +11 -5
  154. package/packages/runtime-cli/dist/codex-protocol.d.ts +2 -2
  155. package/packages/runtime-cli/dist/codex-protocol.js +4 -4
  156. package/packages/runtime-cli/dist/history-merge.d.ts +1 -1
  157. package/packages/runtime-cli/dist/index.d.ts +1 -1
  158. package/packages/runtime-cli/dist/index.js +108 -2
  159. package/packages/runtime-cli/dist/permissions.d.ts +1 -1
  160. package/packages/runtime-cli/dist/session-store.d.ts +2 -1
  161. package/packages/runtime-cli/dist/session-store.js +9 -8
  162. package/packages/shared/dist/index.d.ts +2 -0
  163. package/packages/shared/dist/index.js +2 -0
  164. package/packages/shared/dist/protocol-schemas.d.ts +1077 -0
  165. package/packages/shared/dist/protocol-schemas.js +273 -0
  166. package/packages/shared/dist/protocol-types.d.ts +371 -3
  167. package/packages/shared/dist/protocol.d.ts +181 -2
  168. package/packages/shared/dist/protocol.js +197 -1
  169. package/packages/shared/dist/session-tags.d.ts +12 -0
  170. package/packages/shared/dist/session-tags.js +50 -0
  171. package/apps/cli/dist/commands/account.js.map +0 -1
  172. package/apps/cli/dist/commands/app.js.map +0 -1
  173. package/apps/cli/dist/commands/collect.js.map +0 -1
  174. package/apps/cli/dist/commands/command.js.map +0 -1
  175. package/apps/cli/dist/commands/config.js.map +0 -1
  176. package/apps/cli/dist/commands/daemon.js.map +0 -1
  177. package/apps/cli/dist/commands/lib/args.js.map +0 -1
  178. package/apps/cli/dist/commands/lib/audit.js.map +0 -1
  179. package/apps/cli/dist/commands/lib/bootstrap-config.js.map +0 -1
  180. package/apps/cli/dist/commands/lib/bootstrap-daemon.js.map +0 -1
  181. package/apps/cli/dist/commands/lib/bootstrap-output.js.map +0 -1
  182. package/apps/cli/dist/commands/lib/bootstrap.js.map +0 -1
  183. package/apps/cli/dist/commands/lib/config.js.map +0 -1
  184. package/apps/cli/dist/commands/lib/doctor.js.map +0 -1
  185. package/apps/cli/dist/commands/lib/exit.js.map +0 -1
  186. package/apps/cli/dist/commands/lib/index.js.map +0 -1
  187. package/apps/cli/dist/commands/lib/json.js.map +0 -1
  188. package/apps/cli/dist/commands/lib/local-daemon.js.map +0 -1
  189. package/apps/cli/dist/commands/lib/loop-store.js.map +0 -1
  190. package/apps/cli/dist/commands/lib/paths.js.map +0 -1
  191. package/apps/cli/dist/commands/lib/relay-http.js.map +0 -1
  192. package/apps/cli/dist/commands/lib/scope.js.map +0 -1
  193. package/apps/cli/dist/commands/lib/session-output.js.map +0 -1
  194. package/apps/cli/dist/commands/lib/session-view.js.map +0 -1
  195. package/apps/cli/dist/commands/lib/status.js.map +0 -1
  196. package/apps/cli/dist/commands/lib/types.js.map +0 -1
  197. package/apps/cli/dist/commands/lib/usage.js.map +0 -1
  198. package/apps/cli/dist/commands/lib/workspace.js.map +0 -1
  199. package/apps/cli/dist/commands/loop.js.map +0 -1
  200. package/apps/cli/dist/commands/machine.js.map +0 -1
  201. package/apps/cli/dist/commands/relay.js.map +0 -1
  202. package/apps/cli/dist/commands/remote.js.map +0 -1
  203. package/apps/cli/dist/commands/session.js.map +0 -1
  204. package/apps/cli/dist/commands/token.js.map +0 -1
  205. package/apps/cli/dist/commands/turn.js.map +0 -1
  206. package/apps/cli/dist/errors.js.map +0 -1
  207. package/apps/cli/dist/index.js.map +0 -1
  208. package/apps/daemon/dist/app.js.map +0 -1
  209. package/apps/daemon/dist/args.js.map +0 -1
  210. package/apps/daemon/dist/audit.js.map +0 -1
  211. package/apps/daemon/dist/cli.js.map +0 -1
  212. package/apps/daemon/dist/config.js.map +0 -1
  213. package/apps/daemon/dist/errors.js.map +0 -1
  214. package/apps/daemon/dist/loop/runner.js.map +0 -1
  215. package/apps/daemon/dist/loop/store.js.map +0 -1
  216. package/apps/daemon/dist/pair.js.map +0 -1
  217. package/apps/daemon/dist/paths.js.map +0 -1
  218. package/apps/daemon/dist/process.js.map +0 -1
  219. package/apps/daemon/dist/relay/connection.js.map +0 -1
  220. package/apps/daemon/dist/relay/devtools.js.map +0 -1
  221. package/apps/daemon/dist/relay/register.js.map +0 -1
  222. package/apps/daemon/dist/relay/send.js.map +0 -1
  223. package/apps/daemon/dist/relay-http.js.map +0 -1
  224. package/apps/daemon/dist/runtime/external-provider.js.map +0 -1
  225. package/apps/daemon/dist/runtime.js.map +0 -1
  226. package/apps/daemon/dist/session/create-session.js.map +0 -1
  227. package/apps/daemon/dist/session/directory.js.map +0 -1
  228. package/apps/daemon/dist/session/events.js.map +0 -1
  229. package/apps/daemon/dist/session/file-preview.js.map +0 -1
  230. package/apps/daemon/dist/session/lifecycle.js.map +0 -1
  231. package/apps/daemon/dist/session/metadata.js.map +0 -1
  232. package/apps/daemon/dist/session/primitives.js.map +0 -1
  233. package/apps/daemon/dist/session/prompt.js.map +0 -1
  234. package/apps/daemon/dist/session/runtime-handle.js.map +0 -1
  235. package/apps/daemon/dist/start.js.map +0 -1
  236. package/apps/daemon/dist/state.js.map +0 -1
  237. package/apps/daemon/dist/turn-coordinator.js.map +0 -1
  238. package/apps/daemon/dist/types.js.map +0 -1
  239. package/apps/daemon/dist/utils.js.map +0 -1
  240. package/apps/relay/dist/auth.js.map +0 -1
  241. package/apps/relay/dist/connections.js.map +0 -1
  242. package/apps/relay/dist/controller-handlers.js.map +0 -1
  243. package/apps/relay/dist/db.js.map +0 -1
  244. package/apps/relay/dist/errors.js.map +0 -1
  245. package/apps/relay/dist/http-routes.js.map +0 -1
  246. package/apps/relay/dist/http-schemas.js.map +0 -1
  247. package/apps/relay/dist/index.js.map +0 -1
  248. package/apps/relay/dist/machine-handlers.js.map +0 -1
  249. package/apps/relay/dist/projections.js.map +0 -1
  250. package/apps/relay/dist/relay-context.js.map +0 -1
  251. package/apps/relay/dist/repositories.js.map +0 -1
  252. package/apps/relay/dist/retention.js.map +0 -1
  253. package/apps/relay/dist/scope.js.map +0 -1
  254. package/apps/relay/dist/security.js.map +0 -1
  255. package/apps/relay/dist/types.js.map +0 -1
  256. package/apps/relay/dist/websocket.js.map +0 -1
  257. package/apps/relay/package.json +0 -29
  258. package/packages/agent-sdk/dist/index.d.ts.map +0 -1
  259. package/packages/agent-sdk/dist/index.js.map +0 -1
  260. package/packages/agent-sdk/package.json +0 -20
  261. package/packages/client/dist/account.d.ts.map +0 -1
  262. package/packages/client/dist/account.js.map +0 -1
  263. package/packages/client/dist/client.d.ts.map +0 -1
  264. package/packages/client/dist/client.js.map +0 -1
  265. package/packages/client/dist/errors.d.ts.map +0 -1
  266. package/packages/client/dist/errors.js.map +0 -1
  267. package/packages/client/dist/http.d.ts.map +0 -1
  268. package/packages/client/dist/http.js.map +0 -1
  269. package/packages/client/dist/index.d.ts.map +0 -1
  270. package/packages/client/dist/index.js.map +0 -1
  271. package/packages/client/dist/parsers.d.ts.map +0 -1
  272. package/packages/client/dist/parsers.js.map +0 -1
  273. package/packages/client/dist/transport.d.ts.map +0 -1
  274. package/packages/client/dist/transport.js.map +0 -1
  275. package/packages/client/dist/types.d.ts.map +0 -1
  276. package/packages/client/dist/types.js.map +0 -1
  277. package/packages/client/dist/validation.d.ts.map +0 -1
  278. package/packages/client/dist/validation.js.map +0 -1
  279. package/packages/client/package.json +0 -22
  280. package/packages/pie-provider/dist/index.d.ts.map +0 -1
  281. package/packages/pie-provider/dist/index.js.map +0 -1
  282. package/packages/pie-provider/package.json +0 -26
  283. package/packages/runtime/dist/index.d.ts.map +0 -1
  284. package/packages/runtime/dist/index.js.map +0 -1
  285. package/packages/runtime/package.json +0 -19
  286. package/packages/runtime-acpx/dist/index.d.ts.map +0 -1
  287. package/packages/runtime-acpx/dist/index.js.map +0 -1
  288. package/packages/runtime-acpx/package.json +0 -23
  289. package/packages/runtime-cli/dist/async-queue.d.ts.map +0 -1
  290. package/packages/runtime-cli/dist/async-queue.js.map +0 -1
  291. package/packages/runtime-cli/dist/claude-history.d.ts.map +0 -1
  292. package/packages/runtime-cli/dist/claude-history.js.map +0 -1
  293. package/packages/runtime-cli/dist/claude-json.d.ts.map +0 -1
  294. package/packages/runtime-cli/dist/claude-json.js.map +0 -1
  295. package/packages/runtime-cli/dist/claude-rename.d.ts.map +0 -1
  296. package/packages/runtime-cli/dist/claude-rename.js.map +0 -1
  297. package/packages/runtime-cli/dist/claude-session-store.d.ts.map +0 -1
  298. package/packages/runtime-cli/dist/claude-session-store.js.map +0 -1
  299. package/packages/runtime-cli/dist/claude-turn.d.ts.map +0 -1
  300. package/packages/runtime-cli/dist/claude-turn.js.map +0 -1
  301. package/packages/runtime-cli/dist/codex-app-server.d.ts.map +0 -1
  302. package/packages/runtime-cli/dist/codex-app-server.js.map +0 -1
  303. package/packages/runtime-cli/dist/codex-approvals.d.ts.map +0 -1
  304. package/packages/runtime-cli/dist/codex-approvals.js.map +0 -1
  305. package/packages/runtime-cli/dist/codex-history.d.ts.map +0 -1
  306. package/packages/runtime-cli/dist/codex-history.js.map +0 -1
  307. package/packages/runtime-cli/dist/codex-json-rpc.d.ts.map +0 -1
  308. package/packages/runtime-cli/dist/codex-json-rpc.js.map +0 -1
  309. package/packages/runtime-cli/dist/codex-lifecycle.d.ts.map +0 -1
  310. package/packages/runtime-cli/dist/codex-lifecycle.js.map +0 -1
  311. package/packages/runtime-cli/dist/codex-protocol.d.ts.map +0 -1
  312. package/packages/runtime-cli/dist/codex-protocol.js.map +0 -1
  313. package/packages/runtime-cli/dist/command-resolver.d.ts.map +0 -1
  314. package/packages/runtime-cli/dist/command-resolver.js.map +0 -1
  315. package/packages/runtime-cli/dist/history-merge.d.ts.map +0 -1
  316. package/packages/runtime-cli/dist/history-merge.js.map +0 -1
  317. package/packages/runtime-cli/dist/index.d.ts.map +0 -1
  318. package/packages/runtime-cli/dist/index.js.map +0 -1
  319. package/packages/runtime-cli/dist/permissions.d.ts.map +0 -1
  320. package/packages/runtime-cli/dist/permissions.js.map +0 -1
  321. package/packages/runtime-cli/dist/session-store.d.ts.map +0 -1
  322. package/packages/runtime-cli/dist/session-store.js.map +0 -1
  323. package/packages/runtime-cli/package.json +0 -22
  324. package/packages/shared/dist/args.d.ts.map +0 -1
  325. package/packages/shared/dist/args.js.map +0 -1
  326. package/packages/shared/dist/crypto.d.ts.map +0 -1
  327. package/packages/shared/dist/crypto.js.map +0 -1
  328. package/packages/shared/dist/ids.d.ts.map +0 -1
  329. package/packages/shared/dist/ids.js.map +0 -1
  330. package/packages/shared/dist/index.d.ts.map +0 -1
  331. package/packages/shared/dist/index.js.map +0 -1
  332. package/packages/shared/dist/protocol-schemas.d.ts.map +0 -1
  333. package/packages/shared/dist/protocol-schemas.js.map +0 -1
  334. package/packages/shared/dist/protocol-types.d.ts.map +0 -1
  335. package/packages/shared/dist/protocol-types.js.map +0 -1
  336. package/packages/shared/dist/protocol.d.ts.map +0 -1
  337. package/packages/shared/dist/protocol.js.map +0 -1
  338. package/packages/shared/dist/session-name.d.ts.map +0 -1
  339. package/packages/shared/dist/session-name.js.map +0 -1
  340. package/packages/shared/dist/session-state.d.ts.map +0 -1
  341. package/packages/shared/dist/session-state.js.map +0 -1
  342. package/packages/shared/package.json +0 -24
@@ -48,6 +48,66 @@ function assistantOutputForTurn(events, turnId) {
48
48
  .join("")
49
49
  .trim();
50
50
  }
51
+ function usedMemoriesForTurn(events, turnId) {
52
+ return dedupeUsedMemories(events
53
+ .filter((event) => event.turnId === turnId && event.decoded?.type === "memory_used")
54
+ .flatMap((event) => event.decoded?.type === "memory_used" ? event.decoded.memories : []));
55
+ }
56
+ function dedupeUsedMemories(memories) {
57
+ const seen = new Set();
58
+ const result = [];
59
+ for (const memory of memories) {
60
+ const key = [
61
+ memory.id,
62
+ memory.path,
63
+ memory.citation.path,
64
+ memory.citation.startLine,
65
+ memory.citation.endLine,
66
+ ].join(":");
67
+ if (seen.has(key))
68
+ continue;
69
+ seen.add(key);
70
+ result.push(memory);
71
+ }
72
+ return result;
73
+ }
74
+ function isUsedMemoryArray(value) {
75
+ return Array.isArray(value) && value.every((item) => {
76
+ if (!item || typeof item !== "object" || Array.isArray(item))
77
+ return false;
78
+ const record = item;
79
+ const citation = record.citation;
80
+ return typeof record.id === "string" &&
81
+ (record.layer === "user" || record.layer === "curated" || record.layer === "daily") &&
82
+ typeof record.path === "string" &&
83
+ (!record.title || typeof record.title === "string") &&
84
+ Boolean(citation) &&
85
+ typeof citation?.path === "string" &&
86
+ typeof citation?.startLine === "number" &&
87
+ typeof citation?.endLine === "number";
88
+ });
89
+ }
90
+ function sessionEventLogicalOrder(event) {
91
+ const messageKey = event.messageId ?? "";
92
+ if (event.occurredAt !== undefined) {
93
+ return { time: event.occurredAt, seq: event.turnSeq ?? event.seq, messageKey, id: event.id };
94
+ }
95
+ if (event.messageId?.startsWith("hist_") && event.turnSeq !== undefined) {
96
+ return { time: 0, seq: event.turnSeq, messageKey, id: event.id };
97
+ }
98
+ return { time: event.createdAt, seq: event.seq, messageKey, id: event.id };
99
+ }
100
+ export function compareSessionEventLogicalOrder(left, right) {
101
+ const leftOrder = sessionEventLogicalOrder(left);
102
+ const rightOrder = sessionEventLogicalOrder(right);
103
+ if (leftOrder.time !== rightOrder.time)
104
+ return leftOrder.time - rightOrder.time;
105
+ if (leftOrder.seq !== rightOrder.seq)
106
+ return leftOrder.seq - rightOrder.seq;
107
+ if (leftOrder.messageKey !== rightOrder.messageKey)
108
+ return leftOrder.messageKey < rightOrder.messageKey ? -1 : 1;
109
+ return leftOrder.id - rightOrder.id;
110
+ }
51
111
  function outputPaths(sessionId, turnId) {
52
112
  const dir = path.join(outputRoot, sessionId);
53
113
  const latest = path.join(dir, "latest.md");
@@ -78,6 +138,7 @@ export async function writeTurnOutput(sessionId, turnId, events) {
78
138
  await fs.mkdir(paths.dir, { recursive: true });
79
139
  const output = assistantOutputForTurn(events, turnId) || terminalTextForDone(events, turnId);
80
140
  const turnEvents = events.filter((event) => event.turnId === turnId);
141
+ const usedMemories = usedMemoriesForTurn(events, turnId);
81
142
  const doneEvent = [...turnEvents].reverse().find((event) => event.decoded?.type === "done");
82
143
  const metadata = {
83
144
  sessionId,
@@ -86,6 +147,7 @@ export async function writeTurnOutput(sessionId, turnId, events) {
86
147
  startedAt: turnEvents[0]?.createdAt,
87
148
  completedAt: doneEvent?.createdAt ?? Date.now(),
88
149
  eventCount: turnEvents.length,
150
+ ...(usedMemories.length > 0 ? { usedMemories } : {}),
89
151
  outputPath: paths.turn,
90
152
  latestPath: paths.latest,
91
153
  };
@@ -137,13 +199,15 @@ export async function readStoredTurnOutput(sessionId, turnId) {
137
199
  startedAt: typeof metadata.startedAt === "number" ? metadata.startedAt : undefined,
138
200
  completedAt: typeof metadata.completedAt === "number" ? metadata.completedAt : 0,
139
201
  eventCount: typeof metadata.eventCount === "number" ? metadata.eventCount : 0,
202
+ ...(isUsedMemoryArray(metadata.usedMemories) ? { usedMemories: metadata.usedMemories } : {}),
140
203
  };
141
204
  }
142
205
  export function summarizeTurns(events) {
143
206
  const folded = foldAliasedRuntimeEvents(events);
144
207
  const turns = new Map();
145
- const sorted = [...folded.events].sort((left, right) => left.id - right.id);
208
+ const sorted = [...folded.events].sort(compareSessionEventLogicalOrder);
146
209
  for (const event of sorted) {
210
+ const order = sessionEventLogicalOrder(event);
147
211
  const current = turns.get(event.turnId) ?? {
148
212
  turnId: event.turnId,
149
213
  promptChunks: [],
@@ -155,11 +219,16 @@ export function summarizeTurns(events) {
155
219
  firstEventId: event.id,
156
220
  lastEventId: event.id,
157
221
  eventCount: 0,
222
+ usedMemories: [],
223
+ order,
158
224
  };
159
225
  current.startedAt ??= event.createdAt;
160
226
  current.updatedAt = event.createdAt;
161
227
  current.lastEventId = event.id;
162
228
  current.eventCount += 1;
229
+ current.order = order;
230
+ if (event.turnSeq !== undefined)
231
+ current.turnSeq = event.turnSeq;
163
232
  const payload = event.decoded;
164
233
  if (payload?.type === "user_prompt" && payload.text.trim()) {
165
234
  current.promptChunks.push(payload.text.trim());
@@ -174,6 +243,9 @@ export function summarizeTurns(events) {
174
243
  current.checkpointId = payload.currentHead;
175
244
  current.runtimeTurnId = payload.lastTurnId;
176
245
  }
246
+ else if (payload?.type === "memory_used") {
247
+ current.usedMemories = dedupeUsedMemories([...current.usedMemories, ...payload.memories]);
248
+ }
177
249
  turns.set(event.turnId, current);
178
250
  }
179
251
  return [...turns.values()]
@@ -181,6 +253,7 @@ export function summarizeTurns(events) {
181
253
  turnId: turn.turnId,
182
254
  checkpointId: turn.checkpointId,
183
255
  runtimeTurnId: turn.runtimeTurnId,
256
+ turnSeq: turn.turnSeq,
184
257
  status: turn.status,
185
258
  prompt: turn.promptChunks.join("\n").trim(),
186
259
  output: turn.outputChunks.join("").trim() || turn.terminalText,
@@ -191,8 +264,15 @@ export function summarizeTurns(events) {
191
264
  firstEventId: turn.firstEventId,
192
265
  lastEventId: turn.lastEventId,
193
266
  eventCount: turn.eventCount,
267
+ ...(turn.usedMemories.length > 0 ? { usedMemories: turn.usedMemories } : {}),
268
+ order: turn.order,
194
269
  }))
195
- .sort((left, right) => right.updatedAt - left.updatedAt || right.lastEventId - left.lastEventId);
270
+ .sort((left, right) => right.order.time - left.order.time ||
271
+ right.order.seq - left.order.seq ||
272
+ (right.order.messageKey === left.order.messageKey ? 0 : right.order.messageKey < left.order.messageKey ? -1 : 1) ||
273
+ right.order.id - left.order.id ||
274
+ right.lastEventId - left.lastEventId)
275
+ .map(({ order: _order, ...turn }) => turn);
196
276
  }
197
277
  export function structuredOutputForTurn(sessionId, turn) {
198
278
  const finalOutput = turn.output || turn.terminalText || undefined;
@@ -203,6 +283,7 @@ export function structuredOutputForTurn(sessionId, turn) {
203
283
  status: turn.status,
204
284
  finalOutput,
205
285
  ...(turn.status === "failed" && finalOutput ? { error: finalOutput } : {}),
286
+ ...(turn.usedMemories?.length ? { usedMemories: turn.usedMemories } : {}),
206
287
  };
207
288
  }
208
289
  export function structuredOutputForStoredTurn(output) {
@@ -213,6 +294,7 @@ export function structuredOutputForStoredTurn(output) {
213
294
  status: output.status,
214
295
  finalOutput: output.output || undefined,
215
296
  ...(output.status === "failed" && output.output ? { error: output.output } : {}),
297
+ ...(output.usedMemories?.length ? { usedMemories: output.usedMemories } : {}),
216
298
  artifactPaths: {
217
299
  output: output.outputPath,
218
300
  latest: output.latestPath,
@@ -229,10 +311,12 @@ export function structuredOutputForRunningTurn(sessionId, turnId) {
229
311
  };
230
312
  }
231
313
  function foldAliasedRuntimeEvents(events) {
314
+ events = dedupeSyntheticHistoricalEvents(events);
232
315
  const profiles = new Map();
233
316
  const runtimeToRequest = new Map();
234
317
  for (const event of events) {
235
- const profile = profiles.get(event.turnId) ?? { output: "" };
318
+ const profile = profiles.get(event.turnId) ?? { output: "", hasDone: false, firstEventId: event.id };
319
+ profile.firstEventId = Math.min(profile.firstEventId, event.id);
236
320
  const payload = event.decoded;
237
321
  if (payload?.type === "user_prompt" && profile.prompt === undefined) {
238
322
  profile.prompt = payload.text.trim();
@@ -241,6 +325,7 @@ function foldAliasedRuntimeEvents(events) {
241
325
  profile.output += payload.text;
242
326
  }
243
327
  else if (payload?.type === "done") {
328
+ profile.hasDone = true;
244
329
  const runtimeTurnId = payload.lastTurnId ?? payload.currentHead;
245
330
  if (runtimeTurnId && runtimeTurnId !== event.turnId && !runtimeTurnId.startsWith("event:")) {
246
331
  runtimeToRequest.set(runtimeTurnId, event.turnId);
@@ -262,11 +347,134 @@ function foldAliasedRuntimeEvents(events) {
262
347
  duplicateRuntimeToRequest.set(runtimeTurnId, requestTurnId);
263
348
  }
264
349
  }
350
+ const inferredRuntimeToRequest = inferRuntimeToRequestAliases(profiles, runtimeToRequest);
351
+ const inferredRequestToRuntime = new Map();
352
+ for (const [runtimeTurnId, requestTurnId] of inferredRuntimeToRequest) {
353
+ runtimeToRequest.set(runtimeTurnId, requestTurnId);
354
+ inferredRequestToRuntime.set(requestTurnId, runtimeTurnId);
355
+ }
356
+ const foldedEvents = [];
357
+ for (const event of events) {
358
+ if (duplicateRuntimeTurns.has(event.turnId))
359
+ continue;
360
+ const inferredRequestTurnId = inferredRuntimeToRequest.get(event.turnId);
361
+ if (inferredRequestTurnId) {
362
+ foldedEvents.push({ ...event, turnId: inferredRequestTurnId });
363
+ continue;
364
+ }
365
+ const inferredRuntimeTurnId = inferredRequestToRuntime.get(event.turnId);
366
+ if (inferredRuntimeTurnId && shouldDropRequestSideDuplicateEvent(event, profiles.get(inferredRuntimeTurnId))) {
367
+ continue;
368
+ }
369
+ foldedEvents.push(event);
370
+ }
265
371
  return {
266
- events: duplicateRuntimeTurns.size === 0 ? events : events.filter((event) => !duplicateRuntimeTurns.has(event.turnId)),
267
- runtimeToRequest: duplicateRuntimeToRequest,
372
+ events: foldedEvents,
373
+ runtimeToRequest: new Map([...duplicateRuntimeToRequest, ...inferredRuntimeToRequest]),
268
374
  };
269
375
  }
376
+ function inferRuntimeToRequestAliases(profiles, explicitRuntimeToRequest) {
377
+ const requestsByPrompt = new Map();
378
+ const runtimesByPrompt = new Map();
379
+ for (const [turnId, profile] of profiles) {
380
+ const promptKey = comparableOutput(profile.prompt ?? "");
381
+ if (!promptKey)
382
+ continue;
383
+ if (turnId.startsWith("turn_") && !profile.hasDone) {
384
+ requestsByPrompt.set(promptKey, [...(requestsByPrompt.get(promptKey) ?? []), { turnId, output: profile.output, firstEventId: profile.firstEventId }]);
385
+ }
386
+ else if (!turnId.startsWith("turn_") && profile.hasDone && !explicitRuntimeToRequest.has(turnId)) {
387
+ runtimesByPrompt.set(promptKey, [...(runtimesByPrompt.get(promptKey) ?? []), { turnId, output: profile.output, firstEventId: profile.firstEventId }]);
388
+ }
389
+ }
390
+ const inferred = new Map();
391
+ for (const [promptKey, requests] of requestsByPrompt) {
392
+ const runtimes = runtimesByPrompt.get(promptKey) ?? [];
393
+ if (requests.length !== 1 || runtimes.length !== 1)
394
+ continue;
395
+ const request = requests[0];
396
+ const runtime = runtimes[0];
397
+ if (!request || !runtime)
398
+ continue;
399
+ if (runtime.firstEventId <= request.firstEventId)
400
+ continue;
401
+ if (!outputsAreCompatible(request.output, runtime.output))
402
+ continue;
403
+ inferred.set(runtime.turnId, request.turnId);
404
+ }
405
+ return inferred;
406
+ }
407
+ function outputsAreCompatible(requestOutput, runtimeOutput) {
408
+ const request = comparableOutput(requestOutput);
409
+ const runtime = comparableOutput(runtimeOutput);
410
+ if (!request || !runtime)
411
+ return true;
412
+ return request.includes(runtime) || runtime.includes(request);
413
+ }
414
+ function shouldDropRequestSideDuplicateEvent(event, runtimeProfile) {
415
+ if (!runtimeProfile)
416
+ return false;
417
+ const payload = event.decoded;
418
+ if (payload?.type === "user_prompt") {
419
+ return comparableOutput(payload.text) === comparableOutput(runtimeProfile.prompt ?? "");
420
+ }
421
+ if (payload?.type === "text_delta" && payload.stream !== "thought" && payload.text) {
422
+ const chunk = comparableOutput(payload.text);
423
+ return Boolean(chunk) && comparableOutput(runtimeProfile.output).includes(chunk);
424
+ }
425
+ return false;
426
+ }
427
+ function dedupeSyntheticHistoricalEvents(events) {
428
+ const groups = new Map();
429
+ for (const event of events) {
430
+ const key = historicalComparableEventKey(event);
431
+ if (!key)
432
+ continue;
433
+ groups.set(key, [...(groups.get(key) ?? []), event]);
434
+ }
435
+ const keepIds = new Set();
436
+ const dropIds = new Set();
437
+ for (const group of groups.values()) {
438
+ if (group.length < 2 || !group.some(isSyntheticHistoricalEvent))
439
+ continue;
440
+ const preferred = group.find((event) => !isSyntheticHistoricalEvent(event)) ?? group[0];
441
+ if (preferred)
442
+ keepIds.add(preferred.id);
443
+ for (const event of group) {
444
+ if (event.id !== preferred?.id)
445
+ dropIds.add(event.id);
446
+ }
447
+ }
448
+ return events.filter((event) => !dropIds.has(event.id) || keepIds.has(event.id));
449
+ }
450
+ function isSyntheticHistoricalEvent(event) {
451
+ const messageId = event.messageId ?? "";
452
+ return messageId.startsWith("hist_") || messageId.startsWith("tail_");
453
+ }
454
+ function historicalComparableEventKey(event) {
455
+ const payload = event.decoded;
456
+ if (!payload)
457
+ return undefined;
458
+ if (payload.type === "user_prompt")
459
+ return [event.turnId, "user_prompt", comparableOutput(payload.text)].join("\0");
460
+ if (payload.type === "text_delta" && payload.stream !== "thought") {
461
+ return [event.turnId, "text_delta", payload.stream, comparableOutput(payload.text)].join("\0");
462
+ }
463
+ if (payload.type === "done") {
464
+ return [
465
+ event.turnId,
466
+ "done",
467
+ payload.status,
468
+ payload.currentHead ?? "",
469
+ payload.lastTurnId ?? "",
470
+ comparableOutput(payload.error ?? payload.stopReason ?? ""),
471
+ ].join("\0");
472
+ }
473
+ if (payload.type === "memory_used") {
474
+ return [event.turnId, "memory_used", payload.mode, payload.projectKey, JSON.stringify(payload.memories)].join("\0");
475
+ }
476
+ return undefined;
477
+ }
270
478
  function isDuplicateRuntimeOutput(requestOutput, runtimeOutput) {
271
479
  const request = comparableOutput(requestOutput);
272
480
  if (!request)
@@ -302,7 +510,7 @@ export async function rebuildTurnOutput(client, sessionId, turnId) {
302
510
  }
303
511
  export function conciseEvents(events) {
304
512
  const result = [];
305
- for (const event of events) {
513
+ for (const event of dedupeSyntheticHistoricalEvents(events)) {
306
514
  const payload = event.decoded;
307
515
  if (!payload)
308
516
  continue;
@@ -1,5 +1,5 @@
1
- import type { ControllerClient, DecodedSessionEvent } from "@happy-elves/client";
2
- import type { MachineSnapshot, SessionSnapshot } from "@happy-elves/shared";
1
+ import type { ControllerClient, DecodedSessionEvent } from "../../../../../packages/client/dist/index.js";
2
+ import type { MachineSnapshot, SessionSnapshot } from "../../../../../packages/shared/dist/index.js";
3
3
  import { type MachineMetadata, type OrchestrationSummary, type OrchestrationState } from "./types.js";
4
4
  export declare function showMachine(client: ControllerClient, machine: MachineSnapshot): Promise<MachineSnapshot & {
5
5
  defaultCwd?: string;
@@ -43,7 +43,9 @@ export async function topLevelStatus(flags) {
43
43
  } : undefined,
44
44
  };
45
45
  if (wantsJson(flags)) {
46
- ok("status", data);
46
+ if (!data.relay.ok)
47
+ process.exitCode = 1;
48
+ ok("status", data, {}, data.relay.ok);
47
49
  return;
48
50
  }
49
51
  console.log(`Relay: ${config.relayUrl}${relayError ? ` (unreachable: ${relayError})` : ""}`);
@@ -59,5 +61,7 @@ export async function topLevelStatus(flags) {
59
61
  console.log(`Result: happy-elves turn result ${latestSession.id}`);
60
62
  console.log(`Run: happy-elves turn run ${latestSession.id} --text "..."`);
61
63
  }
64
+ if (!data.relay.ok)
65
+ process.exitCode = 1;
62
66
  }
63
67
  //# sourceMappingURL=status.js.map
@@ -1,5 +1,5 @@
1
- import type { ScopedTokenScope } from "@happy-elves/client";
2
- import type { SessionSnapshot } from "@happy-elves/shared";
1
+ import type { ScopedTokenScope } from "../../../../../packages/client/dist/index.js";
2
+ import type { SessionSnapshot } from "../../../../../packages/shared/dist/index.js";
3
3
  export type CliConfig = {
4
4
  relayUrl: string;
5
5
  controllerToken: string;
@@ -30,6 +30,8 @@ export type SessionMetadata = {
30
30
  name?: string;
31
31
  requestedRuntimeName?: string;
32
32
  runtime?: unknown;
33
+ tags?: string[];
34
+ tagKeys?: string[];
33
35
  };
34
36
  export declare const idleSessionStatuses: SessionSnapshot["status"][];
35
37
  export type OrchestrationState = "pending" | "active" | "idle" | "completed" | "blocked" | "needs-user" | "closed";
@@ -8,7 +8,7 @@ Start or reuse a local Happy Elves controller, daemon, and invite flow.
8
8
 
9
9
  Show the current relay, daemon, machine, and latest session state.
10
10
  `,
11
- doctor: `Usage: happy-elves doctor [--relay <url>] [--json]
11
+ doctor: `Usage: happy-elves doctor [--relay <url>] [--strict] [--json]
12
12
 
13
13
  Check local controller config, relay reachability, and daemon state.
14
14
  `,
@@ -28,6 +28,7 @@ Check local controller config, relay reachability, and daemon state.
28
28
  happy-elves remote invite-controller [--device-name <name>] [--ttl 10m] [--join-url-base <url>] [--json]
29
29
  happy-elves remote join-controller (--url <url> | --code <code> --invite-secret <secret>) [--relay <url>] [--device-id <id>] [--device-name <name>] --json
30
30
  happy-elves remote add-controller [--device-id <id>] [--device-name <name>] --json
31
+ happy-elves remote rename <deviceId> --name <name> --json
31
32
  happy-elves remote revoke <deviceId> --json
32
33
  `,
33
34
  machine: `Usage:
@@ -45,11 +46,16 @@ Check local controller config, relay reachability, and daemon state.
45
46
  file preview is read-only and limited to files inside --root.
46
47
  `,
47
48
  session: `Usage:
48
- happy-elves session create --machine <machineId> [--agent codex] [--cwd <path>] [--name <name>] [--permission-mode <mode>] --json
49
- happy-elves session list [--machine <machineId>] [--agent <agent>] [--cwd <cwd>] [--name <name>] [--limit n] [--all] [--verbose] [--json]
49
+ happy-elves session create --machine <machineId> [--agent codex] [--cwd <path>] [--name <name>] [--permission-mode <mode>] [--tag <tag>] [--hidden --source dogfood] --json
50
+ happy-elves session list [--machine <machineId>] [--agent <agent>] [--cwd <cwd>] [--name <name>] [--tag <tag>] [--limit n] [--all] [--verbose] [--json]
51
+ happy-elves session tag add <sessionId> --tag <tag> --json
52
+ happy-elves session tag remove <sessionId> --tag <tag> --json
53
+ happy-elves session tag list <sessionId> --json
50
54
  happy-elves session history --machine <machineId> [--cwd <path>] [--agent <agent>] [--include-archived] [--limit 20] --json
51
55
  happy-elves session continue <runtimeSessionId> --machine <machineId> [--name <name>] --json
52
56
  happy-elves session status <sessionId> [--verbose] [--json]
57
+ happy-elves session diagnose <sessionId> [--limit 200] [--runtime-limit 500] [--repair-head] [--json]
58
+ happy-elves session repair-binding <sessionId> [--runtime-session <runtimeSessionId>] [--runtime-limit 500] [--keep-source] --json
53
59
  happy-elves session close <sessionId> [--reason <reason>] --json
54
60
 
55
61
  Session management:
@@ -59,22 +65,32 @@ Session management:
59
65
  history hides archived provider sessions unless --include-archived is set.
60
66
  continue turns a runtime history row into a loaded session, or returns the
61
67
  existing loaded session if it already exists.
68
+ diagnose reports the selected session's runtime handle metadata, backfill
69
+ counters, and latest materialized relay page counts for debugging empty or
70
+ stale transcripts. --repair-head advances a stale canonical head to the
71
+ latest completed relay event when the relay already has the event basis.
72
+ repair-binding imports the matching runtime history row as a new loaded
73
+ session and closes the empty/stale source session unless --keep-source is set.
62
74
  close archives a loaded session. There is no separate archive command.
63
75
  `,
64
76
  turn: `Usage:
65
77
  happy-elves turn list <sessionId> [--limit 10] [--verbose] [--json]
66
78
  happy-elves turn status <sessionId> <turnId> [--verbose] [--json]
67
79
  happy-elves turn result <sessionId> [<turnId>] [--verbose] [--json]
68
- happy-elves turn run <sessionId> (--text <prompt> | --text-file <path>) [--detach] [--timeout 1000s] [--runtime-timeout 1000s] [--permission-mode approve-reads|approve-all|deny-all] [--json]
80
+ happy-elves turn run <sessionId> (--text <prompt> | --text-file <path>) [--detach] [--timeout 1000s] [--inactivity-timeout 1000s] [--permission-mode approve-reads|approve-all|deny-all] [--memory off|readonly|readwrite] [--memory-project <key>] [--memory-top-n 3] [--json]
69
81
  happy-elves turn wait <sessionId> <turnId> [--timeout 1000s] --json
82
+ happy-elves turn reconcile <sessionId> [turnId] --json
83
+ happy-elves turn recover <sessionId> [turnId] --text <continuation> --confirm-risk [--detach] --json
70
84
  happy-elves turn cancel <sessionId> <turnId> [--reason <reason>] --json
71
85
  happy-elves turn rewind <sessionId> <turn-or-checkpoint-id> --json
72
- happy-elves turn fork <sessionId> <turn-or-checkpoint-id> --name <name> --json
86
+ happy-elves turn fork <sessionId> <turn-or-checkpoint-id> --name <name> [--copy-tags] --json
73
87
 
74
88
  Turn management:
75
89
  run starts one agent execution. It waits by default; use --detach for
76
90
  background execution.
77
91
  wait/result inspect a specific turn.
92
+ reconcile checks provider state without starting, resuming, or cancelling work.
93
+ recover creates a risk-confirmed recovery session and only sends the new continuation.
78
94
  rewind/fork operate on a turn or checkpoint id supplied by runtime history.
79
95
  `,
80
96
  collect: `Usage:
@@ -84,6 +100,71 @@ Turn management:
84
100
  happy-elves token create [--name <name>] [--machines a,b] [--sessions a,b] [--loops a,b] --actions a,b [--expires-in 24h] --json
85
101
  happy-elves token list [--verbose] [--json]
86
102
  happy-elves token revoke <tokenId> --json
103
+ `,
104
+ workspace: `Usage:
105
+ happy-elves workspace state --json
106
+ happy-elves workspace star <sessionId> --json
107
+ happy-elves workspace unstar <sessionId> --json
108
+ happy-elves workspace recent <sessionId> --json
109
+ happy-elves workspace pin-cwd --machine <machineId> --cwd <cwd> [--label <label>] --json
110
+ happy-elves workspace unpin-cwd --machine <machineId> --cwd <cwd> --json
111
+ happy-elves workspace prefer --project <projectKey> [--machine <machineId>] [--cwd <cwd>] [--agent <agent>] --json
112
+
113
+ Workspace sync records account-level UI/library state shared across devices:
114
+ session stars, recent sessions, pinned workspaces, and current project defaults.
115
+ `,
116
+ gateway: `Usage:
117
+ happy-elves gateway enable [<channelId>] --channel lark --machine <machineId> (--cwd <cwd> | --session <sessionId>) [--agent codex] [--model <model>] --json
118
+ happy-elves gateway enable lark-main --channel lark --machine <machineId> (--cwd <cwd> | --session <sessionId>) --app-id <appId> --app-secret-stdin [--domain feishu|lark] [--inbound mention|all] (--allow-any-sender | --allow-chat <id[,id]> | --allow-sender <id[,id]>) --json
119
+ happy-elves gateway disable [<channelId>] [--machine <machineId>] --json
120
+ happy-elves gateway status [--machine <machineId>] [--include-debug] [--json]
121
+ happy-elves gateway test [<channelId>] [--machine <machineId>] --conversation <externalConversationId> --message-id <externalMessageId> --text <prompt> --json
122
+ happy-elves gateway notify [<channelId>] [--machine <machineId>] --conversation <externalConversationId> [--message-id <id>] --text <message> --json
123
+ happy-elves gateway serve [--host 127.0.0.1] [--port 8789] --json # debug only
124
+
125
+ Gateway v1 official Feishu/Lark path is daemon-backed SDK long connection.
126
+ App secrets are read from stdin and stored only in the target daemon config.
127
+ Lark/Feishu product gateways require an explicit inbound sender/chat policy.
128
+ gateway serve is kept for fake/local debugging only; lark-cli is not a product dependency.
129
+ `,
130
+ memory: `Usage:
131
+ happy-elves memory overview [--machine <machineId>] [--project <projectKey>] [--cwd <cwd>] --json
132
+ happy-elves memory save [--machine <machineId>] [--project <projectKey>] [--layer user|curated|daily] (--text <text> | --text-file <path>) [--title <title>] [--date YYYY-MM-DD] --json
133
+ happy-elves memory read <USER.md|MEMORY.md|memory/YYYY-MM-DD.md> [--project <projectKey>] --json
134
+ happy-elves memory search --query <text> [--project <projectKey>] [--limit 5] --json
135
+ happy-elves memory promote --source <path:start-end[@contentHash]> --layer user|curated [--project <projectKey>] [--title <title>] --json
136
+ happy-elves memory reindex [--project <projectKey>] --json
137
+ happy-elves memory sync [--project <projectKey>] --json
138
+
139
+ Memory uses daemon-local Markdown files: USER.md, MEMORY.md, and memory/YYYY-MM-DD.md.
140
+ Session prompts can run memory off, readonly, or readwrite; readwrite writes daily notes.
141
+ `,
142
+ schedule: `Usage:
143
+ happy-elves schedule create [--session <sessionId> | --cwd <cwd> --agent codex] (--manual | --at <iso-time> | --every 5m | --cron "*/30 * * * *") (--prompt <text> | --prompt-file <path>) [--execution continue|isolated] [--memory inherit|off|readonly|readwrite] [--name <name>] [--machine <machineId>] --json
144
+ happy-elves schedule list [--machine <machineId>] --json
145
+ happy-elves schedule show <scheduleId> [--machine <machineId>] --json
146
+ happy-elves schedule history <scheduleId> [--machine <machineId>] --json
147
+ happy-elves schedule run <scheduleId> [--machine <machineId>] --json
148
+ happy-elves schedule pause <scheduleId> [--machine <machineId>] --json
149
+ happy-elves schedule resume <scheduleId> [--machine <machineId>] --json
150
+ happy-elves schedule delete <scheduleId> [--machine <machineId>] --json
151
+ happy-elves schedule run-due [--machine <machineId>] --json
152
+ happy-elves schedule run-missed <scheduleId> <occurrenceId> [--machine <machineId>] --json
153
+
154
+ Schedule v1 is daemon-local repeat automation. Runs use normal Relay admission
155
+ with deterministic requestId/turnId per occurrence. Offline due times are marked
156
+ missed and are never auto-caught-up. Commands that take a scheduleId auto-locate
157
+ the owning online daemon when --machine is omitted.
158
+ `,
159
+ release: `Usage:
160
+ happy-elves release profile list --json
161
+ happy-elves release profile show [--profile happy-elves] --json
162
+ happy-elves release profile set <name> --release-tag <tag[,tag]> [--reviewer-tag <tag[,tag]>] [--dogfood-tag <tag[,tag]>] --json
163
+ happy-elves release resolve --profile happy-elves --json
164
+ happy-elves release notify --profile happy-elves [--text 发布] [--detach] [--timeout 30m] --json
165
+
166
+ Release routing uses session tags. notify only sends a short prompt to the
167
+ resolved Release Session; it does not run a release runner or arbitrary shell.
87
168
  `,
88
169
  loop: `Usage:
89
170
  happy-elves loop create <sessionId> [--every 15m] (--prompt <text> | --prompt-file <path>) [--stop-on blocked] --json
@@ -95,7 +176,7 @@ Turn management:
95
176
  happy-elves loop delete <loopId> --json
96
177
  `,
97
178
  daemon: `Usage:
98
- happy-elves daemon pair --relay <url> --code <code> --secret <account-secret> [--name <machine-name>] --json
179
+ happy-elves daemon pair --relay <url> --code <code> --secret <account-secret> [--name <machine-name>] [--no-start] --json
99
180
  happy-elves daemon start [--relay <url>] [--json]
100
181
  happy-elves daemon stop [--json]
101
182
  happy-elves daemon restart [--relay <url>] [--json]
@@ -108,6 +189,12 @@ Turn management:
108
189
  happy-elves relay serve [--host 0.0.0.0] [--port 8787] --json
109
190
  happy-elves relay status [--relay <url>] [--json]
110
191
  happy-elves relay doctor [--relay <url>] [--json]
192
+ happy-elves relay audit-db --path <relay.db> [--output <dir>] --json
193
+
194
+ audit-db is the pre-migration data protection gate. It creates a consistent
195
+ SQLite backup with VACUUM INTO and writes a manifest with row hashes for raw
196
+ session events, turn aliases, message/turn ids, ciphertext metadata, stars,
197
+ handoff tables, preferences, workspace sync tables, and unknown tables.
111
198
  `,
112
199
  };
113
200
  export function commandUsageText(command) {
@@ -136,23 +223,45 @@ Core commands:
136
223
  session create --machine <machineId> [--agent codex] [--cwd <path>] [--name <name>] --json
137
224
  session history --machine <machineId> [--cwd <path>] [--limit 20] --json
138
225
  session continue <runtimeSessionId> --machine <machineId> --json
226
+ session repair-binding <sessionId> [--runtime-session <runtimeSessionId>] --json
139
227
  session status <sessionId> [--verbose] [--json]
228
+ session diagnose <sessionId> [--limit 200] [--runtime-limit 500] [--repair-head] [--json]
140
229
  session close <sessionId> [--reason <reason>] --json
230
+ session tag add <sessionId> --tag <tag> --json
231
+ release resolve --profile happy-elves --json
232
+ release notify --profile happy-elves --json
141
233
 
142
234
  turn list <sessionId> [--limit 10] [--json]
143
235
  turn status <sessionId> <turnId> [--json]
144
236
  turn run <sessionId> --text <prompt> [--timeout 1000s] [--json]
145
237
  turn wait <sessionId> <turnId> [--timeout 1000s] [--json]
146
238
  turn result <sessionId> [<turnId>] [--json]
239
+ turn reconcile <sessionId> [turnId] --json
240
+ turn recover <sessionId> [turnId] --text <continuation> --confirm-risk [--json]
147
241
  turn cancel <sessionId> <turnId> [--reason <reason>] --json
148
242
  turn rewind <sessionId> <turn-or-checkpoint-id> --json
149
- turn fork <sessionId> <turn-or-checkpoint-id> --name <name> --json
243
+ turn fork <sessionId> <turn-or-checkpoint-id> --name <name> [--copy-tags] --json
150
244
 
151
245
  remote status --json
152
246
  remote devices [--json]
153
247
  remote invite-controller [--device-name <name>] [--ttl 10m] --json
154
248
  remote join-controller --url <url> [--device-name <name>] --json
155
249
 
250
+ workspace state --json
251
+ workspace star <sessionId> --json
252
+ workspace pin-cwd --machine <machineId> --cwd <cwd> --json
253
+
254
+ gateway status --json
255
+ gateway enable --channel fake --machine <machineId> --cwd <cwd> --json # debug only
256
+ gateway test --conversation <id> --message-id <id> --text <prompt> --json
257
+ gateway notify --conversation <id> --text <message> --json
258
+
259
+ memory save --project <key> --text <fact> --json
260
+ memory search --project <key> --query <prompt> --json
261
+
262
+ schedule create --session <sessionId> --at <iso-time> --prompt <prompt> --json
263
+ schedule run-due --json
264
+
156
265
  relay serve [--host 0.0.0.0] [--port 8787] [--json]
157
266
  relay status [--relay <url>] [--json]
158
267
  relay doctor [--relay <url>] [--json]
@@ -171,7 +280,7 @@ Common flows:
171
280
  More:
172
281
  happy-elves --skill
173
282
  happy-elves <domain> --help
174
- start, status, doctor, collect, config, account, daemon, relay, token, loop.
283
+ start, status, doctor, collect, config, account, daemon, relay, token, workspace, gateway, memory, schedule, loop.
175
284
  `;
176
285
  }
177
286
  export function skillText() {
@@ -211,6 +320,9 @@ Session management:
211
320
  provider sessions unless --include-archived is set.
212
321
  session continue <runtimeSessionId> --machine <machineId> --json continues a
213
322
  runtime history row as a loaded session, or returns an existing sessionId.
323
+ session repair-binding <sessionId> --json recovers a loaded session that was
324
+ bound to the wrong/empty provider history by importing the matching runtime
325
+ history row as a new loaded session.
214
326
  session close <sessionId> --reason "archived" --json archives a loaded
215
327
  session. There is no separate archive command.
216
328
 
@@ -221,8 +333,9 @@ Output modes:
221
333
  not raw metadata or event streams.
222
334
  Add --verbose to status, list, history, turn list, or collect when internal
223
335
  details are needed for debugging.
224
- turn run waits for completion by default with a 1000s timeout. Use --detach
225
- only when you intentionally want background execution.
336
+ turn run waits for completion by default with a 1000s client wait timeout. The
337
+ runtime inactivity watchdog does not limit total runtime and does not cancel
338
+ provider work.
226
339
 
227
340
  Security notes:
228
341
  Account secrets stay on controllers and daemons.
@@ -1,5 +1,5 @@
1
- import type { ControllerClient } from "@happy-elves/client";
2
- import type { HistoricalSessionSnapshot } from "@happy-elves/shared";
1
+ import type { ControllerClient } from "../../../../../packages/client/dist/index.js";
2
+ import type { HistoricalSessionSnapshot } from "../../../../../packages/shared/dist/index.js";
3
3
  export type WorkspaceHistoricalSession = HistoricalSessionSnapshot & {
4
4
  machineId: string;
5
5
  machineName: string;