@resolveio/server-lib 22.3.219 → 22.3.221

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 (745) hide show
  1. package/.nodemon.json +5 -0
  2. package/.vscode/settings.json +21 -0
  3. package/AGENTS.md +195 -0
  4. package/README.md +22 -0
  5. package/build_package.sh +5 -0
  6. package/compileDTS.pl +64 -0
  7. package/docs/ai-assistant-nightly-eval.md +65 -0
  8. package/docs/ai-assistant-preflight-checklist.md +23 -0
  9. package/docs/ai-assistant-report-builder-bridge-playbook.md +115 -0
  10. package/eslint-plugin-custom/index.js +7 -0
  11. package/eslint-plugin-custom/rules/no-filter-zero-index.js +44 -0
  12. package/eslint.config.js +103 -0
  13. package/gulpfile.js +216 -0
  14. package/methodAndPublicationListGenerator.py +375 -0
  15. package/mongodbensurers.js +2 -0
  16. package/mongostop.js +3 -0
  17. package/package.json +1 -1
  18. package/scripts/cleanup-bypassed-callmethod-logs.js +616 -0
  19. package/settings.development.json +25 -0
  20. package/settings.development.redacted.json +25 -0
  21. package/src/.env +12 -0
  22. package/src/ai/assistant-core-heuristics.ts +379 -0
  23. package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +185 -0
  24. package/src/ai/resolveio-platform-intelligence-memory.ts +325 -0
  25. package/{ai/resolveio-platform-intelligence-types.d.ts → src/ai/resolveio-platform-intelligence-types.ts} +20 -15
  26. package/src/ai/resolveio-platform-intelligence.ts +462 -0
  27. package/src/client-server-app.ts +12 -0
  28. package/src/collections/ai-run.collection.ts +117 -0
  29. package/src/collections/ai-terminal-conversation.collection.ts +91 -0
  30. package/src/collections/ai-terminal-issue-report.collection.ts +99 -0
  31. package/src/collections/ai-terminal-message.collection.ts +77 -0
  32. package/src/collections/app-setting.collection.ts +104 -0
  33. package/src/collections/app-status.collection.ts +58 -0
  34. package/src/collections/communication-metric.collection.ts +84 -0
  35. package/src/collections/counter.collection.ts +56 -0
  36. package/src/collections/cron-job-history.collection.ts +94 -0
  37. package/src/collections/cron-job.collection.ts +92 -0
  38. package/src/collections/customer-notification.collection.ts +131 -0
  39. package/src/collections/customer-portal-password.collection.ts +76 -0
  40. package/src/collections/email-history.collection.ts +134 -0
  41. package/src/collections/email-verified.collection.ts +62 -0
  42. package/src/collections/file.collection.ts +74 -0
  43. package/src/collections/flag-update.collection.ts +57 -0
  44. package/src/collections/flag.collection.ts +57 -0
  45. package/src/collections/log-method-latency.collection.ts +77 -0
  46. package/src/collections/log-subscription.collection.ts +80 -0
  47. package/src/collections/log.collection.ts +93 -0
  48. package/src/collections/logged-in-users.collection.ts +67 -0
  49. package/src/collections/monitor-cpu.collection.ts +65 -0
  50. package/src/collections/monitor-function.collection.ts +74 -0
  51. package/src/collections/monitor-memory.collection.ts +77 -0
  52. package/src/collections/monitor-mongo.collection.ts +71 -0
  53. package/src/collections/notification.collection.ts +57 -0
  54. package/src/collections/openai-usage-ledger.collection.ts +131 -0
  55. package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
  56. package/src/collections/report-builder-library.collection.ts +89 -0
  57. package/src/collections/report-builder-report.collection.ts +184 -0
  58. package/src/collections/user-group.collection.ts +89 -0
  59. package/src/collections/user-guide.collection.ts +57 -0
  60. package/src/collections/user.collection.ts +181 -0
  61. package/src/cron/cron.ts +117 -0
  62. package/src/fixtures/cron-jobs.ts +95 -0
  63. package/src/fixtures/init.ts +35 -0
  64. package/src/http/auth.ts +818 -0
  65. package/src/http/health.ts +7 -0
  66. package/src/http/home.ts +90 -0
  67. package/src/http/slow-query-publication.ts +49 -0
  68. package/src/index.ts +1 -0
  69. package/src/managers/ai-assistant-codex-manager.manager.ts +1131 -0
  70. package/src/managers/ai-run-evidence.manager.ts +264 -0
  71. package/src/managers/communication-metric.manager.ts +82 -0
  72. package/src/managers/cron.manager.ts +333 -0
  73. package/src/managers/customer-notification-content.manager.ts +236 -0
  74. package/src/managers/diagnostic-manager-bootstrap.ts +165 -0
  75. package/src/managers/error-auto-fix.manager.ts +2767 -0
  76. package/src/managers/local-log.manager.ts +113 -0
  77. package/src/managers/method.manager.ts +1857 -0
  78. package/src/managers/mongo.manager.ts +4575 -0
  79. package/src/managers/monitor.manager.ts +507 -0
  80. package/src/managers/openai-usage-ledger.manager.ts +112 -0
  81. package/src/managers/slow-query-verifier.manager.ts +3590 -0
  82. package/src/managers/slow-query.manager.ts +519 -0
  83. package/src/managers/subscription.manager.ts +3128 -0
  84. package/src/managers/websocket.manager.ts +746 -0
  85. package/src/managers/worker-dispatcher.manager.ts +1360 -0
  86. package/src/managers/worker-server.manager.ts +536 -0
  87. package/src/methods/accounts.ts +532 -0
  88. package/src/methods/ai-terminal.ts +29070 -0
  89. package/src/methods/app-settings.ts +114 -0
  90. package/src/methods/aws.ts +649 -0
  91. package/src/methods/collections.ts +641 -0
  92. package/src/methods/counters.ts +69 -0
  93. package/src/methods/cron-jobs.ts +2614 -0
  94. package/src/methods/customer-notifications.ts +458 -0
  95. package/src/methods/diagnostics.ts +616 -0
  96. package/src/methods/flag-updates.ts +7 -0
  97. package/src/methods/flags.ts +7 -0
  98. package/src/methods/logs.ts +657 -0
  99. package/src/methods/mongo-explorer.ts +1880 -0
  100. package/src/methods/monitor.ts +540 -0
  101. package/src/methods/pdf.ts +1236 -0
  102. package/src/methods/publications.ts +129 -0
  103. package/src/methods/report-builder.ts +3300 -0
  104. package/src/methods/support.ts +335 -0
  105. package/src/models/ai-run.model.ts +27 -0
  106. package/src/models/ai-terminal-conversation.model.ts +19 -0
  107. package/src/models/ai-terminal-issue-report.model.ts +21 -0
  108. package/src/models/ai-terminal-message.model.ts +24 -0
  109. package/src/models/app-setting.model.ts +17 -0
  110. package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
  111. package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
  112. package/src/models/collection-document.model.ts +24 -0
  113. package/src/models/communication-metric.model.ts +23 -0
  114. package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
  115. package/src/models/cron-job-history.model.ts +16 -0
  116. package/src/models/cron-job.model.ts +15 -0
  117. package/src/models/customer-notification.model.ts +28 -0
  118. package/src/models/customer-portal-password.model.ts +12 -0
  119. package/src/models/dialog.model.ts +25 -0
  120. package/{models/email-history.model.js → src/models/email-history.model.ts} +36 -4
  121. package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
  122. package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
  123. package/{models/flag-update.model.d.ts → src/models/flag-update.model.ts} +4 -3
  124. package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
  125. package/src/models/log-method-latency.model.ts +11 -0
  126. package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +11 -9
  127. package/src/models/log.model.ts +19 -0
  128. package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
  129. package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
  130. package/src/models/method.model.ts +25 -0
  131. package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
  132. package/src/models/monitor-function.model.ts +16 -0
  133. package/src/models/monitor-memory.model.ts +17 -0
  134. package/src/models/monitor-mongo.model.ts +15 -0
  135. package/{models/notification.model.d.ts → src/models/notification.model.ts} +6 -4
  136. package/src/models/openai-usage-ledger.model.ts +56 -0
  137. package/src/models/pagination.model.ts +35 -0
  138. package/src/models/permission.model.ts +14 -0
  139. package/src/models/report-builder-dashboard-builder.model.ts +29 -0
  140. package/src/models/report-builder-library.model.ts +20 -0
  141. package/src/models/report-builder-report.model.ts +136 -0
  142. package/src/models/report-builder.model.ts +68 -0
  143. package/src/models/select-data-label.model.ts +9 -0
  144. package/src/models/server-message.model.ts +31 -0
  145. package/src/models/slow-query-report.model.ts +23 -0
  146. package/src/models/subscription.model.ts +73 -0
  147. package/src/models/support-ticket.model.ts +104 -0
  148. package/src/models/user-group.model.ts +24 -0
  149. package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
  150. package/src/models/user.model.ts +96 -0
  151. package/src/private/images/ResolveIO.png +0 -0
  152. package/src/publications/ai-terminal.ts +73 -0
  153. package/src/publications/app-settings.ts +25 -0
  154. package/src/publications/app-status.ts +13 -0
  155. package/src/publications/cron-jobs.ts +40 -0
  156. package/src/publications/customer-notifications.ts +101 -0
  157. package/src/publications/files.ts +33 -0
  158. package/src/publications/flags-update.ts +19 -0
  159. package/src/publications/flags.ts +19 -0
  160. package/src/publications/logs.ts +163 -0
  161. package/src/publications/notifications.ts +13 -0
  162. package/src/publications/report-builder-dashboard-builders.ts +39 -0
  163. package/src/publications/report-builder-libraries.ts +41 -0
  164. package/src/publications/report-builder-reports.ts +47 -0
  165. package/src/publications/super-admin.ts +13 -0
  166. package/src/publications/user-groups.ts +12 -0
  167. package/src/publications/user-guides.ts +12 -0
  168. package/src/resolveio-server-app.ts +617 -0
  169. package/src/server-app.ts +3354 -0
  170. package/src/services/codex-client.ts +1231 -0
  171. package/src/services/openai-client.ts +265 -0
  172. package/src/types/error-report.ts +26 -0
  173. package/src/types/js-tiktoken.d.ts +11 -0
  174. package/src/types/slow-query-report.ts +28 -0
  175. package/src/util/ai-qa-policy.ts +925 -0
  176. package/src/util/ai-run-evidence-adapters.ts +8347 -0
  177. package/src/util/ai-run-evidence-dashboard.ts +323 -0
  178. package/src/util/ai-run-evidence-eval.ts +1057 -0
  179. package/src/util/ai-run-evidence.ts +1430 -0
  180. package/src/util/ai-runner-artifacts.ts +586 -0
  181. package/src/util/ai-runner-manager-autopilot.ts +961 -0
  182. package/src/util/ai-runner-manager-policy.ts +5011 -0
  183. package/src/util/ai-runner-qa-auth.ts +838 -0
  184. package/src/util/ai-runner-qa-tools.ts +3536 -0
  185. package/src/util/aicoder-runner-v6.ts +3121 -0
  186. package/src/util/common.ts +649 -0
  187. package/src/util/customer-portal-password.ts +183 -0
  188. package/src/util/error-reporter.ts +332 -0
  189. package/src/util/error-tracking.ts +79 -0
  190. package/src/util/openai-usage-cost.ts +114 -0
  191. package/src/util/report-builder-unwinds.ts +180 -0
  192. package/src/util/runner-process-janitor.ts +219 -0
  193. package/src/util/schema-report-builder.ts +448 -0
  194. package/src/util/slow-query-reporter.ts +216 -0
  195. package/src/util/subscription-dependency-context.ts +1096 -0
  196. package/src/util/support-runner-v5.ts +10040 -0
  197. package/src/util/tokenizer.ts +38 -0
  198. package/src/workers/codex-runner.worker.ts +142 -0
  199. package/start_server.sh +5 -0
  200. package/tests/ai-assistant-corpus-build.ts +484 -0
  201. package/tests/ai-assistant-corpus-replay-e2e.ts +774 -0
  202. package/tests/ai-assistant-data-parity-e2e.ts +1989 -0
  203. package/tests/ai-assistant-eval-triage.ts +831 -0
  204. package/tests/ai-assistant-openai-e2e.ts +1061 -0
  205. package/tests/ai-assistant-openai-git-e2e.ts +155 -0
  206. package/tests/ai-assistant-preflight-matrix.ts +215 -0
  207. package/tests/ai-assistant-routing-eval.test.ts +585 -0
  208. package/tests/ai-assistant-snf-live-eval.ts +975 -0
  209. package/tests/ai-assistant-utils.test.ts +4834 -0
  210. package/tests/ai-manager-autopilot-snapshot.test.ts +193 -0
  211. package/tests/ai-manager-recovery-checkpoint.test.ts +1383 -0
  212. package/tests/ai-run-eval.test.ts +132 -0
  213. package/tests/ai-run-evidence.test.ts +3773 -0
  214. package/tests/ai-runner-contract.test.ts +515 -0
  215. package/tests/aicoder-runner-v6.test.ts +822 -0
  216. package/tests/error-reporter.test.ts +145 -0
  217. package/tests/method-publication-generator.test.ts +46 -0
  218. package/tests/report-builder-linking.test.ts +79 -0
  219. package/tests/resolveio-platform-intelligence.test.ts +352 -0
  220. package/tests/server-app-cron-owner.test.ts +127 -0
  221. package/tests/subscription-connect-race.test.ts +158 -0
  222. package/tests/subscription-dependency-context.test.ts +324 -0
  223. package/tests/subscription-manager-collection-tracking.test.ts +86 -0
  224. package/tests/subscription-manager-invalidation.test.ts +86 -0
  225. package/tests/support-runner-v5.test.ts +3201 -0
  226. package/tsconfig.json +34 -0
  227. package/ai/assistant-core-heuristics.d.ts +0 -11
  228. package/ai/assistant-core-heuristics.js +0 -356
  229. package/ai/assistant-core-heuristics.js.map +0 -1
  230. package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +0 -3
  231. package/ai/resolveio-platform-intelligence-memory-corpus.js +0 -214
  232. package/ai/resolveio-platform-intelligence-memory-corpus.js.map +0 -1
  233. package/ai/resolveio-platform-intelligence-memory.d.ts +0 -20
  234. package/ai/resolveio-platform-intelligence-memory.js +0 -341
  235. package/ai/resolveio-platform-intelligence-memory.js.map +0 -1
  236. package/ai/resolveio-platform-intelligence-types.js +0 -4
  237. package/ai/resolveio-platform-intelligence-types.js.map +0 -1
  238. package/ai/resolveio-platform-intelligence.d.ts +0 -6
  239. package/ai/resolveio-platform-intelligence.js +0 -463
  240. package/ai/resolveio-platform-intelligence.js.map +0 -1
  241. package/client-server-app.d.ts +0 -1
  242. package/client-server-app.js +0 -68
  243. package/client-server-app.js.map +0 -1
  244. package/collections/ai-run.collection.d.ts +0 -3
  245. package/collections/ai-run.collection.js +0 -170
  246. package/collections/ai-run.collection.js.map +0 -1
  247. package/collections/ai-terminal-conversation.collection.d.ts +0 -2
  248. package/collections/ai-terminal-conversation.collection.js +0 -140
  249. package/collections/ai-terminal-conversation.collection.js.map +0 -1
  250. package/collections/ai-terminal-issue-report.collection.d.ts +0 -2
  251. package/collections/ai-terminal-issue-report.collection.js +0 -148
  252. package/collections/ai-terminal-issue-report.collection.js.map +0 -1
  253. package/collections/ai-terminal-message.collection.d.ts +0 -2
  254. package/collections/ai-terminal-message.collection.js +0 -121
  255. package/collections/ai-terminal-message.collection.js.map +0 -1
  256. package/collections/app-setting.collection.d.ts +0 -3
  257. package/collections/app-setting.collection.js +0 -103
  258. package/collections/app-setting.collection.js.map +0 -1
  259. package/collections/app-status.collection.d.ts +0 -3
  260. package/collections/app-status.collection.js +0 -57
  261. package/collections/app-status.collection.js.map +0 -1
  262. package/collections/communication-metric.collection.d.ts +0 -2
  263. package/collections/communication-metric.collection.js +0 -133
  264. package/collections/communication-metric.collection.js.map +0 -1
  265. package/collections/counter.collection.d.ts +0 -3
  266. package/collections/counter.collection.js +0 -56
  267. package/collections/counter.collection.js.map +0 -1
  268. package/collections/cron-job-history.collection.d.ts +0 -3
  269. package/collections/cron-job-history.collection.js +0 -137
  270. package/collections/cron-job-history.collection.js.map +0 -1
  271. package/collections/cron-job.collection.d.ts +0 -3
  272. package/collections/cron-job.collection.js +0 -92
  273. package/collections/cron-job.collection.js.map +0 -1
  274. package/collections/customer-notification.collection.d.ts +0 -3
  275. package/collections/customer-notification.collection.js +0 -130
  276. package/collections/customer-notification.collection.js.map +0 -1
  277. package/collections/customer-portal-password.collection.d.ts +0 -3
  278. package/collections/customer-portal-password.collection.js +0 -75
  279. package/collections/customer-portal-password.collection.js.map +0 -1
  280. package/collections/email-history.collection.d.ts +0 -3
  281. package/collections/email-history.collection.js +0 -134
  282. package/collections/email-history.collection.js.map +0 -1
  283. package/collections/email-verified.collection.d.ts +0 -3
  284. package/collections/email-verified.collection.js +0 -62
  285. package/collections/email-verified.collection.js.map +0 -1
  286. package/collections/file.collection.d.ts +0 -3
  287. package/collections/file.collection.js +0 -74
  288. package/collections/file.collection.js.map +0 -1
  289. package/collections/flag-update.collection.d.ts +0 -3
  290. package/collections/flag-update.collection.js +0 -57
  291. package/collections/flag-update.collection.js.map +0 -1
  292. package/collections/flag.collection.d.ts +0 -3
  293. package/collections/flag.collection.js +0 -57
  294. package/collections/flag.collection.js.map +0 -1
  295. package/collections/log-method-latency.collection.d.ts +0 -3
  296. package/collections/log-method-latency.collection.js +0 -77
  297. package/collections/log-method-latency.collection.js.map +0 -1
  298. package/collections/log-subscription.collection.d.ts +0 -3
  299. package/collections/log-subscription.collection.js +0 -80
  300. package/collections/log-subscription.collection.js.map +0 -1
  301. package/collections/log.collection.d.ts +0 -3
  302. package/collections/log.collection.js +0 -93
  303. package/collections/log.collection.js.map +0 -1
  304. package/collections/logged-in-users.collection.d.ts +0 -3
  305. package/collections/logged-in-users.collection.js +0 -67
  306. package/collections/logged-in-users.collection.js.map +0 -1
  307. package/collections/monitor-cpu.collection.d.ts +0 -3
  308. package/collections/monitor-cpu.collection.js +0 -65
  309. package/collections/monitor-cpu.collection.js.map +0 -1
  310. package/collections/monitor-function.collection.d.ts +0 -3
  311. package/collections/monitor-function.collection.js +0 -74
  312. package/collections/monitor-function.collection.js.map +0 -1
  313. package/collections/monitor-memory.collection.d.ts +0 -3
  314. package/collections/monitor-memory.collection.js +0 -77
  315. package/collections/monitor-memory.collection.js.map +0 -1
  316. package/collections/monitor-mongo.collection.d.ts +0 -3
  317. package/collections/monitor-mongo.collection.js +0 -71
  318. package/collections/monitor-mongo.collection.js.map +0 -1
  319. package/collections/notification.collection.d.ts +0 -3
  320. package/collections/notification.collection.js +0 -57
  321. package/collections/notification.collection.js.map +0 -1
  322. package/collections/openai-usage-ledger.collection.d.ts +0 -2
  323. package/collections/openai-usage-ledger.collection.js +0 -188
  324. package/collections/openai-usage-ledger.collection.js.map +0 -1
  325. package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
  326. package/collections/report-builder-dashboard-builder.collection.js +0 -109
  327. package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
  328. package/collections/report-builder-library.collection.d.ts +0 -3
  329. package/collections/report-builder-library.collection.js +0 -87
  330. package/collections/report-builder-library.collection.js.map +0 -1
  331. package/collections/report-builder-report.collection.d.ts +0 -4
  332. package/collections/report-builder-report.collection.js +0 -184
  333. package/collections/report-builder-report.collection.js.map +0 -1
  334. package/collections/user-group.collection.d.ts +0 -4
  335. package/collections/user-group.collection.js +0 -89
  336. package/collections/user-group.collection.js.map +0 -1
  337. package/collections/user-guide.collection.d.ts +0 -3
  338. package/collections/user-guide.collection.js +0 -57
  339. package/collections/user-guide.collection.js.map +0 -1
  340. package/collections/user.collection.d.ts +0 -4
  341. package/collections/user.collection.js +0 -180
  342. package/collections/user.collection.js.map +0 -1
  343. package/cron/cron.d.ts +0 -14
  344. package/cron/cron.js +0 -216
  345. package/cron/cron.js.map +0 -1
  346. package/fixtures/cron-jobs.d.ts +0 -1
  347. package/fixtures/cron-jobs.js +0 -150
  348. package/fixtures/cron-jobs.js.map +0 -1
  349. package/fixtures/init.d.ts +0 -1
  350. package/fixtures/init.js +0 -91
  351. package/fixtures/init.js.map +0 -1
  352. package/http/auth.d.ts +0 -2
  353. package/http/auth.js +0 -951
  354. package/http/auth.js.map +0 -1
  355. package/http/health.d.ts +0 -1
  356. package/http/health.js +0 -11
  357. package/http/health.js.map +0 -1
  358. package/http/home.d.ts +0 -1
  359. package/http/home.js +0 -134
  360. package/http/home.js.map +0 -1
  361. package/http/slow-query-publication.d.ts +0 -2
  362. package/http/slow-query-publication.js +0 -99
  363. package/http/slow-query-publication.js.map +0 -1
  364. package/index.d.ts +0 -1
  365. package/index.js +0 -19
  366. package/index.js.map +0 -1
  367. package/managers/ai-assistant-codex-manager.manager.d.ts +0 -67
  368. package/managers/ai-assistant-codex-manager.manager.js +0 -1113
  369. package/managers/ai-assistant-codex-manager.manager.js.map +0 -1
  370. package/managers/ai-run-evidence.manager.d.ts +0 -36
  371. package/managers/ai-run-evidence.manager.js +0 -377
  372. package/managers/ai-run-evidence.manager.js.map +0 -1
  373. package/managers/communication-metric.manager.d.ts +0 -16
  374. package/managers/communication-metric.manager.js +0 -134
  375. package/managers/communication-metric.manager.js.map +0 -1
  376. package/managers/cron.manager.d.ts +0 -20
  377. package/managers/cron.manager.js +0 -534
  378. package/managers/cron.manager.js.map +0 -1
  379. package/managers/customer-notification-content.manager.d.ts +0 -55
  380. package/managers/customer-notification-content.manager.js +0 -158
  381. package/managers/customer-notification-content.manager.js.map +0 -1
  382. package/managers/diagnostic-manager-bootstrap.d.ts +0 -9
  383. package/managers/diagnostic-manager-bootstrap.js +0 -260
  384. package/managers/diagnostic-manager-bootstrap.js.map +0 -1
  385. package/managers/error-auto-fix.manager.d.ts +0 -149
  386. package/managers/error-auto-fix.manager.js +0 -3064
  387. package/managers/error-auto-fix.manager.js.map +0 -1
  388. package/managers/local-log.manager.d.ts +0 -18
  389. package/managers/local-log.manager.js +0 -88
  390. package/managers/local-log.manager.js.map +0 -1
  391. package/managers/method.manager.d.ts +0 -84
  392. package/managers/method.manager.js +0 -1964
  393. package/managers/method.manager.js.map +0 -1
  394. package/managers/mongo.manager.d.ts +0 -224
  395. package/managers/mongo.manager.js +0 -5000
  396. package/managers/mongo.manager.js.map +0 -1
  397. package/managers/monitor.manager.d.ts +0 -70
  398. package/managers/monitor.manager.js +0 -550
  399. package/managers/monitor.manager.js.map +0 -1
  400. package/managers/openai-usage-ledger.manager.d.ts +0 -30
  401. package/managers/openai-usage-ledger.manager.js +0 -142
  402. package/managers/openai-usage-ledger.manager.js.map +0 -1
  403. package/managers/slow-query-verifier.manager.d.ts +0 -144
  404. package/managers/slow-query-verifier.manager.js +0 -3857
  405. package/managers/slow-query-verifier.manager.js.map +0 -1
  406. package/managers/slow-query.manager.d.ts +0 -28
  407. package/managers/slow-query.manager.js +0 -468
  408. package/managers/slow-query.manager.js.map +0 -1
  409. package/managers/subscription.manager.d.ts +0 -169
  410. package/managers/subscription.manager.js +0 -3434
  411. package/managers/subscription.manager.js.map +0 -1
  412. package/managers/websocket.manager.d.ts +0 -73
  413. package/managers/websocket.manager.js +0 -673
  414. package/managers/websocket.manager.js.map +0 -1
  415. package/managers/worker-dispatcher.manager.d.ts +0 -120
  416. package/managers/worker-dispatcher.manager.js +0 -1266
  417. package/managers/worker-dispatcher.manager.js.map +0 -1
  418. package/managers/worker-server.manager.d.ts +0 -35
  419. package/managers/worker-server.manager.js +0 -582
  420. package/managers/worker-server.manager.js.map +0 -1
  421. package/methods/accounts.d.ts +0 -2
  422. package/methods/accounts.js +0 -624
  423. package/methods/accounts.js.map +0 -1
  424. package/methods/ai-terminal.d.ts +0 -458
  425. package/methods/ai-terminal.js +0 -27991
  426. package/methods/ai-terminal.js.map +0 -1
  427. package/methods/app-settings.d.ts +0 -2
  428. package/methods/app-settings.js +0 -169
  429. package/methods/app-settings.js.map +0 -1
  430. package/methods/aws.d.ts +0 -2
  431. package/methods/aws.js +0 -877
  432. package/methods/aws.js.map +0 -1
  433. package/methods/collections.d.ts +0 -2
  434. package/methods/collections.js +0 -719
  435. package/methods/collections.js.map +0 -1
  436. package/methods/counters.d.ts +0 -2
  437. package/methods/counters.js +0 -113
  438. package/methods/counters.js.map +0 -1
  439. package/methods/cron-jobs.d.ts +0 -2
  440. package/methods/cron-jobs.js +0 -2475
  441. package/methods/cron-jobs.js.map +0 -1
  442. package/methods/customer-notifications.d.ts +0 -2
  443. package/methods/customer-notifications.js +0 -528
  444. package/methods/customer-notifications.js.map +0 -1
  445. package/methods/diagnostics.d.ts +0 -2
  446. package/methods/diagnostics.js +0 -703
  447. package/methods/diagnostics.js.map +0 -1
  448. package/methods/flag-updates.d.ts +0 -2
  449. package/methods/flag-updates.js +0 -8
  450. package/methods/flag-updates.js.map +0 -1
  451. package/methods/flags.d.ts +0 -2
  452. package/methods/flags.js +0 -8
  453. package/methods/flags.js.map +0 -1
  454. package/methods/logs.d.ts +0 -2
  455. package/methods/logs.js +0 -751
  456. package/methods/logs.js.map +0 -1
  457. package/methods/mongo-explorer.d.ts +0 -2
  458. package/methods/mongo-explorer.js +0 -1808
  459. package/methods/mongo-explorer.js.map +0 -1
  460. package/methods/monitor.d.ts +0 -2
  461. package/methods/monitor.js +0 -543
  462. package/methods/monitor.js.map +0 -1
  463. package/methods/pdf.d.ts +0 -2
  464. package/methods/pdf.js +0 -1216
  465. package/methods/pdf.js.map +0 -1
  466. package/methods/publications.d.ts +0 -1
  467. package/methods/publications.js +0 -183
  468. package/methods/publications.js.map +0 -1
  469. package/methods/report-builder.d.ts +0 -2
  470. package/methods/report-builder.js +0 -3094
  471. package/methods/report-builder.js.map +0 -1
  472. package/methods/support.d.ts +0 -2
  473. package/methods/support.js +0 -430
  474. package/methods/support.js.map +0 -1
  475. package/models/ai-run.model.d.ts +0 -19
  476. package/models/ai-run.model.js +0 -4
  477. package/models/ai-run.model.js.map +0 -1
  478. package/models/ai-terminal-conversation.model.d.ts +0 -17
  479. package/models/ai-terminal-conversation.model.js +0 -4
  480. package/models/ai-terminal-conversation.model.js.map +0 -1
  481. package/models/ai-terminal-issue-report.model.d.ts +0 -19
  482. package/models/ai-terminal-issue-report.model.js +0 -4
  483. package/models/ai-terminal-issue-report.model.js.map +0 -1
  484. package/models/ai-terminal-message.model.d.ts +0 -22
  485. package/models/ai-terminal-message.model.js +0 -4
  486. package/models/ai-terminal-message.model.js.map +0 -1
  487. package/models/app-setting.model.d.ts +0 -16
  488. package/models/app-setting.model.js +0 -4
  489. package/models/app-setting.model.js.map +0 -1
  490. package/models/app-status.model.js +0 -4
  491. package/models/app-status.model.js.map +0 -1
  492. package/models/billing-logged-in-users.model.js +0 -4
  493. package/models/billing-logged-in-users.model.js.map +0 -1
  494. package/models/collection-document.model.d.ts +0 -21
  495. package/models/collection-document.model.js +0 -4
  496. package/models/collection-document.model.js.map +0 -1
  497. package/models/communication-metric.model.d.ts +0 -20
  498. package/models/communication-metric.model.js +0 -4
  499. package/models/communication-metric.model.js.map +0 -1
  500. package/models/counter.model.js +0 -4
  501. package/models/counter.model.js.map +0 -1
  502. package/models/cron-job-history.model.d.ts +0 -15
  503. package/models/cron-job-history.model.js +0 -4
  504. package/models/cron-job-history.model.js.map +0 -1
  505. package/models/cron-job.model.d.ts +0 -14
  506. package/models/cron-job.model.js +0 -4
  507. package/models/cron-job.model.js.map +0 -1
  508. package/models/customer-notification.model.d.ts +0 -26
  509. package/models/customer-notification.model.js +0 -4
  510. package/models/customer-notification.model.js.map +0 -1
  511. package/models/customer-portal-password.model.d.ts +0 -11
  512. package/models/customer-portal-password.model.js +0 -4
  513. package/models/customer-portal-password.model.js.map +0 -1
  514. package/models/dialog.model.d.ts +0 -23
  515. package/models/dialog.model.js +0 -4
  516. package/models/dialog.model.js.map +0 -1
  517. package/models/email-history.model.d.ts +0 -32
  518. package/models/email-history.model.js.map +0 -1
  519. package/models/email-verified.model.js +0 -4
  520. package/models/email-verified.model.js.map +0 -1
  521. package/models/file.model.js +0 -4
  522. package/models/file.model.js.map +0 -1
  523. package/models/flag-update.model.js +0 -4
  524. package/models/flag-update.model.js.map +0 -1
  525. package/models/flag.model.js +0 -4
  526. package/models/flag.model.js.map +0 -1
  527. package/models/log-method-latency.model.d.ts +0 -10
  528. package/models/log-method-latency.model.js +0 -4
  529. package/models/log-method-latency.model.js.map +0 -1
  530. package/models/log-subscription.model.js +0 -4
  531. package/models/log-subscription.model.js.map +0 -1
  532. package/models/log.model.d.ts +0 -17
  533. package/models/log.model.js +0 -4
  534. package/models/log.model.js.map +0 -1
  535. package/models/logged-in-users.model.js +0 -4
  536. package/models/logged-in-users.model.js.map +0 -1
  537. package/models/method-response.model.js +0 -4
  538. package/models/method-response.model.js.map +0 -1
  539. package/models/method.model.d.ts +0 -26
  540. package/models/method.model.js +0 -4
  541. package/models/method.model.js.map +0 -1
  542. package/models/monitor-cpu.model.js +0 -4
  543. package/models/monitor-cpu.model.js.map +0 -1
  544. package/models/monitor-function.model.d.ts +0 -14
  545. package/models/monitor-function.model.js +0 -4
  546. package/models/monitor-function.model.js.map +0 -1
  547. package/models/monitor-memory.model.d.ts +0 -15
  548. package/models/monitor-memory.model.js +0 -4
  549. package/models/monitor-memory.model.js.map +0 -1
  550. package/models/monitor-mongo.model.d.ts +0 -13
  551. package/models/monitor-mongo.model.js +0 -4
  552. package/models/monitor-mongo.model.js.map +0 -1
  553. package/models/notification.model.js +0 -4
  554. package/models/notification.model.js.map +0 -1
  555. package/models/openai-usage-ledger.model.d.ts +0 -30
  556. package/models/openai-usage-ledger.model.js +0 -4
  557. package/models/openai-usage-ledger.model.js.map +0 -1
  558. package/models/pagination.model.d.ts +0 -11
  559. package/models/pagination.model.js +0 -28
  560. package/models/pagination.model.js.map +0 -1
  561. package/models/permission.model.d.ts +0 -12
  562. package/models/permission.model.js +0 -4
  563. package/models/permission.model.js.map +0 -1
  564. package/models/report-builder-dashboard-builder.model.d.ts +0 -25
  565. package/models/report-builder-dashboard-builder.model.js +0 -4
  566. package/models/report-builder-dashboard-builder.model.js.map +0 -1
  567. package/models/report-builder-library.model.d.ts +0 -17
  568. package/models/report-builder-library.model.js +0 -4
  569. package/models/report-builder-library.model.js.map +0 -1
  570. package/models/report-builder-report.model.d.ts +0 -121
  571. package/models/report-builder-report.model.js +0 -4
  572. package/models/report-builder-report.model.js.map +0 -1
  573. package/models/report-builder.model.d.ts +0 -61
  574. package/models/report-builder.model.js +0 -4
  575. package/models/report-builder.model.js.map +0 -1
  576. package/models/select-data-label.model.d.ts +0 -9
  577. package/models/select-data-label.model.js +0 -4
  578. package/models/select-data-label.model.js.map +0 -1
  579. package/models/server-message.model.d.ts +0 -32
  580. package/models/server-message.model.js +0 -4
  581. package/models/server-message.model.js.map +0 -1
  582. package/models/slow-query-report.model.d.ts +0 -23
  583. package/models/slow-query-report.model.js +0 -4
  584. package/models/slow-query-report.model.js.map +0 -1
  585. package/models/subscription.model.d.ts +0 -31
  586. package/models/subscription.model.js +0 -4
  587. package/models/subscription.model.js.map +0 -1
  588. package/models/support-ticket.model.d.ts +0 -87
  589. package/models/support-ticket.model.js +0 -4
  590. package/models/support-ticket.model.js.map +0 -1
  591. package/models/user-group.model.d.ts +0 -20
  592. package/models/user-group.model.js +0 -4
  593. package/models/user-group.model.js.map +0 -1
  594. package/models/user-guide.model.js +0 -4
  595. package/models/user-guide.model.js.map +0 -1
  596. package/models/user.model.d.ts +0 -84
  597. package/models/user.model.js +0 -4
  598. package/models/user.model.js.map +0 -1
  599. package/private/images/ResolveIO.png +0 -0
  600. package/public_api.js +0 -127
  601. package/public_api.js.map +0 -1
  602. package/publications/ai-terminal.d.ts +0 -1
  603. package/publications/ai-terminal.js +0 -122
  604. package/publications/ai-terminal.js.map +0 -1
  605. package/publications/app-settings.d.ts +0 -2
  606. package/publications/app-settings.js +0 -28
  607. package/publications/app-settings.js.map +0 -1
  608. package/publications/app-status.d.ts +0 -2
  609. package/publications/app-status.js +0 -16
  610. package/publications/app-status.js.map +0 -1
  611. package/publications/cron-jobs.d.ts +0 -2
  612. package/publications/cron-jobs.js +0 -88
  613. package/publications/cron-jobs.js.map +0 -1
  614. package/publications/customer-notifications.d.ts +0 -2
  615. package/publications/customer-notifications.js +0 -161
  616. package/publications/customer-notifications.js.map +0 -1
  617. package/publications/files.d.ts +0 -2
  618. package/publications/files.js +0 -36
  619. package/publications/files.js.map +0 -1
  620. package/publications/flags-update.d.ts +0 -2
  621. package/publications/flags-update.js +0 -22
  622. package/publications/flags-update.js.map +0 -1
  623. package/publications/flags.d.ts +0 -2
  624. package/publications/flags.js +0 -22
  625. package/publications/flags.js.map +0 -1
  626. package/publications/logs.d.ts +0 -2
  627. package/publications/logs.js +0 -164
  628. package/publications/logs.js.map +0 -1
  629. package/publications/notifications.d.ts +0 -2
  630. package/publications/notifications.js +0 -16
  631. package/publications/notifications.js.map +0 -1
  632. package/publications/report-builder-dashboard-builders.d.ts +0 -2
  633. package/publications/report-builder-dashboard-builders.js +0 -42
  634. package/publications/report-builder-dashboard-builders.js.map +0 -1
  635. package/publications/report-builder-libraries.d.ts +0 -2
  636. package/publications/report-builder-libraries.js +0 -90
  637. package/publications/report-builder-libraries.js.map +0 -1
  638. package/publications/report-builder-reports.d.ts +0 -2
  639. package/publications/report-builder-reports.js +0 -50
  640. package/publications/report-builder-reports.js.map +0 -1
  641. package/publications/super-admin.d.ts +0 -2
  642. package/publications/super-admin.js +0 -16
  643. package/publications/super-admin.js.map +0 -1
  644. package/publications/user-groups.d.ts +0 -1
  645. package/publications/user-groups.js +0 -16
  646. package/publications/user-groups.js.map +0 -1
  647. package/publications/user-guides.d.ts +0 -1
  648. package/publications/user-guides.js +0 -16
  649. package/publications/user-guides.js.map +0 -1
  650. package/resolveio-server-app.d.ts +0 -70
  651. package/resolveio-server-app.js +0 -801
  652. package/resolveio-server-app.js.map +0 -1
  653. package/server-app.d.ts +0 -228
  654. package/server-app.js +0 -3566
  655. package/server-app.js.map +0 -1
  656. package/services/codex-client.d.ts +0 -128
  657. package/services/codex-client.js +0 -1629
  658. package/services/codex-client.js.map +0 -1
  659. package/services/openai-client.d.ts +0 -46
  660. package/services/openai-client.js +0 -318
  661. package/services/openai-client.js.map +0 -1
  662. package/types/error-report.d.ts +0 -25
  663. package/types/error-report.js +0 -4
  664. package/types/error-report.js.map +0 -1
  665. package/types/slow-query-report.d.ts +0 -27
  666. package/types/slow-query-report.js +0 -6
  667. package/types/slow-query-report.js.map +0 -1
  668. package/util/ai-qa-policy.d.ts +0 -124
  669. package/util/ai-qa-policy.js +0 -736
  670. package/util/ai-qa-policy.js.map +0 -1
  671. package/util/ai-run-evidence-adapters.d.ts +0 -109
  672. package/util/ai-run-evidence-adapters.js +0 -7234
  673. package/util/ai-run-evidence-adapters.js.map +0 -1
  674. package/util/ai-run-evidence-dashboard.d.ts +0 -88
  675. package/util/ai-run-evidence-dashboard.js +0 -343
  676. package/util/ai-run-evidence-dashboard.js.map +0 -1
  677. package/util/ai-run-evidence-eval.d.ts +0 -86
  678. package/util/ai-run-evidence-eval.js +0 -1018
  679. package/util/ai-run-evidence-eval.js.map +0 -1
  680. package/util/ai-run-evidence.d.ts +0 -244
  681. package/util/ai-run-evidence.js +0 -1096
  682. package/util/ai-run-evidence.js.map +0 -1
  683. package/util/ai-runner-artifacts.d.ts +0 -82
  684. package/util/ai-runner-artifacts.js +0 -713
  685. package/util/ai-runner-artifacts.js.map +0 -1
  686. package/util/ai-runner-manager-autopilot.d.ts +0 -210
  687. package/util/ai-runner-manager-autopilot.js +0 -642
  688. package/util/ai-runner-manager-autopilot.js.map +0 -1
  689. package/util/ai-runner-manager-policy.d.ts +0 -807
  690. package/util/ai-runner-manager-policy.js +0 -3501
  691. package/util/ai-runner-manager-policy.js.map +0 -1
  692. package/util/ai-runner-qa-auth.d.ts +0 -5
  693. package/util/ai-runner-qa-auth.js +0 -839
  694. package/util/ai-runner-qa-auth.js.map +0 -1
  695. package/util/ai-runner-qa-tools.d.ts +0 -26
  696. package/util/ai-runner-qa-tools.js +0 -3520
  697. package/util/ai-runner-qa-tools.js.map +0 -1
  698. package/util/aicoder-runner-v6.d.ts +0 -426
  699. package/util/aicoder-runner-v6.js +0 -2464
  700. package/util/aicoder-runner-v6.js.map +0 -1
  701. package/util/common.d.ts +0 -31
  702. package/util/common.js +0 -683
  703. package/util/common.js.map +0 -1
  704. package/util/customer-portal-password.d.ts +0 -13
  705. package/util/customer-portal-password.js +0 -209
  706. package/util/customer-portal-password.js.map +0 -1
  707. package/util/error-reporter.d.ts +0 -52
  708. package/util/error-reporter.js +0 -326
  709. package/util/error-reporter.js.map +0 -1
  710. package/util/error-tracking.d.ts +0 -13
  711. package/util/error-tracking.js +0 -120
  712. package/util/error-tracking.js.map +0 -1
  713. package/util/openai-usage-cost.d.ts +0 -6
  714. package/util/openai-usage-cost.js +0 -103
  715. package/util/openai-usage-cost.js.map +0 -1
  716. package/util/report-builder-unwinds.d.ts +0 -15
  717. package/util/report-builder-unwinds.js +0 -156
  718. package/util/report-builder-unwinds.js.map +0 -1
  719. package/util/runner-process-janitor.d.ts +0 -27
  720. package/util/runner-process-janitor.js +0 -208
  721. package/util/runner-process-janitor.js.map +0 -1
  722. package/util/schema-report-builder.d.ts +0 -6
  723. package/util/schema-report-builder.js +0 -481
  724. package/util/schema-report-builder.js.map +0 -1
  725. package/util/slow-query-reporter.d.ts +0 -28
  726. package/util/slow-query-reporter.js +0 -226
  727. package/util/slow-query-reporter.js.map +0 -1
  728. package/util/subscription-dependency-context.d.ts +0 -34
  729. package/util/subscription-dependency-context.js +0 -1283
  730. package/util/subscription-dependency-context.js.map +0 -1
  731. package/util/support-runner-v5.d.ts +0 -1426
  732. package/util/support-runner-v5.js +0 -7624
  733. package/util/support-runner-v5.js.map +0 -1
  734. package/util/tokenizer.d.ts +0 -5
  735. package/util/tokenizer.js +0 -41
  736. package/util/tokenizer.js.map +0 -1
  737. package/workers/codex-runner.worker.d.ts +0 -1
  738. package/workers/codex-runner.worker.js +0 -192
  739. package/workers/codex-runner.worker.js.map +0 -1
  740. /package/{private → src/private}/email-templates/enrollment.html +0 -0
  741. /package/{private → src/private}/email-templates/forgot-password.html +0 -0
  742. /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
  743. /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
  744. /package/{private → src/private}/email-templates/support-ticket.html +0 -0
  745. /package/{public_api.d.ts → src/public_api.ts} +0 -0
@@ -1,582 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __read = (this && this.__read) || function (o, n) {
50
- var m = typeof Symbol === "function" && o[Symbol.iterator];
51
- if (!m) return o;
52
- var i = m.call(o), r, ar = [], e;
53
- try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
- }
56
- catch (error) { e = { error: error }; }
57
- finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
62
- }
63
- return ar;
64
- };
65
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
- if (ar || !(i in from)) {
68
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
- ar[i] = from[i];
70
- }
71
- }
72
- return to.concat(ar || Array.prototype.slice.call(from));
73
- };
74
- Object.defineProperty(exports, "__esModule", { value: true });
75
- exports.WorkerServerManager = void 0;
76
- var msgpackr_1 = require("msgpackr");
77
- var WebSocket = require("ws");
78
- var common_1 = require("../util/common");
79
- var method_manager_1 = require("./method.manager");
80
- var WorkerServerManager = /** @class */ (function () {
81
- function WorkerServerManager() {
82
- this._runningTasks = [];
83
- this._taskLogThresholdMs = 200;
84
- this._isConnected = false;
85
- this._lastConnectionAttemptAt = 0;
86
- this._lastConnectedAt = 0;
87
- this._lastDisconnectedAt = 0;
88
- this._connectionLossStartedAt = 0;
89
- this._lastDisconnectReason = '';
90
- }
91
- WorkerServerManager.create = function (methodManager, serverConfig) {
92
- var workerServerManager = new WorkerServerManager();
93
- workerServerManager.initialize(methodManager, serverConfig);
94
- return workerServerManager;
95
- };
96
- WorkerServerManager.prototype.initialize = function (methodManager, serverConfig) {
97
- var _this = this;
98
- this._methodManager = methodManager;
99
- this._serverConfig = serverConfig;
100
- if (this._methodManager && typeof this._methodManager.onReady === 'function') {
101
- this._methodManager.onReady(function () { return _this.startWorkerInstance(); });
102
- }
103
- else {
104
- this.startWorkerInstance();
105
- }
106
- };
107
- WorkerServerManager.prototype.markWorkerConnectionAttempt = function () {
108
- var now = Date.now();
109
- this._lastConnectionAttemptAt = now;
110
- if (!this._isConnected && !this._connectionLossStartedAt) {
111
- this._connectionLossStartedAt = now;
112
- }
113
- };
114
- WorkerServerManager.prototype.markWorkerConnected = function () {
115
- var now = Date.now();
116
- this._isConnected = true;
117
- this._lastConnectedAt = now;
118
- this._lastDisconnectedAt = 0;
119
- this._connectionLossStartedAt = 0;
120
- this._lastDisconnectReason = '';
121
- };
122
- WorkerServerManager.prototype.markWorkerDisconnected = function (reason) {
123
- var now = Date.now();
124
- this._isConnected = false;
125
- this._lastDisconnectedAt = now;
126
- if (!this._connectionLossStartedAt) {
127
- this._connectionLossStartedAt = now;
128
- }
129
- this._lastDisconnectReason = String(reason || 'Worker websocket disconnected.');
130
- };
131
- WorkerServerManager.prototype.getConnectionHealth = function () {
132
- return {
133
- isConnected: this._isConnected,
134
- lastConnectionAttemptAt: this._lastConnectionAttemptAt,
135
- lastConnectedAt: this._lastConnectedAt,
136
- lastDisconnectedAt: this._lastDisconnectedAt,
137
- connectionLossStartedAt: this._connectionLossStartedAt,
138
- currentOutageMs: (!this._isConnected && this._connectionLossStartedAt)
139
- ? Math.max(0, Date.now() - this._connectionLossStartedAt)
140
- : 0,
141
- lastDisconnectReason: this._lastDisconnectReason
142
- };
143
- };
144
- WorkerServerManager.prototype.startWorkerInstance = function () {
145
- var _this = this;
146
- var workerIndex = encodeURIComponent(String(process.env.WORKER_INDEX || ''));
147
- var workerInstance = encodeURIComponent(String(process.env.NODE_APP_INSTANCE || ''));
148
- var workerToken = encodeURIComponent(String(this._serverConfig['WORKER_TOKEN'] || ''));
149
- var wsUrl = this._serverConfig['SERVER_URL'] + '/websocket?workerToken=' + workerToken + '&workerIndex=' + workerIndex + '&workerInstance=' + workerInstance;
150
- var ws = new WebSocket(wsUrl);
151
- this.markWorkerConnectionAttempt();
152
- var lastComm = new Date();
153
- var interval = null;
154
- var missedPongs = 0;
155
- var heartbeatIntervalMs = 15000;
156
- var maxMissedPongs = 2;
157
- var maxSilenceMs = heartbeatIntervalMs * (maxMissedPongs + 1);
158
- var openTimeout = null;
159
- var opened = false;
160
- // Set timeout if the socket never opens
161
- openTimeout = setTimeout(function () {
162
- if (!opened) {
163
- _this.markWorkerDisconnected('WebSocket connection timeout.');
164
- console.error(new Date(), 'WebSocket connection timeout. Retrying...');
165
- ws.terminate(); // force close if still connecting
166
- }
167
- }, 10000); // 10 seconds timeout
168
- ws.on('open', function () {
169
- opened = true;
170
- clearTimeout(openTimeout);
171
- _this.markWorkerConnected();
172
- console.log(new Date(), 'Connected to main server as worker', process.env.WORKER_INDEX, process.env.NODE_APP_INSTANCE);
173
- _this.sendWorkerResponse(ws, 'ping');
174
- interval = setInterval(function () {
175
- var now = Date.now();
176
- var last = lastComm ? lastComm.getTime() : 0;
177
- var silenceMs = last ? now - last : maxSilenceMs + 1;
178
- if (silenceMs > maxSilenceMs || missedPongs > maxMissedPongs) {
179
- _this.markWorkerDisconnected('Worker websocket heartbeat timed out.');
180
- ws.close();
181
- return;
182
- }
183
- missedPongs += 1;
184
- _this.sendWorkerResponse(ws, 'ping');
185
- }, heartbeatIntervalMs);
186
- });
187
- ws.on('message', function (rawData) { return __awaiter(_this, void 0, void 0, function () {
188
- var msg_1, messageBuffer, chunks, view, heartbeat, msg;
189
- return __generator(this, function (_a) {
190
- switch (_a.label) {
191
- case 0:
192
- lastComm = new Date();
193
- if (!(typeof rawData === 'string')) return [3 /*break*/, 5];
194
- if (this._methodManager.getEnableDebug()) {
195
- console.log(new Date(), 'Message Recv', rawData);
196
- }
197
- if (!(rawData === 'ping')) return [3 /*break*/, 1];
198
- if (this._methodManager.getEnableDebug()) {
199
- console.log(new Date(), 'Recv Ping, Sending Pong');
200
- }
201
- this.sendWorkerResponse(ws, 'pong');
202
- return [3 /*break*/, 4];
203
- case 1:
204
- if (!(rawData === 'pong')) return [3 /*break*/, 2];
205
- if (this._methodManager.getEnableDebug()) {
206
- console.log(new Date(), 'Recv Pong');
207
- }
208
- missedPongs = 0;
209
- return [3 /*break*/, 4];
210
- case 2:
211
- try {
212
- msg_1 = JSON.parse(rawData, common_1.dateReviver);
213
- }
214
- catch (e) {
215
- console.error('Worker parse error', e);
216
- return [2 /*return*/];
217
- }
218
- if (!(msg_1.type === 'task')) return [3 /*break*/, 4];
219
- return [4 /*yield*/, this.handleIncomingTask(ws, msg_1)];
220
- case 3:
221
- _a.sent();
222
- _a.label = 4;
223
- case 4: return [2 /*return*/];
224
- case 5:
225
- if (Buffer.isBuffer(rawData)) {
226
- messageBuffer = rawData;
227
- }
228
- else if (Array.isArray(rawData)) {
229
- chunks = rawData;
230
- messageBuffer = Buffer.concat(chunks);
231
- }
232
- else if (rawData instanceof ArrayBuffer) {
233
- messageBuffer = Buffer.from(rawData);
234
- }
235
- else if (ArrayBuffer.isView(rawData)) {
236
- view = rawData;
237
- messageBuffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);
238
- }
239
- else {
240
- messageBuffer = Buffer.from(rawData);
241
- }
242
- if (this._methodManager.getEnableDebug()) {
243
- console.log(new Date(), 'Message Recv (binary)', messageBuffer.length);
244
- }
245
- if (messageBuffer.length === 4) {
246
- heartbeat = messageBuffer.toString('utf8');
247
- if (heartbeat === 'ping') {
248
- if (this._methodManager.getEnableDebug()) {
249
- console.log(new Date(), 'Recv Ping (binary), Sending Pong');
250
- }
251
- this.sendWorkerResponse(ws, 'pong');
252
- return [2 /*return*/];
253
- }
254
- else if (heartbeat === 'pong') {
255
- if (this._methodManager.getEnableDebug()) {
256
- console.log(new Date(), 'Recv Pong (binary)');
257
- }
258
- missedPongs = 0;
259
- return [2 /*return*/];
260
- }
261
- }
262
- try {
263
- msg = (0, msgpackr_1.unpack)(messageBuffer);
264
- }
265
- catch (e) {
266
- console.error('Worker binary parse error', e);
267
- return [2 /*return*/];
268
- }
269
- if (!(msg.type === 'task')) return [3 /*break*/, 7];
270
- return [4 /*yield*/, this.handleIncomingTask(ws, msg)];
271
- case 6:
272
- _a.sent();
273
- _a.label = 7;
274
- case 7: return [2 /*return*/];
275
- }
276
- });
277
- }); });
278
- ws.on('close', function (code, reason) {
279
- var closeReason = reason && reason.length
280
- ? "Worker websocket closed (".concat(code, "): ").concat(reason.toString())
281
- : "Worker websocket closed (".concat(code, ")");
282
- _this.markWorkerDisconnected(closeReason);
283
- setTimeout(function () {
284
- _this.startWorkerInstance();
285
- }, 1000);
286
- if (interval) {
287
- clearInterval(interval);
288
- }
289
- clearTimeout(openTimeout);
290
- });
291
- ws.on('error', function (err) {
292
- var message = (err === null || err === void 0 ? void 0 : err.message) || '';
293
- var statusMatch = message.match(/Unexpected server response:\s*(\d{3})/);
294
- var statusCode = statusMatch ? statusMatch[1] : null;
295
- var isRestartNoise = statusCode === '502';
296
- if (statusCode && !isRestartNoise) {
297
- console.error(new Date(), "Worker WS error: Failure ".concat(statusCode));
298
- }
299
- else if (!isRestartNoise) {
300
- console.error(new Date(), 'Worker WS error:', err);
301
- }
302
- else if (_this._methodManager.getEnableDebug()) {
303
- console.log(new Date(), 'Worker WS reconnecting after main restart', message);
304
- }
305
- _this.markWorkerDisconnected(message || 'Worker websocket error.');
306
- ws.close();
307
- });
308
- };
309
- WorkerServerManager.prototype.handleIncomingTask = function (ws, data) {
310
- return __awaiter(this, void 0, void 0, function () {
311
- var taskId, messageId, method, params, userContext, receivedAt, queuedAt, dispatchedAt, queueWaitMs, dispatchDelayMs, missingMethod, error_1, timedOut, timeoutHandle, managerThis, result, packedResult, meta, publicationPayload, publicationMeta, isPublicationResponse, payload, err_1, errorAt_1, runMs_1, totalMs_1, errorAt, runMs, totalMs;
312
- var _a;
313
- var _this = this;
314
- var _b;
315
- return __generator(this, function (_c) {
316
- switch (_c.label) {
317
- case 0:
318
- taskId = data.taskId, messageId = data.messageId, method = data.method, params = data.params, userContext = data.userContext;
319
- receivedAt = Date.now();
320
- queuedAt = data.queuedAt;
321
- dispatchedAt = data.dispatchedAt;
322
- queueWaitMs = queuedAt && dispatchedAt ? (0, common_1.round)(dispatchedAt - queuedAt) : (queuedAt ? (0, common_1.round)(receivedAt - queuedAt) : null);
323
- dispatchDelayMs = dispatchedAt ? (0, common_1.round)(receivedAt - dispatchedAt) : null;
324
- this._runningTasks.push(taskId);
325
- missingMethod = !method || !this._methodManager.getMethod(method);
326
- if (!(!taskId || !method || missingMethod)) return [3 /*break*/, 5];
327
- if (!missingMethod) return [3 /*break*/, 4];
328
- console.error(new Date(), 'No method in method manager for handleIncomingTask worker server', method);
329
- if (!this._methodManager.getMethod('insertErrorLog')) return [3 /*break*/, 4];
330
- _c.label = 1;
331
- case 1:
332
- _c.trys.push([1, 3, , 4]);
333
- return [4 /*yield*/, this._methodManager.callMethod('insertErrorLog', "No Method in worker server handleIncomingTask: ".concat(method, " - ").concat(JSON.stringify(data, null, 2)))];
334
- case 2:
335
- _c.sent();
336
- return [3 /*break*/, 4];
337
- case 3:
338
- error_1 = _c.sent();
339
- console.error(new Date(), 'insertErrorLog failed in worker-server', error_1);
340
- return [3 /*break*/, 4];
341
- case 4:
342
- // console.log('Invalid task message received', data);
343
- this.logWorkerEvent('workerTaskInvalid', {
344
- taskId: taskId,
345
- method: method,
346
- messageId: messageId,
347
- queueWaitMs: queueWaitMs,
348
- dispatchDelayMs: dispatchDelayMs,
349
- userContext: userContext,
350
- params: params
351
- });
352
- this.sendWorkerResponse(ws, {
353
- type: 'taskComplete',
354
- taskId: taskId,
355
- messageId: messageId,
356
- error: true,
357
- result: 'Invalid task'
358
- });
359
- return [2 /*return*/];
360
- case 5:
361
- timedOut = false;
362
- timeoutHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
363
- var timeoutAt, runMs, totalMs;
364
- return __generator(this, function (_a) {
365
- switch (_a.label) {
366
- case 0:
367
- timedOut = true;
368
- timeoutAt = Date.now();
369
- runMs = (0, common_1.round)(timeoutAt - receivedAt);
370
- totalMs = queuedAt ? (0, common_1.round)(timeoutAt - queuedAt) : null;
371
- console.error(new Date(), 'Worker timed out on task:', taskId, 'Method:', method);
372
- this.logWorkerEvent('workerTaskTimeout', {
373
- taskId: taskId,
374
- method: method,
375
- messageId: messageId,
376
- runMs: runMs,
377
- queueWaitMs: queueWaitMs,
378
- dispatchDelayMs: dispatchDelayMs,
379
- totalMs: totalMs,
380
- userContext: userContext,
381
- params: params
382
- });
383
- this.sendWorkerResponse(ws, {
384
- type: 'taskComplete',
385
- taskId: taskId,
386
- messageId: messageId,
387
- error: true,
388
- result: 'Task timed out'
389
- });
390
- return [4 /*yield*/, this._methodManager.callMethod('insertErrorLog', "Timeout in Method: ".concat(method, " - ").concat(JSON.stringify(data, null, 2)))];
391
- case 1:
392
- _a.sent();
393
- return [2 /*return*/];
394
- }
395
- });
396
- }); }, ((_b = this._methodManager.getMethod(method)) === null || _b === void 0 ? void 0 : _b.timeoutOverride) || (1000 * 60 * 2));
397
- _c.label = 6;
398
- case 6:
399
- _c.trys.push([6, 8, , 10]);
400
- managerThis = Object.assign({}, this._methodManager, method_manager_1.MethodManager.prototype, {
401
- id_user: (userContext === null || userContext === void 0 ? void 0 : userContext.id_user) || '',
402
- user: (userContext === null || userContext === void 0 ? void 0 : userContext.user) || '',
403
- id_ws: (userContext === null || userContext === void 0 ? void 0 : userContext.id_ws) || ''
404
- });
405
- if (this._methodManager.getEnableDebug()) {
406
- console.log(new Date(), 'Running method', method);
407
- }
408
- return [4 /*yield*/, (_a = this._methodManager.callMethod).call.apply(_a, __spreadArray([managerThis, method], __read(params), false))];
409
- case 7:
410
- result = _c.sent();
411
- packedResult = null;
412
- meta = null;
413
- publicationPayload = undefined;
414
- publicationMeta = null;
415
- isPublicationResponse = !!(result && result.__publicationResponse);
416
- try {
417
- if (isPublicationResponse) {
418
- publicationPayload = result.payload;
419
- publicationMeta = {
420
- type: 'publication',
421
- publication: result.publication,
422
- subscriptionData: result.subscriptionData,
423
- userSpecific: result.userSpecific,
424
- snapshot: result.snapshot
425
- };
426
- }
427
- if (isPublicationResponse) {
428
- meta = publicationMeta;
429
- packedResult = (0, msgpackr_1.pack)(publicationPayload);
430
- result = null;
431
- }
432
- else {
433
- packedResult = (0, msgpackr_1.pack)(result);
434
- }
435
- }
436
- catch (packErr) {
437
- console.error(new Date(), 'Worker pack error', packErr);
438
- if (isPublicationResponse) {
439
- meta = publicationMeta;
440
- result = publicationPayload;
441
- }
442
- }
443
- if (this._methodManager.getEnableDebug()) {
444
- console.log(new Date(), 'Finished method', method);
445
- }
446
- if (!timedOut) {
447
- clearTimeout(timeoutHandle);
448
- payload = {
449
- type: 'taskComplete',
450
- taskId: taskId,
451
- messageId: messageId,
452
- error: false,
453
- result: packedResult ? null : result,
454
- packedResult: packedResult,
455
- encoding: 'msgpack',
456
- meta: meta
457
- };
458
- this.sendWorkerResponse(ws, payload);
459
- }
460
- this._runningTasks = this._runningTasks.filter(function (a) { return a !== taskId; });
461
- if (this._methodManager.getEnableDebug()) {
462
- console.log(new Date(), 'Done with Task', JSON.stringify(this._runningTasks, null, 2));
463
- }
464
- return [3 /*break*/, 10];
465
- case 8:
466
- err_1 = _c.sent();
467
- if (!timedOut) {
468
- clearTimeout(timeoutHandle);
469
- errorAt_1 = Date.now();
470
- runMs_1 = (0, common_1.round)(errorAt_1 - receivedAt);
471
- totalMs_1 = queuedAt ? (0, common_1.round)(errorAt_1 - queuedAt) : null;
472
- console.error('Worker failed task:', taskId, 'Method:', method, err_1);
473
- err_1.message = 'Worker failed task:' + taskId + ' Method:' + method + ' - ' + err_1.message;
474
- this.logWorkerEvent('workerTaskError', {
475
- taskId: taskId,
476
- method: method,
477
- messageId: messageId,
478
- runMs: runMs_1,
479
- queueWaitMs: queueWaitMs,
480
- dispatchDelayMs: dispatchDelayMs,
481
- totalMs: totalMs_1,
482
- userContext: userContext,
483
- params: params,
484
- error: err_1
485
- });
486
- this.sendWorkerResponse(ws, {
487
- type: 'taskComplete',
488
- taskId: taskId,
489
- messageId: messageId,
490
- error: true,
491
- result: err_1 || 'Unknown error'
492
- });
493
- throw err_1;
494
- }
495
- errorAt = Date.now();
496
- runMs = (0, common_1.round)(errorAt - receivedAt);
497
- totalMs = queuedAt ? (0, common_1.round)(errorAt - queuedAt) : null;
498
- this.logWorkerEvent('workerTaskError', {
499
- taskId: taskId,
500
- method: method,
501
- messageId: messageId,
502
- runMs: runMs,
503
- queueWaitMs: queueWaitMs,
504
- dispatchDelayMs: dispatchDelayMs,
505
- totalMs: totalMs,
506
- userContext: userContext,
507
- params: params,
508
- error: err_1
509
- });
510
- console.error(new Date(), "Error in Method: ".concat(method, " - ").concat(JSON.stringify(data, null, 2)));
511
- return [4 /*yield*/, this._methodManager.callMethod('insertErrorLog', "Error in Method: ".concat(method, " - ").concat(JSON.stringify(data, null, 2)))];
512
- case 9:
513
- _c.sent();
514
- this._runningTasks = this._runningTasks.filter(function (a) { return a !== taskId; });
515
- return [3 /*break*/, 10];
516
- case 10: return [2 /*return*/];
517
- }
518
- });
519
- });
520
- };
521
- WorkerServerManager.prototype.logWorkerEvent = function (event, details) {
522
- console.log(this.safeStringify(__assign({ ts: new Date().toISOString(), event: event }, details)));
523
- };
524
- WorkerServerManager.prototype.safeStringify = function (value) {
525
- try {
526
- var seen_1 = new WeakSet();
527
- return JSON.stringify(value, function (key, val) {
528
- if (key === '__proto__') {
529
- return undefined;
530
- }
531
- if (typeof val === 'bigint') {
532
- return val.toString();
533
- }
534
- if (val instanceof Error) {
535
- return {
536
- name: val.name,
537
- message: val.message,
538
- stack: val.stack
539
- };
540
- }
541
- if (val && typeof val === 'object') {
542
- if (seen_1.has(val)) {
543
- return '[Circular]';
544
- }
545
- seen_1.add(val);
546
- }
547
- return val;
548
- });
549
- }
550
- catch (err) {
551
- return JSON.stringify({
552
- error: 'safeStringifyFailed',
553
- message: (err === null || err === void 0 ? void 0 : err.message) || String(err)
554
- });
555
- }
556
- };
557
- WorkerServerManager.prototype.sendWorkerResponse = function (ws, payload) {
558
- if (this._methodManager.getEnableDebug()) {
559
- console.log(new Date(), 'Sending', typeof payload === 'string' ? payload : '[binary]');
560
- }
561
- if (ws && ws.readyState === WebSocket.OPEN) {
562
- try {
563
- if (typeof payload === 'string') {
564
- ws.send(payload);
565
- }
566
- else {
567
- ws.send((0, msgpackr_1.pack)(payload));
568
- }
569
- }
570
- catch (err) {
571
- console.error('Failed to send worker response:', err);
572
- }
573
- }
574
- else if (ws) {
575
- ws.close();
576
- }
577
- };
578
- return WorkerServerManager;
579
- }());
580
- exports.WorkerServerManager = WorkerServerManager;
581
-
582
- //# sourceMappingURL=worker-server.manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/managers/worker-server.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAwC;AACxC,8BAAgC;AAEhC,yCAAoD;AACpD,mDAAiD;AAYjD;IAYC;QATQ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C,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,EAAE,IAAI,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,CAAC;gBACJ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBACjC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAClB,CAAC;qBACI,CAAC;oBACL,EAAE,CAAC,IAAI,CAAC,IAAA,eAAI,EAAC,OAAO,CAAC,CAAC,CAAC;gBACxB,CAAC;YACF,CAAC;YACD,OAAO,GAAG,EAAE,CAAC;gBACZ,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACvD,CAAC;QACF,CAAC;aACI,IAAI,EAAE,EAAE,CAAC;YACb,EAAE,CAAC,KAAK,EAAE,CAAC;QACZ,CAAC;IACF,CAAC;IACF,0BAAC;AAAD,CAvgBA,AAugBC,IAAA;AAvgBY,kDAAmB","file":"worker-server.manager.js","sourcesContent":["import { pack, unpack } from 'msgpackr';\nimport * as WebSocket from 'ws';\nimport { TaskPayload, TaskResponse } from '../models/server-message.model';\nimport { dateReviver, round } from '../util/common';\nimport { MethodManager } from './method.manager';\n\nexport interface WorkerServerConnectionHealth {\n\tisConnected: boolean;\n\tlastConnectionAttemptAt: number;\n\tlastConnectedAt: number;\n\tlastDisconnectedAt: number;\n\tconnectionLossStartedAt: number;\n\tcurrentOutageMs: number;\n\tlastDisconnectReason: string;\n}\n\nexport class WorkerServerManager {\n\tprivate _methodManager: MethodManager;\n\tprivate _serverConfig;\n\tprivate _runningTasks = [];\n\tprivate _taskLogThresholdMs = 200;\n\tprivate _isConnected = false;\n\tprivate _lastConnectionAttemptAt = 0;\n\tprivate _lastConnectedAt = 0;\n\tprivate _lastDisconnectedAt = 0;\n\tprivate _connectionLossStartedAt = 0;\n\tprivate _lastDisconnectReason = '';\n\n\tconstructor() {}\n\t\n\tstatic create(methodManager: MethodManager, serverConfig) {\n\t\tconst workerServerManager = new WorkerServerManager();\n\t\tworkerServerManager.initialize(methodManager, serverConfig);\n\t\treturn workerServerManager;\n\t}\n\n\tpublic initialize(methodManager: MethodManager, serverConfig) {\n\t\tthis._methodManager = methodManager;\n\t\tthis._serverConfig = serverConfig;\n\t\tif (this._methodManager && typeof this._methodManager.onReady === 'function') {\n\t\t\tthis._methodManager.onReady(() => this.startWorkerInstance());\n\t\t}\n\t\telse {\n\t\t\tthis.startWorkerInstance();\n\t\t}\n\t}\n\n\tprivate markWorkerConnectionAttempt() {\n\t\tconst now = Date.now();\n\t\tthis._lastConnectionAttemptAt = now;\n\t\tif (!this._isConnected && !this._connectionLossStartedAt) {\n\t\t\tthis._connectionLossStartedAt = now;\n\t\t}\n\t}\n\n\tprivate markWorkerConnected() {\n\t\tconst now = Date.now();\n\t\tthis._isConnected = true;\n\t\tthis._lastConnectedAt = now;\n\t\tthis._lastDisconnectedAt = 0;\n\t\tthis._connectionLossStartedAt = 0;\n\t\tthis._lastDisconnectReason = '';\n\t}\n\n\tprivate markWorkerDisconnected(reason: string) {\n\t\tconst now = Date.now();\n\t\tthis._isConnected = false;\n\t\tthis._lastDisconnectedAt = now;\n\t\tif (!this._connectionLossStartedAt) {\n\t\t\tthis._connectionLossStartedAt = now;\n\t\t}\n\t\tthis._lastDisconnectReason = String(reason || 'Worker websocket disconnected.');\n\t}\n\n\tpublic getConnectionHealth(): WorkerServerConnectionHealth {\n\t\treturn {\n\t\t\tisConnected: this._isConnected,\n\t\t\tlastConnectionAttemptAt: this._lastConnectionAttemptAt,\n\t\t\tlastConnectedAt: this._lastConnectedAt,\n\t\t\tlastDisconnectedAt: this._lastDisconnectedAt,\n\t\t\tconnectionLossStartedAt: this._connectionLossStartedAt,\n\t\t\tcurrentOutageMs: (!this._isConnected && this._connectionLossStartedAt)\n\t\t\t\t? Math.max(0, Date.now() - this._connectionLossStartedAt)\n\t\t\t\t: 0,\n\t\t\tlastDisconnectReason: this._lastDisconnectReason\n\t\t};\n\t}\n\n\tprivate startWorkerInstance() {\n\t\tconst workerIndex = encodeURIComponent(String(process.env.WORKER_INDEX || ''));\n\t\tconst workerInstance = encodeURIComponent(String(process.env.NODE_APP_INSTANCE || ''));\n\t\tconst workerToken = encodeURIComponent(String(this._serverConfig['WORKER_TOKEN'] || ''));\n\t\tlet wsUrl = this._serverConfig['SERVER_URL'] + '/websocket?workerToken=' + workerToken + '&workerIndex=' + workerIndex + '&workerInstance=' + workerInstance;\n\t\tconst ws = new WebSocket(wsUrl);\n\n\t\tthis.markWorkerConnectionAttempt();\n\n\t\tlet lastComm = new Date();\n\t\tlet interval = null;\n\t\tlet missedPongs = 0;\n\t\tconst heartbeatIntervalMs = 15000;\n\t\tconst maxMissedPongs = 2;\n\t\tconst maxSilenceMs = heartbeatIntervalMs * (maxMissedPongs + 1);\n\t\tlet openTimeout = null;\n\t\tlet opened = false;\n\n\t\t// Set timeout if the socket never opens\n\t\topenTimeout = setTimeout(() => {\n\t\t\tif (!opened) {\n\t\t\t\tthis.markWorkerDisconnected('WebSocket connection timeout.');\n\t\t\t\tconsole.error(new Date(), 'WebSocket connection timeout. Retrying...');\n\t\t\t\tws.terminate(); // force close if still connecting\n\t\t\t}\n\t\t}, 10000); // 10 seconds timeout\n\n\t\tws.on('open', () => {\n\t\t\topened = true;\n\t\t\tclearTimeout(openTimeout);\n\t\t\tthis.markWorkerConnected();\n\n\t\t\tconsole.log(new Date(), 'Connected to main server as worker', process.env.WORKER_INDEX, process.env.NODE_APP_INSTANCE);\n\t\t\tthis.sendWorkerResponse(ws, 'ping');\n\n\t\t\tinterval = setInterval(() => {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst last = lastComm ? lastComm.getTime() : 0;\n\t\t\t\tconst silenceMs = last ? now - last : maxSilenceMs + 1;\n\t\t\t\tif (silenceMs > maxSilenceMs || missedPongs > maxMissedPongs) {\n\t\t\t\t\tthis.markWorkerDisconnected('Worker websocket heartbeat timed out.');\n\t\t\t\t\tws.close();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmissedPongs += 1;\n\t\t\t\tthis.sendWorkerResponse(ws, 'ping');\n\t\t\t}, heartbeatIntervalMs);\n\t\t});\n\n\t\tws.on('message', async (rawData: WebSocket.RawData) => {\n\t\t\tlastComm = new Date();\n\t\t\tif (typeof rawData === 'string') {\n\t\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\t\tconsole.log(new Date(), 'Message Recv', rawData);\n\t\t\t\t}\n\n\t\t\t\tif (rawData === 'ping') {\n\t\t\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Recv Ping, Sending Pong');\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tthis.sendWorkerResponse(ws, 'pong');\n\t\t\t\t}\n\t\t\t\telse if (rawData === 'pong') {\n\t\t\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Recv Pong');\n\t\t\t\t\t}\n\t\t\t\t\tmissedPongs = 0;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet msg: any;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmsg = JSON.parse(rawData, dateReviver);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\tconsole.error('Worker parse error', e);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\n\t\t\t\t\tif (msg.type === 'task') {\n\t\t\t\t\t\tawait this.handleIncomingTask(ws, msg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet messageBuffer: Buffer;\n\n\t\t\tif (Buffer.isBuffer(rawData)) {\n\t\t\t\tmessageBuffer = rawData;\n\t\t\t}\n\t\t\telse if (Array.isArray(rawData)) {\n\t\t\t\tconst chunks = rawData as unknown as ReadonlyArray<Uint8Array>;\n\t\t\t\tmessageBuffer = Buffer.concat(chunks);\n\t\t\t}\n\t\t\telse if (rawData instanceof ArrayBuffer) {\n\t\t\t\tmessageBuffer = Buffer.from(rawData);\n\t\t\t}\n\t\t\telse if (ArrayBuffer.isView(rawData)) {\n\t\t\t\tconst view = rawData as NodeJS.ArrayBufferView;\n\t\t\t\tmessageBuffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessageBuffer = Buffer.from(rawData as any);\n\t\t\t}\n\n\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Message Recv (binary)', messageBuffer.length);\n\t\t\t}\n\n\t\t\tif (messageBuffer.length === 4) {\n\t\t\t\tlet heartbeat = messageBuffer.toString('utf8');\n\n\t\t\t\tif (heartbeat === 'ping') {\n\t\t\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Recv Ping (binary), Sending Pong');\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sendWorkerResponse(ws, 'pong');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (heartbeat === 'pong') {\n\t\t\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Recv Pong (binary)');\n\t\t\t\t\t}\n\t\t\t\t\tmissedPongs = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet msg: TaskPayload;\n\n\t\t\ttry {\n\t\t\t\tmsg = unpack(messageBuffer);\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\tconsole.error('Worker binary parse error', e);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (msg.type === 'task') {\n\t\t\t\tawait this.handleIncomingTask(ws, msg);\n\t\t\t}\n\t\t});\n \n\t\tws.on('close', (code, reason) => {\n\t\t\tconst closeReason = reason && reason.length\n\t\t\t\t? `Worker websocket closed (${code}): ${reason.toString()}`\n\t\t\t\t: `Worker websocket closed (${code})`;\n\t\t\tthis.markWorkerDisconnected(closeReason);\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.startWorkerInstance();\n\t\t\t}, 1000);\n\n\t\t\tif (interval) {\n\t\t\t\tclearInterval(interval);\n\t\t\t}\n\t\t\tclearTimeout(openTimeout);\n\t\t});\n\n\t\tws.on('error', (err) => {\n\t\t\tconst message = err?.message || '';\n\t\t\tconst statusMatch = message.match(/Unexpected server response:\\s*(\\d{3})/);\n\t\t\tconst statusCode = statusMatch ? statusMatch[1] : null;\n\t\t\tconst isRestartNoise = statusCode === '502';\n\t\t\tif (statusCode && !isRestartNoise) {\n\t\t\t\tconsole.error(new Date(), `Worker WS error: Failure ${statusCode}`);\n\t\t\t}\n\t\t\telse if (!isRestartNoise) {\n\t\t\t\tconsole.error(new Date(), 'Worker WS error:', err);\n\t\t\t}\n\t\t\telse if (this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Worker WS reconnecting after main restart', message);\n\t\t\t}\n\t\t\tthis.markWorkerDisconnected(message || 'Worker websocket error.');\n\t\t\tws.close();\n\t\t});\n\t}\n\n private async handleIncomingTask(ws: WebSocket.WebSocket, data: TaskPayload) {\n let { taskId, messageId, method, params, userContext } = data;\n\t\tconst receivedAt = Date.now();\n\t\tconst queuedAt = data.queuedAt;\n\t\tconst dispatchedAt = data.dispatchedAt;\n\t\tconst queueWaitMs = queuedAt && dispatchedAt ? round(dispatchedAt - queuedAt) : (queuedAt ? round(receivedAt - queuedAt) : null);\n\t\tconst dispatchDelayMs = dispatchedAt ? round(receivedAt - dispatchedAt) : null;\n this._runningTasks.push(taskId);\n const missingMethod = !method || !this._methodManager.getMethod(method);\n if (!taskId || !method || missingMethod) {\n if (missingMethod) {\n console.error(new Date(), 'No method in method manager for handleIncomingTask worker server', method);\n\t\t\t\tif (this._methodManager.getMethod('insertErrorLog')) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._methodManager.callMethod('insertErrorLog', `No Method in worker server handleIncomingTask: ${method} - ${JSON.stringify(data, null, 2)}`);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\tconsole.error(new Date(), 'insertErrorLog failed in worker-server', error);\n\t\t\t\t\t}\n\t\t\t\t}\n }\n\n // console.log('Invalid task message received', data);\n\t\t\tthis.logWorkerEvent('workerTaskInvalid', {\n\t\t\t\ttaskId,\n\t\t\t\tmethod,\n\t\t\t\tmessageId,\n\t\t\t\tqueueWaitMs,\n\t\t\t\tdispatchDelayMs,\n\t\t\t\tuserContext,\n\t\t\t\tparams\n\t\t\t});\n this.sendWorkerResponse(ws, {\n type: 'taskComplete',\n taskId,\n messageId,\n error: true,\n result: 'Invalid task'\n });\n\n return;\n }\n\n let timedOut = false;\n let timeoutHandle = setTimeout(async () => {\n timedOut = true;\n\t\t\tconst timeoutAt = Date.now();\n\t\t\tconst runMs = round(timeoutAt - receivedAt);\n\t\t\tconst totalMs = queuedAt ? round(timeoutAt - queuedAt) : null;\n console.error(new Date(), 'Worker timed out on task:', taskId, 'Method:', method);\n\n\t\t\tthis.logWorkerEvent('workerTaskTimeout', {\n\t\t\t\ttaskId,\n\t\t\t\tmethod,\n\t\t\t\tmessageId,\n\t\t\t\trunMs,\n\t\t\t\tqueueWaitMs,\n\t\t\t\tdispatchDelayMs,\n\t\t\t\ttotalMs,\n\t\t\t\tuserContext,\n\t\t\t\tparams\n\t\t\t});\n\n this.sendWorkerResponse(ws, {\n type: 'taskComplete',\n taskId,\n messageId,\n error: true,\n result: 'Task timed out'\n });\n\n await this._methodManager.callMethod('insertErrorLog', `Timeout in Method: ${method} - ${JSON.stringify(data, null, 2)}`);\n }, this._methodManager.getMethod(method)?.timeoutOverride || (1000 * 60 * 2));\n\n try {\n let managerThis = Object.assign({}, this._methodManager, MethodManager.prototype, {\n id_user: userContext?.id_user || '',\n user: userContext?.user || '',\n id_ws: userContext?.id_ws || ''\n });\n\n if (this._methodManager.getEnableDebug()) {\n console.log(new Date(), 'Running method', method);\n }\n\n\t\t\tlet result = await this._methodManager.callMethod.call(managerThis, method, ...params);\n\t\t\tlet packedResult: Uint8Array | Buffer = null;\n\t\t\tlet meta: Record<string, any> = null;\n\t\t\tlet publicationPayload: any = undefined;\n\t\t\tlet publicationMeta: Record<string, any> = null;\n\t\t\tconst isPublicationResponse = !!(result && result.__publicationResponse);\n\n\t\t\ttry {\n\t\t\t\tif (isPublicationResponse) {\n\t\t\t\t\tpublicationPayload = result.payload;\n\t\t\t\t\tpublicationMeta = {\n\t\t\t\t\t\ttype: 'publication',\n\t\t\t\t\t\tpublication: result.publication,\n\t\t\t\t\t\tsubscriptionData: result.subscriptionData,\n\t\t\t\t\t\tuserSpecific: result.userSpecific,\n\t\t\t\t\t\tsnapshot: result.snapshot\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (isPublicationResponse) {\n\t\t\t\t\tmeta = publicationMeta;\n\t\t\t\t\tpackedResult = <Buffer>pack(publicationPayload);\n\t\t\t\t\tresult = null;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tpackedResult = <Buffer>pack(result);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (packErr) {\n\t\t\t\tconsole.error(new Date(), 'Worker pack error', packErr);\n\t\t\t\tif (isPublicationResponse) {\n\t\t\t\t\tmeta = publicationMeta;\n\t\t\t\t\tresult = publicationPayload;\n\t\t\t\t}\n\t\t\t}\n\n\n\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Finished method', method);\n\t\t\t}\n\n\t\t\tif (!timedOut) {\n\t\t\t\tclearTimeout(timeoutHandle);\n\t\t\t\tconst payload: TaskResponse = {\n\t\t\t\t\ttype: 'taskComplete',\n\t\t\t\t\ttaskId,\n\t\t\t\t\tmessageId,\n\t\t\t\t\terror: false,\n\t\t\t\t\tresult: packedResult ? null : result,\n\t\t\t\t\tpackedResult,\n\t\t\t\t\tencoding: 'msgpack',\n\t\t\t\t\tmeta\n\t\t\t\t};\n\n\t\t\t\tthis.sendWorkerResponse(ws, payload);\n\t\t\t}\n\n this._runningTasks = this._runningTasks.filter(a => a !== taskId);\n \n if (this._methodManager.getEnableDebug()) {\n console.log(new Date(), 'Done with Task', JSON.stringify(this._runningTasks, null, 2));\n }\n }\n catch (err) {\n if (!timedOut) {\n clearTimeout(timeoutHandle);\n\t\t\t\tconst errorAt = Date.now();\n\t\t\t\tconst runMs = round(errorAt - receivedAt);\n\t\t\t\tconst totalMs = queuedAt ? round(errorAt - queuedAt) : null;\n console.error('Worker failed task:', taskId, 'Method:', method, err);\n err.message = 'Worker failed task:' + taskId + ' Method:' + method + ' - ' + err.message;\n\t\t\t\tthis.logWorkerEvent('workerTaskError', {\n\t\t\t\t\ttaskId,\n\t\t\t\t\tmethod,\n\t\t\t\t\tmessageId,\n\t\t\t\t\trunMs,\n\t\t\t\t\tqueueWaitMs,\n\t\t\t\t\tdispatchDelayMs,\n\t\t\t\t\ttotalMs,\n\t\t\t\t\tuserContext,\n\t\t\t\t\tparams,\n\t\t\t\t\terror: err\n\t\t\t\t});\n this.sendWorkerResponse(ws, {\n type: 'taskComplete',\n taskId,\n messageId,\n error: true,\n result: err || 'Unknown error'\n });\n throw err;\n }\n\n\t\t\tconst errorAt = Date.now();\n\t\t\tconst runMs = round(errorAt - receivedAt);\n\t\t\tconst totalMs = queuedAt ? round(errorAt - queuedAt) : null;\n\t\t\tthis.logWorkerEvent('workerTaskError', {\n\t\t\t\ttaskId,\n\t\t\t\tmethod,\n\t\t\t\tmessageId,\n\t\t\t\trunMs,\n\t\t\t\tqueueWaitMs,\n\t\t\t\tdispatchDelayMs,\n\t\t\t\ttotalMs,\n\t\t\t\tuserContext,\n\t\t\t\tparams,\n\t\t\t\terror: err\n\t\t\t});\n\n console.error(new Date(), `Error in Method: ${method} - ${JSON.stringify(data, null, 2)}`);\n \n await this._methodManager.callMethod('insertErrorLog', `Error in Method: ${method} - ${JSON.stringify(data, null, 2)}`);\n \n this._runningTasks = this._runningTasks.filter(a => a !== taskId);\n }\n }\n\n\tprivate logWorkerEvent(event: string, details: Record<string, any>) {\n\t\tconsole.log(this.safeStringify({\n\t\t\tts: new Date().toISOString(),\n\t\t\tevent,\n\t\t\t...details\n\t\t}));\n\t}\n\n\tprivate safeStringify(value: any): string {\n\t\ttry {\n\t\t\tconst seen = new WeakSet();\n\t\t\treturn JSON.stringify(value, (key, val) => {\n\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (typeof val === 'bigint') {\n\t\t\t\t\treturn val.toString();\n\t\t\t\t}\n\t\t\t\tif (val instanceof Error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: val.name,\n\t\t\t\t\t\tmessage: val.message,\n\t\t\t\t\t\tstack: val.stack\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (val && typeof val === 'object') {\n\t\t\t\t\tif (seen.has(val)) {\n\t\t\t\t\t\treturn '[Circular]';\n\t\t\t\t\t}\n\t\t\t\t\tseen.add(val);\n\t\t\t\t}\n\t\t\t\treturn val;\n\t\t\t});\n\t\t}\n\t\tcatch (err) {\n\t\t\treturn JSON.stringify({\n\t\t\t\terror: 'safeStringifyFailed',\n\t\t\t\tmessage: err?.message || String(err)\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic sendWorkerResponse(ws, payload: TaskResponse | string) {\n\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\tconsole.log(new Date(), 'Sending', typeof payload === 'string' ? payload : '[binary]');\n\t\t}\n\n\t\tif (ws && ws.readyState === WebSocket.OPEN) {\n\t\t\ttry {\n\t\t\t\tif (typeof payload === 'string') {\n\t\t\t\t\tws.send(payload);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tws.send(pack(payload));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconsole.error('Failed to send worker response:', err);\n\t\t\t}\n\t\t}\n\t\telse if (ws) {\n\t\t\tws.close();\n\t\t}\n\t}\n}\n"]}