@resolveio/server-lib 22.3.221 → 22.3.223
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.
- package/ai/assistant-core-heuristics.d.ts +11 -0
- package/ai/assistant-core-heuristics.js +356 -0
- package/ai/assistant-core-heuristics.js.map +1 -0
- package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +3 -0
- package/ai/resolveio-platform-intelligence-memory-corpus.js +214 -0
- package/ai/resolveio-platform-intelligence-memory-corpus.js.map +1 -0
- package/ai/resolveio-platform-intelligence-memory.d.ts +20 -0
- package/ai/resolveio-platform-intelligence-memory.js +341 -0
- package/ai/resolveio-platform-intelligence-memory.js.map +1 -0
- package/{src/ai/resolveio-platform-intelligence-types.ts → ai/resolveio-platform-intelligence-types.d.ts} +15 -20
- package/ai/resolveio-platform-intelligence-types.js +4 -0
- package/ai/resolveio-platform-intelligence-types.js.map +1 -0
- package/ai/resolveio-platform-intelligence.d.ts +6 -0
- package/ai/resolveio-platform-intelligence.js +463 -0
- package/ai/resolveio-platform-intelligence.js.map +1 -0
- package/client-server-app.d.ts +1 -0
- package/client-server-app.js +68 -0
- package/client-server-app.js.map +1 -0
- package/collections/ai-run.collection.d.ts +3 -0
- package/collections/ai-run.collection.js +170 -0
- package/collections/ai-run.collection.js.map +1 -0
- package/collections/ai-terminal-conversation.collection.d.ts +2 -0
- package/collections/ai-terminal-conversation.collection.js +140 -0
- package/collections/ai-terminal-conversation.collection.js.map +1 -0
- package/collections/ai-terminal-issue-report.collection.d.ts +2 -0
- package/collections/ai-terminal-issue-report.collection.js +148 -0
- package/collections/ai-terminal-issue-report.collection.js.map +1 -0
- package/collections/ai-terminal-message.collection.d.ts +2 -0
- package/collections/ai-terminal-message.collection.js +121 -0
- package/collections/ai-terminal-message.collection.js.map +1 -0
- package/collections/app-setting.collection.d.ts +3 -0
- package/collections/app-setting.collection.js +103 -0
- package/collections/app-setting.collection.js.map +1 -0
- package/collections/app-status.collection.d.ts +3 -0
- package/collections/app-status.collection.js +57 -0
- package/collections/app-status.collection.js.map +1 -0
- package/collections/communication-metric.collection.d.ts +2 -0
- package/collections/communication-metric.collection.js +133 -0
- package/collections/communication-metric.collection.js.map +1 -0
- package/collections/counter.collection.d.ts +3 -0
- package/collections/counter.collection.js +56 -0
- package/collections/counter.collection.js.map +1 -0
- package/collections/cron-job-history.collection.d.ts +3 -0
- package/collections/cron-job-history.collection.js +137 -0
- package/collections/cron-job-history.collection.js.map +1 -0
- package/collections/cron-job.collection.d.ts +3 -0
- package/collections/cron-job.collection.js +92 -0
- package/collections/cron-job.collection.js.map +1 -0
- package/collections/customer-notification.collection.d.ts +3 -0
- package/collections/customer-notification.collection.js +130 -0
- package/collections/customer-notification.collection.js.map +1 -0
- package/collections/customer-portal-password.collection.d.ts +3 -0
- package/collections/customer-portal-password.collection.js +75 -0
- package/collections/customer-portal-password.collection.js.map +1 -0
- package/collections/email-history.collection.d.ts +3 -0
- package/collections/email-history.collection.js +134 -0
- package/collections/email-history.collection.js.map +1 -0
- package/collections/email-verified.collection.d.ts +3 -0
- package/collections/email-verified.collection.js +62 -0
- package/collections/email-verified.collection.js.map +1 -0
- package/collections/file.collection.d.ts +3 -0
- package/collections/file.collection.js +74 -0
- package/collections/file.collection.js.map +1 -0
- package/collections/flag-update.collection.d.ts +3 -0
- package/collections/flag-update.collection.js +57 -0
- package/collections/flag-update.collection.js.map +1 -0
- package/collections/flag.collection.d.ts +3 -0
- package/collections/flag.collection.js +57 -0
- package/collections/flag.collection.js.map +1 -0
- package/collections/log-method-latency.collection.d.ts +3 -0
- package/collections/log-method-latency.collection.js +77 -0
- package/collections/log-method-latency.collection.js.map +1 -0
- package/collections/log-subscription.collection.d.ts +3 -0
- package/collections/log-subscription.collection.js +80 -0
- package/collections/log-subscription.collection.js.map +1 -0
- package/collections/log.collection.d.ts +3 -0
- package/collections/log.collection.js +93 -0
- package/collections/log.collection.js.map +1 -0
- package/collections/logged-in-users.collection.d.ts +3 -0
- package/collections/logged-in-users.collection.js +67 -0
- package/collections/logged-in-users.collection.js.map +1 -0
- package/collections/monitor-cpu.collection.d.ts +3 -0
- package/collections/monitor-cpu.collection.js +65 -0
- package/collections/monitor-cpu.collection.js.map +1 -0
- package/collections/monitor-function.collection.d.ts +3 -0
- package/collections/monitor-function.collection.js +74 -0
- package/collections/monitor-function.collection.js.map +1 -0
- package/collections/monitor-memory.collection.d.ts +3 -0
- package/collections/monitor-memory.collection.js +77 -0
- package/collections/monitor-memory.collection.js.map +1 -0
- package/collections/monitor-mongo.collection.d.ts +3 -0
- package/collections/monitor-mongo.collection.js +71 -0
- package/collections/monitor-mongo.collection.js.map +1 -0
- package/collections/notification.collection.d.ts +3 -0
- package/collections/notification.collection.js +57 -0
- package/collections/notification.collection.js.map +1 -0
- package/collections/openai-usage-ledger.collection.d.ts +2 -0
- package/collections/openai-usage-ledger.collection.js +188 -0
- package/collections/openai-usage-ledger.collection.js.map +1 -0
- package/collections/report-builder-dashboard-builder.collection.d.ts +3 -0
- package/collections/report-builder-dashboard-builder.collection.js +109 -0
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -0
- package/collections/report-builder-library.collection.d.ts +3 -0
- package/collections/report-builder-library.collection.js +87 -0
- package/collections/report-builder-library.collection.js.map +1 -0
- package/collections/report-builder-report.collection.d.ts +4 -0
- package/collections/report-builder-report.collection.js +184 -0
- package/collections/report-builder-report.collection.js.map +1 -0
- package/collections/user-group.collection.d.ts +4 -0
- package/collections/user-group.collection.js +89 -0
- package/collections/user-group.collection.js.map +1 -0
- package/collections/user-guide.collection.d.ts +3 -0
- package/collections/user-guide.collection.js +57 -0
- package/collections/user-guide.collection.js.map +1 -0
- package/collections/user.collection.d.ts +4 -0
- package/collections/user.collection.js +180 -0
- package/collections/user.collection.js.map +1 -0
- package/cron/cron.d.ts +14 -0
- package/cron/cron.js +216 -0
- package/cron/cron.js.map +1 -0
- package/fixtures/cron-jobs.d.ts +1 -0
- package/fixtures/cron-jobs.js +150 -0
- package/fixtures/cron-jobs.js.map +1 -0
- package/fixtures/init.d.ts +1 -0
- package/fixtures/init.js +91 -0
- package/fixtures/init.js.map +1 -0
- package/http/auth.d.ts +2 -0
- package/http/auth.js +951 -0
- package/http/auth.js.map +1 -0
- package/http/health.d.ts +1 -0
- package/http/health.js +11 -0
- package/http/health.js.map +1 -0
- package/http/home.d.ts +1 -0
- package/http/home.js +134 -0
- package/http/home.js.map +1 -0
- package/http/slow-query-publication.d.ts +2 -0
- package/http/slow-query-publication.js +99 -0
- package/http/slow-query-publication.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/index.js.map +1 -0
- package/managers/ai-assistant-codex-manager.manager.d.ts +67 -0
- package/managers/ai-assistant-codex-manager.manager.js +1113 -0
- package/managers/ai-assistant-codex-manager.manager.js.map +1 -0
- package/managers/ai-run-evidence.manager.d.ts +36 -0
- package/managers/ai-run-evidence.manager.js +377 -0
- package/managers/ai-run-evidence.manager.js.map +1 -0
- package/managers/communication-metric.manager.d.ts +16 -0
- package/managers/communication-metric.manager.js +134 -0
- package/managers/communication-metric.manager.js.map +1 -0
- package/managers/cron.manager.d.ts +20 -0
- package/managers/cron.manager.js +534 -0
- package/managers/cron.manager.js.map +1 -0
- package/managers/customer-notification-content.manager.d.ts +55 -0
- package/managers/customer-notification-content.manager.js +158 -0
- package/managers/customer-notification-content.manager.js.map +1 -0
- package/managers/diagnostic-manager-bootstrap.d.ts +9 -0
- package/managers/diagnostic-manager-bootstrap.js +260 -0
- package/managers/diagnostic-manager-bootstrap.js.map +1 -0
- package/managers/error-auto-fix.manager.d.ts +149 -0
- package/managers/error-auto-fix.manager.js +3064 -0
- package/managers/error-auto-fix.manager.js.map +1 -0
- package/managers/local-log.manager.d.ts +18 -0
- package/managers/local-log.manager.js +88 -0
- package/managers/local-log.manager.js.map +1 -0
- package/managers/method.manager.d.ts +84 -0
- package/managers/method.manager.js +1964 -0
- package/managers/method.manager.js.map +1 -0
- package/managers/mongo.manager.d.ts +224 -0
- package/managers/mongo.manager.js +5000 -0
- package/managers/mongo.manager.js.map +1 -0
- package/managers/monitor.manager.d.ts +70 -0
- package/managers/monitor.manager.js +550 -0
- package/managers/monitor.manager.js.map +1 -0
- package/managers/openai-usage-ledger.manager.d.ts +30 -0
- package/managers/openai-usage-ledger.manager.js +142 -0
- package/managers/openai-usage-ledger.manager.js.map +1 -0
- package/managers/slow-query-verifier.manager.d.ts +144 -0
- package/managers/slow-query-verifier.manager.js +3857 -0
- package/managers/slow-query-verifier.manager.js.map +1 -0
- package/managers/slow-query.manager.d.ts +28 -0
- package/managers/slow-query.manager.js +468 -0
- package/managers/slow-query.manager.js.map +1 -0
- package/managers/subscription.manager.d.ts +169 -0
- package/managers/subscription.manager.js +3434 -0
- package/managers/subscription.manager.js.map +1 -0
- package/managers/websocket.manager.d.ts +73 -0
- package/managers/websocket.manager.js +673 -0
- package/managers/websocket.manager.js.map +1 -0
- package/managers/worker-dispatcher.manager.d.ts +120 -0
- package/managers/worker-dispatcher.manager.js +1266 -0
- package/managers/worker-dispatcher.manager.js.map +1 -0
- package/managers/worker-server.manager.d.ts +35 -0
- package/managers/worker-server.manager.js +582 -0
- package/managers/worker-server.manager.js.map +1 -0
- package/methods/accounts.d.ts +2 -0
- package/methods/accounts.js +624 -0
- package/methods/accounts.js.map +1 -0
- package/methods/ai-terminal.d.ts +458 -0
- package/methods/ai-terminal.js +27991 -0
- package/methods/ai-terminal.js.map +1 -0
- package/methods/app-settings.d.ts +2 -0
- package/methods/app-settings.js +169 -0
- package/methods/app-settings.js.map +1 -0
- package/methods/aws.d.ts +2 -0
- package/methods/aws.js +877 -0
- package/methods/aws.js.map +1 -0
- package/methods/collections.d.ts +2 -0
- package/methods/collections.js +719 -0
- package/methods/collections.js.map +1 -0
- package/methods/counters.d.ts +2 -0
- package/methods/counters.js +113 -0
- package/methods/counters.js.map +1 -0
- package/methods/cron-jobs.d.ts +2 -0
- package/methods/cron-jobs.js +2475 -0
- package/methods/cron-jobs.js.map +1 -0
- package/methods/customer-notifications.d.ts +2 -0
- package/methods/customer-notifications.js +528 -0
- package/methods/customer-notifications.js.map +1 -0
- package/methods/diagnostics.d.ts +2 -0
- package/methods/diagnostics.js +703 -0
- package/methods/diagnostics.js.map +1 -0
- package/methods/flag-updates.d.ts +2 -0
- package/methods/flag-updates.js +8 -0
- package/methods/flag-updates.js.map +1 -0
- package/methods/flags.d.ts +2 -0
- package/methods/flags.js +8 -0
- package/methods/flags.js.map +1 -0
- package/methods/logs.d.ts +2 -0
- package/methods/logs.js +751 -0
- package/methods/logs.js.map +1 -0
- package/methods/mongo-explorer.d.ts +2 -0
- package/methods/mongo-explorer.js +1808 -0
- package/methods/mongo-explorer.js.map +1 -0
- package/methods/monitor.d.ts +2 -0
- package/methods/monitor.js +543 -0
- package/methods/monitor.js.map +1 -0
- package/methods/pdf.d.ts +2 -0
- package/methods/pdf.js +1216 -0
- package/methods/pdf.js.map +1 -0
- package/methods/publications.d.ts +1 -0
- package/methods/publications.js +183 -0
- package/methods/publications.js.map +1 -0
- package/methods/report-builder.d.ts +2 -0
- package/methods/report-builder.js +3094 -0
- package/methods/report-builder.js.map +1 -0
- package/methods/support.d.ts +2 -0
- package/methods/support.js +430 -0
- package/methods/support.js.map +1 -0
- package/models/ai-run.model.d.ts +19 -0
- package/models/ai-run.model.js +4 -0
- package/models/ai-run.model.js.map +1 -0
- package/models/ai-terminal-conversation.model.d.ts +17 -0
- package/models/ai-terminal-conversation.model.js +4 -0
- package/models/ai-terminal-conversation.model.js.map +1 -0
- package/models/ai-terminal-issue-report.model.d.ts +19 -0
- package/models/ai-terminal-issue-report.model.js +4 -0
- package/models/ai-terminal-issue-report.model.js.map +1 -0
- package/models/ai-terminal-message.model.d.ts +22 -0
- package/models/ai-terminal-message.model.js +4 -0
- package/models/ai-terminal-message.model.js.map +1 -0
- package/models/app-setting.model.d.ts +16 -0
- package/models/app-setting.model.js +4 -0
- package/models/app-setting.model.js.map +1 -0
- package/{src/models/app-status.model.ts → models/app-status.model.d.ts} +2 -3
- package/models/app-status.model.js +4 -0
- package/models/app-status.model.js.map +1 -0
- package/{src/models/billing-logged-in-users.model.ts → models/billing-logged-in-users.model.d.ts} +4 -5
- package/models/billing-logged-in-users.model.js +4 -0
- package/models/billing-logged-in-users.model.js.map +1 -0
- package/models/collection-document.model.d.ts +21 -0
- package/models/collection-document.model.js +4 -0
- package/models/collection-document.model.js.map +1 -0
- package/models/communication-metric.model.d.ts +20 -0
- package/models/communication-metric.model.js +4 -0
- package/models/communication-metric.model.js.map +1 -0
- package/{src/models/counter.model.ts → models/counter.model.d.ts} +3 -4
- package/models/counter.model.js +4 -0
- package/models/counter.model.js.map +1 -0
- package/models/cron-job-history.model.d.ts +15 -0
- package/models/cron-job-history.model.js +4 -0
- package/models/cron-job-history.model.js.map +1 -0
- package/models/cron-job.model.d.ts +14 -0
- package/models/cron-job.model.js +4 -0
- package/models/cron-job.model.js.map +1 -0
- package/models/customer-notification.model.d.ts +26 -0
- package/models/customer-notification.model.js +4 -0
- package/models/customer-notification.model.js.map +1 -0
- package/models/customer-portal-password.model.d.ts +11 -0
- package/models/customer-portal-password.model.js +4 -0
- package/models/customer-portal-password.model.js.map +1 -0
- package/models/dialog.model.d.ts +23 -0
- package/models/dialog.model.js +4 -0
- package/models/dialog.model.js.map +1 -0
- package/models/email-history.model.d.ts +32 -0
- package/{src/models/email-history.model.ts → models/email-history.model.js} +4 -36
- package/models/email-history.model.js.map +1 -0
- package/{src/models/email-verified.model.ts → models/email-verified.model.d.ts} +5 -6
- package/models/email-verified.model.js +4 -0
- package/models/email-verified.model.js.map +1 -0
- package/{src/models/file.model.ts → models/file.model.d.ts} +7 -8
- package/models/file.model.js +4 -0
- package/models/file.model.js.map +1 -0
- package/{src/models/flag-update.model.ts → models/flag-update.model.d.ts} +3 -4
- package/models/flag-update.model.js +4 -0
- package/models/flag-update.model.js.map +1 -0
- package/{src/models/flag.model.ts → models/flag.model.d.ts} +3 -4
- package/models/flag.model.js +4 -0
- package/models/flag.model.js.map +1 -0
- package/models/log-method-latency.model.d.ts +10 -0
- package/models/log-method-latency.model.js +4 -0
- package/models/log-method-latency.model.js.map +1 -0
- package/{src/models/log-subscription.model.ts → models/log-subscription.model.d.ts} +9 -11
- package/models/log-subscription.model.js +4 -0
- package/models/log-subscription.model.js.map +1 -0
- package/models/log.model.d.ts +17 -0
- package/models/log.model.js +4 -0
- package/models/log.model.js.map +1 -0
- package/{src/models/logged-in-users.model.ts → models/logged-in-users.model.d.ts} +5 -6
- package/models/logged-in-users.model.js +4 -0
- package/models/logged-in-users.model.js.map +1 -0
- package/{src/models/method-response.model.ts → models/method-response.model.d.ts} +6 -7
- package/models/method-response.model.js +4 -0
- package/models/method-response.model.js.map +1 -0
- package/models/method.model.d.ts +26 -0
- package/models/method.model.js +4 -0
- package/models/method.model.js.map +1 -0
- package/{src/models/monitor-cpu.model.ts → models/monitor-cpu.model.d.ts} +7 -9
- package/models/monitor-cpu.model.js +4 -0
- package/models/monitor-cpu.model.js.map +1 -0
- package/models/monitor-function.model.d.ts +14 -0
- package/models/monitor-function.model.js +4 -0
- package/models/monitor-function.model.js.map +1 -0
- package/models/monitor-memory.model.d.ts +15 -0
- package/models/monitor-memory.model.js +4 -0
- package/models/monitor-memory.model.js.map +1 -0
- package/models/monitor-mongo.model.d.ts +13 -0
- package/models/monitor-mongo.model.js +4 -0
- package/models/monitor-mongo.model.js.map +1 -0
- package/{src/models/notification.model.ts → models/notification.model.d.ts} +4 -6
- package/models/notification.model.js +4 -0
- package/models/notification.model.js.map +1 -0
- package/models/openai-usage-ledger.model.d.ts +30 -0
- package/models/openai-usage-ledger.model.js +4 -0
- package/models/openai-usage-ledger.model.js.map +1 -0
- package/models/pagination.model.d.ts +11 -0
- package/models/pagination.model.js +28 -0
- package/models/pagination.model.js.map +1 -0
- package/models/permission.model.d.ts +12 -0
- package/models/permission.model.js +4 -0
- package/models/permission.model.js.map +1 -0
- package/models/report-builder-dashboard-builder.model.d.ts +25 -0
- package/models/report-builder-dashboard-builder.model.js +4 -0
- package/models/report-builder-dashboard-builder.model.js.map +1 -0
- package/models/report-builder-library.model.d.ts +17 -0
- package/models/report-builder-library.model.js +4 -0
- package/models/report-builder-library.model.js.map +1 -0
- package/models/report-builder-report.model.d.ts +121 -0
- package/models/report-builder-report.model.js +4 -0
- package/models/report-builder-report.model.js.map +1 -0
- package/models/report-builder.model.d.ts +61 -0
- package/models/report-builder.model.js +4 -0
- package/models/report-builder.model.js.map +1 -0
- package/models/select-data-label.model.d.ts +9 -0
- package/models/select-data-label.model.js +4 -0
- package/models/select-data-label.model.js.map +1 -0
- package/models/server-message.model.d.ts +32 -0
- package/models/server-message.model.js +4 -0
- package/models/server-message.model.js.map +1 -0
- package/models/slow-query-report.model.d.ts +23 -0
- package/models/slow-query-report.model.js +4 -0
- package/models/slow-query-report.model.js.map +1 -0
- package/models/subscription.model.d.ts +31 -0
- package/models/subscription.model.js +4 -0
- package/models/subscription.model.js.map +1 -0
- package/models/support-ticket.model.d.ts +87 -0
- package/models/support-ticket.model.js +4 -0
- package/models/support-ticket.model.js.map +1 -0
- package/models/user-group.model.d.ts +20 -0
- package/models/user-group.model.js +4 -0
- package/models/user-group.model.js.map +1 -0
- package/{src/models/user-guide.model.ts → models/user-guide.model.d.ts} +4 -5
- package/models/user-guide.model.js +4 -0
- package/models/user-guide.model.js.map +1 -0
- package/models/user.model.d.ts +84 -0
- package/models/user.model.js +4 -0
- package/models/user.model.js.map +1 -0
- package/package.json +1 -1
- package/private/images/ResolveIO.png +0 -0
- package/public_api.js +127 -0
- package/public_api.js.map +1 -0
- package/publications/ai-terminal.d.ts +1 -0
- package/publications/ai-terminal.js +122 -0
- package/publications/ai-terminal.js.map +1 -0
- package/publications/app-settings.d.ts +2 -0
- package/publications/app-settings.js +28 -0
- package/publications/app-settings.js.map +1 -0
- package/publications/app-status.d.ts +2 -0
- package/publications/app-status.js +16 -0
- package/publications/app-status.js.map +1 -0
- package/publications/cron-jobs.d.ts +2 -0
- package/publications/cron-jobs.js +88 -0
- package/publications/cron-jobs.js.map +1 -0
- package/publications/customer-notifications.d.ts +2 -0
- package/publications/customer-notifications.js +161 -0
- package/publications/customer-notifications.js.map +1 -0
- package/publications/files.d.ts +2 -0
- package/publications/files.js +36 -0
- package/publications/files.js.map +1 -0
- package/publications/flags-update.d.ts +2 -0
- package/publications/flags-update.js +22 -0
- package/publications/flags-update.js.map +1 -0
- package/publications/flags.d.ts +2 -0
- package/publications/flags.js +22 -0
- package/publications/flags.js.map +1 -0
- package/publications/logs.d.ts +2 -0
- package/publications/logs.js +164 -0
- package/publications/logs.js.map +1 -0
- package/publications/notifications.d.ts +2 -0
- package/publications/notifications.js +16 -0
- package/publications/notifications.js.map +1 -0
- package/publications/report-builder-dashboard-builders.d.ts +2 -0
- package/publications/report-builder-dashboard-builders.js +42 -0
- package/publications/report-builder-dashboard-builders.js.map +1 -0
- package/publications/report-builder-libraries.d.ts +2 -0
- package/publications/report-builder-libraries.js +90 -0
- package/publications/report-builder-libraries.js.map +1 -0
- package/publications/report-builder-reports.d.ts +2 -0
- package/publications/report-builder-reports.js +50 -0
- package/publications/report-builder-reports.js.map +1 -0
- package/publications/super-admin.d.ts +2 -0
- package/publications/super-admin.js +16 -0
- package/publications/super-admin.js.map +1 -0
- package/publications/user-groups.d.ts +1 -0
- package/publications/user-groups.js +16 -0
- package/publications/user-groups.js.map +1 -0
- package/publications/user-guides.d.ts +1 -0
- package/publications/user-guides.js +16 -0
- package/publications/user-guides.js.map +1 -0
- package/resolveio-server-app.d.ts +70 -0
- package/resolveio-server-app.js +801 -0
- package/resolveio-server-app.js.map +1 -0
- package/server-app.d.ts +228 -0
- package/server-app.js +3566 -0
- package/server-app.js.map +1 -0
- package/services/codex-client.d.ts +128 -0
- package/services/codex-client.js +1629 -0
- package/services/codex-client.js.map +1 -0
- package/services/openai-client.d.ts +46 -0
- package/services/openai-client.js +318 -0
- package/services/openai-client.js.map +1 -0
- package/types/error-report.d.ts +25 -0
- package/types/error-report.js +4 -0
- package/types/error-report.js.map +1 -0
- package/types/slow-query-report.d.ts +27 -0
- package/types/slow-query-report.js +6 -0
- package/types/slow-query-report.js.map +1 -0
- package/util/ai-qa-policy.d.ts +124 -0
- package/util/ai-qa-policy.js +736 -0
- package/util/ai-qa-policy.js.map +1 -0
- package/util/ai-run-evidence-adapters.d.ts +109 -0
- package/util/ai-run-evidence-adapters.js +7234 -0
- package/util/ai-run-evidence-adapters.js.map +1 -0
- package/util/ai-run-evidence-dashboard.d.ts +88 -0
- package/util/ai-run-evidence-dashboard.js +343 -0
- package/util/ai-run-evidence-dashboard.js.map +1 -0
- package/util/ai-run-evidence-eval.d.ts +86 -0
- package/util/ai-run-evidence-eval.js +1018 -0
- package/util/ai-run-evidence-eval.js.map +1 -0
- package/util/ai-run-evidence.d.ts +244 -0
- package/util/ai-run-evidence.js +1096 -0
- package/util/ai-run-evidence.js.map +1 -0
- package/util/ai-runner-artifacts.d.ts +82 -0
- package/util/ai-runner-artifacts.js +713 -0
- package/util/ai-runner-artifacts.js.map +1 -0
- package/util/ai-runner-manager-autopilot.d.ts +210 -0
- package/util/ai-runner-manager-autopilot.js +642 -0
- package/util/ai-runner-manager-autopilot.js.map +1 -0
- package/util/ai-runner-manager-policy.d.ts +807 -0
- package/util/ai-runner-manager-policy.js +3501 -0
- package/util/ai-runner-manager-policy.js.map +1 -0
- package/util/ai-runner-qa-auth.d.ts +5 -0
- package/util/ai-runner-qa-auth.js +839 -0
- package/util/ai-runner-qa-auth.js.map +1 -0
- package/util/ai-runner-qa-tools.d.ts +26 -0
- package/util/ai-runner-qa-tools.js +3520 -0
- package/util/ai-runner-qa-tools.js.map +1 -0
- package/util/aicoder-runner-v6.d.ts +426 -0
- package/util/aicoder-runner-v6.js +2464 -0
- package/util/aicoder-runner-v6.js.map +1 -0
- package/util/common.d.ts +31 -0
- package/util/common.js +683 -0
- package/util/common.js.map +1 -0
- package/util/customer-portal-password.d.ts +13 -0
- package/util/customer-portal-password.js +209 -0
- package/util/customer-portal-password.js.map +1 -0
- package/util/error-reporter.d.ts +52 -0
- package/util/error-reporter.js +326 -0
- package/util/error-reporter.js.map +1 -0
- package/util/error-tracking.d.ts +13 -0
- package/util/error-tracking.js +120 -0
- package/util/error-tracking.js.map +1 -0
- package/util/openai-usage-cost.d.ts +6 -0
- package/util/openai-usage-cost.js +103 -0
- package/util/openai-usage-cost.js.map +1 -0
- package/util/report-builder-unwinds.d.ts +15 -0
- package/util/report-builder-unwinds.js +156 -0
- package/util/report-builder-unwinds.js.map +1 -0
- package/util/runner-process-janitor.d.ts +27 -0
- package/util/runner-process-janitor.js +208 -0
- package/util/runner-process-janitor.js.map +1 -0
- package/util/schema-report-builder.d.ts +6 -0
- package/util/schema-report-builder.js +481 -0
- package/util/schema-report-builder.js.map +1 -0
- package/util/slow-query-reporter.d.ts +28 -0
- package/util/slow-query-reporter.js +226 -0
- package/util/slow-query-reporter.js.map +1 -0
- package/util/subscription-dependency-context.d.ts +34 -0
- package/util/subscription-dependency-context.js +1283 -0
- package/util/subscription-dependency-context.js.map +1 -0
- package/util/support-runner-v5.d.ts +1426 -0
- package/util/support-runner-v5.js +7647 -0
- package/util/support-runner-v5.js.map +1 -0
- package/util/tokenizer.d.ts +5 -0
- package/util/tokenizer.js +41 -0
- package/util/tokenizer.js.map +1 -0
- package/workers/codex-runner.worker.d.ts +1 -0
- package/workers/codex-runner.worker.js +192 -0
- package/workers/codex-runner.worker.js.map +1 -0
- package/.nodemon.json +0 -5
- package/.vscode/settings.json +0 -21
- package/AGENTS.md +0 -195
- package/README.md +0 -22
- package/build_package.sh +0 -5
- package/compileDTS.pl +0 -64
- package/docs/ai-assistant-nightly-eval.md +0 -65
- package/docs/ai-assistant-preflight-checklist.md +0 -23
- package/docs/ai-assistant-report-builder-bridge-playbook.md +0 -115
- package/eslint-plugin-custom/index.js +0 -7
- package/eslint-plugin-custom/rules/no-filter-zero-index.js +0 -44
- package/eslint.config.js +0 -103
- package/gulpfile.js +0 -216
- package/methodAndPublicationListGenerator.py +0 -375
- package/mongodbensurers.js +0 -2
- package/mongostop.js +0 -3
- package/scripts/cleanup-bypassed-callmethod-logs.js +0 -616
- package/settings.development.json +0 -25
- package/settings.development.redacted.json +0 -25
- package/src/.env +0 -12
- package/src/ai/assistant-core-heuristics.ts +0 -379
- package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +0 -185
- package/src/ai/resolveio-platform-intelligence-memory.ts +0 -325
- package/src/ai/resolveio-platform-intelligence.ts +0 -462
- package/src/client-server-app.ts +0 -12
- package/src/collections/ai-run.collection.ts +0 -117
- package/src/collections/ai-terminal-conversation.collection.ts +0 -91
- package/src/collections/ai-terminal-issue-report.collection.ts +0 -99
- package/src/collections/ai-terminal-message.collection.ts +0 -77
- package/src/collections/app-setting.collection.ts +0 -104
- package/src/collections/app-status.collection.ts +0 -58
- package/src/collections/communication-metric.collection.ts +0 -84
- package/src/collections/counter.collection.ts +0 -56
- package/src/collections/cron-job-history.collection.ts +0 -94
- package/src/collections/cron-job.collection.ts +0 -92
- package/src/collections/customer-notification.collection.ts +0 -131
- package/src/collections/customer-portal-password.collection.ts +0 -76
- package/src/collections/email-history.collection.ts +0 -134
- package/src/collections/email-verified.collection.ts +0 -62
- package/src/collections/file.collection.ts +0 -74
- package/src/collections/flag-update.collection.ts +0 -57
- package/src/collections/flag.collection.ts +0 -57
- package/src/collections/log-method-latency.collection.ts +0 -77
- package/src/collections/log-subscription.collection.ts +0 -80
- package/src/collections/log.collection.ts +0 -93
- package/src/collections/logged-in-users.collection.ts +0 -67
- package/src/collections/monitor-cpu.collection.ts +0 -65
- package/src/collections/monitor-function.collection.ts +0 -74
- package/src/collections/monitor-memory.collection.ts +0 -77
- package/src/collections/monitor-mongo.collection.ts +0 -71
- package/src/collections/notification.collection.ts +0 -57
- package/src/collections/openai-usage-ledger.collection.ts +0 -131
- package/src/collections/report-builder-dashboard-builder.collection.ts +0 -109
- package/src/collections/report-builder-library.collection.ts +0 -89
- package/src/collections/report-builder-report.collection.ts +0 -184
- package/src/collections/user-group.collection.ts +0 -89
- package/src/collections/user-guide.collection.ts +0 -57
- package/src/collections/user.collection.ts +0 -181
- package/src/cron/cron.ts +0 -117
- package/src/fixtures/cron-jobs.ts +0 -95
- package/src/fixtures/init.ts +0 -35
- package/src/http/auth.ts +0 -818
- package/src/http/health.ts +0 -7
- package/src/http/home.ts +0 -90
- package/src/http/slow-query-publication.ts +0 -49
- package/src/index.ts +0 -1
- package/src/managers/ai-assistant-codex-manager.manager.ts +0 -1131
- package/src/managers/ai-run-evidence.manager.ts +0 -264
- package/src/managers/communication-metric.manager.ts +0 -82
- package/src/managers/cron.manager.ts +0 -333
- package/src/managers/customer-notification-content.manager.ts +0 -236
- package/src/managers/diagnostic-manager-bootstrap.ts +0 -165
- package/src/managers/error-auto-fix.manager.ts +0 -2767
- package/src/managers/local-log.manager.ts +0 -113
- package/src/managers/method.manager.ts +0 -1857
- package/src/managers/mongo.manager.ts +0 -4575
- package/src/managers/monitor.manager.ts +0 -507
- package/src/managers/openai-usage-ledger.manager.ts +0 -112
- package/src/managers/slow-query-verifier.manager.ts +0 -3590
- package/src/managers/slow-query.manager.ts +0 -519
- package/src/managers/subscription.manager.ts +0 -3128
- package/src/managers/websocket.manager.ts +0 -746
- package/src/managers/worker-dispatcher.manager.ts +0 -1360
- package/src/managers/worker-server.manager.ts +0 -536
- package/src/methods/accounts.ts +0 -532
- package/src/methods/ai-terminal.ts +0 -29070
- package/src/methods/app-settings.ts +0 -114
- package/src/methods/aws.ts +0 -649
- package/src/methods/collections.ts +0 -641
- package/src/methods/counters.ts +0 -69
- package/src/methods/cron-jobs.ts +0 -2614
- package/src/methods/customer-notifications.ts +0 -458
- package/src/methods/diagnostics.ts +0 -616
- package/src/methods/flag-updates.ts +0 -7
- package/src/methods/flags.ts +0 -7
- package/src/methods/logs.ts +0 -657
- package/src/methods/mongo-explorer.ts +0 -1880
- package/src/methods/monitor.ts +0 -540
- package/src/methods/pdf.ts +0 -1236
- package/src/methods/publications.ts +0 -129
- package/src/methods/report-builder.ts +0 -3300
- package/src/methods/support.ts +0 -335
- package/src/models/ai-run.model.ts +0 -27
- package/src/models/ai-terminal-conversation.model.ts +0 -19
- package/src/models/ai-terminal-issue-report.model.ts +0 -21
- package/src/models/ai-terminal-message.model.ts +0 -24
- package/src/models/app-setting.model.ts +0 -17
- package/src/models/collection-document.model.ts +0 -24
- package/src/models/communication-metric.model.ts +0 -23
- package/src/models/cron-job-history.model.ts +0 -16
- package/src/models/cron-job.model.ts +0 -15
- package/src/models/customer-notification.model.ts +0 -28
- package/src/models/customer-portal-password.model.ts +0 -12
- package/src/models/dialog.model.ts +0 -25
- package/src/models/log-method-latency.model.ts +0 -11
- package/src/models/log.model.ts +0 -19
- package/src/models/method.model.ts +0 -25
- package/src/models/monitor-function.model.ts +0 -16
- package/src/models/monitor-memory.model.ts +0 -17
- package/src/models/monitor-mongo.model.ts +0 -15
- package/src/models/openai-usage-ledger.model.ts +0 -56
- package/src/models/pagination.model.ts +0 -35
- package/src/models/permission.model.ts +0 -14
- package/src/models/report-builder-dashboard-builder.model.ts +0 -29
- package/src/models/report-builder-library.model.ts +0 -20
- package/src/models/report-builder-report.model.ts +0 -136
- package/src/models/report-builder.model.ts +0 -68
- package/src/models/select-data-label.model.ts +0 -9
- package/src/models/server-message.model.ts +0 -31
- package/src/models/slow-query-report.model.ts +0 -23
- package/src/models/subscription.model.ts +0 -73
- package/src/models/support-ticket.model.ts +0 -104
- package/src/models/user-group.model.ts +0 -24
- package/src/models/user.model.ts +0 -96
- package/src/private/images/ResolveIO.png +0 -0
- package/src/publications/ai-terminal.ts +0 -73
- package/src/publications/app-settings.ts +0 -25
- package/src/publications/app-status.ts +0 -13
- package/src/publications/cron-jobs.ts +0 -40
- package/src/publications/customer-notifications.ts +0 -101
- package/src/publications/files.ts +0 -33
- package/src/publications/flags-update.ts +0 -19
- package/src/publications/flags.ts +0 -19
- package/src/publications/logs.ts +0 -163
- package/src/publications/notifications.ts +0 -13
- package/src/publications/report-builder-dashboard-builders.ts +0 -39
- package/src/publications/report-builder-libraries.ts +0 -41
- package/src/publications/report-builder-reports.ts +0 -47
- package/src/publications/super-admin.ts +0 -13
- package/src/publications/user-groups.ts +0 -12
- package/src/publications/user-guides.ts +0 -12
- package/src/resolveio-server-app.ts +0 -617
- package/src/server-app.ts +0 -3354
- package/src/services/codex-client.ts +0 -1231
- package/src/services/openai-client.ts +0 -265
- package/src/types/error-report.ts +0 -26
- package/src/types/js-tiktoken.d.ts +0 -11
- package/src/types/slow-query-report.ts +0 -28
- package/src/util/ai-qa-policy.ts +0 -925
- package/src/util/ai-run-evidence-adapters.ts +0 -8347
- package/src/util/ai-run-evidence-dashboard.ts +0 -323
- package/src/util/ai-run-evidence-eval.ts +0 -1057
- package/src/util/ai-run-evidence.ts +0 -1430
- package/src/util/ai-runner-artifacts.ts +0 -586
- package/src/util/ai-runner-manager-autopilot.ts +0 -961
- package/src/util/ai-runner-manager-policy.ts +0 -5011
- package/src/util/ai-runner-qa-auth.ts +0 -838
- package/src/util/ai-runner-qa-tools.ts +0 -3536
- package/src/util/aicoder-runner-v6.ts +0 -3121
- package/src/util/common.ts +0 -649
- package/src/util/customer-portal-password.ts +0 -183
- package/src/util/error-reporter.ts +0 -332
- package/src/util/error-tracking.ts +0 -79
- package/src/util/openai-usage-cost.ts +0 -114
- package/src/util/report-builder-unwinds.ts +0 -180
- package/src/util/runner-process-janitor.ts +0 -219
- package/src/util/schema-report-builder.ts +0 -448
- package/src/util/slow-query-reporter.ts +0 -216
- package/src/util/subscription-dependency-context.ts +0 -1096
- package/src/util/support-runner-v5.ts +0 -10040
- package/src/util/tokenizer.ts +0 -38
- package/src/workers/codex-runner.worker.ts +0 -142
- package/start_server.sh +0 -5
- package/tests/ai-assistant-corpus-build.ts +0 -484
- package/tests/ai-assistant-corpus-replay-e2e.ts +0 -774
- package/tests/ai-assistant-data-parity-e2e.ts +0 -1989
- package/tests/ai-assistant-eval-triage.ts +0 -831
- package/tests/ai-assistant-openai-e2e.ts +0 -1061
- package/tests/ai-assistant-openai-git-e2e.ts +0 -155
- package/tests/ai-assistant-preflight-matrix.ts +0 -215
- package/tests/ai-assistant-routing-eval.test.ts +0 -585
- package/tests/ai-assistant-snf-live-eval.ts +0 -975
- package/tests/ai-assistant-utils.test.ts +0 -4834
- package/tests/ai-manager-autopilot-snapshot.test.ts +0 -193
- package/tests/ai-manager-recovery-checkpoint.test.ts +0 -1383
- package/tests/ai-run-eval.test.ts +0 -132
- package/tests/ai-run-evidence.test.ts +0 -3773
- package/tests/ai-runner-contract.test.ts +0 -515
- package/tests/aicoder-runner-v6.test.ts +0 -822
- package/tests/error-reporter.test.ts +0 -145
- package/tests/method-publication-generator.test.ts +0 -46
- package/tests/report-builder-linking.test.ts +0 -79
- package/tests/resolveio-platform-intelligence.test.ts +0 -352
- package/tests/server-app-cron-owner.test.ts +0 -127
- package/tests/subscription-connect-race.test.ts +0 -158
- package/tests/subscription-dependency-context.test.ts +0 -324
- package/tests/subscription-manager-collection-tracking.test.ts +0 -86
- package/tests/subscription-manager-invalidation.test.ts +0 -86
- package/tests/support-runner-v5.test.ts +0 -3201
- package/tsconfig.json +0 -34
- /package/{src/private → private}/email-templates/enrollment.html +0 -0
- /package/{src/private → private}/email-templates/forgot-password.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-modified.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket.html +0 -0
- /package/{src/public_api.ts → public_api.d.ts} +0 -0
|
@@ -0,0 +1,1266 @@
|
|
|
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 __values = (this && this.__values) || function(o) {
|
|
14
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
15
|
+
if (m) return m.call(o);
|
|
16
|
+
if (o && typeof o.length === "number") return {
|
|
17
|
+
next: function () {
|
|
18
|
+
if (o && i >= o.length) o = void 0;
|
|
19
|
+
return { value: o && o[i++], done: !o };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
23
|
+
};
|
|
24
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
+
if (!m) return o;
|
|
27
|
+
var i = m.call(o), r, ar = [], e;
|
|
28
|
+
try {
|
|
29
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) { e = { error: error }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e) throw e.error; }
|
|
37
|
+
}
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
41
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42
|
+
if (ar || !(i in from)) {
|
|
43
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
44
|
+
ar[i] = from[i];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.WorkerDispatcherManager = void 0;
|
|
51
|
+
var WebSocket = require("ws");
|
|
52
|
+
var common_1 = require("../util/common");
|
|
53
|
+
var msgpackr_1 = require("msgpackr");
|
|
54
|
+
var WorkerDispatcherManager = /** @class */ (function () {
|
|
55
|
+
function WorkerDispatcherManager() {
|
|
56
|
+
this._workers = [];
|
|
57
|
+
this._taskQueue = [];
|
|
58
|
+
this._clientRequests = {};
|
|
59
|
+
this._pendingTasks = new Map();
|
|
60
|
+
this._debugNoWorkerTaskIds = new Set();
|
|
61
|
+
this._debugCodexTaskIds = new Set();
|
|
62
|
+
this._taskTimings = new Map();
|
|
63
|
+
this._dispatchRetryTimer = null;
|
|
64
|
+
this._dispatchRetryDelayMs = 25;
|
|
65
|
+
this._nonCodexReserve = 0;
|
|
66
|
+
this._publicationWorkerIndexes = null;
|
|
67
|
+
this._publicationWorkerInstances = null;
|
|
68
|
+
this._codexWorkerIndexes = null;
|
|
69
|
+
this._codexWorkerInstances = null;
|
|
70
|
+
this.MAX_CONCURRENCY = 10;
|
|
71
|
+
this.WORKER_TASK_LOG_THRESHOLD_MS = 200;
|
|
72
|
+
this.WORKER_PUBLICATION_SLOW_MS = 20000;
|
|
73
|
+
this._workerTaskDebug = false;
|
|
74
|
+
this._aiWorkerDebug = false;
|
|
75
|
+
}
|
|
76
|
+
WorkerDispatcherManager.create = function (websocketManager, methodManager) {
|
|
77
|
+
var workerDispatcherManager = new WorkerDispatcherManager();
|
|
78
|
+
workerDispatcherManager.initialize(websocketManager, methodManager);
|
|
79
|
+
return workerDispatcherManager;
|
|
80
|
+
};
|
|
81
|
+
WorkerDispatcherManager.prototype.initialize = function (websocketManager, methodManager) {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
this._websocketManager = websocketManager;
|
|
84
|
+
this._methodManager = methodManager;
|
|
85
|
+
this._workerTaskDebug = this.parseDebugFlag((_a = process.env.WORKER_TASK_DEBUG) !== null && _a !== void 0 ? _a : process.env.WORKER_DISPATCH_DEBUG);
|
|
86
|
+
this._aiWorkerDebug = this.parseDebugFlag(process.env.AI_ASSISTANT_WORKER_DEBUG);
|
|
87
|
+
var slowPublicationMs = parseInt((_b = process.env.WORKER_PUBLICATION_SLOW_MS) !== null && _b !== void 0 ? _b : '', 10);
|
|
88
|
+
if (!Number.isNaN(slowPublicationMs) && slowPublicationMs > 0) {
|
|
89
|
+
this.WORKER_PUBLICATION_SLOW_MS = slowPublicationMs;
|
|
90
|
+
}
|
|
91
|
+
this._nonCodexReserve = this.parsePositiveInt((_c = process.env.WORKER_NON_CODEX_RESERVE) !== null && _c !== void 0 ? _c : process.env.WORKER_RESERVED_SLOTS, 0);
|
|
92
|
+
this._publicationWorkerIndexes = this.parseWorkerSelector(process.env.PUBLICATION_WORKER_INDEX
|
|
93
|
+
|| process.env.SUBSCRIPTION_WORKER_INDEX
|
|
94
|
+
|| process.env.WORKER_PUBLICATION_INDEX);
|
|
95
|
+
this._publicationWorkerInstances = this.parseWorkerSelector(process.env.PUBLICATION_WORKER_INSTANCE
|
|
96
|
+
|| process.env.SUBSCRIPTION_WORKER_INSTANCE
|
|
97
|
+
|| process.env.WORKER_PUBLICATION_INSTANCE);
|
|
98
|
+
this._codexWorkerIndexes = this.parseWorkerSelector(process.env.AI_ASSISTANT_CODEX_WORKER_INDEX
|
|
99
|
+
|| process.env.CODEX_WORKER_INDEX
|
|
100
|
+
|| process.env.WORKER_CODEX_INDEX);
|
|
101
|
+
this._codexWorkerInstances = this.parseWorkerSelector(process.env.AI_ASSISTANT_CODEX_WORKER_INSTANCE
|
|
102
|
+
|| process.env.CODEX_WORKER_INSTANCE
|
|
103
|
+
|| process.env.WORKER_CODEX_INSTANCE);
|
|
104
|
+
};
|
|
105
|
+
WorkerDispatcherManager.prototype.parseDebugFlag = function (value) {
|
|
106
|
+
if (value === true) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (value === false || value === null || value === undefined) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (typeof value === 'number') {
|
|
113
|
+
return value === 1;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'string') {
|
|
116
|
+
var normalized = value.trim().toLowerCase();
|
|
117
|
+
return ['1', 'true', 'yes', 'y', 'on'].includes(normalized);
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
WorkerDispatcherManager.prototype.parsePositiveInt = function (value, fallback) {
|
|
122
|
+
var parsed = parseInt(value !== null && value !== void 0 ? value : '', 10);
|
|
123
|
+
if (Number.isNaN(parsed) || parsed < 0) {
|
|
124
|
+
return fallback;
|
|
125
|
+
}
|
|
126
|
+
return parsed;
|
|
127
|
+
};
|
|
128
|
+
WorkerDispatcherManager.prototype.parseWorkerSelector = function (value) {
|
|
129
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
130
|
+
if (value === null || value === undefined) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
var parts = [];
|
|
134
|
+
if (Array.isArray(value)) {
|
|
135
|
+
try {
|
|
136
|
+
for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
137
|
+
var item = value_1_1.value;
|
|
138
|
+
var entry = String(item !== null && item !== void 0 ? item : '').split(',');
|
|
139
|
+
try {
|
|
140
|
+
for (var entry_1 = (e_2 = void 0, __values(entry)), entry_1_1 = entry_1.next(); !entry_1_1.done; entry_1_1 = entry_1.next()) {
|
|
141
|
+
var chunk = entry_1_1.value;
|
|
142
|
+
var trimmed = String(chunk !== null && chunk !== void 0 ? chunk : '').trim();
|
|
143
|
+
if (trimmed) {
|
|
144
|
+
parts.push(trimmed);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
149
|
+
finally {
|
|
150
|
+
try {
|
|
151
|
+
if (entry_1_1 && !entry_1_1.done && (_b = entry_1.return)) _b.call(entry_1);
|
|
152
|
+
}
|
|
153
|
+
finally { if (e_2) throw e_2.error; }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
158
|
+
finally {
|
|
159
|
+
try {
|
|
160
|
+
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
161
|
+
}
|
|
162
|
+
finally { if (e_1) throw e_1.error; }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
var entry = String(value !== null && value !== void 0 ? value : '').split(',');
|
|
167
|
+
try {
|
|
168
|
+
for (var entry_2 = __values(entry), entry_2_1 = entry_2.next(); !entry_2_1.done; entry_2_1 = entry_2.next()) {
|
|
169
|
+
var chunk = entry_2_1.value;
|
|
170
|
+
var trimmed = String(chunk !== null && chunk !== void 0 ? chunk : '').trim();
|
|
171
|
+
if (trimmed) {
|
|
172
|
+
parts.push(trimmed);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
177
|
+
finally {
|
|
178
|
+
try {
|
|
179
|
+
if (entry_2_1 && !entry_2_1.done && (_c = entry_2.return)) _c.call(entry_2);
|
|
180
|
+
}
|
|
181
|
+
finally { if (e_3) throw e_3.error; }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!parts.length) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return new Set(parts);
|
|
188
|
+
};
|
|
189
|
+
WorkerDispatcherManager.prototype.selectorToArray = function (value) {
|
|
190
|
+
if (!value) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return Array.from(value.values());
|
|
194
|
+
};
|
|
195
|
+
WorkerDispatcherManager.prototype.hasWorkerSelector = function (indexes, instances) {
|
|
196
|
+
return !!(indexes && indexes.size) || !!(instances && instances.size);
|
|
197
|
+
};
|
|
198
|
+
WorkerDispatcherManager.prototype.workerMatchesSelector = function (worker, indexes, instances) {
|
|
199
|
+
if (!this.hasWorkerSelector(indexes, instances)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
var normalizedIndex = this.normalizeWorkerIndex(worker.workerIndex);
|
|
203
|
+
var normalizedInstance = this.normalizeWorkerIndex(worker.workerInstance);
|
|
204
|
+
var indexMatch = indexes ? (normalizedIndex ? indexes.has(normalizedIndex) : false) : true;
|
|
205
|
+
var instanceMatch = instances ? (normalizedInstance ? instances.has(normalizedInstance) : false) : true;
|
|
206
|
+
return indexMatch && instanceMatch;
|
|
207
|
+
};
|
|
208
|
+
WorkerDispatcherManager.prototype.resolveTaskQueue = function (methodName) {
|
|
209
|
+
var _a;
|
|
210
|
+
var method = (_a = this._methodManager) === null || _a === void 0 ? void 0 : _a.getMethod(methodName);
|
|
211
|
+
var queue = method === null || method === void 0 ? void 0 : method.workerQueue;
|
|
212
|
+
if (queue === 'publication' || queue === 'codex') {
|
|
213
|
+
return queue;
|
|
214
|
+
}
|
|
215
|
+
return 'default';
|
|
216
|
+
};
|
|
217
|
+
WorkerDispatcherManager.prototype.summarizePublicationValue = function (value) {
|
|
218
|
+
if (value === null || value === undefined) {
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
var valueType = typeof value;
|
|
222
|
+
if (valueType === 'string' || valueType === 'number' || valueType === 'boolean') {
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
if (Array.isArray(value)) {
|
|
226
|
+
return "[Array(".concat(value.length, ")]");
|
|
227
|
+
}
|
|
228
|
+
if (valueType === 'object') {
|
|
229
|
+
return "[Object keys=".concat(Object.keys(value).length, "]");
|
|
230
|
+
}
|
|
231
|
+
return "[".concat(valueType, "]");
|
|
232
|
+
};
|
|
233
|
+
WorkerDispatcherManager.prototype.getPublicationLogInfo = function (method, params) {
|
|
234
|
+
var _this = this;
|
|
235
|
+
if (method !== 'runPublication' || !Array.isArray(params)) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
var publication = typeof params[0] === 'string' ? params[0] : null;
|
|
239
|
+
var subscriptionData = Array.isArray(params[1]) ? params[1] : [];
|
|
240
|
+
var userId = typeof params[2] === 'string' ? params[2] : null;
|
|
241
|
+
var subscriptionDataPreview = subscriptionData.slice(0, 3).map(function (item) { return _this.summarizePublicationValue(item); });
|
|
242
|
+
return {
|
|
243
|
+
publication: publication,
|
|
244
|
+
subscriptionDataCount: subscriptionData.length,
|
|
245
|
+
subscriptionDataPreview: subscriptionDataPreview,
|
|
246
|
+
userId: userId
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
WorkerDispatcherManager.prototype.isSafeShutdown = function () {
|
|
250
|
+
return !this._taskQueue.length && !this._pendingTasks.size;
|
|
251
|
+
};
|
|
252
|
+
WorkerDispatcherManager.prototype.addWorker = function (ws) {
|
|
253
|
+
var _this = this;
|
|
254
|
+
this._workers.push({
|
|
255
|
+
id: ws['id_worker'],
|
|
256
|
+
ws: ws,
|
|
257
|
+
activeTasks: [],
|
|
258
|
+
workerIndex: ws['workerIndex'],
|
|
259
|
+
workerInstance: ws['workerInstance']
|
|
260
|
+
});
|
|
261
|
+
setInterval(function () {
|
|
262
|
+
if (_this._methodManager.getEnableDebug()) {
|
|
263
|
+
console.log(JSON.stringify(_this._workers.map(function (a) {
|
|
264
|
+
return {
|
|
265
|
+
id: a.id,
|
|
266
|
+
activeTasks: a.activeTasks
|
|
267
|
+
};
|
|
268
|
+
}), null, 2));
|
|
269
|
+
}
|
|
270
|
+
}, 5000);
|
|
271
|
+
if (this._taskQueue.length) {
|
|
272
|
+
this.dispatchQueue();
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
WorkerDispatcherManager.prototype.failActiveWorkerTask = function (task, reason) {
|
|
276
|
+
var _a;
|
|
277
|
+
if (!task || !task.taskId) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
var pendingTask = this._pendingTasks.get(task.taskId);
|
|
281
|
+
if (pendingTask) {
|
|
282
|
+
clearTimeout(pendingTask.timeout);
|
|
283
|
+
if (pendingTask.promise) {
|
|
284
|
+
pendingTask.promise.reject(reason);
|
|
285
|
+
}
|
|
286
|
+
this._pendingTasks.delete(task.taskId);
|
|
287
|
+
}
|
|
288
|
+
this._taskTimings.delete(task.taskId);
|
|
289
|
+
if (this._clientRequests[task.taskId]) {
|
|
290
|
+
delete this._clientRequests[task.taskId];
|
|
291
|
+
}
|
|
292
|
+
if (!((_a = task.userContext) === null || _a === void 0 ? void 0 : _a.id_ws) || task.messageId === undefined || task.messageId === null) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
var clientWS = this._websocketManager ? this._websocketManager.getWebSocket(task.userContext.id_ws) : null;
|
|
296
|
+
if (!clientWS) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
var response = {
|
|
300
|
+
messageId: task.messageId,
|
|
301
|
+
hasError: true,
|
|
302
|
+
data: reason
|
|
303
|
+
};
|
|
304
|
+
this._websocketManager.send(clientWS, response);
|
|
305
|
+
};
|
|
306
|
+
WorkerDispatcherManager.prototype.disconnectWorker = function (workerId, reason) {
|
|
307
|
+
var e_4, _a;
|
|
308
|
+
var _b;
|
|
309
|
+
if (reason === void 0) { reason = 'Worker disconnected.'; }
|
|
310
|
+
var worker = this._workers.find(function (w) { return w.id === workerId; });
|
|
311
|
+
this._workers = this._workers.filter(function (w) { return w.id !== workerId; });
|
|
312
|
+
if (!worker || !((_b = worker.activeTasks) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
var activeTasks = __spreadArray([], __read(worker.activeTasks), false);
|
|
316
|
+
worker.activeTasks = [];
|
|
317
|
+
try {
|
|
318
|
+
for (var activeTasks_1 = __values(activeTasks), activeTasks_1_1 = activeTasks_1.next(); !activeTasks_1_1.done; activeTasks_1_1 = activeTasks_1.next()) {
|
|
319
|
+
var activeTask = activeTasks_1_1.value;
|
|
320
|
+
this.failActiveWorkerTask(activeTask, reason);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
324
|
+
finally {
|
|
325
|
+
try {
|
|
326
|
+
if (activeTasks_1_1 && !activeTasks_1_1.done && (_a = activeTasks_1.return)) _a.call(activeTasks_1);
|
|
327
|
+
}
|
|
328
|
+
finally { if (e_4) throw e_4.error; }
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
WorkerDispatcherManager.prototype.hasWorkers = function () {
|
|
332
|
+
return this._workers.length > 0;
|
|
333
|
+
};
|
|
334
|
+
WorkerDispatcherManager.prototype.getQueueSnapshot = function () {
|
|
335
|
+
var activeTasks = this._workers.reduce(function (total, worker) { return total + (worker.activeTasks ? worker.activeTasks.length : 0); }, 0);
|
|
336
|
+
return {
|
|
337
|
+
queueDepth: this._taskQueue.length,
|
|
338
|
+
pendingTasks: this._pendingTasks.size,
|
|
339
|
+
workerCount: this._workers.length,
|
|
340
|
+
activeTasks: activeTasks,
|
|
341
|
+
workers: this._workers.map(function (worker) { return ({
|
|
342
|
+
id: worker.id,
|
|
343
|
+
index: worker.workerIndex,
|
|
344
|
+
instance: worker.workerInstance,
|
|
345
|
+
activeTasks: worker.activeTasks ? worker.activeTasks.length : 0
|
|
346
|
+
}); })
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
WorkerDispatcherManager.prototype.hasWorkersForMethod = function (methodName) {
|
|
350
|
+
var _this = this;
|
|
351
|
+
if (!this._workers.length) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
var method = this._methodManager.getMethod(methodName);
|
|
355
|
+
var taskQueue = this.resolveTaskQueue(methodName);
|
|
356
|
+
var targetWorkerIndex = this.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerIndex);
|
|
357
|
+
var targetWorkerInstance = this.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerInstance);
|
|
358
|
+
var hasExplicitTarget = !!targetWorkerIndex || !!targetWorkerInstance;
|
|
359
|
+
var candidates = this.filterGeneralPurposeWorkers(__spreadArray([], __read(this._workers), false), hasExplicitTarget);
|
|
360
|
+
var hasPublicationSelector = this.hasWorkerSelector(this._publicationWorkerIndexes, this._publicationWorkerInstances);
|
|
361
|
+
if (hasPublicationSelector && !hasExplicitTarget) {
|
|
362
|
+
if (taskQueue === 'publication') {
|
|
363
|
+
candidates = candidates.filter(function (worker) {
|
|
364
|
+
return _this.workerMatchesSelector(worker, _this._publicationWorkerIndexes, _this._publicationWorkerInstances);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
candidates = candidates.filter(function (worker) {
|
|
369
|
+
return !_this.workerMatchesSelector(worker, _this._publicationWorkerIndexes, _this._publicationWorkerInstances);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
var hasCodexSelector = this.hasWorkerSelector(this._codexWorkerIndexes, this._codexWorkerInstances);
|
|
374
|
+
if (hasCodexSelector) {
|
|
375
|
+
if (taskQueue === 'codex') {
|
|
376
|
+
candidates = candidates.filter(function (worker) {
|
|
377
|
+
return _this.workerMatchesSelector(worker, _this._codexWorkerIndexes, _this._codexWorkerInstances);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
else if (!hasExplicitTarget) {
|
|
381
|
+
candidates = candidates.filter(function (worker) {
|
|
382
|
+
return !_this.workerMatchesSelector(worker, _this._codexWorkerIndexes, _this._codexWorkerInstances);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (targetWorkerIndex) {
|
|
387
|
+
candidates = candidates.filter(function (worker) { return _this.normalizeWorkerIndex(worker.workerIndex) === targetWorkerIndex; });
|
|
388
|
+
}
|
|
389
|
+
if (targetWorkerInstance) {
|
|
390
|
+
candidates = candidates.filter(function (worker) { return _this.normalizeWorkerIndex(worker.workerInstance) === targetWorkerInstance; });
|
|
391
|
+
}
|
|
392
|
+
return candidates.length > 0;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Add a new task to our in-memory queue and try to dispatch.
|
|
396
|
+
*/
|
|
397
|
+
WorkerDispatcherManager.prototype.sendClientTask = function (messageId, method, params, userContext) {
|
|
398
|
+
var taskId = 'task-' + (0, common_1.objectIdHexString)();
|
|
399
|
+
var queuedAt = Date.now();
|
|
400
|
+
this._taskQueue.push({
|
|
401
|
+
type: 'task',
|
|
402
|
+
taskId: taskId,
|
|
403
|
+
messageId: messageId,
|
|
404
|
+
method: method,
|
|
405
|
+
params: params,
|
|
406
|
+
userContext: userContext,
|
|
407
|
+
queuedAt: queuedAt
|
|
408
|
+
});
|
|
409
|
+
this._taskTimings.set(taskId, {
|
|
410
|
+
queuedAt: queuedAt,
|
|
411
|
+
method: method,
|
|
412
|
+
messageId: messageId,
|
|
413
|
+
userContext: userContext,
|
|
414
|
+
params: params
|
|
415
|
+
});
|
|
416
|
+
if (userContext && userContext.id_ws) {
|
|
417
|
+
this._clientRequests[taskId] = userContext.id_ws;
|
|
418
|
+
}
|
|
419
|
+
if (this.shouldDebug()) {
|
|
420
|
+
var publicationInfo = this.getPublicationLogInfo(method, params);
|
|
421
|
+
var logPayload = {
|
|
422
|
+
taskId: taskId,
|
|
423
|
+
method: method,
|
|
424
|
+
messageId: messageId,
|
|
425
|
+
priority: method === 'runPublication' ? 'publication' : 'method',
|
|
426
|
+
queueDepth: this._taskQueue.length,
|
|
427
|
+
userContext: userContext
|
|
428
|
+
};
|
|
429
|
+
if (publicationInfo) {
|
|
430
|
+
Object.assign(logPayload, publicationInfo);
|
|
431
|
+
}
|
|
432
|
+
this.logWorkerEvent('workerTaskQueued', logPayload);
|
|
433
|
+
}
|
|
434
|
+
this.dispatchQueue();
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Same as sendInternalTask but returns a Promise so you can `await` it.
|
|
438
|
+
*/
|
|
439
|
+
WorkerDispatcherManager.prototype.sendInternalPromise = function (method, params) {
|
|
440
|
+
var _this = this;
|
|
441
|
+
if (params === void 0) { params = []; }
|
|
442
|
+
if (!Array.isArray(params)) {
|
|
443
|
+
params = [params];
|
|
444
|
+
}
|
|
445
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
446
|
+
return new Promise(function (resolve, reject) {
|
|
447
|
+
var taskId = 'task-' + (0, common_1.objectIdHexString)();
|
|
448
|
+
var queuedAt = Date.now();
|
|
449
|
+
_this._taskQueue.push({
|
|
450
|
+
type: 'task',
|
|
451
|
+
taskId: taskId,
|
|
452
|
+
method: method,
|
|
453
|
+
params: params,
|
|
454
|
+
messageId: 0,
|
|
455
|
+
userContext: {
|
|
456
|
+
user: 'Internal System'
|
|
457
|
+
},
|
|
458
|
+
queuedAt: queuedAt
|
|
459
|
+
});
|
|
460
|
+
_this._taskTimings.set(taskId, {
|
|
461
|
+
queuedAt: queuedAt,
|
|
462
|
+
method: method,
|
|
463
|
+
messageId: 0,
|
|
464
|
+
userContext: { user: 'Internal System' },
|
|
465
|
+
params: params
|
|
466
|
+
});
|
|
467
|
+
_this._pendingTasks.set(taskId, {
|
|
468
|
+
timeout: null,
|
|
469
|
+
promise: { resolve: resolve, reject: reject }
|
|
470
|
+
});
|
|
471
|
+
if (_this._methodManager.getEnableDebug()) {
|
|
472
|
+
console.log(new Date(), 'Send Internal Promise', _this._taskQueue);
|
|
473
|
+
}
|
|
474
|
+
if (_this.shouldDebug()) {
|
|
475
|
+
var publicationInfo = _this.getPublicationLogInfo(method, params);
|
|
476
|
+
var logPayload = {
|
|
477
|
+
taskId: taskId,
|
|
478
|
+
method: method,
|
|
479
|
+
messageId: 0,
|
|
480
|
+
priority: method === 'runPublication' ? 'publication' : 'method',
|
|
481
|
+
queueDepth: _this._taskQueue.length,
|
|
482
|
+
userContext: { user: 'Internal System' }
|
|
483
|
+
};
|
|
484
|
+
if (publicationInfo) {
|
|
485
|
+
Object.assign(logPayload, publicationInfo);
|
|
486
|
+
}
|
|
487
|
+
_this.logWorkerEvent('workerTaskQueued', logPayload);
|
|
488
|
+
}
|
|
489
|
+
_this.dispatchQueue();
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
/**
|
|
493
|
+
* Send a task internally and resolve with the raw TaskResponse (includes packedResult/meta).
|
|
494
|
+
*/
|
|
495
|
+
WorkerDispatcherManager.prototype.sendInternalPromiseRaw = function (method, params) {
|
|
496
|
+
var _this = this;
|
|
497
|
+
if (params === void 0) { params = []; }
|
|
498
|
+
if (!Array.isArray(params)) {
|
|
499
|
+
params = [params];
|
|
500
|
+
}
|
|
501
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
502
|
+
return new Promise(function (resolve, reject) {
|
|
503
|
+
var taskId = 'task-' + (0, common_1.objectIdHexString)();
|
|
504
|
+
var queuedAt = Date.now();
|
|
505
|
+
_this._taskQueue.push({
|
|
506
|
+
type: 'task',
|
|
507
|
+
taskId: taskId,
|
|
508
|
+
method: method,
|
|
509
|
+
params: params,
|
|
510
|
+
messageId: 0,
|
|
511
|
+
userContext: {
|
|
512
|
+
user: 'Internal System'
|
|
513
|
+
},
|
|
514
|
+
queuedAt: queuedAt
|
|
515
|
+
});
|
|
516
|
+
_this._taskTimings.set(taskId, {
|
|
517
|
+
queuedAt: queuedAt,
|
|
518
|
+
method: method,
|
|
519
|
+
messageId: 0,
|
|
520
|
+
userContext: { user: 'Internal System' },
|
|
521
|
+
params: params
|
|
522
|
+
});
|
|
523
|
+
_this._pendingTasks.set(taskId, {
|
|
524
|
+
timeout: null,
|
|
525
|
+
promise: { resolve: resolve, reject: reject },
|
|
526
|
+
resolveRaw: true
|
|
527
|
+
});
|
|
528
|
+
if (_this._methodManager.getEnableDebug()) {
|
|
529
|
+
console.log(new Date(), 'Send Internal Raw Promise', _this._taskQueue);
|
|
530
|
+
}
|
|
531
|
+
if (_this.shouldDebug()) {
|
|
532
|
+
var publicationInfo = _this.getPublicationLogInfo(method, params);
|
|
533
|
+
var logPayload = {
|
|
534
|
+
taskId: taskId,
|
|
535
|
+
method: method,
|
|
536
|
+
messageId: 0,
|
|
537
|
+
priority: method === 'runPublication' ? 'publication' : 'method',
|
|
538
|
+
queueDepth: _this._taskQueue.length,
|
|
539
|
+
userContext: { user: 'Internal System' }
|
|
540
|
+
};
|
|
541
|
+
if (publicationInfo) {
|
|
542
|
+
Object.assign(logPayload, publicationInfo);
|
|
543
|
+
}
|
|
544
|
+
_this.logWorkerEvent('workerTaskQueued', logPayload);
|
|
545
|
+
}
|
|
546
|
+
_this.dispatchQueue();
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* Send a task internally without returning a promise.
|
|
551
|
+
*/
|
|
552
|
+
WorkerDispatcherManager.prototype.sendInternalTask = function (method, params) {
|
|
553
|
+
if (params === void 0) { params = []; }
|
|
554
|
+
if (!Array.isArray(params)) {
|
|
555
|
+
params = [params];
|
|
556
|
+
}
|
|
557
|
+
var taskId = 'task-' + (0, common_1.objectIdHexString)();
|
|
558
|
+
var queuedAt = Date.now();
|
|
559
|
+
this._taskQueue.push({
|
|
560
|
+
type: 'task',
|
|
561
|
+
taskId: taskId,
|
|
562
|
+
method: method,
|
|
563
|
+
params: params,
|
|
564
|
+
messageId: 0,
|
|
565
|
+
userContext: {
|
|
566
|
+
user: 'Internal System'
|
|
567
|
+
},
|
|
568
|
+
queuedAt: queuedAt
|
|
569
|
+
});
|
|
570
|
+
this._taskTimings.set(taskId, {
|
|
571
|
+
queuedAt: queuedAt,
|
|
572
|
+
method: method,
|
|
573
|
+
messageId: 0,
|
|
574
|
+
userContext: { user: 'Internal System' },
|
|
575
|
+
params: params
|
|
576
|
+
});
|
|
577
|
+
if (this._methodManager.getEnableDebug()) {
|
|
578
|
+
console.log(new Date(), 'Send Internal Task', this._taskQueue);
|
|
579
|
+
}
|
|
580
|
+
if (this.shouldDebug()) {
|
|
581
|
+
var publicationInfo = this.getPublicationLogInfo(method, params);
|
|
582
|
+
var logPayload = {
|
|
583
|
+
taskId: taskId,
|
|
584
|
+
method: method,
|
|
585
|
+
messageId: 0,
|
|
586
|
+
priority: method === 'runPublication' ? 'publication' : 'method',
|
|
587
|
+
queueDepth: this._taskQueue.length,
|
|
588
|
+
userContext: { user: 'Internal System' }
|
|
589
|
+
};
|
|
590
|
+
if (publicationInfo) {
|
|
591
|
+
Object.assign(logPayload, publicationInfo);
|
|
592
|
+
}
|
|
593
|
+
this.logWorkerEvent('workerTaskQueued', logPayload);
|
|
594
|
+
}
|
|
595
|
+
this.dispatchQueue();
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* The main loop that assigns tasks from _taskQueue to any worker that has capacity.
|
|
599
|
+
*/
|
|
600
|
+
WorkerDispatcherManager.prototype.dispatchQueue = function () {
|
|
601
|
+
var e_5, _a;
|
|
602
|
+
var _this = this;
|
|
603
|
+
if (!this._taskQueue.length) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (!this._workers.length) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
var priorityMatchers = [
|
|
610
|
+
function (task) { return _this.resolveTaskQueue(task.method) === 'publication'; },
|
|
611
|
+
function (task) { return _this.resolveTaskQueue(task.method) === 'default'; },
|
|
612
|
+
function (task) { return _this.resolveTaskQueue(task.method) === 'codex'; }
|
|
613
|
+
];
|
|
614
|
+
var tryAssignTask = function (matcher) {
|
|
615
|
+
for (var i = 0; i < _this._taskQueue.length; i++) {
|
|
616
|
+
var task = _this._taskQueue[i];
|
|
617
|
+
if (!matcher(task)) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
var targetWorker = _this.findWorkerForTask(task);
|
|
621
|
+
if (targetWorker) {
|
|
622
|
+
_this._taskQueue.splice(i, 1);
|
|
623
|
+
_this.assignTaskToWorker(targetWorker, task);
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return false;
|
|
628
|
+
};
|
|
629
|
+
while (this._taskQueue.length > 0) {
|
|
630
|
+
var assigned = false;
|
|
631
|
+
try {
|
|
632
|
+
for (var priorityMatchers_1 = (e_5 = void 0, __values(priorityMatchers)), priorityMatchers_1_1 = priorityMatchers_1.next(); !priorityMatchers_1_1.done; priorityMatchers_1_1 = priorityMatchers_1.next()) {
|
|
633
|
+
var matcher = priorityMatchers_1_1.value;
|
|
634
|
+
if (tryAssignTask(matcher)) {
|
|
635
|
+
assigned = true;
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
641
|
+
finally {
|
|
642
|
+
try {
|
|
643
|
+
if (priorityMatchers_1_1 && !priorityMatchers_1_1.done && (_a = priorityMatchers_1.return)) _a.call(priorityMatchers_1);
|
|
644
|
+
}
|
|
645
|
+
finally { if (e_5) throw e_5.error; }
|
|
646
|
+
}
|
|
647
|
+
if (!assigned) {
|
|
648
|
+
this.logNoWorkerAvailability();
|
|
649
|
+
this.scheduleDispatchRetry();
|
|
650
|
+
if (this._methodManager.getEnableDebug()) {
|
|
651
|
+
console.log(new Date(), 'No Worker Available', JSON.stringify(this._workers, null, 2));
|
|
652
|
+
}
|
|
653
|
+
return; // nothing can run right now due to per-worker limits
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
WorkerDispatcherManager.prototype.scheduleDispatchRetry = function (delayMs) {
|
|
658
|
+
var _this = this;
|
|
659
|
+
if (delayMs === void 0) { delayMs = this._dispatchRetryDelayMs; }
|
|
660
|
+
if (this._dispatchRetryTimer) {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
this._dispatchRetryTimer = setTimeout(function () {
|
|
664
|
+
_this._dispatchRetryTimer = null;
|
|
665
|
+
_this.dispatchQueue();
|
|
666
|
+
}, delayMs);
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Returns the worker with the fewest activeTasks that is under maxConcurrency and per-method limit.
|
|
670
|
+
*/
|
|
671
|
+
WorkerDispatcherManager.prototype.findWorkerForTask = function (task) {
|
|
672
|
+
var _this = this;
|
|
673
|
+
var method = this._methodManager.getMethod(task.method);
|
|
674
|
+
var taskQueue = this.resolveTaskQueue(task.method);
|
|
675
|
+
var methodLimit = method && method.maxConcurrency && method.maxConcurrency > 0 ? method.maxConcurrency : null;
|
|
676
|
+
var methodLimitPerInstance = method && method.maxConcurrencyPerInstance && method.maxConcurrencyPerInstance > 0
|
|
677
|
+
? method.maxConcurrencyPerInstance
|
|
678
|
+
: null;
|
|
679
|
+
var targetWorkerIndex = this.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerIndex);
|
|
680
|
+
var targetWorkerInstance = this.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerInstance);
|
|
681
|
+
var hasExplicitTarget = !!targetWorkerIndex || !!targetWorkerInstance;
|
|
682
|
+
var preferNonZero = !targetWorkerIndex;
|
|
683
|
+
var debugCodex = this._aiWorkerDebug && taskQueue === 'codex';
|
|
684
|
+
var debugState = debugCodex ? {
|
|
685
|
+
taskId: task.taskId,
|
|
686
|
+
method: task.method,
|
|
687
|
+
queueDepth: this._taskQueue.length,
|
|
688
|
+
targetWorkerIndex: targetWorkerIndex || null,
|
|
689
|
+
targetWorkerInstance: targetWorkerInstance || null,
|
|
690
|
+
workerCount: this._workers.length,
|
|
691
|
+
publicationSelector: {
|
|
692
|
+
indexes: this.selectorToArray(this._publicationWorkerIndexes),
|
|
693
|
+
instances: this.selectorToArray(this._publicationWorkerInstances)
|
|
694
|
+
},
|
|
695
|
+
codexSelector: {
|
|
696
|
+
indexes: this.selectorToArray(this._codexWorkerIndexes),
|
|
697
|
+
instances: this.selectorToArray(this._codexWorkerInstances)
|
|
698
|
+
},
|
|
699
|
+
maxConcurrency: this.MAX_CONCURRENCY,
|
|
700
|
+
nonCodexReserve: this._nonCodexReserve
|
|
701
|
+
} : null;
|
|
702
|
+
var candidates = this._workers.filter(function (x) { return x.activeTasks.length < _this.MAX_CONCURRENCY; });
|
|
703
|
+
candidates = this.filterGeneralPurposeWorkers(candidates, hasExplicitTarget);
|
|
704
|
+
if (debugState) {
|
|
705
|
+
debugState.candidatesInitial = candidates.length;
|
|
706
|
+
}
|
|
707
|
+
var hasPublicationSelector = this.hasWorkerSelector(this._publicationWorkerIndexes, this._publicationWorkerInstances);
|
|
708
|
+
if (hasPublicationSelector && !hasExplicitTarget) {
|
|
709
|
+
if (taskQueue === 'publication') {
|
|
710
|
+
candidates = candidates.filter(function (worker) {
|
|
711
|
+
return _this.workerMatchesSelector(worker, _this._publicationWorkerIndexes, _this._publicationWorkerInstances);
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
candidates = candidates.filter(function (worker) {
|
|
716
|
+
return !_this.workerMatchesSelector(worker, _this._publicationWorkerIndexes, _this._publicationWorkerInstances);
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (debugState) {
|
|
721
|
+
debugState.candidatesAfterPublicationFilter = candidates.length;
|
|
722
|
+
debugState.hasPublicationSelector = hasPublicationSelector;
|
|
723
|
+
}
|
|
724
|
+
var hasCodexSelector = this.hasWorkerSelector(this._codexWorkerIndexes, this._codexWorkerInstances);
|
|
725
|
+
if (hasCodexSelector) {
|
|
726
|
+
if (taskQueue === 'codex') {
|
|
727
|
+
candidates = candidates.filter(function (worker) {
|
|
728
|
+
return _this.workerMatchesSelector(worker, _this._codexWorkerIndexes, _this._codexWorkerInstances);
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
else if (!hasExplicitTarget) {
|
|
732
|
+
candidates = candidates.filter(function (worker) {
|
|
733
|
+
return !_this.workerMatchesSelector(worker, _this._codexWorkerIndexes, _this._codexWorkerInstances);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (debugState) {
|
|
738
|
+
debugState.candidatesAfterCodexFilter = candidates.length;
|
|
739
|
+
debugState.hasCodexSelector = hasCodexSelector;
|
|
740
|
+
}
|
|
741
|
+
if (targetWorkerIndex) {
|
|
742
|
+
candidates = candidates.filter(function (worker) { return _this.normalizeWorkerIndex(worker.workerIndex) === targetWorkerIndex; });
|
|
743
|
+
}
|
|
744
|
+
if (targetWorkerInstance) {
|
|
745
|
+
candidates = candidates.filter(function (worker) { return _this.normalizeWorkerIndex(worker.workerInstance) === targetWorkerInstance; });
|
|
746
|
+
}
|
|
747
|
+
if (debugState) {
|
|
748
|
+
debugState.candidatesAfterTargetFilter = candidates.length;
|
|
749
|
+
}
|
|
750
|
+
if (!candidates.length) {
|
|
751
|
+
this.logCodexSelection(debugState, 'noCandidates');
|
|
752
|
+
return null;
|
|
753
|
+
}
|
|
754
|
+
var eligible = candidates.filter(function (worker) {
|
|
755
|
+
if (!methodLimit) {
|
|
756
|
+
if (!methodLimitPerInstance) {
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (methodLimitPerInstance) {
|
|
761
|
+
var currentInstance = worker.activeTasks.filter(function (a) { return a.method === task.method; }).length;
|
|
762
|
+
if (currentInstance >= methodLimitPerInstance) {
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (!methodLimit) {
|
|
767
|
+
return true;
|
|
768
|
+
}
|
|
769
|
+
var idx = worker.workerIndex || 'unknown';
|
|
770
|
+
var current = 0;
|
|
771
|
+
_this._workers.forEach(function (w) {
|
|
772
|
+
if ((w.workerIndex || 'unknown') === idx) {
|
|
773
|
+
current += w.activeTasks.filter(function (a) { return a.method === task.method; }).length;
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
return current < methodLimit;
|
|
777
|
+
});
|
|
778
|
+
if (debugState) {
|
|
779
|
+
debugState.eligibleAfterLimits = eligible.length;
|
|
780
|
+
}
|
|
781
|
+
if (!eligible.length) {
|
|
782
|
+
this.logCodexSelection(debugState, 'limitsExceeded');
|
|
783
|
+
return null;
|
|
784
|
+
}
|
|
785
|
+
if (taskQueue === 'codex' && this._nonCodexReserve > 0) {
|
|
786
|
+
eligible = eligible.filter(function (worker) { return (_this.MAX_CONCURRENCY - worker.activeTasks.length) > _this._nonCodexReserve; });
|
|
787
|
+
}
|
|
788
|
+
if (debugState) {
|
|
789
|
+
debugState.eligibleAfterReserve = eligible.length;
|
|
790
|
+
}
|
|
791
|
+
if (!eligible.length) {
|
|
792
|
+
this.logCodexSelection(debugState, 'reserveBlocked');
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
eligible.sort(function (x, y) {
|
|
796
|
+
var totalX = _this.getWorkerLoad(x);
|
|
797
|
+
var totalY = _this.getWorkerLoad(y);
|
|
798
|
+
if (totalX !== totalY) {
|
|
799
|
+
return totalX - totalY;
|
|
800
|
+
}
|
|
801
|
+
if (preferNonZero) {
|
|
802
|
+
var xZero = _this.isWorkerZero(x) ? 1 : 0;
|
|
803
|
+
var yZero = _this.isWorkerZero(y) ? 1 : 0;
|
|
804
|
+
if (xZero !== yZero) {
|
|
805
|
+
return xZero - yZero;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
var idxX = _this.normalizeWorkerIndex(x.workerIndex) || '';
|
|
809
|
+
var idxY = _this.normalizeWorkerIndex(y.workerIndex) || '';
|
|
810
|
+
var idxCompare = idxX.localeCompare(idxY, undefined, { numeric: true, sensitivity: 'base' });
|
|
811
|
+
if (idxCompare !== 0) {
|
|
812
|
+
return idxCompare;
|
|
813
|
+
}
|
|
814
|
+
var instX = _this.normalizeWorkerIndex(x.workerInstance) || '';
|
|
815
|
+
var instY = _this.normalizeWorkerIndex(y.workerInstance) || '';
|
|
816
|
+
return instX.localeCompare(instY, undefined, { numeric: true, sensitivity: 'base' });
|
|
817
|
+
});
|
|
818
|
+
var selected = eligible[0];
|
|
819
|
+
if (this._aiWorkerDebug && taskQueue === 'codex') {
|
|
820
|
+
console.log(new Date(), '[AI Worker Debug] AI worker selected', {
|
|
821
|
+
taskId: task.taskId,
|
|
822
|
+
method: task.method,
|
|
823
|
+
workerIndex: (selected === null || selected === void 0 ? void 0 : selected.workerIndex) || null,
|
|
824
|
+
workerInstance: (selected === null || selected === void 0 ? void 0 : selected.workerInstance) || null,
|
|
825
|
+
activeTasks: (selected === null || selected === void 0 ? void 0 : selected.activeTasks) ? selected.activeTasks.length : 0,
|
|
826
|
+
queueDepth: this._taskQueue.length
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
return selected;
|
|
830
|
+
};
|
|
831
|
+
WorkerDispatcherManager.prototype.logCodexSelection = function (debugState, reason) {
|
|
832
|
+
if (!debugState || !this._aiWorkerDebug) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
var taskId = String(debugState.taskId || '');
|
|
836
|
+
if (!taskId || this._debugCodexTaskIds.has(taskId)) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
this._debugCodexTaskIds.add(taskId);
|
|
840
|
+
console.warn(new Date(), '[AI Worker Debug] AI worker selection issue', __assign({ reason: reason }, debugState));
|
|
841
|
+
};
|
|
842
|
+
WorkerDispatcherManager.prototype.normalizeWorkerIndex = function (value) {
|
|
843
|
+
if (value === null || value === undefined) {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
var normalized = String(value).trim();
|
|
847
|
+
return normalized.length ? normalized : null;
|
|
848
|
+
};
|
|
849
|
+
WorkerDispatcherManager.prototype.isGeneralPurposeWorker = function (worker) {
|
|
850
|
+
var normalizedIndex = this.normalizeWorkerIndex(worker === null || worker === void 0 ? void 0 : worker.workerIndex);
|
|
851
|
+
var normalizedInstance = this.normalizeWorkerIndex(worker === null || worker === void 0 ? void 0 : worker.workerInstance);
|
|
852
|
+
if (!normalizedIndex || !normalizedInstance) {
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
return /^[0-9]+$/.test(normalizedIndex) && /^[0-9]+$/.test(normalizedInstance);
|
|
856
|
+
};
|
|
857
|
+
WorkerDispatcherManager.prototype.filterGeneralPurposeWorkers = function (candidates, hasExplicitTarget) {
|
|
858
|
+
var _this = this;
|
|
859
|
+
if (hasExplicitTarget) {
|
|
860
|
+
return candidates;
|
|
861
|
+
}
|
|
862
|
+
return candidates.filter(function (worker) { return _this.isGeneralPurposeWorker(worker); });
|
|
863
|
+
};
|
|
864
|
+
WorkerDispatcherManager.prototype.getWorkerLoad = function (worker) {
|
|
865
|
+
return worker.activeTasks.reduce(function (sum, task) { return sum + task.weight; }, 0);
|
|
866
|
+
};
|
|
867
|
+
WorkerDispatcherManager.prototype.isWorkerZero = function (worker) {
|
|
868
|
+
return this.normalizeWorkerIndex(worker.workerIndex) === '0';
|
|
869
|
+
};
|
|
870
|
+
WorkerDispatcherManager.prototype.assignTaskToWorker = function (worker, task) {
|
|
871
|
+
var _this = this;
|
|
872
|
+
var method = this._methodManager.getMethod(task.method);
|
|
873
|
+
if (!method) {
|
|
874
|
+
console.error('Failed to send task to worker - Could not find method:', task.method);
|
|
875
|
+
this._taskTimings.delete(task.taskId);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
var dispatchedAt = Date.now();
|
|
879
|
+
var timing = this._taskTimings.get(task.taskId) || { queuedAt: dispatchedAt };
|
|
880
|
+
timing.dispatchedAt = dispatchedAt;
|
|
881
|
+
timing.method = task.method;
|
|
882
|
+
timing.messageId = task.messageId;
|
|
883
|
+
timing.userContext = task.userContext;
|
|
884
|
+
if (!timing.params) {
|
|
885
|
+
timing.params = task.params;
|
|
886
|
+
}
|
|
887
|
+
this._taskTimings.set(task.taskId, timing);
|
|
888
|
+
worker.activeTasks.push({
|
|
889
|
+
taskId: task.taskId,
|
|
890
|
+
weight: method && method.workerTaskWeight ? method.workerTaskWeight : 1,
|
|
891
|
+
method: task.method,
|
|
892
|
+
startedAt: dispatchedAt,
|
|
893
|
+
messageId: task.messageId,
|
|
894
|
+
userContext: task.userContext
|
|
895
|
+
});
|
|
896
|
+
this._debugNoWorkerTaskIds.delete(task.taskId);
|
|
897
|
+
var payload = {
|
|
898
|
+
type: 'task',
|
|
899
|
+
taskId: task.taskId,
|
|
900
|
+
messageId: task.messageId,
|
|
901
|
+
method: task.method,
|
|
902
|
+
params: task.params,
|
|
903
|
+
userContext: task.userContext || {},
|
|
904
|
+
queuedAt: timing.queuedAt,
|
|
905
|
+
dispatchedAt: dispatchedAt
|
|
906
|
+
};
|
|
907
|
+
if (this.shouldDebug()) {
|
|
908
|
+
var publicationInfo = this.getPublicationLogInfo(task.method, task.params);
|
|
909
|
+
var logPayload = {
|
|
910
|
+
taskId: task.taskId,
|
|
911
|
+
method: task.method,
|
|
912
|
+
messageId: task.messageId,
|
|
913
|
+
priority: task.method === 'runPublication' ? 'publication' : 'method',
|
|
914
|
+
worker: {
|
|
915
|
+
id: worker.id,
|
|
916
|
+
index: worker.workerIndex,
|
|
917
|
+
instance: worker.workerInstance
|
|
918
|
+
},
|
|
919
|
+
queueDepth: this._taskQueue.length
|
|
920
|
+
};
|
|
921
|
+
if (publicationInfo) {
|
|
922
|
+
Object.assign(logPayload, publicationInfo);
|
|
923
|
+
}
|
|
924
|
+
this.logWorkerEvent('workerTaskAssigned', logPayload);
|
|
925
|
+
}
|
|
926
|
+
var timeoutHandle = setTimeout(function () {
|
|
927
|
+
var timeoutAt = Date.now();
|
|
928
|
+
var queuedAt = timing.queuedAt;
|
|
929
|
+
var queueWaitMs = queuedAt ? (0, common_1.round)(dispatchedAt - queuedAt) : null;
|
|
930
|
+
var dispatchToTimeoutMs = (0, common_1.round)(timeoutAt - dispatchedAt);
|
|
931
|
+
var timeoutMessage = 'Task timed out after 2m in WorkerDispatcherManager for method: ' + task.method;
|
|
932
|
+
var publicationInfo = _this.getPublicationLogInfo(task.method, task.params);
|
|
933
|
+
var logPayload = {
|
|
934
|
+
taskId: task.taskId,
|
|
935
|
+
method: task.method,
|
|
936
|
+
messageId: task.messageId,
|
|
937
|
+
queueWaitMs: queueWaitMs,
|
|
938
|
+
dispatchToTimeoutMs: dispatchToTimeoutMs,
|
|
939
|
+
userContext: task.userContext,
|
|
940
|
+
worker: {
|
|
941
|
+
id: worker.id,
|
|
942
|
+
index: worker.workerIndex,
|
|
943
|
+
instance: worker.workerInstance
|
|
944
|
+
},
|
|
945
|
+
workers: _this._workers.map(function (a) { return a.activeTasks; })
|
|
946
|
+
};
|
|
947
|
+
if (publicationInfo) {
|
|
948
|
+
Object.assign(logPayload, publicationInfo);
|
|
949
|
+
}
|
|
950
|
+
_this.logWorkerEvent('workerTaskTimeout', logPayload);
|
|
951
|
+
_this.disconnectWorker(worker.id, timeoutMessage);
|
|
952
|
+
if (worker.ws && worker.ws.readyState !== WebSocket.CLOSED) {
|
|
953
|
+
try {
|
|
954
|
+
worker.ws.close();
|
|
955
|
+
}
|
|
956
|
+
catch (_a) {
|
|
957
|
+
try {
|
|
958
|
+
worker.ws.terminate();
|
|
959
|
+
}
|
|
960
|
+
catch (_b) {
|
|
961
|
+
// Ignore socket cleanup errors after timeout.
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}, method.timeoutOverride || (1000 * 60 * 2));
|
|
966
|
+
// If we already stored a promise for this task (from sendInternalPromise), add the timeout now
|
|
967
|
+
var existing = this._pendingTasks.get(task.taskId);
|
|
968
|
+
if (!existing) {
|
|
969
|
+
existing = { timeout: null, method: task.method };
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
existing.method = task.method;
|
|
973
|
+
}
|
|
974
|
+
existing.timeout = timeoutHandle;
|
|
975
|
+
this._pendingTasks.set(task.taskId, existing);
|
|
976
|
+
try {
|
|
977
|
+
this.sendWorkerPayload(worker.ws, payload);
|
|
978
|
+
}
|
|
979
|
+
catch (err) {
|
|
980
|
+
console.error('Failed to send task to worker:', err);
|
|
981
|
+
clearTimeout(timeoutHandle);
|
|
982
|
+
worker.activeTasks = worker.activeTasks.filter(function (a) { return a.taskId !== task.taskId; });
|
|
983
|
+
// Put task back in front
|
|
984
|
+
this._taskQueue.unshift(task);
|
|
985
|
+
this.dispatchQueue();
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
WorkerDispatcherManager.prototype.logNoWorkerAvailability = function () {
|
|
989
|
+
var e_6, _a;
|
|
990
|
+
var _this = this;
|
|
991
|
+
if (!this.shouldDebug()) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
var workers = this._workers.map(function (worker) { return ({
|
|
995
|
+
id: worker.id,
|
|
996
|
+
index: _this.normalizeWorkerIndex(worker.workerIndex),
|
|
997
|
+
instance: _this.normalizeWorkerIndex(worker.workerInstance),
|
|
998
|
+
activeTasks: worker.activeTasks.length
|
|
999
|
+
}); });
|
|
1000
|
+
var _loop_1 = function (task) {
|
|
1001
|
+
var method = this_1._methodManager.getMethod(task.method);
|
|
1002
|
+
var targetWorkerIndex = this_1.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerIndex);
|
|
1003
|
+
var targetWorkerInstance = this_1.normalizeWorkerIndex(method === null || method === void 0 ? void 0 : method.targetWorkerInstance);
|
|
1004
|
+
if (!targetWorkerIndex && !targetWorkerInstance) {
|
|
1005
|
+
return "continue";
|
|
1006
|
+
}
|
|
1007
|
+
if (this_1._debugNoWorkerTaskIds.has(task.taskId)) {
|
|
1008
|
+
return "continue";
|
|
1009
|
+
}
|
|
1010
|
+
var hasMatch = this_1._workers.some(function (worker) {
|
|
1011
|
+
return (!targetWorkerIndex || _this.normalizeWorkerIndex(worker.workerIndex) === targetWorkerIndex) &&
|
|
1012
|
+
(!targetWorkerInstance || _this.normalizeWorkerIndex(worker.workerInstance) === targetWorkerInstance);
|
|
1013
|
+
});
|
|
1014
|
+
if (!hasMatch) {
|
|
1015
|
+
this_1._debugNoWorkerTaskIds.add(task.taskId);
|
|
1016
|
+
console.warn(new Date(), '[WorkerDispatcher] No matching worker for task', {
|
|
1017
|
+
taskId: task.taskId,
|
|
1018
|
+
method: task.method,
|
|
1019
|
+
targetWorkerIndex: targetWorkerIndex,
|
|
1020
|
+
targetWorkerInstance: targetWorkerInstance,
|
|
1021
|
+
workers: workers
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var this_1 = this;
|
|
1026
|
+
try {
|
|
1027
|
+
for (var _b = __values(this._taskQueue), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1028
|
+
var task = _c.value;
|
|
1029
|
+
_loop_1(task);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1033
|
+
finally {
|
|
1034
|
+
try {
|
|
1035
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1036
|
+
}
|
|
1037
|
+
finally { if (e_6) throw e_6.error; }
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
WorkerDispatcherManager.prototype.shouldDebug = function () {
|
|
1041
|
+
var _a;
|
|
1042
|
+
if (this._methodManager.getEnableDebug()) {
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
if (this._workerTaskDebug) {
|
|
1046
|
+
return true;
|
|
1047
|
+
}
|
|
1048
|
+
return this.parseDebugFlag((_a = process.env.WORKER_TASK_DEBUG) !== null && _a !== void 0 ? _a : process.env.WORKER_DISPATCH_DEBUG);
|
|
1049
|
+
};
|
|
1050
|
+
WorkerDispatcherManager.prototype.logWorkerEvent = function (event, details) {
|
|
1051
|
+
console.log(this.safeStringify(__assign({ ts: new Date().toISOString(), event: event }, details)));
|
|
1052
|
+
};
|
|
1053
|
+
WorkerDispatcherManager.prototype.safeStringify = function (value) {
|
|
1054
|
+
try {
|
|
1055
|
+
var seen_1 = new WeakSet();
|
|
1056
|
+
return JSON.stringify(value, function (key, val) {
|
|
1057
|
+
if (key === '__proto__') {
|
|
1058
|
+
return undefined;
|
|
1059
|
+
}
|
|
1060
|
+
if (typeof val === 'bigint') {
|
|
1061
|
+
return val.toString();
|
|
1062
|
+
}
|
|
1063
|
+
if (val instanceof Error) {
|
|
1064
|
+
return {
|
|
1065
|
+
name: val.name,
|
|
1066
|
+
message: val.message,
|
|
1067
|
+
stack: val.stack
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
if (val && typeof val === 'object') {
|
|
1071
|
+
if (seen_1.has(val)) {
|
|
1072
|
+
return '[Circular]';
|
|
1073
|
+
}
|
|
1074
|
+
seen_1.add(val);
|
|
1075
|
+
}
|
|
1076
|
+
return val;
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
catch (err) {
|
|
1080
|
+
return JSON.stringify({
|
|
1081
|
+
error: 'safeStringifyFailed',
|
|
1082
|
+
message: (err === null || err === void 0 ? void 0 : err.message) || String(err)
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
/**
|
|
1087
|
+
* Handle messages coming back from a worker (like 'taskComplete').
|
|
1088
|
+
*/
|
|
1089
|
+
WorkerDispatcherManager.prototype.handleWorkerMessage = function (workerId, rawMessage) {
|
|
1090
|
+
var data;
|
|
1091
|
+
try {
|
|
1092
|
+
if (typeof rawMessage === 'string') {
|
|
1093
|
+
data = JSON.parse(rawMessage, common_1.dateReviver);
|
|
1094
|
+
}
|
|
1095
|
+
else if (Buffer.isBuffer(rawMessage)) {
|
|
1096
|
+
data = (0, msgpackr_1.unpack)(rawMessage);
|
|
1097
|
+
}
|
|
1098
|
+
else if (Array.isArray(rawMessage)) {
|
|
1099
|
+
var chunks = rawMessage;
|
|
1100
|
+
data = (0, msgpackr_1.unpack)(Buffer.concat(chunks));
|
|
1101
|
+
}
|
|
1102
|
+
else if (rawMessage instanceof ArrayBuffer) {
|
|
1103
|
+
data = (0, msgpackr_1.unpack)(Buffer.from(rawMessage));
|
|
1104
|
+
}
|
|
1105
|
+
else if (ArrayBuffer.isView(rawMessage)) {
|
|
1106
|
+
var view = rawMessage;
|
|
1107
|
+
data = (0, msgpackr_1.unpack)(Buffer.from(view.buffer, view.byteOffset, view.byteLength));
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
console.error('Unsupported worker message type received:', typeof rawMessage);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
catch (err) {
|
|
1115
|
+
console.error('Failed to parse worker message:', err);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (data.type === 'taskComplete') {
|
|
1119
|
+
var worker = this._workers.find(function (x) { return x.id === workerId; });
|
|
1120
|
+
if (!worker) {
|
|
1121
|
+
console.error('Unknown worker for taskComplete:', workerId);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
var taskId_1 = data.taskId, messageId = data.messageId, error = data.error, result = data.result;
|
|
1125
|
+
var timing = this._taskTimings.get(taskId_1);
|
|
1126
|
+
var methodName = timing === null || timing === void 0 ? void 0 : timing.method;
|
|
1127
|
+
var isAiMethod = !!methodName && methodName.startsWith('ai');
|
|
1128
|
+
var unpackedResult = result;
|
|
1129
|
+
var pendingTask = this._pendingTasks.get(taskId_1);
|
|
1130
|
+
var resolveRaw = !!(pendingTask === null || pendingTask === void 0 ? void 0 : pendingTask.resolveRaw);
|
|
1131
|
+
if (!error && !resolveRaw && unpackedResult === null && data['packedResult']) {
|
|
1132
|
+
try {
|
|
1133
|
+
unpackedResult = (0, msgpackr_1.unpack)(data['packedResult']);
|
|
1134
|
+
}
|
|
1135
|
+
catch (err) {
|
|
1136
|
+
console.error('Failed to unpack worker result', err);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
worker.activeTasks = worker.activeTasks.filter(function (a) { return a.taskId !== taskId_1; });
|
|
1140
|
+
this._taskTimings.delete(taskId_1);
|
|
1141
|
+
if (this._aiWorkerDebug && isAiMethod) {
|
|
1142
|
+
var packedBytes = data['packedResult'] && data['packedResult'].byteLength
|
|
1143
|
+
? data['packedResult'].byteLength
|
|
1144
|
+
: null;
|
|
1145
|
+
var resultBytes = null;
|
|
1146
|
+
if (!packedBytes) {
|
|
1147
|
+
try {
|
|
1148
|
+
resultBytes = Buffer.byteLength(JSON.stringify(result));
|
|
1149
|
+
}
|
|
1150
|
+
catch (_a) {
|
|
1151
|
+
resultBytes = null;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
console.log(new Date(), '[AI Worker Debug] worker result', {
|
|
1155
|
+
taskId: taskId_1,
|
|
1156
|
+
method: methodName,
|
|
1157
|
+
messageId: messageId,
|
|
1158
|
+
hasError: !!error,
|
|
1159
|
+
packedBytes: packedBytes,
|
|
1160
|
+
resultBytes: resultBytes,
|
|
1161
|
+
workerIndex: (worker === null || worker === void 0 ? void 0 : worker.workerIndex) || null,
|
|
1162
|
+
workerInstance: (worker === null || worker === void 0 ? void 0 : worker.workerInstance) || null,
|
|
1163
|
+
queueDepth: this._taskQueue.length
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
if (pendingTask) {
|
|
1167
|
+
if (pendingTask.promise) {
|
|
1168
|
+
if (error) {
|
|
1169
|
+
pendingTask.promise.reject(unpackedResult);
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
pendingTask.promise.resolve(resolveRaw ? data : unpackedResult);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
clearTimeout(pendingTask.timeout);
|
|
1176
|
+
this._pendingTasks.delete(taskId_1);
|
|
1177
|
+
}
|
|
1178
|
+
// Look up original request if it came from a client
|
|
1179
|
+
var clientReqId = this._clientRequests[taskId_1];
|
|
1180
|
+
if (clientReqId) {
|
|
1181
|
+
var res = {
|
|
1182
|
+
messageId: messageId,
|
|
1183
|
+
hasError: false,
|
|
1184
|
+
data: result
|
|
1185
|
+
};
|
|
1186
|
+
if (error) {
|
|
1187
|
+
res.hasError = true;
|
|
1188
|
+
res.data = result;
|
|
1189
|
+
}
|
|
1190
|
+
var clientReqWS = this._websocketManager.getWebSocket(clientReqId);
|
|
1191
|
+
if (clientReqWS) {
|
|
1192
|
+
if (!error && data['packedResult']) {
|
|
1193
|
+
this._websocketManager.sendPackedBuffer(clientReqWS, messageId, false, data['packedResult'], data['encoding'] || 'msgpack', { passThrough: true });
|
|
1194
|
+
}
|
|
1195
|
+
else {
|
|
1196
|
+
this._websocketManager.send(clientReqWS, res);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (this._clientRequests[taskId_1]) {
|
|
1200
|
+
delete this._clientRequests[taskId_1];
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
// Try to dispatch more from the queue
|
|
1204
|
+
if (this._taskQueue.length) {
|
|
1205
|
+
this.dispatchQueue();
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
WorkerDispatcherManager.prototype.sendWorkerPayload = function (ws, payload) {
|
|
1210
|
+
if (!ws) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
if (ws.readyState !== WebSocket.OPEN) {
|
|
1214
|
+
if (typeof payload !== 'string') {
|
|
1215
|
+
var task_1 = payload;
|
|
1216
|
+
this.disconnectWorker(ws['id_worker'], 'Worker socket not open for method: ' + task_1.method);
|
|
1217
|
+
try {
|
|
1218
|
+
ws.close();
|
|
1219
|
+
}
|
|
1220
|
+
catch (_a) { }
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
this.disconnectWorker(ws['id_worker'], 'Worker socket not open.');
|
|
1224
|
+
try {
|
|
1225
|
+
ws.close();
|
|
1226
|
+
}
|
|
1227
|
+
catch (_b) { }
|
|
1228
|
+
}
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (typeof payload === 'string') {
|
|
1232
|
+
try {
|
|
1233
|
+
ws.send(payload);
|
|
1234
|
+
}
|
|
1235
|
+
catch (err) {
|
|
1236
|
+
this.disconnectWorker(ws['id_worker'], 'Failed to send worker payload: ' + (err === null || err === void 0 ? void 0 : err.toString()));
|
|
1237
|
+
try {
|
|
1238
|
+
ws.close();
|
|
1239
|
+
}
|
|
1240
|
+
catch (_c) { }
|
|
1241
|
+
console.error('Failed to send worker payload:', err);
|
|
1242
|
+
}
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
var task = payload;
|
|
1246
|
+
var payloadBuffer = (0, msgpackr_1.pack)(task);
|
|
1247
|
+
try {
|
|
1248
|
+
ws.send(payloadBuffer);
|
|
1249
|
+
}
|
|
1250
|
+
catch (err) {
|
|
1251
|
+
if (this._methodManager.getEnableDebug()) {
|
|
1252
|
+
console.log(new Date(), 'Sending to Server', task);
|
|
1253
|
+
}
|
|
1254
|
+
this.disconnectWorker(ws['id_worker'], 'Failed to send worker response for method: ' + task.method);
|
|
1255
|
+
try {
|
|
1256
|
+
ws.close();
|
|
1257
|
+
}
|
|
1258
|
+
catch (_d) { }
|
|
1259
|
+
console.error('Failed to send worker response:', err);
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
return WorkerDispatcherManager;
|
|
1263
|
+
}());
|
|
1264
|
+
exports.WorkerDispatcherManager = WorkerDispatcherManager;
|
|
1265
|
+
|
|
1266
|
+
//# sourceMappingURL=worker-dispatcher.manager.js.map
|