@fleettools/server 0.1.0 → 0.1.1

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 (300) hide show
  1. package/package.json +1 -1
  2. package/.flightline/checkpoints.db +0 -0
  3. package/.flightline/ctk/04a5510b-1e09-40c6-91c8-399c22138708.json +0 -9
  4. package/.flightline/ctk/0ecde721-7827-4039-995a-974e24493cc5.json +0 -9
  5. package/.flightline/ctk/268bbdbd-ddd7-46b2-845f-56a138aa518a.json +0 -9
  6. package/.flightline/ctk/6f476f2e-776c-407a-b441-b9365c0bae95.json +0 -9
  7. package/.flightline/ctk/7e10d0d5-fbc2-4661-af03-53de89e064db.json +0 -9
  8. package/.flightline/ctk/90783096-b7d4-49c5-8153-3c35018a2e61.json +0 -9
  9. package/.flightline/ctk/9a3b6d18-8a46-4728-90aa-279800a8e397.json +0 -9
  10. package/.flightline/ctk/ae30e192-b386-4ee2-899c-93f86785d3f3.json +0 -9
  11. package/.flightline/ctk/d0e9c49e-10df-413e-8cf7-37232b1838ca.json +0 -9
  12. package/.flightline/ctk/eae1a12b-2e9d-4c3f-8619-dafbb1346e96.json +0 -9
  13. package/.flightline/mailboxes/mbx_00dae6ba-0b5e-4a8d-a86d-93c8640872c3/manifest.json +0 -6
  14. package/.flightline/mailboxes/mbx_05b0bfa9-c4f5-4f68-ba75-6202820f49c3/manifest.json +0 -6
  15. package/.flightline/mailboxes/mbx_0a6b8fb2-729e-4385-8241-839c36b929d7/manifest.json +0 -6
  16. package/.flightline/mailboxes/mbx_0abca4ab-8e34-409c-997f-481e80e450dc/manifest.json +0 -6
  17. package/.flightline/mailboxes/mbx_173e5fb9-8203-418d-93c2-4f8c91f2d842/manifest.json +0 -6
  18. package/.flightline/mailboxes/mbx_22b62201-0570-4ce8-b0a7-0f4b445f6d9e/manifest.json +0 -6
  19. package/.flightline/mailboxes/mbx_2724efb1-76e1-4147-9620-4defcc65510f/manifest.json +0 -6
  20. package/.flightline/mailboxes/mbx_35b8bfcd-5a54-48f1-8759-cb1f8ffe775d/manifest.json +0 -6
  21. package/.flightline/mailboxes/mbx_3bc5193a-604d-4f52-be00-e56277643358/manifest.json +0 -6
  22. package/.flightline/mailboxes/mbx_3bd500f3-c111-427a-8cd7-a004125d6dc1/manifest.json +0 -6
  23. package/.flightline/mailboxes/mbx_45ce9ae8-5299-44dc-a1b5-4d63914a9609/manifest.json +0 -6
  24. package/.flightline/mailboxes/mbx_4779c645-1efc-4c76-ab21-ff93f973ee8f/manifest.json +0 -6
  25. package/.flightline/mailboxes/mbx_482237cf-87c8-486e-a24d-0941be2f480d/manifest.json +0 -6
  26. package/.flightline/mailboxes/mbx_4b7e23c8-5680-4edd-a276-88803dd5fb6f/manifest.json +0 -6
  27. package/.flightline/mailboxes/mbx_4dd3b945-d846-4c7a-94eb-6eeb25a0dc6b/manifest.json +0 -6
  28. package/.flightline/mailboxes/mbx_4ec41a62-62bb-4be4-b3ce-282d5a33acce/manifest.json +0 -6
  29. package/.flightline/mailboxes/mbx_4ff7ee7e-0c8a-43d6-a829-7c62c10af3b0/manifest.json +0 -6
  30. package/.flightline/mailboxes/mbx_7661e4fb-a919-4af1-86f7-3eaef22f1d81/manifest.json +0 -6
  31. package/.flightline/mailboxes/mbx_7ca872bb-69ab-4e7d-a7c6-4888ec8e7749/manifest.json +0 -6
  32. package/.flightline/mailboxes/mbx_7e6d5707-2aa5-4770-a7be-6b1be93d0d87/manifest.json +0 -6
  33. package/.flightline/mailboxes/mbx_87bef50d-3c59-429b-a995-5872f6278c37/manifest.json +0 -6
  34. package/.flightline/mailboxes/mbx_88d1ea56-0b69-48c4-9fcf-ce1e1f7527ba/manifest.json +0 -6
  35. package/.flightline/mailboxes/mbx_8bfb6bd7-07d1-4836-ae9d-3c93668c6dfe/manifest.json +0 -6
  36. package/.flightline/mailboxes/mbx_93355083-e95b-4341-b625-56fcc1e4fc0c/manifest.json +0 -6
  37. package/.flightline/mailboxes/mbx_999fd94c-ca56-4fec-8d30-8b677cf40ad6/manifest.json +0 -6
  38. package/.flightline/mailboxes/mbx_a039fd15-7ee1-4bd6-906d-55dea8d0e489/manifest.json +0 -6
  39. package/.flightline/mailboxes/mbx_a0b7363f-7cc6-4940-8e29-2dc85793a77d/manifest.json +0 -6
  40. package/.flightline/mailboxes/mbx_a31e8b61-9643-4c78-939d-d1696d0420d9/manifest.json +0 -6
  41. package/.flightline/mailboxes/mbx_acc51591-256c-4bed-9a51-514b1811f4cd/manifest.json +0 -6
  42. package/.flightline/mailboxes/mbx_b1efebd9-5981-49fa-8775-20fa00d0c902/manifest.json +0 -6
  43. package/.flightline/mailboxes/mbx_ba9d4c61-39a3-4852-95d7-bd34e3605a43/manifest.json +0 -6
  44. package/.flightline/mailboxes/mbx_c549b60f-65fd-48d5-8cd6-2f053292b112/manifest.json +0 -6
  45. package/.flightline/mailboxes/mbx_d0f839a5-3ab9-42e2-b438-df5825d049fe/manifest.json +0 -6
  46. package/.flightline/mailboxes/mbx_d826d57e-9817-4f3c-ab94-2bfafa352f6d/manifest.json +0 -6
  47. package/.flightline/mailboxes/mbx_da102f37-632c-4c0b-be4c-4270a74c06b9/manifest.json +0 -6
  48. package/.flightline/mailboxes/mbx_df4506f5-67f2-4cf6-9113-93994b76f39b/manifest.json +0 -6
  49. package/.flightline/mailboxes/mbx_e038e93b-87ea-4122-9578-6540018697b7/manifest.json +0 -6
  50. package/.flightline/mailboxes/mbx_e0c171c5-407f-44dc-9ef9-e26e8b99ceac/manifest.json +0 -6
  51. package/.flightline/mailboxes/mbx_e64770bf-7220-4d0f-848c-d751ea1c7376/manifest.json +0 -6
  52. package/.flightline/mailboxes/mbx_e7f0edda-0fab-484d-ab4d-d8a8e363cd14/manifest.json +0 -6
  53. package/.flightline/mailboxes/mbx_ec7d9118-8594-4d79-bf79-f43afdfaf156/manifest.json +0 -6
  54. package/.flightline/mailboxes/mbx_ee06ec01-03e4-485a-ae2b-d8bdb6e7a3a8/manifest.json +0 -6
  55. package/.flightline/mailboxes/mbx_fd467681-f9cf-4a54-b06a-836df6de2ccc/manifest.json +0 -6
  56. package/.flightline/progress.db +0 -0
  57. package/.flightline/recovery.log +0 -1
  58. package/.flightline/tasks.db +0 -0
  59. package/.flightline/tech-orders/to_0c93d981-6b4e-4055-8678-f39c009d1db1.json +0 -11
  60. package/.flightline/tech-orders/to_1862f8ed-c487-4914-9f1e-528af6d4f053.json +0 -11
  61. package/.flightline/tech-orders/to_2335a57d-f400-4efa-b108-e13ece57520d.json +0 -11
  62. package/.flightline/tech-orders/to_2bd8dbdd-ac57-4b84-b977-33a3637d10d1.json +0 -11
  63. package/.flightline/tech-orders/to_37057c01-39b5-403a-991f-afb186abde95.json +0 -11
  64. package/.flightline/tech-orders/to_9e7288bb-c0fd-488a-a83d-1e9337bd0f1f.json +0 -11
  65. package/.flightline/tech-orders/to_aa0fe80b-9de7-40f6-a106-353b5bca10bd.json +0 -11
  66. package/.flightline/tech-orders/to_c1a0f480-c863-4203-a070-76ad77137845.json +0 -11
  67. package/.flightline/tech-orders/to_cf1e882a-cf56-45a4-8d19-494925e5f449.json +0 -11
  68. package/.flightline/work-orders/wo_5a29168d-5fb4-41d7-8dac-1d1151d9248f/manifest.json +0 -15
  69. package/.flightline/work-orders/wo_6c8c38bb-17a1-4885-ada4-dbfc5cc12d7a/manifest.json +0 -15
  70. package/.flightline/work-orders/wo_cadeb9b2-ea42-4491-b429-e2d467942b5c/manifest.json +0 -12
  71. package/.flightline/work-orders/wo_cc7b669c-16c4-4ef7-8a76-d1813219d0be/manifest.json +0 -15
  72. package/dist/server/api/src/coordination/agent-lifecycle.d.ts +0 -12
  73. package/dist/server/api/src/coordination/agent-lifecycle.d.ts.map +0 -1
  74. package/dist/server/api/src/coordination/agent-lifecycle.js +0 -12
  75. package/dist/server/api/src/coordination/agent-lifecycle.js.map +0 -1
  76. package/dist/server/api/src/coordination/agent-runner.d.ts +0 -9
  77. package/dist/server/api/src/coordination/agent-runner.d.ts.map +0 -1
  78. package/dist/server/api/src/coordination/agent-runner.js +0 -416
  79. package/dist/server/api/src/coordination/agent-runner.js.map +0 -1
  80. package/dist/server/api/src/coordination/agent-spawner-routes.d.ts +0 -7
  81. package/dist/server/api/src/coordination/agent-spawner-routes.d.ts.map +0 -1
  82. package/dist/server/api/src/coordination/agent-spawner-routes.js +0 -321
  83. package/dist/server/api/src/coordination/agent-spawner-routes.js.map +0 -1
  84. package/dist/server/api/src/coordination/agent-spawner.d.ts +0 -187
  85. package/dist/server/api/src/coordination/agent-spawner.d.ts.map +0 -1
  86. package/dist/server/api/src/coordination/agent-spawner.js +0 -712
  87. package/dist/server/api/src/coordination/agent-spawner.js.map +0 -1
  88. package/dist/server/api/src/coordination/agents.d.ts +0 -13
  89. package/dist/server/api/src/coordination/agents.d.ts.map +0 -1
  90. package/dist/server/api/src/coordination/agents.js +0 -464
  91. package/dist/server/api/src/coordination/agents.js.map +0 -1
  92. package/dist/server/api/src/coordination/checkpoint-routes.d.ts +0 -33
  93. package/dist/server/api/src/coordination/checkpoint-routes.d.ts.map +0 -1
  94. package/dist/server/api/src/coordination/checkpoint-routes.js +0 -323
  95. package/dist/server/api/src/coordination/checkpoint-routes.js.map +0 -1
  96. package/dist/server/api/src/coordination/conflict-resolver.d.ts +0 -152
  97. package/dist/server/api/src/coordination/conflict-resolver.d.ts.map +0 -1
  98. package/dist/server/api/src/coordination/conflict-resolver.js +0 -502
  99. package/dist/server/api/src/coordination/conflict-resolver.js.map +0 -1
  100. package/dist/server/api/src/coordination/missions.d.ts +0 -9
  101. package/dist/server/api/src/coordination/missions.d.ts.map +0 -1
  102. package/dist/server/api/src/coordination/missions.js +0 -148
  103. package/dist/server/api/src/coordination/missions.js.map +0 -1
  104. package/dist/server/api/src/coordination/monitor.d.ts +0 -175
  105. package/dist/server/api/src/coordination/monitor.d.ts.map +0 -1
  106. package/dist/server/api/src/coordination/monitor.js +0 -410
  107. package/dist/server/api/src/coordination/monitor.js.map +0 -1
  108. package/dist/server/api/src/coordination/notifier.d.ts +0 -160
  109. package/dist/server/api/src/coordination/notifier.d.ts.map +0 -1
  110. package/dist/server/api/src/coordination/notifier.js +0 -422
  111. package/dist/server/api/src/coordination/notifier.js.map +0 -1
  112. package/dist/server/api/src/coordination/progress-tracker.d.ts +0 -98
  113. package/dist/server/api/src/coordination/progress-tracker.d.ts.map +0 -1
  114. package/dist/server/api/src/coordination/progress-tracker.js +0 -323
  115. package/dist/server/api/src/coordination/progress-tracker.js.map +0 -1
  116. package/dist/server/api/src/coordination/recovery-manager.d.ts +0 -135
  117. package/dist/server/api/src/coordination/recovery-manager.d.ts.map +0 -1
  118. package/dist/server/api/src/coordination/recovery-manager.js +0 -435
  119. package/dist/server/api/src/coordination/recovery-manager.js.map +0 -1
  120. package/dist/server/api/src/coordination/task-decomposer.d.ts +0 -90
  121. package/dist/server/api/src/coordination/task-decomposer.d.ts.map +0 -1
  122. package/dist/server/api/src/coordination/task-decomposer.js +0 -412
  123. package/dist/server/api/src/coordination/task-decomposer.js.map +0 -1
  124. package/dist/server/api/src/coordination/task-queue-routes.d.ts +0 -7
  125. package/dist/server/api/src/coordination/task-queue-routes.d.ts.map +0 -1
  126. package/dist/server/api/src/coordination/task-queue-routes.js +0 -266
  127. package/dist/server/api/src/coordination/task-queue-routes.js.map +0 -1
  128. package/dist/server/api/src/coordination/task-queue.d.ts +0 -104
  129. package/dist/server/api/src/coordination/task-queue.d.ts.map +0 -1
  130. package/dist/server/api/src/coordination/task-queue.js +0 -378
  131. package/dist/server/api/src/coordination/task-queue.js.map +0 -1
  132. package/dist/server/api/src/coordination/tasks.d.ts +0 -7
  133. package/dist/server/api/src/coordination/tasks.d.ts.map +0 -1
  134. package/dist/server/api/src/coordination/tasks.js +0 -59
  135. package/dist/server/api/src/coordination/tasks.js.map +0 -1
  136. package/dist/server/api/src/decomposition/cli.d.ts +0 -18
  137. package/dist/server/api/src/decomposition/cli.d.ts.map +0 -1
  138. package/dist/server/api/src/decomposition/cli.js +0 -191
  139. package/dist/server/api/src/decomposition/cli.js.map +0 -1
  140. package/dist/server/api/src/decomposition/codebase-analyzer.d.ts +0 -59
  141. package/dist/server/api/src/decomposition/codebase-analyzer.d.ts.map +0 -1
  142. package/dist/server/api/src/decomposition/codebase-analyzer.js +0 -274
  143. package/dist/server/api/src/decomposition/codebase-analyzer.js.map +0 -1
  144. package/dist/server/api/src/decomposition/dependency-resolver.d.ts +0 -68
  145. package/dist/server/api/src/decomposition/dependency-resolver.d.ts.map +0 -1
  146. package/dist/server/api/src/decomposition/dependency-resolver.js +0 -261
  147. package/dist/server/api/src/decomposition/dependency-resolver.js.map +0 -1
  148. package/dist/server/api/src/decomposition/index.d.ts +0 -17
  149. package/dist/server/api/src/decomposition/index.d.ts.map +0 -1
  150. package/dist/server/api/src/decomposition/index.js +0 -19
  151. package/dist/server/api/src/decomposition/index.js.map +0 -1
  152. package/dist/server/api/src/decomposition/parallelization.d.ts +0 -40
  153. package/dist/server/api/src/decomposition/parallelization.d.ts.map +0 -1
  154. package/dist/server/api/src/decomposition/parallelization.js +0 -144
  155. package/dist/server/api/src/decomposition/parallelization.js.map +0 -1
  156. package/dist/server/api/src/decomposition/planner.d.ts +0 -84
  157. package/dist/server/api/src/decomposition/planner.d.ts.map +0 -1
  158. package/dist/server/api/src/decomposition/planner.js +0 -415
  159. package/dist/server/api/src/decomposition/planner.js.map +0 -1
  160. package/dist/server/api/src/decomposition/routes.d.ts +0 -13
  161. package/dist/server/api/src/decomposition/routes.d.ts.map +0 -1
  162. package/dist/server/api/src/decomposition/routes.js +0 -114
  163. package/dist/server/api/src/decomposition/routes.js.map +0 -1
  164. package/dist/server/api/src/decomposition/strategies.d.ts +0 -43
  165. package/dist/server/api/src/decomposition/strategies.d.ts.map +0 -1
  166. package/dist/server/api/src/decomposition/strategies.js +0 -147
  167. package/dist/server/api/src/decomposition/strategies.js.map +0 -1
  168. package/dist/server/api/src/decomposition/types.d.ts +0 -1090
  169. package/dist/server/api/src/decomposition/types.d.ts.map +0 -1
  170. package/dist/server/api/src/decomposition/types.js +0 -65
  171. package/dist/server/api/src/decomposition/types.js.map +0 -1
  172. package/dist/server/api/src/decomposition/validator.d.ts +0 -84
  173. package/dist/server/api/src/decomposition/validator.d.ts.map +0 -1
  174. package/dist/server/api/src/decomposition/validator.js +0 -314
  175. package/dist/server/api/src/decomposition/validator.js.map +0 -1
  176. package/dist/server/api/src/flightline/ctk.d.ts +0 -2
  177. package/dist/server/api/src/flightline/ctk.d.ts.map +0 -1
  178. package/dist/server/api/src/flightline/ctk.js +0 -114
  179. package/dist/server/api/src/flightline/ctk.js.map +0 -1
  180. package/dist/server/api/src/flightline/tech-orders.d.ts +0 -2
  181. package/dist/server/api/src/flightline/tech-orders.d.ts.map +0 -1
  182. package/dist/server/api/src/flightline/tech-orders.js +0 -74
  183. package/dist/server/api/src/flightline/tech-orders.js.map +0 -1
  184. package/dist/server/api/src/flightline/work-orders.d.ts +0 -2
  185. package/dist/server/api/src/flightline/work-orders.d.ts.map +0 -1
  186. package/dist/server/api/src/flightline/work-orders.js +0 -178
  187. package/dist/server/api/src/flightline/work-orders.js.map +0 -1
  188. package/dist/server/api/src/index.d.ts +0 -3
  189. package/dist/server/api/src/index.d.ts.map +0 -1
  190. package/dist/server/api/src/index.js +0 -192
  191. package/dist/server/api/src/index.js.map +0 -1
  192. package/dist/server/api/src/middleware/agent-validation.d.ts +0 -161
  193. package/dist/server/api/src/middleware/agent-validation.d.ts.map +0 -1
  194. package/dist/server/api/src/middleware/agent-validation.js +0 -112
  195. package/dist/server/api/src/middleware/agent-validation.js.map +0 -1
  196. package/dist/server/api/src/middleware/error-handler.d.ts +0 -8
  197. package/dist/server/api/src/middleware/error-handler.d.ts.map +0 -1
  198. package/dist/server/api/src/middleware/error-handler.js +0 -54
  199. package/dist/server/api/src/middleware/error-handler.js.map +0 -1
  200. package/dist/server/api/src/middleware/logger.d.ts +0 -8
  201. package/dist/server/api/src/middleware/logger.d.ts.map +0 -1
  202. package/dist/server/api/src/middleware/logger.js +0 -31
  203. package/dist/server/api/src/middleware/logger.js.map +0 -1
  204. package/dist/server/api/src/middleware/validation.d.ts +0 -322
  205. package/dist/server/api/src/middleware/validation.d.ts.map +0 -1
  206. package/dist/server/api/src/middleware/validation.js +0 -189
  207. package/dist/server/api/src/middleware/validation.js.map +0 -1
  208. package/dist/server/api/src/squawk/blocker-handler.d.ts +0 -111
  209. package/dist/server/api/src/squawk/blocker-handler.d.ts.map +0 -1
  210. package/dist/server/api/src/squawk/blocker-handler.js +0 -262
  211. package/dist/server/api/src/squawk/blocker-handler.js.map +0 -1
  212. package/dist/server/api/src/squawk/coordinator.d.ts +0 -2
  213. package/dist/server/api/src/squawk/coordinator.d.ts.map +0 -1
  214. package/dist/server/api/src/squawk/coordinator.js +0 -24
  215. package/dist/server/api/src/squawk/coordinator.js.map +0 -1
  216. package/dist/server/api/src/squawk/cursor.d.ts +0 -2
  217. package/dist/server/api/src/squawk/cursor.d.ts.map +0 -1
  218. package/dist/server/api/src/squawk/cursor.js +0 -55
  219. package/dist/server/api/src/squawk/cursor.js.map +0 -1
  220. package/dist/server/api/src/squawk/dependency-resolver.d.ts +0 -107
  221. package/dist/server/api/src/squawk/dependency-resolver.d.ts.map +0 -1
  222. package/dist/server/api/src/squawk/dependency-resolver.js +0 -324
  223. package/dist/server/api/src/squawk/dependency-resolver.js.map +0 -1
  224. package/dist/server/api/src/squawk/dispatch-orchestrator.d.ts +0 -117
  225. package/dist/server/api/src/squawk/dispatch-orchestrator.d.ts.map +0 -1
  226. package/dist/server/api/src/squawk/dispatch-orchestrator.js +0 -296
  227. package/dist/server/api/src/squawk/dispatch-orchestrator.js.map +0 -1
  228. package/dist/server/api/src/squawk/lock-coordinator.d.ts +0 -118
  229. package/dist/server/api/src/squawk/lock-coordinator.d.ts.map +0 -1
  230. package/dist/server/api/src/squawk/lock-coordinator.js +0 -279
  231. package/dist/server/api/src/squawk/lock-coordinator.js.map +0 -1
  232. package/dist/server/api/src/squawk/lock.d.ts +0 -2
  233. package/dist/server/api/src/squawk/lock.d.ts.map +0 -1
  234. package/dist/server/api/src/squawk/lock.js +0 -87
  235. package/dist/server/api/src/squawk/lock.js.map +0 -1
  236. package/dist/server/api/src/squawk/mailbox.d.ts +0 -2
  237. package/dist/server/api/src/squawk/mailbox.d.ts.map +0 -1
  238. package/dist/server/api/src/squawk/mailbox.js +0 -66
  239. package/dist/server/api/src/squawk/mailbox.js.map +0 -1
  240. package/dist/server/api/src/squawk/spawning.d.ts +0 -79
  241. package/dist/server/api/src/squawk/spawning.d.ts.map +0 -1
  242. package/dist/server/api/src/squawk/spawning.js +0 -226
  243. package/dist/server/api/src/squawk/spawning.js.map +0 -1
  244. package/dist/server/api/src/squawk/specialist-tools.d.ts +0 -206
  245. package/dist/server/api/src/squawk/specialist-tools.d.ts.map +0 -1
  246. package/dist/server/api/src/squawk/specialist-tools.js +0 -411
  247. package/dist/server/api/src/squawk/specialist-tools.js.map +0 -1
  248. package/dist/server/api/src/types/api.d.ts +0 -63
  249. package/dist/server/api/src/types/api.d.ts.map +0 -1
  250. package/dist/server/api/src/types/api.js +0 -5
  251. package/dist/server/api/src/types/api.js.map +0 -1
  252. package/dist/squawk/src/db/index.d.ts +0 -30
  253. package/dist/squawk/src/db/index.d.ts.map +0 -1
  254. package/dist/squawk/src/db/index.js +0 -329
  255. package/dist/squawk/src/db/index.js.map +0 -1
  256. package/dist/squawk/src/db/sqlite.d.ts +0 -31
  257. package/dist/squawk/src/db/sqlite.d.ts.map +0 -1
  258. package/dist/squawk/src/db/sqlite.js +0 -558
  259. package/dist/squawk/src/db/sqlite.js.map +0 -1
  260. package/dist/squawk/src/db/types.d.ts +0 -611
  261. package/dist/squawk/src/db/types.d.ts.map +0 -1
  262. package/dist/squawk/src/db/types.js +0 -4
  263. package/dist/squawk/src/db/types.js.map +0 -1
  264. package/e2e-integration.test.ts +0 -290
  265. package/integration.test.ts +0 -186
  266. package/phase1-integration.test.ts +0 -455
  267. package/phase2-verification.test.ts +0 -135
  268. package/server.log +0 -58
  269. package/src/agent-runner.js +0 -877
  270. package/src/coordination/agent-lifecycle.ts +0 -13
  271. package/src/coordination/agent-runner.ts +0 -479
  272. package/src/coordination/agent-spawner-routes.ts +0 -340
  273. package/src/coordination/agent-spawner.ts +0 -885
  274. package/src/coordination/agents.ts +0 -525
  275. package/src/coordination/checkpoint-routes.ts +0 -382
  276. package/src/coordination/conflict-resolver.ts +0 -640
  277. package/src/coordination/missions.ts +0 -219
  278. package/src/coordination/monitor.ts +0 -593
  279. package/src/coordination/notifier.ts +0 -547
  280. package/src/coordination/progress-tracker.ts +0 -410
  281. package/src/coordination/recovery-manager.ts +0 -531
  282. package/src/coordination/task-decomposer.ts +0 -491
  283. package/src/coordination/task-queue-routes.ts +0 -284
  284. package/src/coordination/task-queue.ts +0 -480
  285. package/src/coordination/tasks.ts +0 -72
  286. package/src/flightline/ctk.ts +0 -131
  287. package/src/flightline/tech-orders.ts +0 -85
  288. package/src/flightline/work-orders.ts +0 -202
  289. package/src/index.ts +0 -211
  290. package/src/middleware/agent-validation.ts +0 -130
  291. package/src/middleware/error-handler.ts +0 -59
  292. package/src/middleware/logger.ts +0 -37
  293. package/src/middleware/validation.ts +0 -235
  294. package/src/squawk/coordinator.ts +0 -26
  295. package/src/squawk/cursor.ts +0 -62
  296. package/src/squawk/lock.ts +0 -98
  297. package/src/squawk/mailbox.ts +0 -75
  298. package/src/types/api.ts +0 -71
  299. package/test-api.ts +0 -310
  300. package/test-enhanced-agents.ts +0 -428
@@ -1,712 +0,0 @@
1
- /**
2
- * Agent Spawner for FleetTools Coordination System
3
- *
4
- * Manages agent lifecycle: spawning, monitoring, and termination
5
- * Integrates with Squawk mailbox system for coordination
6
- */
7
- import { randomUUID } from 'node:crypto';
8
- import path from 'node:path';
9
- export var AgentType;
10
- (function (AgentType) {
11
- AgentType["FRONTEND"] = "frontend";
12
- AgentType["BACKEND"] = "backend";
13
- AgentType["TESTING"] = "testing";
14
- AgentType["DOCUMENTATION"] = "documentation";
15
- AgentType["SECURITY"] = "security";
16
- AgentType["PERFORMANCE"] = "performance";
17
- })(AgentType || (AgentType = {}));
18
- export var AgentStatus;
19
- (function (AgentStatus) {
20
- AgentStatus["SPAWNING"] = "spawning";
21
- AgentStatus["RUNNING"] = "running";
22
- AgentStatus["IDLE"] = "idle";
23
- AgentStatus["BUSY"] = "busy";
24
- AgentStatus["ERROR"] = "error";
25
- AgentStatus["TERMINATED"] = "terminated";
26
- AgentStatus["FAILED"] = "failed";
27
- })(AgentStatus || (AgentStatus = {}));
28
- export class AgentSpawner {
29
- agents = new Map();
30
- mailboxPath;
31
- heartbeatInterval;
32
- recoveryInterval;
33
- heartbeatTimeout = 60000; // 60 seconds
34
- recoveryEnabled = true;
35
- constructor(mailboxPath) {
36
- this.mailboxPath = mailboxPath || path.join(process.cwd(), '.flightline', 'mailboxes');
37
- this.startHeartbeatMonitoring();
38
- this.startRecoveryMonitoring();
39
- }
40
- /**
41
- * Spawn a new agent with timeout and retry logic
42
- */
43
- async spawn(request) {
44
- const agentId = `agt_${randomUUID()}`;
45
- const mailboxId = `mbx_${randomUUID()}`;
46
- const timeout = request.config?.timeout || 300000;
47
- const maxRetries = request.config?.retries || 3;
48
- const agent = {
49
- id: agentId,
50
- type: request.type,
51
- status: AgentStatus.SPAWNING,
52
- mailboxId,
53
- createdAt: new Date().toISOString(),
54
- updatedAt: new Date().toISOString(),
55
- metadata: {
56
- ...request.metadata,
57
- spawnRequest: request,
58
- spawnAttempts: 0,
59
- maxRetries
60
- }
61
- };
62
- let lastError = null;
63
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
64
- try {
65
- agent.metadata.spawnAttempts = attempt;
66
- agent.updatedAt = new Date().toISOString();
67
- await this.createMailbox(mailboxId, agentId);
68
- const pid = await this.executeAgentSpawn(agent, request);
69
- agent.pid = pid;
70
- agent.status = AgentStatus.RUNNING;
71
- agent.updatedAt = new Date().toISOString();
72
- this.agents.set(agentId, agent);
73
- console.log(`✓ Agent spawned: ${agentId} (${request.type}) - attempt ${attempt}`);
74
- return agent;
75
- }
76
- catch (error) {
77
- lastError = error;
78
- agent.status = AgentStatus.FAILED;
79
- agent.updatedAt = new Date().toISOString();
80
- console.error(`✗ Agent spawn attempt ${attempt} failed:`, error.message);
81
- if (attempt < maxRetries) {
82
- const retryDelay = Math.min(5000 * attempt, 15000);
83
- console.log(`Retrying agent spawn in ${retryDelay}ms...`);
84
- await new Promise(resolve => setTimeout(resolve, retryDelay));
85
- try {
86
- await this.cleanupFailedSpawn(agentId);
87
- }
88
- catch (cleanupError) {
89
- console.error(`Cleanup failed:`, cleanupError.message);
90
- }
91
- }
92
- }
93
- }
94
- agent.status = AgentStatus.FAILED;
95
- agent.updatedAt = new Date().toISOString();
96
- agent.metadata.lastError = lastError?.message || 'Unknown error';
97
- this.agents.set(agentId, agent);
98
- console.error(`✗ Agent spawn failed after ${maxRetries} attempts: ${agentId}`);
99
- throw new Error(`Agent spawn failed after ${maxRetries} attempts: ${lastError?.message}`);
100
- }
101
- /**
102
- * Monitor agent status and health with comprehensive checks
103
- */
104
- async monitor(agentId) {
105
- const agent = this.agents.get(agentId);
106
- if (!agent) {
107
- throw new Error(`Agent not found: ${agentId}`);
108
- }
109
- const monitor = {
110
- status: agent.status,
111
- uptime: this.calculateUptime(agent.createdAt),
112
- lastHeartbeat: await this.getLastHeartbeat(agentId),
113
- resourceUsage: await this.getAgentResourceUsage(agentId),
114
- errors: await this.getAgentErrors(agentId)
115
- };
116
- if (agent.pid) {
117
- try {
118
- process.kill(agent.pid, 0);
119
- monitor.status = AgentStatus.RUNNING;
120
- if (agent.status !== AgentStatus.RUNNING) {
121
- agent.status = AgentStatus.RUNNING;
122
- agent.updatedAt = new Date().toISOString();
123
- this.agents.set(agentId, agent);
124
- }
125
- }
126
- catch {
127
- monitor.status = AgentStatus.TERMINATED;
128
- agent.status = AgentStatus.TERMINATED;
129
- agent.updatedAt = new Date().toISOString();
130
- this.agents.set(agentId, agent);
131
- }
132
- }
133
- if (monitor.errors && monitor.errors.length > 5) {
134
- monitor.status = AgentStatus.ERROR;
135
- agent.status = AgentStatus.ERROR;
136
- agent.updatedAt = new Date().toISOString();
137
- this.agents.set(agentId, agent);
138
- }
139
- return monitor;
140
- }
141
- /**
142
- * Terminate an agent
143
- */
144
- async terminate(agentId, graceful = true) {
145
- const agent = this.agents.get(agentId);
146
- if (!agent) {
147
- throw new Error(`Agent not found: ${agentId}`);
148
- }
149
- console.log(`Terminating agent: ${agentId} (${agent.type})`);
150
- try {
151
- if (agent.pid) {
152
- if (graceful) {
153
- process.kill(agent.pid, 'SIGTERM');
154
- await new Promise(resolve => setTimeout(resolve, 5000));
155
- try {
156
- process.kill(agent.pid, 0);
157
- process.kill(agent.pid, 'SIGKILL');
158
- console.log(`⚠️ Force killed agent: ${agentId}`);
159
- }
160
- catch {
161
- console.log(`✓ Agent terminated gracefully: ${agentId}`);
162
- }
163
- }
164
- else {
165
- process.kill(agent.pid, 'SIGKILL');
166
- console.log(`✓ Agent terminated: ${agentId}`);
167
- }
168
- }
169
- await this.cleanupMailbox(agent.mailboxId);
170
- agent.status = AgentStatus.TERMINATED;
171
- agent.updatedAt = new Date().toISOString();
172
- console.log(`✓ Agent cleanup complete: ${agentId}`);
173
- }
174
- catch (error) {
175
- agent.status = AgentStatus.ERROR;
176
- agent.updatedAt = new Date().toISOString();
177
- console.error(`✗ Error terminating agent ${agentId}:`, error.message);
178
- throw new Error(`Agent termination failed: ${error.message}`);
179
- }
180
- }
181
- /**
182
- * Get all active agents
183
- */
184
- getActiveAgents() {
185
- return Array.from(this.agents.values()).filter(agent => agent.status === AgentStatus.RUNNING ||
186
- agent.status === AgentStatus.IDLE ||
187
- agent.status === AgentStatus.BUSY);
188
- }
189
- /**
190
- * Get agents by type
191
- */
192
- getAgentsByType(type) {
193
- return Array.from(this.agents.values()).filter(agent => agent.type === type);
194
- }
195
- /**
196
- * Get agent by ID
197
- */
198
- getAgent(agentId) {
199
- return this.agents.get(agentId);
200
- }
201
- async createMailbox(mailboxId, agentId) {
202
- const mailboxDir = path.join(this.mailboxPath, mailboxId);
203
- await this.ensureDirectory(mailboxDir);
204
- const manifest = {
205
- id: mailboxId,
206
- agentId,
207
- createdAt: new Date().toISOString(),
208
- type: 'agent-mailbox'
209
- };
210
- const manifestPath = path.join(mailboxDir, 'manifest.json');
211
- await this.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
212
- }
213
- async cleanupMailbox(mailboxId) {
214
- const mailboxDir = path.join(this.mailboxPath, mailboxId);
215
- try {
216
- await this.removeDirectory(mailboxDir);
217
- console.log(`✓ Cleaned up mailbox: ${mailboxId}`);
218
- }
219
- catch (error) {
220
- console.error(`⚠️ Failed to cleanup mailbox ${mailboxId}:`, error.message);
221
- }
222
- }
223
- async executeAgentSpawn(agent, request) {
224
- const { spawn } = await import('node:child_process');
225
- return new Promise((resolve, reject) => {
226
- const args = [
227
- 'src/agent-runner.js',
228
- '--agent-id', agent.id,
229
- '--agent-type', agent.type,
230
- '--mailbox-id', agent.mailboxId,
231
- '--task', request.task || ''
232
- ];
233
- if (request.config?.timeout) {
234
- args.push('--timeout', request.config.timeout.toString());
235
- }
236
- const childProcess = spawn('bun', args, {
237
- stdio: ['pipe', 'pipe', 'pipe'],
238
- detached: false,
239
- cwd: process.cwd()
240
- });
241
- childProcess.on('spawn', () => {
242
- console.log(`Agent process spawned with PID: ${childProcess.pid}`);
243
- resolve(childProcess.pid);
244
- });
245
- childProcess.on('error', (error) => {
246
- console.error(`Failed to spawn agent process:`, error);
247
- reject(error);
248
- });
249
- if (childProcess.stdout) {
250
- childProcess.stdout.on('data', (data) => {
251
- console.log(`[${agent.id}] ${data.toString().trim()}`);
252
- });
253
- }
254
- if (childProcess.stderr) {
255
- childProcess.stderr.on('data', (data) => {
256
- console.error(`[${agent.id}] ERROR: ${data.toString().trim()}`);
257
- });
258
- }
259
- childProcess.on('close', (code) => {
260
- if (code !== 0) {
261
- console.log(`Agent ${agent.id} exited with code: ${code}`);
262
- }
263
- });
264
- });
265
- }
266
- async cleanupFailedSpawn(agentId) {
267
- try {
268
- const agent = this.agents.get(agentId);
269
- if (agent?.pid) {
270
- try {
271
- process.kill(agent.pid, 'SIGKILL');
272
- console.log(`✓ Cleaned up process ${agent.pid}`);
273
- }
274
- catch {
275
- }
276
- }
277
- const agentHandle = this.agents.get(agentId);
278
- if (agentHandle?.mailboxId) {
279
- await this.cleanupMailbox(agentHandle.mailboxId);
280
- }
281
- }
282
- catch (error) {
283
- console.error(`Cleanup error for ${agentId}:`, error.message);
284
- }
285
- }
286
- async getLastHeartbeat(agentId) {
287
- const agent = this.agents.get(agentId);
288
- return agent?.metadata?.lastHeartbeat;
289
- }
290
- async getAgentErrors(agentId) {
291
- const agent = this.agents.get(agentId);
292
- return agent?.metadata?.errors || [];
293
- }
294
- async getAgentResourceUsage(agentId) {
295
- const agent = this.agents.get(agentId);
296
- if (agent?.pid) {
297
- try {
298
- // Get actual resource usage using process information
299
- const usage = await this.getProcessResourceUsage(agent.pid);
300
- // Store usage history for trend analysis
301
- this.storeResourceHistory(agentId, usage);
302
- return usage;
303
- }
304
- catch (error) {
305
- console.warn(`Failed to get resource usage for agent ${agentId}:`, error);
306
- return undefined;
307
- }
308
- }
309
- return undefined;
310
- }
311
- async getProcessResourceUsage(pid) {
312
- try {
313
- // Try to get actual process resource usage
314
- if (process.platform === 'linux') {
315
- return await this.getLinuxProcessUsage(pid);
316
- }
317
- else if (process.platform === 'darwin') {
318
- return await this.getMacOSProcessUsage(pid);
319
- }
320
- else {
321
- // Fallback to mock data for other platforms
322
- return this.getMockResourceUsage();
323
- }
324
- }
325
- catch (error) {
326
- // Fallback to mock data if actual measurement fails
327
- return this.getMockResourceUsage();
328
- }
329
- }
330
- async getLinuxProcessUsage(pid) {
331
- const { exec } = await import('node:child_process');
332
- return new Promise((resolve, reject) => {
333
- exec(`ps -p ${pid} -o %mem,%cpu --no-headers`, (error, stdout) => {
334
- if (error) {
335
- reject(error);
336
- return;
337
- }
338
- const match = stdout.trim().match(/\s*(\d+\.?\d*)\s+(\d+\.?\d*)/);
339
- if (match) {
340
- resolve({
341
- memory: parseFloat(match[1]) * 10, // Convert percentage to MB estimate
342
- cpu: parseFloat(match[2])
343
- });
344
- }
345
- else {
346
- reject(new Error('Failed to parse process usage'));
347
- }
348
- });
349
- });
350
- }
351
- async getMacOSProcessUsage(pid) {
352
- const { exec } = await import('node:child_process');
353
- return new Promise((resolve, reject) => {
354
- exec(`ps -p ${pid} -o %mem,%cpu -r`, (error, stdout) => {
355
- if (error) {
356
- reject(error);
357
- return;
358
- }
359
- const lines = stdout.trim().split('\n');
360
- if (lines.length > 1) {
361
- const match = lines[1].match(/\s*(\d+\.?\d*)\s+(\d+\.?\d*)/);
362
- if (match) {
363
- resolve({
364
- memory: parseFloat(match[1]) * 10, // Convert percentage to MB estimate
365
- cpu: parseFloat(match[2])
366
- });
367
- }
368
- }
369
- reject(new Error('Failed to parse macOS process usage'));
370
- });
371
- });
372
- }
373
- getMockResourceUsage() {
374
- return {
375
- memory: Math.floor(Math.random() * 200) + 50,
376
- cpu: Math.floor(Math.random() * 60) + 5
377
- };
378
- }
379
- storeResourceHistory(agentId, usage) {
380
- const agent = this.agents.get(agentId);
381
- if (!agent)
382
- return;
383
- const history = agent.metadata?.resourceHistory || [];
384
- history.push({
385
- timestamp: new Date().toISOString(),
386
- ...usage
387
- });
388
- // Keep only last 100 data points
389
- const recentHistory = history.slice(-100);
390
- agent.metadata = {
391
- ...agent.metadata,
392
- resourceHistory: recentHistory,
393
- lastResourceCheck: new Date().toISOString()
394
- };
395
- this.agents.set(agentId, agent);
396
- }
397
- async getResourceHistory(agentId) {
398
- const agent = this.agents.get(agentId);
399
- return agent?.metadata?.resourceHistory || [];
400
- }
401
- async getResourceTrends(agentId) {
402
- const history = await this.getResourceHistory(agentId);
403
- if (history.length === 0) {
404
- return { avgMemory: 0, avgCpu: 0, peakMemory: 0, peakCpu: 0 };
405
- }
406
- const memoryValues = history.map(h => h.memory);
407
- const cpuValues = history.map(h => h.cpu);
408
- return {
409
- avgMemory: memoryValues.reduce((a, b) => a + b, 0) / memoryValues.length,
410
- avgCpu: cpuValues.reduce((a, b) => a + b, 0) / cpuValues.length,
411
- peakMemory: Math.max(...memoryValues),
412
- peakCpu: Math.max(...cpuValues)
413
- };
414
- }
415
- async updateHeartbeat(agentId) {
416
- const agent = this.agents.get(agentId);
417
- if (!agent)
418
- return;
419
- agent.metadata = {
420
- ...agent.metadata,
421
- lastHeartbeat: new Date().toISOString()
422
- };
423
- agent.updatedAt = new Date().toISOString();
424
- this.agents.set(agentId, agent);
425
- }
426
- async logError(agentId, error) {
427
- const agent = this.agents.get(agentId);
428
- if (!agent)
429
- return;
430
- const errors = agent.metadata?.errors || [];
431
- const errorEntry = {
432
- timestamp: new Date().toISOString(),
433
- error,
434
- count: 1
435
- };
436
- const existingError = errors.find(e => e.error === error);
437
- if (existingError) {
438
- existingError.count++;
439
- existingError.timestamp = new Date().toISOString();
440
- }
441
- else {
442
- errors.push(errorEntry);
443
- }
444
- agent.metadata = {
445
- ...agent.metadata,
446
- errors: errors.slice(-10)
447
- };
448
- agent.updatedAt = new Date().toISOString();
449
- this.agents.set(agentId, agent);
450
- }
451
- calculateUptime(createdAt) {
452
- const created = new Date(createdAt).getTime();
453
- const now = Date.now();
454
- return Math.floor((now - created) / 1000);
455
- }
456
- async ensureDirectory(dirPath) {
457
- const { mkdir } = await import('node:fs/promises');
458
- await mkdir(dirPath, { recursive: true });
459
- }
460
- async writeFile(filePath, content) {
461
- const { writeFile } = await import('node:fs/promises');
462
- await writeFile(filePath, content, 'utf-8');
463
- }
464
- async removeDirectory(dirPath) {
465
- const { rm } = await import('node:fs/promises');
466
- await rm(dirPath, { recursive: true, force: true });
467
- }
468
- /**
469
- * Start heartbeat monitoring for all agents
470
- */
471
- startHeartbeatMonitoring() {
472
- this.heartbeatInterval = setInterval(async () => {
473
- await this.checkAgentHeartbeats();
474
- }, 30000); // Check every 30 seconds
475
- console.log('✓ Agent heartbeat monitoring started');
476
- }
477
- /**
478
- * Start automatic recovery monitoring
479
- */
480
- startRecoveryMonitoring() {
481
- if (!this.recoveryEnabled)
482
- return;
483
- this.recoveryInterval = setInterval(async () => {
484
- await this.performRecoveryChecks();
485
- }, 60000); // Check every minute
486
- console.log('✓ Agent recovery monitoring started');
487
- }
488
- /**
489
- * Check heartbeats for all running agents
490
- */
491
- async checkAgentHeartbeats() {
492
- const now = Date.now();
493
- const agentsToCheck = Array.from(this.agents.values())
494
- .filter(agent => agent.status === AgentStatus.RUNNING || agent.status === AgentStatus.BUSY);
495
- for (const agent of agentsToCheck) {
496
- const lastHeartbeat = agent.metadata?.lastHeartbeat;
497
- if (lastHeartbeat) {
498
- const lastHeartbeatTime = new Date(lastHeartbeat).getTime();
499
- const timeSinceLastHeartbeat = now - lastHeartbeatTime;
500
- if (timeSinceLastHeartbeat > this.heartbeatTimeout) {
501
- console.warn(`⚠️ Agent ${agent.id} missed heartbeat (${timeSinceLastHeartbeat}ms ago)`);
502
- await this.handleMissedHeartbeat(agent);
503
- }
504
- }
505
- else {
506
- console.warn(`⚠️ Agent ${agent.id} has no heartbeat recorded`);
507
- }
508
- }
509
- }
510
- /**
511
- * Handle missed heartbeat scenarios
512
- */
513
- async handleMissedHeartbeat(agent) {
514
- // Check if process is still running
515
- if (agent.pid) {
516
- try {
517
- process.kill(agent.pid, 0); // Check if process exists
518
- // Process exists but no heartbeat - might be stuck
519
- agent.status = AgentStatus.ERROR;
520
- agent.metadata = {
521
- ...agent.metadata,
522
- error: 'Missed heartbeat but process running',
523
- missedHeartbeatAt: new Date().toISOString()
524
- };
525
- agent.updatedAt = new Date().toISOString();
526
- this.agents.set(agent.id, agent);
527
- console.warn(`⚠️ Agent ${agent.id} marked as error due to missed heartbeat`);
528
- // Send recovery event
529
- await this.sendRecoveryEvent(agent, 'missed_heartbeat');
530
- }
531
- catch {
532
- // Process doesn't exist - agent died
533
- agent.status = AgentStatus.FAILED;
534
- agent.metadata = {
535
- ...agent.metadata,
536
- error: 'Process died - no heartbeat received',
537
- diedAt: new Date().toISOString()
538
- };
539
- agent.updatedAt = new Date().toISOString();
540
- this.agents.set(agent.id, agent);
541
- console.error(`❌ Agent ${agent.id} failed - process died`);
542
- // Attempt recovery
543
- await this.attemptAgentRecovery(agent);
544
- }
545
- }
546
- }
547
- /**
548
- * Perform recovery checks and attempts
549
- */
550
- async performRecoveryChecks() {
551
- const failedAgents = Array.from(this.agents.values())
552
- .filter(agent => agent.status === AgentStatus.FAILED || agent.status === AgentStatus.ERROR);
553
- for (const agent of failedAgents) {
554
- const lastRecoveryAttempt = agent.metadata?.lastRecoveryAttempt;
555
- const now = Date.now();
556
- // Only attempt recovery if not tried recently (5 minute cooldown)
557
- if (!lastRecoveryAttempt || (now - new Date(lastRecoveryAttempt).getTime() > 300000)) {
558
- await this.attemptAgentRecovery(agent);
559
- }
560
- }
561
- }
562
- /**
563
- * Attempt to recover a failed agent
564
- */
565
- async attemptAgentRecovery(agent) {
566
- console.log(`🔄 Attempting to recover agent ${agent.id}...`);
567
- try {
568
- // Mark recovery attempt
569
- agent.metadata = {
570
- ...agent.metadata,
571
- lastRecoveryAttempt: new Date().toISOString(),
572
- recoveryAttempts: (agent.metadata?.recoveryAttempts || 0) + 1
573
- };
574
- // Check if we've exceeded max recovery attempts
575
- if (agent.metadata.recoveryAttempts > 3) {
576
- console.error(`❌ Agent ${agent.id} exceeded max recovery attempts`);
577
- await this.sendRecoveryEvent(agent, 'recovery_exhausted');
578
- return;
579
- }
580
- // Clean up existing process if any
581
- if (agent.pid) {
582
- try {
583
- process.kill(agent.pid, 'SIGKILL');
584
- }
585
- catch {
586
- // Process already dead
587
- }
588
- }
589
- // Get original spawn request
590
- const spawnRequest = agent.metadata?.spawnRequest;
591
- if (!spawnRequest) {
592
- console.error(`❌ Cannot recover agent ${agent.id} - no spawn request found`);
593
- return;
594
- }
595
- // Attempt to respawn with same configuration
596
- const newAgentId = `agt_${randomUUID()}`;
597
- agent.id = newAgentId;
598
- agent.status = AgentStatus.SPAWNING;
599
- agent.updatedAt = new Date().toISOString();
600
- // Create new mailbox
601
- const newMailboxId = `mbx_${randomUUID()}`;
602
- await this.createMailbox(newMailboxId, newAgentId);
603
- // Spawn new process
604
- const newPid = await this.executeAgentSpawn(agent, spawnRequest);
605
- agent.pid = newPid;
606
- agent.mailboxId = newMailboxId;
607
- agent.status = AgentStatus.RUNNING;
608
- agent.updatedAt = new Date().toISOString();
609
- // Update agent in registry
610
- this.agents.delete(agent.id.replace(newAgentId, '')); // Remove old ID if different
611
- this.agents.set(newAgentId, agent);
612
- console.log(`✅ Agent ${newAgentId} recovered successfully`);
613
- await this.sendRecoveryEvent(agent, 'recovery_success');
614
- }
615
- catch (error) {
616
- console.error(`❌ Agent ${agent.id} recovery failed:`, error.message);
617
- agent.status = AgentStatus.FAILED;
618
- agent.metadata = {
619
- ...agent.metadata,
620
- recoveryError: error.message,
621
- recoveryFailedAt: new Date().toISOString()
622
- };
623
- agent.updatedAt = new Date().toISOString();
624
- await this.sendRecoveryEvent(agent, 'recovery_failed');
625
- }
626
- }
627
- /**
628
- * Send recovery event notifications
629
- */
630
- async sendRecoveryEvent(agent, eventType) {
631
- try {
632
- const event = {
633
- type: 'agent_recovery',
634
- agentId: agent.id,
635
- agentType: agent.type,
636
- eventType,
637
- timestamp: new Date().toISOString(),
638
- metadata: {
639
- status: agent.status,
640
- recoveryAttempts: agent.metadata?.recoveryAttempts || 0,
641
- lastError: agent.metadata?.error || agent.metadata?.recoveryError
642
- }
643
- };
644
- // In a real implementation, this would send to notification system
645
- console.log(`📢 Recovery event: ${eventType} for agent ${agent.id}`);
646
- console.log(` Event:`, JSON.stringify(event, null, 2));
647
- }
648
- catch (error) {
649
- console.error(`Failed to send recovery event:`, error.message);
650
- }
651
- }
652
- /**
653
- * Get agent health status with detailed metrics
654
- */
655
- async getAgentHealth(agentId) {
656
- const monitor = await this.monitor(agentId);
657
- const agent = this.agents.get(agentId);
658
- const now = Date.now();
659
- const lastHeartbeat = agent?.metadata?.lastHeartbeat;
660
- const isHealthy = monitor.status === AgentStatus.RUNNING &&
661
- (!lastHeartbeat || (now - new Date(lastHeartbeat).getTime() < this.heartbeatTimeout));
662
- return {
663
- status: monitor.status,
664
- isHealthy,
665
- lastHeartbeat,
666
- uptime: monitor.uptime,
667
- resourceUsage: monitor.resourceUsage,
668
- errors: monitor.errors,
669
- recoveryAttempts: agent?.metadata?.recoveryAttempts || 0
670
- };
671
- }
672
- /**
673
- * Get system-wide agent health summary
674
- */
675
- async getSystemHealth() {
676
- const allAgents = Array.from(this.agents.values());
677
- const healthChecks = await Promise.all(allAgents.map(agent => this.getAgentHealth(agent.id)));
678
- const healthy = healthChecks.filter(h => h.isHealthy).length;
679
- const unhealthy = healthChecks.filter(h => !h.isHealthy && h.status !== AgentStatus.FAILED).length;
680
- const failed = healthChecks.filter(h => h.status === AgentStatus.FAILED).length;
681
- const recovering = allAgents.filter(a => a.metadata?.recoveryAttempts > 0).length;
682
- const total = allAgents.length;
683
- let overallHealth = 'healthy';
684
- if (failed / total > 0.3) {
685
- overallHealth = 'critical';
686
- }
687
- else if (unhealthy / total > 0.2) {
688
- overallHealth = 'degraded';
689
- }
690
- return {
691
- totalAgents: total,
692
- healthyAgents: healthy,
693
- unhealthyAgents: unhealthy,
694
- recoveringAgents: recovering,
695
- failedAgents: failed,
696
- overallHealth
697
- };
698
- }
699
- /**
700
- * Cleanup method to stop monitoring intervals
701
- */
702
- cleanup() {
703
- if (this.heartbeatInterval) {
704
- clearInterval(this.heartbeatInterval);
705
- }
706
- if (this.recoveryInterval) {
707
- clearInterval(this.recoveryInterval);
708
- }
709
- console.log('✓ Agent monitoring stopped');
710
- }
711
- }
712
- //# sourceMappingURL=agent-spawner.js.map