@resolveio/server-lib 22.3.221 → 22.3.222
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 +7643 -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,1113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __values = (this && this.__values) || function(o) {
|
|
50
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
+
if (m) return m.call(o);
|
|
52
|
+
if (o && typeof o.length === "number") return {
|
|
53
|
+
next: function () {
|
|
54
|
+
if (o && i >= o.length) o = void 0;
|
|
55
|
+
return { value: o && o[i++], done: !o };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.AiAssistantCodexManager = void 0;
|
|
62
|
+
var ai_terminal_conversation_collection_1 = require("../collections/ai-terminal-conversation.collection");
|
|
63
|
+
var ai_terminal_issue_report_collection_1 = require("../collections/ai-terminal-issue-report.collection");
|
|
64
|
+
var ai_terminal_message_collection_1 = require("../collections/ai-terminal-message.collection");
|
|
65
|
+
var fs_1 = require("fs");
|
|
66
|
+
var os = require("os");
|
|
67
|
+
var path = require("path");
|
|
68
|
+
var child_process_1 = require("child_process");
|
|
69
|
+
var util_1 = require("util");
|
|
70
|
+
var DEFAULT_POLL_INTERVAL_MS = 15000;
|
|
71
|
+
var DEFAULT_LOOKBACK_MINUTES = 120;
|
|
72
|
+
var DEFAULT_MAX_MESSAGES_PER_POLL = 100;
|
|
73
|
+
var DEFAULT_MAX_REMEDIATIONS_PER_POLL = 3;
|
|
74
|
+
var DEFAULT_REMEDIATION_TIMEOUT_MS = 20 * 60 * 1000;
|
|
75
|
+
var DEFAULT_REMEDIATION_MAX_BUFFER_BYTES = 1024 * 1024;
|
|
76
|
+
var DEFAULT_REMEDIATION_MAX_ATTEMPTS_PER_ISSUE = 2;
|
|
77
|
+
var DEFAULT_REMEDIATION_COOLDOWN_MINUTES = 15;
|
|
78
|
+
var DEFAULT_REPLAY_TIMEOUT_MS = 5 * 60 * 1000;
|
|
79
|
+
var DEFAULT_REPLAY_MAX_BUFFER_BYTES = 1024 * 1024;
|
|
80
|
+
var DEFAULT_REPLAY_MAX_ATTEMPTS_PER_ISSUE = 2;
|
|
81
|
+
var DEFAULT_REPLAY_COOLDOWN_MINUTES = 10;
|
|
82
|
+
var MAX_STORED_OUTPUT_CHARS = 4000;
|
|
83
|
+
var execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
84
|
+
function normalizeOptionalString(value) {
|
|
85
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
86
|
+
}
|
|
87
|
+
function parseBooleanEnv(value, fallback) {
|
|
88
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
89
|
+
if (!normalized) {
|
|
90
|
+
return fallback;
|
|
91
|
+
}
|
|
92
|
+
if (['1', 'true', 'yes', 'on', 'enabled'].includes(normalized)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
if (['0', 'false', 'no', 'off', 'disabled'].includes(normalized)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return fallback;
|
|
99
|
+
}
|
|
100
|
+
function parsePositiveInt(value, fallback, min) {
|
|
101
|
+
if (min === void 0) { min = 1; }
|
|
102
|
+
var parsed = parseInt(String(value !== null && value !== void 0 ? value : '').trim(), 10);
|
|
103
|
+
if (!Number.isFinite(parsed) || Number.isNaN(parsed) || parsed < min) {
|
|
104
|
+
return fallback;
|
|
105
|
+
}
|
|
106
|
+
return parsed;
|
|
107
|
+
}
|
|
108
|
+
function parsePositiveIntWithMax(value, fallback, min, max) {
|
|
109
|
+
var parsed = parsePositiveInt(value, fallback, min);
|
|
110
|
+
return Math.min(parsed, max);
|
|
111
|
+
}
|
|
112
|
+
function resolveEnabledFlag() {
|
|
113
|
+
var _a;
|
|
114
|
+
var explicitValue = (_a = process.env.AI_ASSISTANT_CODEX_MANAGER_ENABLED) !== null && _a !== void 0 ? _a : process.env.AI_ASSISTANT_QUALITY_MANAGER_ENABLED;
|
|
115
|
+
if (explicitValue !== undefined && explicitValue !== null && String(explicitValue).trim() !== '') {
|
|
116
|
+
return parseBooleanEnv(explicitValue, false);
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
var AiAssistantCodexManager = /** @class */ (function () {
|
|
121
|
+
function AiAssistantCodexManager(config, runtime) {
|
|
122
|
+
this._interval = null;
|
|
123
|
+
this._inFlight = false;
|
|
124
|
+
this._cursorMessageId = '';
|
|
125
|
+
this.config = config;
|
|
126
|
+
this.runtime = runtime;
|
|
127
|
+
this._cursorCreatedAt = new Date(Date.now() - (config.lookbackMinutes * 60 * 1000));
|
|
128
|
+
}
|
|
129
|
+
AiAssistantCodexManager.createIfEnabled = function (runtime) {
|
|
130
|
+
var config = this.resolveConfig();
|
|
131
|
+
if (!config.enabled) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (!this.shouldRunOnCurrentProcess(config, runtime)) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
var manager = new AiAssistantCodexManager(config, runtime);
|
|
138
|
+
manager.initialize();
|
|
139
|
+
return manager;
|
|
140
|
+
};
|
|
141
|
+
AiAssistantCodexManager.resolveConfig = function () {
|
|
142
|
+
var targetWorkerIndex = normalizeOptionalString(process.env.AI_ASSISTANT_CODEX_MANAGER_WORKER_INDEX
|
|
143
|
+
|| process.env.AI_ASSISTANT_CODEX_WORKER_INDEX
|
|
144
|
+
|| process.env.CODEX_WORKER_INDEX
|
|
145
|
+
|| 'ai-assistant-manager') || 'ai-assistant-manager';
|
|
146
|
+
var targetWorkerInstance = normalizeOptionalString(process.env.AI_ASSISTANT_CODEX_MANAGER_WORKER_INSTANCE) || null;
|
|
147
|
+
return {
|
|
148
|
+
enabled: resolveEnabledFlag(),
|
|
149
|
+
runOnAnyWorker: parseBooleanEnv(process.env.AI_ASSISTANT_CODEX_MANAGER_RUN_ANY_WORKER, false),
|
|
150
|
+
targetWorkerIndex: targetWorkerIndex,
|
|
151
|
+
targetWorkerInstance: targetWorkerInstance,
|
|
152
|
+
pollIntervalMs: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_INTERVAL_MS, DEFAULT_POLL_INTERVAL_MS, 1000),
|
|
153
|
+
lookbackMinutes: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_LOOKBACK_MINUTES, DEFAULT_LOOKBACK_MINUTES, 1),
|
|
154
|
+
maxMessagesPerPoll: parsePositiveIntWithMax(process.env.AI_ASSISTANT_CODEX_MANAGER_MAX_MESSAGES_PER_POLL, DEFAULT_MAX_MESSAGES_PER_POLL, 1, 1000),
|
|
155
|
+
maxRemediationsPerPoll: parsePositiveIntWithMax(process.env.AI_ASSISTANT_CODEX_MANAGER_MAX_REMEDIATIONS_PER_POLL, DEFAULT_MAX_REMEDIATIONS_PER_POLL, 1, 100),
|
|
156
|
+
autoReportEnabled: parseBooleanEnv(process.env.AI_ASSISTANT_CODEX_MANAGER_AUTO_REPORT, true),
|
|
157
|
+
autoRemediationEnabled: parseBooleanEnv(process.env.AI_ASSISTANT_CODEX_MANAGER_AUTO_REMEDIATE, false),
|
|
158
|
+
remediationHookPath: normalizeOptionalString(process.env.AI_ASSISTANT_CODEX_MANAGER_REMEDIATE_HOOK),
|
|
159
|
+
remediationTimeoutMs: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REMEDIATE_TIMEOUT_MS, DEFAULT_REMEDIATION_TIMEOUT_MS, 1000),
|
|
160
|
+
remediationMaxBufferBytes: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REMEDIATE_MAX_BUFFER_BYTES, DEFAULT_REMEDIATION_MAX_BUFFER_BYTES, 1024),
|
|
161
|
+
remediationMaxAttemptsPerIssue: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REMEDIATE_MAX_ATTEMPTS_PER_ISSUE, DEFAULT_REMEDIATION_MAX_ATTEMPTS_PER_ISSUE, 1),
|
|
162
|
+
remediationCooldownMinutes: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REMEDIATE_COOLDOWN_MINUTES, DEFAULT_REMEDIATION_COOLDOWN_MINUTES, 1),
|
|
163
|
+
autoReplayEnabled: parseBooleanEnv(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_ENABLED, false),
|
|
164
|
+
replayCommand: normalizeOptionalString(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_COMMAND),
|
|
165
|
+
replayTimeoutMs: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_TIMEOUT_MS, DEFAULT_REPLAY_TIMEOUT_MS, 1000),
|
|
166
|
+
replayMaxBufferBytes: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_MAX_BUFFER_BYTES, DEFAULT_REPLAY_MAX_BUFFER_BYTES, 1024),
|
|
167
|
+
replayMaxAttemptsPerIssue: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_MAX_ATTEMPTS_PER_ISSUE, DEFAULT_REPLAY_MAX_ATTEMPTS_PER_ISSUE, 1),
|
|
168
|
+
replayCooldownMinutes: parsePositiveInt(process.env.AI_ASSISTANT_CODEX_MANAGER_REPLAY_COOLDOWN_MINUTES, DEFAULT_REPLAY_COOLDOWN_MINUTES, 1),
|
|
169
|
+
debug: parseBooleanEnv(process.env.AI_ASSISTANT_CODEX_MANAGER_DEBUG, false)
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
AiAssistantCodexManager.shouldRunOnCurrentProcess = function (config, runtime) {
|
|
173
|
+
var workerIndex = normalizeOptionalString(runtime.workerIndex);
|
|
174
|
+
var workerInstance = normalizeOptionalString(runtime.workerInstance);
|
|
175
|
+
if (!runtime.isWorkersEnabled) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (!runtime.isWorkerInstance) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
if (config.runOnAnyWorker) {
|
|
182
|
+
if (config.targetWorkerInstance) {
|
|
183
|
+
return workerInstance === config.targetWorkerInstance;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (workerIndex !== config.targetWorkerIndex) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (config.targetWorkerInstance && workerInstance !== config.targetWorkerInstance) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
};
|
|
195
|
+
AiAssistantCodexManager.prototype.initialize = function () {
|
|
196
|
+
var _this = this;
|
|
197
|
+
console.log(new Date(), '[AI Assistant Codex Manager] started', {
|
|
198
|
+
workerIndex: process.env.WORKER_INDEX || null,
|
|
199
|
+
workerInstance: process.env.NODE_APP_INSTANCE || null,
|
|
200
|
+
pollIntervalMs: this.config.pollIntervalMs,
|
|
201
|
+
maxMessagesPerPoll: this.config.maxMessagesPerPoll,
|
|
202
|
+
lookbackMinutes: this.config.lookbackMinutes,
|
|
203
|
+
autoRemediationEnabled: this.config.autoRemediationEnabled,
|
|
204
|
+
remediationHookPath: this.config.remediationHookPath || null,
|
|
205
|
+
autoReplayEnabled: this.config.autoReplayEnabled
|
|
206
|
+
});
|
|
207
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
208
|
+
var error_1;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
_a.trys.push([0, 2, , 3]);
|
|
213
|
+
return [4 /*yield*/, this.pollOnce()];
|
|
214
|
+
case 1:
|
|
215
|
+
_a.sent();
|
|
216
|
+
return [3 /*break*/, 3];
|
|
217
|
+
case 2:
|
|
218
|
+
error_1 = _a.sent();
|
|
219
|
+
console.error(new Date(), '[AI Assistant Codex Manager] initial poll failed', error_1);
|
|
220
|
+
return [3 /*break*/, 3];
|
|
221
|
+
case 3: return [2 /*return*/];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}); }, 2500);
|
|
225
|
+
this._interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
226
|
+
var error_2;
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
switch (_a.label) {
|
|
229
|
+
case 0:
|
|
230
|
+
_a.trys.push([0, 2, , 3]);
|
|
231
|
+
return [4 /*yield*/, this.pollOnce()];
|
|
232
|
+
case 1:
|
|
233
|
+
_a.sent();
|
|
234
|
+
return [3 /*break*/, 3];
|
|
235
|
+
case 2:
|
|
236
|
+
error_2 = _a.sent();
|
|
237
|
+
console.error(new Date(), '[AI Assistant Codex Manager] poll failed', error_2);
|
|
238
|
+
return [3 /*break*/, 3];
|
|
239
|
+
case 3: return [2 /*return*/];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}); }, this.config.pollIntervalMs);
|
|
243
|
+
};
|
|
244
|
+
AiAssistantCodexManager.prototype.pollOnce = function () {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var query, messages, messages_1, messages_1_1, message, createdAt, e_1_1;
|
|
247
|
+
var e_1, _a;
|
|
248
|
+
return __generator(this, function (_b) {
|
|
249
|
+
switch (_b.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
if (this._inFlight) {
|
|
252
|
+
return [2 /*return*/];
|
|
253
|
+
}
|
|
254
|
+
this._inFlight = true;
|
|
255
|
+
_b.label = 1;
|
|
256
|
+
case 1:
|
|
257
|
+
_b.trys.push([1, , 13, 14]);
|
|
258
|
+
query = {
|
|
259
|
+
role: 'assistant',
|
|
260
|
+
$or: [
|
|
261
|
+
{ createdAt: { $gt: this._cursorCreatedAt } },
|
|
262
|
+
{ createdAt: this._cursorCreatedAt, _id: { $gt: this._cursorMessageId || '' } }
|
|
263
|
+
]
|
|
264
|
+
};
|
|
265
|
+
return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.find(query, {
|
|
266
|
+
sort: { createdAt: 1, _id: 1 },
|
|
267
|
+
limit: this.config.maxMessagesPerPoll
|
|
268
|
+
})];
|
|
269
|
+
case 2:
|
|
270
|
+
messages = _b.sent();
|
|
271
|
+
if (!(Array.isArray(messages) && messages.length)) return [3 /*break*/, 10];
|
|
272
|
+
_b.label = 3;
|
|
273
|
+
case 3:
|
|
274
|
+
_b.trys.push([3, 8, 9, 10]);
|
|
275
|
+
messages_1 = __values(messages), messages_1_1 = messages_1.next();
|
|
276
|
+
_b.label = 4;
|
|
277
|
+
case 4:
|
|
278
|
+
if (!!messages_1_1.done) return [3 /*break*/, 7];
|
|
279
|
+
message = messages_1_1.value;
|
|
280
|
+
createdAt = (message === null || message === void 0 ? void 0 : message.createdAt) ? new Date(message.createdAt) : null;
|
|
281
|
+
if (createdAt && Number.isFinite(createdAt.getTime())) {
|
|
282
|
+
this._cursorCreatedAt = createdAt;
|
|
283
|
+
}
|
|
284
|
+
this._cursorMessageId = normalizeOptionalString(message === null || message === void 0 ? void 0 : message._id);
|
|
285
|
+
return [4 /*yield*/, this.processMessage(message)];
|
|
286
|
+
case 5:
|
|
287
|
+
_b.sent();
|
|
288
|
+
_b.label = 6;
|
|
289
|
+
case 6:
|
|
290
|
+
messages_1_1 = messages_1.next();
|
|
291
|
+
return [3 /*break*/, 4];
|
|
292
|
+
case 7: return [3 /*break*/, 10];
|
|
293
|
+
case 8:
|
|
294
|
+
e_1_1 = _b.sent();
|
|
295
|
+
e_1 = { error: e_1_1 };
|
|
296
|
+
return [3 /*break*/, 10];
|
|
297
|
+
case 9:
|
|
298
|
+
try {
|
|
299
|
+
if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) _a.call(messages_1);
|
|
300
|
+
}
|
|
301
|
+
finally { if (e_1) throw e_1.error; }
|
|
302
|
+
return [7 /*endfinally*/];
|
|
303
|
+
case 10:
|
|
304
|
+
if (!this.config.autoRemediationEnabled) return [3 /*break*/, 12];
|
|
305
|
+
return [4 /*yield*/, this.pollRemediationQueue()];
|
|
306
|
+
case 11:
|
|
307
|
+
_b.sent();
|
|
308
|
+
_b.label = 12;
|
|
309
|
+
case 12: return [3 /*break*/, 14];
|
|
310
|
+
case 13:
|
|
311
|
+
this._inFlight = false;
|
|
312
|
+
return [7 /*endfinally*/];
|
|
313
|
+
case 14: return [2 /*return*/];
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
AiAssistantCodexManager.prototype.processMessage = function (message) {
|
|
319
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
+
var messageId, conversationId, metadata, decision, issueReportId;
|
|
321
|
+
var _a;
|
|
322
|
+
return __generator(this, function (_b) {
|
|
323
|
+
switch (_b.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
messageId = normalizeOptionalString(message === null || message === void 0 ? void 0 : message._id);
|
|
326
|
+
conversationId = normalizeOptionalString(message === null || message === void 0 ? void 0 : message.id_conversation);
|
|
327
|
+
if (!messageId || !conversationId) {
|
|
328
|
+
return [2 /*return*/];
|
|
329
|
+
}
|
|
330
|
+
metadata = this.normalizeMetadata(message === null || message === void 0 ? void 0 : message.metadata);
|
|
331
|
+
if (metadata.pending === true) {
|
|
332
|
+
return [2 /*return*/];
|
|
333
|
+
}
|
|
334
|
+
if ((_a = metadata.quality_manager) === null || _a === void 0 ? void 0 : _a.checked_at) {
|
|
335
|
+
return [2 /*return*/];
|
|
336
|
+
}
|
|
337
|
+
decision = this.evaluateMessageQuality(message, metadata);
|
|
338
|
+
issueReportId = '';
|
|
339
|
+
if (!(decision.status === 'needs_review' && this.config.autoReportEnabled)) return [3 /*break*/, 2];
|
|
340
|
+
return [4 /*yield*/, this.ensureAutomatedIssueReport(message, decision)];
|
|
341
|
+
case 1:
|
|
342
|
+
issueReportId = _b.sent();
|
|
343
|
+
_b.label = 2;
|
|
344
|
+
case 2: return [4 /*yield*/, this.markMessageQualityReviewed(messageId, decision, issueReportId)];
|
|
345
|
+
case 3:
|
|
346
|
+
_b.sent();
|
|
347
|
+
if (!(issueReportId && this.config.autoRemediationEnabled)) return [3 /*break*/, 5];
|
|
348
|
+
return [4 /*yield*/, this.runIssueRemediation(issueReportId, { source: 'auto', trigger: 'message_quality' })];
|
|
349
|
+
case 4:
|
|
350
|
+
_b.sent();
|
|
351
|
+
_b.label = 5;
|
|
352
|
+
case 5: return [2 /*return*/];
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
AiAssistantCodexManager.prototype.evaluateMessageQuality = function (message, metadata) {
|
|
358
|
+
var _a, _b;
|
|
359
|
+
var content = normalizeOptionalString(message === null || message === void 0 ? void 0 : message.content);
|
|
360
|
+
var toolError = normalizeOptionalString((_b = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.tool_execution) === null || _a === void 0 ? void 0 : _a.outcome) === null || _b === void 0 ? void 0 : _b.error);
|
|
361
|
+
if (metadata.failed === true) {
|
|
362
|
+
return {
|
|
363
|
+
status: 'needs_review',
|
|
364
|
+
reason: 'Assistant response finalized in failed state.',
|
|
365
|
+
code: 'metadata_failed'
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (/I ran into an internal error while preparing that response/i.test(content)) {
|
|
369
|
+
return {
|
|
370
|
+
status: 'needs_review',
|
|
371
|
+
reason: 'Assistant returned internal error text.',
|
|
372
|
+
code: 'internal_error_copy'
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (/That took longer than expected\./i.test(content)) {
|
|
376
|
+
return {
|
|
377
|
+
status: 'needs_review',
|
|
378
|
+
reason: 'Assistant response timed out.',
|
|
379
|
+
code: 'timeout_copy'
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (/I could not finish this request within the assistant time budget/i.test(content)) {
|
|
383
|
+
return {
|
|
384
|
+
status: 'needs_review',
|
|
385
|
+
reason: 'Assistant run exceeded configured time budget.',
|
|
386
|
+
code: 'run_budget_exceeded_copy'
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
if (toolError) {
|
|
390
|
+
return {
|
|
391
|
+
status: 'needs_review',
|
|
392
|
+
reason: "Assistant tool execution error: ".concat(toolError).slice(0, 500),
|
|
393
|
+
code: 'tool_execution_error'
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
status: 'pass',
|
|
398
|
+
reason: 'Quality check passed.',
|
|
399
|
+
code: 'ok'
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
AiAssistantCodexManager.prototype.ensureAutomatedIssueReport = function (message, decision) {
|
|
403
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
+
var messageId, conversationId, existing, conversation, assistantContent, requestId, userPrompt, now, doc, insertResult, issueId;
|
|
405
|
+
var _a;
|
|
406
|
+
return __generator(this, function (_b) {
|
|
407
|
+
switch (_b.label) {
|
|
408
|
+
case 0:
|
|
409
|
+
messageId = normalizeOptionalString(message === null || message === void 0 ? void 0 : message._id);
|
|
410
|
+
conversationId = normalizeOptionalString(message === null || message === void 0 ? void 0 : message.id_conversation);
|
|
411
|
+
if (!messageId || !conversationId) {
|
|
412
|
+
return [2 /*return*/, ''];
|
|
413
|
+
}
|
|
414
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.findOne({
|
|
415
|
+
id_message: messageId,
|
|
416
|
+
source: 'automated'
|
|
417
|
+
})];
|
|
418
|
+
case 1:
|
|
419
|
+
existing = _b.sent();
|
|
420
|
+
if (existing === null || existing === void 0 ? void 0 : existing._id) {
|
|
421
|
+
return [2 /*return*/, normalizeOptionalString(existing._id)];
|
|
422
|
+
}
|
|
423
|
+
return [4 /*yield*/, ai_terminal_conversation_collection_1.AiTerminalConversations.findById(conversationId)];
|
|
424
|
+
case 2:
|
|
425
|
+
conversation = _b.sent();
|
|
426
|
+
if (!conversation) {
|
|
427
|
+
return [2 /*return*/, ''];
|
|
428
|
+
}
|
|
429
|
+
assistantContent = normalizeOptionalString(message === null || message === void 0 ? void 0 : message.content);
|
|
430
|
+
requestId = normalizeOptionalString((_a = message === null || message === void 0 ? void 0 : message.metadata) === null || _a === void 0 ? void 0 : _a.request_id);
|
|
431
|
+
return [4 /*yield*/, this.resolveClosestUserPrompt(conversationId, message === null || message === void 0 ? void 0 : message.createdAt)];
|
|
432
|
+
case 3:
|
|
433
|
+
userPrompt = _b.sent();
|
|
434
|
+
now = new Date();
|
|
435
|
+
doc = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ id_conversation: conversationId, status: 'open', source: 'automated', reason: decision.reason }, (userPrompt ? { user_prompt: userPrompt } : {})), (assistantContent ? { assistant_content: assistantContent } : {})), (requestId ? { request_id: requestId } : {})), { id_message: messageId }), (normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_client) ? { id_client: normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_client) } : {})), (normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_app) ? { id_app: normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_app) } : {})), (normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_user) ? { id_user: normalizeOptionalString(conversation === null || conversation === void 0 ? void 0 : conversation.id_user) } : {})), { metadata: {
|
|
436
|
+
quality_manager: {
|
|
437
|
+
code: decision.code,
|
|
438
|
+
checked_at: now,
|
|
439
|
+
worker_index: normalizeOptionalString(process.env.WORKER_INDEX),
|
|
440
|
+
worker_instance: normalizeOptionalString(process.env.NODE_APP_INSTANCE)
|
|
441
|
+
}
|
|
442
|
+
}, createdAt: now, updatedAt: now });
|
|
443
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.insertOne(doc)];
|
|
444
|
+
case 4:
|
|
445
|
+
insertResult = _b.sent();
|
|
446
|
+
issueId = normalizeOptionalString(insertResult === null || insertResult === void 0 ? void 0 : insertResult._id);
|
|
447
|
+
console.log(new Date(), '[AI Assistant Codex Manager] created automated issue report', {
|
|
448
|
+
id_issue_report: issueId || null,
|
|
449
|
+
id_conversation: conversationId,
|
|
450
|
+
id_message: messageId,
|
|
451
|
+
code: decision.code
|
|
452
|
+
});
|
|
453
|
+
return [2 /*return*/, issueId];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
AiAssistantCodexManager.prototype.pollRemediationQueue = function () {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var issues, issues_1, issues_1_1, issue, issueId, remediationResult, e_2_1;
|
|
461
|
+
var e_2, _a;
|
|
462
|
+
return __generator(this, function (_b) {
|
|
463
|
+
switch (_b.label) {
|
|
464
|
+
case 0: return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.find({
|
|
465
|
+
source: 'automated',
|
|
466
|
+
status: { $in: ['open', 'triaged'] },
|
|
467
|
+
$or: [
|
|
468
|
+
{ 'metadata.quality_manager.remediation.status': { $exists: false } },
|
|
469
|
+
{ 'metadata.quality_manager.remediation.status': { $in: ['queued', 'failed', 'skipped'] } }
|
|
470
|
+
]
|
|
471
|
+
}, {
|
|
472
|
+
sort: { updatedAt: 1, createdAt: 1 },
|
|
473
|
+
limit: this.config.maxRemediationsPerPoll
|
|
474
|
+
})];
|
|
475
|
+
case 1:
|
|
476
|
+
issues = _b.sent();
|
|
477
|
+
if (!Array.isArray(issues) || !issues.length) {
|
|
478
|
+
return [2 /*return*/];
|
|
479
|
+
}
|
|
480
|
+
_b.label = 2;
|
|
481
|
+
case 2:
|
|
482
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
483
|
+
issues_1 = __values(issues), issues_1_1 = issues_1.next();
|
|
484
|
+
_b.label = 3;
|
|
485
|
+
case 3:
|
|
486
|
+
if (!!issues_1_1.done) return [3 /*break*/, 6];
|
|
487
|
+
issue = issues_1_1.value;
|
|
488
|
+
issueId = normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue._id);
|
|
489
|
+
if (!issueId) {
|
|
490
|
+
return [3 /*break*/, 5];
|
|
491
|
+
}
|
|
492
|
+
return [4 /*yield*/, this.runIssueRemediation(issueId, { source: 'auto', trigger: 'poll' })];
|
|
493
|
+
case 4:
|
|
494
|
+
remediationResult = _b.sent();
|
|
495
|
+
if ((remediationResult === null || remediationResult === void 0 ? void 0 : remediationResult.status) === 'success' || (remediationResult === null || remediationResult === void 0 ? void 0 : remediationResult.status) === 'running') {
|
|
496
|
+
return [3 /*break*/, 6];
|
|
497
|
+
}
|
|
498
|
+
_b.label = 5;
|
|
499
|
+
case 5:
|
|
500
|
+
issues_1_1 = issues_1.next();
|
|
501
|
+
return [3 /*break*/, 3];
|
|
502
|
+
case 6: return [3 /*break*/, 9];
|
|
503
|
+
case 7:
|
|
504
|
+
e_2_1 = _b.sent();
|
|
505
|
+
e_2 = { error: e_2_1 };
|
|
506
|
+
return [3 /*break*/, 9];
|
|
507
|
+
case 8:
|
|
508
|
+
try {
|
|
509
|
+
if (issues_1_1 && !issues_1_1.done && (_a = issues_1.return)) _a.call(issues_1);
|
|
510
|
+
}
|
|
511
|
+
finally { if (e_2) throw e_2.error; }
|
|
512
|
+
return [7 /*endfinally*/];
|
|
513
|
+
case 9: return [2 /*return*/];
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
AiAssistantCodexManager.prototype.runIssueRemediation = function (issueReportId_1) {
|
|
519
|
+
return __awaiter(this, arguments, void 0, function (issueReportId, options) {
|
|
520
|
+
var issueId, issue, force, source, now, metadata, qualityManager, remediation, existingStatus, attemptsUsed, maxAttempts, cooldownMinutes, cooldownMs, lastAttemptAt, ageMs, attemptCount, startedAtMs, contextPath, parsedOutput, execResult, finishedAt, durationMs, stdout, stderr, outputStatus, success, remediationStatus, remediationReason, replayResult, error_3, finishedAt, durationMs, err, stdout, stderr, exitCode, timeoutHit, reason, nextAttemptAt, _a;
|
|
521
|
+
if (options === void 0) { options = {}; }
|
|
522
|
+
return __generator(this, function (_b) {
|
|
523
|
+
switch (_b.label) {
|
|
524
|
+
case 0:
|
|
525
|
+
issueId = normalizeOptionalString(issueReportId);
|
|
526
|
+
if (!issueId) {
|
|
527
|
+
return [2 /*return*/, {
|
|
528
|
+
status: 'failed',
|
|
529
|
+
reason: 'Issue report id is required.'
|
|
530
|
+
}];
|
|
531
|
+
}
|
|
532
|
+
if (!this.config.autoRemediationEnabled) {
|
|
533
|
+
return [2 /*return*/, {
|
|
534
|
+
status: 'skipped',
|
|
535
|
+
reason: 'Auto remediation is disabled.'
|
|
536
|
+
}];
|
|
537
|
+
}
|
|
538
|
+
if (!this.config.remediationHookPath) {
|
|
539
|
+
return [2 /*return*/, {
|
|
540
|
+
status: 'skipped',
|
|
541
|
+
reason: 'Remediation hook path is not configured.'
|
|
542
|
+
}];
|
|
543
|
+
}
|
|
544
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.findById(issueId)];
|
|
545
|
+
case 1:
|
|
546
|
+
issue = _b.sent();
|
|
547
|
+
if (!issue) {
|
|
548
|
+
return [2 /*return*/, {
|
|
549
|
+
status: 'not_found',
|
|
550
|
+
reason: 'Issue report not found.'
|
|
551
|
+
}];
|
|
552
|
+
}
|
|
553
|
+
force = options.force === true;
|
|
554
|
+
source = options.source === 'manual' ? 'manual' : 'auto';
|
|
555
|
+
now = new Date();
|
|
556
|
+
metadata = this.normalizeMetadata(issue.metadata);
|
|
557
|
+
qualityManager = this.normalizeMetadata(metadata.quality_manager);
|
|
558
|
+
remediation = this.normalizeMetadata(qualityManager.remediation);
|
|
559
|
+
existingStatus = normalizeOptionalString(remediation.status).toLowerCase();
|
|
560
|
+
attemptsUsed = Number.isFinite(Number(remediation.attempt_count)) ? Number(remediation.attempt_count) : 0;
|
|
561
|
+
maxAttempts = this.config.remediationMaxAttemptsPerIssue;
|
|
562
|
+
cooldownMinutes = this.config.remediationCooldownMinutes;
|
|
563
|
+
cooldownMs = cooldownMinutes * 60 * 1000;
|
|
564
|
+
lastAttemptAt = this.parseDate(remediation.last_attempt_at);
|
|
565
|
+
if (!force && existingStatus === 'running') {
|
|
566
|
+
return [2 /*return*/, {
|
|
567
|
+
status: 'running',
|
|
568
|
+
reason: 'Remediation already running.',
|
|
569
|
+
issueId: issueId
|
|
570
|
+
}];
|
|
571
|
+
}
|
|
572
|
+
if (!force && maxAttempts > 0 && attemptsUsed >= maxAttempts) {
|
|
573
|
+
return [2 /*return*/, {
|
|
574
|
+
status: 'skipped',
|
|
575
|
+
reason: "Remediation attempt budget reached (".concat(attemptsUsed, "/").concat(maxAttempts, ")."),
|
|
576
|
+
issueId: issueId
|
|
577
|
+
}];
|
|
578
|
+
}
|
|
579
|
+
if (!force && existingStatus === 'failed' && lastAttemptAt) {
|
|
580
|
+
ageMs = now.getTime() - lastAttemptAt.getTime();
|
|
581
|
+
if (ageMs >= 0 && ageMs < cooldownMs) {
|
|
582
|
+
return [2 /*return*/, {
|
|
583
|
+
status: 'skipped',
|
|
584
|
+
reason: 'Remediation cooldown active.',
|
|
585
|
+
issueId: issueId,
|
|
586
|
+
nextAttemptAt: new Date(lastAttemptAt.getTime() + cooldownMs)
|
|
587
|
+
}];
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
attemptCount = attemptsUsed + 1;
|
|
591
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
592
|
+
$set: {
|
|
593
|
+
'metadata.quality_manager.remediation': __assign(__assign({}, remediation), { status: 'running', source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, hook: this.config.remediationHookPath, last_attempt_at: now, updated_at: now, last_error: '', last_exit_code: null }),
|
|
594
|
+
updatedAt: now
|
|
595
|
+
}
|
|
596
|
+
})];
|
|
597
|
+
case 2:
|
|
598
|
+
_b.sent();
|
|
599
|
+
startedAtMs = Date.now();
|
|
600
|
+
return [4 /*yield*/, this.writeRemediationContextFile(issue, {
|
|
601
|
+
issueId: issueId,
|
|
602
|
+
attemptCount: attemptCount,
|
|
603
|
+
source: source,
|
|
604
|
+
trigger: normalizeOptionalString(options.trigger) || 'unspecified'
|
|
605
|
+
})];
|
|
606
|
+
case 3:
|
|
607
|
+
contextPath = _b.sent();
|
|
608
|
+
parsedOutput = null;
|
|
609
|
+
_b.label = 4;
|
|
610
|
+
case 4:
|
|
611
|
+
_b.trys.push([4, 9, 11, 16]);
|
|
612
|
+
return [4 /*yield*/, execFileAsync(this.config.remediationHookPath, [contextPath], {
|
|
613
|
+
timeout: this.config.remediationTimeoutMs,
|
|
614
|
+
maxBuffer: this.config.remediationMaxBufferBytes,
|
|
615
|
+
env: __assign(__assign({}, process.env), { RIO_AI_ASSISTANT_REMEDIATION_CONTEXT: contextPath, RIO_AI_ASSISTANT_REMEDIATION_ISSUE_ID: issueId })
|
|
616
|
+
})];
|
|
617
|
+
case 5:
|
|
618
|
+
execResult = _b.sent();
|
|
619
|
+
finishedAt = new Date();
|
|
620
|
+
durationMs = Date.now() - startedAtMs;
|
|
621
|
+
stdout = this.toSafeOutput(execResult === null || execResult === void 0 ? void 0 : execResult.stdout);
|
|
622
|
+
stderr = this.toSafeOutput(execResult === null || execResult === void 0 ? void 0 : execResult.stderr);
|
|
623
|
+
parsedOutput = this.parseOutputJson(stdout);
|
|
624
|
+
outputStatus = normalizeOptionalString(parsedOutput === null || parsedOutput === void 0 ? void 0 : parsedOutput.status).toLowerCase();
|
|
625
|
+
success = outputStatus ? ['success', 'ok', 'completed', 'pass'].includes(outputStatus) : true;
|
|
626
|
+
remediationStatus = success ? 'success' : 'failed';
|
|
627
|
+
remediationReason = normalizeOptionalString(parsedOutput === null || parsedOutput === void 0 ? void 0 : parsedOutput.reason)
|
|
628
|
+
|| (success ? 'Remediation hook completed successfully.' : 'Remediation hook reported a non-success status.');
|
|
629
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
630
|
+
$set: __assign(__assign({ 'metadata.quality_manager.remediation': __assign(__assign({}, remediation), { status: remediationStatus, source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, hook: this.config.remediationHookPath, last_attempt_at: now, last_success_at: success ? finishedAt : remediation.last_success_at, last_error: success ? '' : remediationReason, last_exit_code: success ? 0 : null, last_duration_ms: durationMs, last_stdout: stdout, last_stderr: stderr, last_output: parsedOutput || undefined, updated_at: finishedAt }) }, (success ? { status: 'triaged' } : {})), { updatedAt: finishedAt })
|
|
631
|
+
})];
|
|
632
|
+
case 6:
|
|
633
|
+
_b.sent();
|
|
634
|
+
replayResult = null;
|
|
635
|
+
if (!(success && this.config.autoReplayEnabled)) return [3 /*break*/, 8];
|
|
636
|
+
return [4 /*yield*/, this.runIssueReplay(issueId, {
|
|
637
|
+
source: source,
|
|
638
|
+
trigger: normalizeOptionalString(options.trigger) || 'post_remediation'
|
|
639
|
+
})];
|
|
640
|
+
case 7:
|
|
641
|
+
replayResult = _b.sent();
|
|
642
|
+
_b.label = 8;
|
|
643
|
+
case 8:
|
|
644
|
+
console.log(new Date(), '[AI Assistant Codex Manager] remediation completed', {
|
|
645
|
+
id_issue_report: issueId,
|
|
646
|
+
status: remediationStatus,
|
|
647
|
+
attempt: attemptCount,
|
|
648
|
+
durationMs: durationMs,
|
|
649
|
+
replayStatus: (replayResult === null || replayResult === void 0 ? void 0 : replayResult.status) || null
|
|
650
|
+
});
|
|
651
|
+
return [2 /*return*/, {
|
|
652
|
+
status: remediationStatus,
|
|
653
|
+
reason: remediationReason,
|
|
654
|
+
issueId: issueId,
|
|
655
|
+
attemptCount: attemptCount,
|
|
656
|
+
durationMs: durationMs,
|
|
657
|
+
replayStatus: (replayResult === null || replayResult === void 0 ? void 0 : replayResult.status) || '',
|
|
658
|
+
replayReason: (replayResult === null || replayResult === void 0 ? void 0 : replayResult.reason) || ''
|
|
659
|
+
}];
|
|
660
|
+
case 9:
|
|
661
|
+
error_3 = _b.sent();
|
|
662
|
+
finishedAt = new Date();
|
|
663
|
+
durationMs = Date.now() - startedAtMs;
|
|
664
|
+
err = error_3 || {};
|
|
665
|
+
stdout = this.toSafeOutput(err.stdout);
|
|
666
|
+
stderr = this.toSafeOutput(err.stderr);
|
|
667
|
+
exitCode = Number.isFinite(Number(err.code)) ? Number(err.code) : null;
|
|
668
|
+
timeoutHit = (err === null || err === void 0 ? void 0 : err.killed) === true || normalizeOptionalString(err === null || err === void 0 ? void 0 : err.signal).toUpperCase() === 'SIGTERM';
|
|
669
|
+
reason = timeoutHit
|
|
670
|
+
? "Remediation hook timed out after ".concat(this.config.remediationTimeoutMs, "ms.")
|
|
671
|
+
: (normalizeOptionalString(err === null || err === void 0 ? void 0 : err.message) || 'Remediation hook failed.');
|
|
672
|
+
nextAttemptAt = new Date(finishedAt.getTime() + cooldownMs);
|
|
673
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
674
|
+
$set: {
|
|
675
|
+
'metadata.quality_manager.remediation': __assign(__assign({}, remediation), { status: 'failed', source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, hook: this.config.remediationHookPath, last_attempt_at: now, last_error: reason, last_exit_code: exitCode, last_duration_ms: durationMs, last_stdout: stdout, last_stderr: stderr, last_output: parsedOutput || undefined, next_attempt_at: nextAttemptAt, updated_at: finishedAt }),
|
|
676
|
+
updatedAt: finishedAt
|
|
677
|
+
}
|
|
678
|
+
})];
|
|
679
|
+
case 10:
|
|
680
|
+
_b.sent();
|
|
681
|
+
console.error(new Date(), '[AI Assistant Codex Manager] remediation failed', {
|
|
682
|
+
id_issue_report: issueId,
|
|
683
|
+
attempt: attemptCount,
|
|
684
|
+
reason: reason,
|
|
685
|
+
exitCode: exitCode,
|
|
686
|
+
durationMs: durationMs
|
|
687
|
+
});
|
|
688
|
+
return [2 /*return*/, {
|
|
689
|
+
status: 'failed',
|
|
690
|
+
reason: reason,
|
|
691
|
+
issueId: issueId,
|
|
692
|
+
attemptCount: attemptCount,
|
|
693
|
+
durationMs: durationMs,
|
|
694
|
+
exitCode: exitCode
|
|
695
|
+
}];
|
|
696
|
+
case 11:
|
|
697
|
+
if (!contextPath) return [3 /*break*/, 15];
|
|
698
|
+
_b.label = 12;
|
|
699
|
+
case 12:
|
|
700
|
+
_b.trys.push([12, 14, , 15]);
|
|
701
|
+
return [4 /*yield*/, fs_1.promises.unlink(contextPath)];
|
|
702
|
+
case 13:
|
|
703
|
+
_b.sent();
|
|
704
|
+
return [3 /*break*/, 15];
|
|
705
|
+
case 14:
|
|
706
|
+
_a = _b.sent();
|
|
707
|
+
return [3 /*break*/, 15];
|
|
708
|
+
case 15: return [7 /*endfinally*/];
|
|
709
|
+
case 16: return [2 /*return*/];
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
};
|
|
714
|
+
AiAssistantCodexManager.prototype.runIssueReplay = function (issueReportId_1) {
|
|
715
|
+
return __awaiter(this, arguments, void 0, function (issueReportId, options) {
|
|
716
|
+
var issueId, source, issue, force, now, metadata, qualityManager, replay, existingStatus, attemptsUsed, maxAttempts, cooldownMinutes, cooldownMs, lastAttemptAt, ageMs, attemptCount, startedAtMs, contextPath, parsedOutput, execResult, finishedAt, durationMs, stdout, stderr, outputStatus, success, replayStatus, replayReason, error_4, finishedAt, durationMs, err, stdout, stderr, exitCode, timeoutHit, reason, nextAttemptAt, _a;
|
|
717
|
+
if (options === void 0) { options = {}; }
|
|
718
|
+
return __generator(this, function (_b) {
|
|
719
|
+
switch (_b.label) {
|
|
720
|
+
case 0:
|
|
721
|
+
issueId = normalizeOptionalString(issueReportId);
|
|
722
|
+
if (!issueId) {
|
|
723
|
+
return [2 /*return*/, {
|
|
724
|
+
status: 'failed',
|
|
725
|
+
reason: 'Issue report id is required.'
|
|
726
|
+
}];
|
|
727
|
+
}
|
|
728
|
+
source = options.source === 'manual' ? 'manual' : 'auto';
|
|
729
|
+
if (!this.config.autoReplayEnabled && source !== 'manual') {
|
|
730
|
+
return [2 /*return*/, {
|
|
731
|
+
status: 'skipped',
|
|
732
|
+
reason: 'Auto replay is disabled.'
|
|
733
|
+
}];
|
|
734
|
+
}
|
|
735
|
+
if (!this.config.replayCommand) {
|
|
736
|
+
return [2 /*return*/, {
|
|
737
|
+
status: 'skipped',
|
|
738
|
+
reason: 'Replay command is not configured.'
|
|
739
|
+
}];
|
|
740
|
+
}
|
|
741
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.findById(issueId)];
|
|
742
|
+
case 1:
|
|
743
|
+
issue = _b.sent();
|
|
744
|
+
if (!issue) {
|
|
745
|
+
return [2 /*return*/, {
|
|
746
|
+
status: 'not_found',
|
|
747
|
+
reason: 'Issue report not found.'
|
|
748
|
+
}];
|
|
749
|
+
}
|
|
750
|
+
force = options.force === true;
|
|
751
|
+
now = new Date();
|
|
752
|
+
metadata = this.normalizeMetadata(issue.metadata);
|
|
753
|
+
qualityManager = this.normalizeMetadata(metadata.quality_manager);
|
|
754
|
+
replay = this.normalizeMetadata(qualityManager.replay);
|
|
755
|
+
existingStatus = normalizeOptionalString(replay.status).toLowerCase();
|
|
756
|
+
attemptsUsed = Number.isFinite(Number(replay.attempt_count)) ? Number(replay.attempt_count) : 0;
|
|
757
|
+
maxAttempts = this.config.replayMaxAttemptsPerIssue;
|
|
758
|
+
cooldownMinutes = this.config.replayCooldownMinutes;
|
|
759
|
+
cooldownMs = cooldownMinutes * 60 * 1000;
|
|
760
|
+
lastAttemptAt = this.parseDate(replay.last_attempt_at);
|
|
761
|
+
if (!force && existingStatus === 'running') {
|
|
762
|
+
return [2 /*return*/, {
|
|
763
|
+
status: 'running',
|
|
764
|
+
reason: 'Replay already running.',
|
|
765
|
+
issueId: issueId
|
|
766
|
+
}];
|
|
767
|
+
}
|
|
768
|
+
if (!force && existingStatus === 'success') {
|
|
769
|
+
return [2 /*return*/, {
|
|
770
|
+
status: 'skipped',
|
|
771
|
+
reason: 'Replay already succeeded.',
|
|
772
|
+
issueId: issueId
|
|
773
|
+
}];
|
|
774
|
+
}
|
|
775
|
+
if (!force && maxAttempts > 0 && attemptsUsed >= maxAttempts) {
|
|
776
|
+
return [2 /*return*/, {
|
|
777
|
+
status: 'skipped',
|
|
778
|
+
reason: "Replay attempt budget reached (".concat(attemptsUsed, "/").concat(maxAttempts, ")."),
|
|
779
|
+
issueId: issueId
|
|
780
|
+
}];
|
|
781
|
+
}
|
|
782
|
+
if (!force && existingStatus === 'failed' && lastAttemptAt) {
|
|
783
|
+
ageMs = now.getTime() - lastAttemptAt.getTime();
|
|
784
|
+
if (ageMs >= 0 && ageMs < cooldownMs) {
|
|
785
|
+
return [2 /*return*/, {
|
|
786
|
+
status: 'skipped',
|
|
787
|
+
reason: 'Replay cooldown active.',
|
|
788
|
+
issueId: issueId,
|
|
789
|
+
nextAttemptAt: new Date(lastAttemptAt.getTime() + cooldownMs)
|
|
790
|
+
}];
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
attemptCount = attemptsUsed + 1;
|
|
794
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
795
|
+
$set: {
|
|
796
|
+
'metadata.quality_manager.replay': __assign(__assign({}, replay), { status: 'running', source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, command: this.config.replayCommand, last_attempt_at: now, updated_at: now, last_error: '', last_exit_code: null }),
|
|
797
|
+
updatedAt: now
|
|
798
|
+
}
|
|
799
|
+
})];
|
|
800
|
+
case 2:
|
|
801
|
+
_b.sent();
|
|
802
|
+
startedAtMs = Date.now();
|
|
803
|
+
return [4 /*yield*/, this.writeReplayContextFile(issue, {
|
|
804
|
+
issueId: issueId,
|
|
805
|
+
attemptCount: attemptCount,
|
|
806
|
+
source: source,
|
|
807
|
+
trigger: normalizeOptionalString(options.trigger) || 'unspecified'
|
|
808
|
+
})];
|
|
809
|
+
case 3:
|
|
810
|
+
contextPath = _b.sent();
|
|
811
|
+
parsedOutput = null;
|
|
812
|
+
_b.label = 4;
|
|
813
|
+
case 4:
|
|
814
|
+
_b.trys.push([4, 7, 9, 14]);
|
|
815
|
+
return [4 /*yield*/, execFileAsync('/bin/bash', ['-lc', this.config.replayCommand], {
|
|
816
|
+
timeout: this.config.replayTimeoutMs,
|
|
817
|
+
maxBuffer: this.config.replayMaxBufferBytes,
|
|
818
|
+
env: __assign(__assign({}, process.env), { RIO_AI_ASSISTANT_REPLAY_CONTEXT: contextPath, RIO_AI_ASSISTANT_REPLAY_ISSUE_ID: issueId })
|
|
819
|
+
})];
|
|
820
|
+
case 5:
|
|
821
|
+
execResult = _b.sent();
|
|
822
|
+
finishedAt = new Date();
|
|
823
|
+
durationMs = Date.now() - startedAtMs;
|
|
824
|
+
stdout = this.toSafeOutput(execResult === null || execResult === void 0 ? void 0 : execResult.stdout);
|
|
825
|
+
stderr = this.toSafeOutput(execResult === null || execResult === void 0 ? void 0 : execResult.stderr);
|
|
826
|
+
parsedOutput = this.parseOutputJson(stdout);
|
|
827
|
+
outputStatus = normalizeOptionalString(parsedOutput === null || parsedOutput === void 0 ? void 0 : parsedOutput.status).toLowerCase();
|
|
828
|
+
success = outputStatus ? ['success', 'ok', 'completed', 'pass'].includes(outputStatus) : true;
|
|
829
|
+
replayStatus = success ? 'success' : 'failed';
|
|
830
|
+
replayReason = normalizeOptionalString(parsedOutput === null || parsedOutput === void 0 ? void 0 : parsedOutput.reason)
|
|
831
|
+
|| (success ? 'Replay command completed successfully.' : 'Replay command reported a non-success status.');
|
|
832
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
833
|
+
$set: {
|
|
834
|
+
'metadata.quality_manager.replay': __assign(__assign({}, replay), { status: replayStatus, source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, command: this.config.replayCommand, last_attempt_at: now, last_success_at: success ? finishedAt : replay.last_success_at, last_error: success ? '' : replayReason, last_exit_code: success ? 0 : null, last_duration_ms: durationMs, last_stdout: stdout, last_stderr: stderr, last_output: parsedOutput || undefined, updated_at: finishedAt }),
|
|
835
|
+
updatedAt: finishedAt
|
|
836
|
+
}
|
|
837
|
+
})];
|
|
838
|
+
case 6:
|
|
839
|
+
_b.sent();
|
|
840
|
+
console.log(new Date(), '[AI Assistant Codex Manager] replay completed', {
|
|
841
|
+
id_issue_report: issueId,
|
|
842
|
+
status: replayStatus,
|
|
843
|
+
attempt: attemptCount,
|
|
844
|
+
durationMs: durationMs
|
|
845
|
+
});
|
|
846
|
+
return [2 /*return*/, {
|
|
847
|
+
status: replayStatus,
|
|
848
|
+
reason: replayReason,
|
|
849
|
+
issueId: issueId,
|
|
850
|
+
attemptCount: attemptCount,
|
|
851
|
+
durationMs: durationMs
|
|
852
|
+
}];
|
|
853
|
+
case 7:
|
|
854
|
+
error_4 = _b.sent();
|
|
855
|
+
finishedAt = new Date();
|
|
856
|
+
durationMs = Date.now() - startedAtMs;
|
|
857
|
+
err = error_4 || {};
|
|
858
|
+
stdout = this.toSafeOutput(err.stdout);
|
|
859
|
+
stderr = this.toSafeOutput(err.stderr);
|
|
860
|
+
exitCode = Number.isFinite(Number(err.code)) ? Number(err.code) : null;
|
|
861
|
+
timeoutHit = (err === null || err === void 0 ? void 0 : err.killed) === true || normalizeOptionalString(err === null || err === void 0 ? void 0 : err.signal).toUpperCase() === 'SIGTERM';
|
|
862
|
+
reason = timeoutHit
|
|
863
|
+
? "Replay command timed out after ".concat(this.config.replayTimeoutMs, "ms.")
|
|
864
|
+
: (normalizeOptionalString(err === null || err === void 0 ? void 0 : err.message) || 'Replay command failed.');
|
|
865
|
+
nextAttemptAt = new Date(finishedAt.getTime() + cooldownMs);
|
|
866
|
+
return [4 /*yield*/, ai_terminal_issue_report_collection_1.AiTerminalIssueReports.updateOne({ _id: issueId }, {
|
|
867
|
+
$set: {
|
|
868
|
+
'metadata.quality_manager.replay': __assign(__assign({}, replay), { status: 'failed', source: source, trigger: normalizeOptionalString(options.trigger) || 'unspecified', attempt_count: attemptCount, max_attempts: maxAttempts, cooldown_minutes: cooldownMinutes, command: this.config.replayCommand, last_attempt_at: now, last_error: reason, last_exit_code: exitCode, last_duration_ms: durationMs, last_stdout: stdout, last_stderr: stderr, last_output: parsedOutput || undefined, next_attempt_at: nextAttemptAt, updated_at: finishedAt }),
|
|
869
|
+
updatedAt: finishedAt
|
|
870
|
+
}
|
|
871
|
+
})];
|
|
872
|
+
case 8:
|
|
873
|
+
_b.sent();
|
|
874
|
+
console.error(new Date(), '[AI Assistant Codex Manager] replay failed', {
|
|
875
|
+
id_issue_report: issueId,
|
|
876
|
+
attempt: attemptCount,
|
|
877
|
+
reason: reason,
|
|
878
|
+
exitCode: exitCode,
|
|
879
|
+
durationMs: durationMs
|
|
880
|
+
});
|
|
881
|
+
return [2 /*return*/, {
|
|
882
|
+
status: 'failed',
|
|
883
|
+
reason: reason,
|
|
884
|
+
issueId: issueId,
|
|
885
|
+
attemptCount: attemptCount,
|
|
886
|
+
durationMs: durationMs,
|
|
887
|
+
exitCode: exitCode
|
|
888
|
+
}];
|
|
889
|
+
case 9:
|
|
890
|
+
if (!contextPath) return [3 /*break*/, 13];
|
|
891
|
+
_b.label = 10;
|
|
892
|
+
case 10:
|
|
893
|
+
_b.trys.push([10, 12, , 13]);
|
|
894
|
+
return [4 /*yield*/, fs_1.promises.unlink(contextPath)];
|
|
895
|
+
case 11:
|
|
896
|
+
_b.sent();
|
|
897
|
+
return [3 /*break*/, 13];
|
|
898
|
+
case 12:
|
|
899
|
+
_a = _b.sent();
|
|
900
|
+
return [3 /*break*/, 13];
|
|
901
|
+
case 13: return [7 /*endfinally*/];
|
|
902
|
+
case 14: return [2 /*return*/];
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
};
|
|
907
|
+
AiAssistantCodexManager.prototype.markMessageQualityReviewed = function (messageId_1, decision_1) {
|
|
908
|
+
return __awaiter(this, arguments, void 0, function (messageId, decision, issueReportId) {
|
|
909
|
+
var now, qualityPayload;
|
|
910
|
+
if (issueReportId === void 0) { issueReportId = ''; }
|
|
911
|
+
return __generator(this, function (_a) {
|
|
912
|
+
switch (_a.label) {
|
|
913
|
+
case 0:
|
|
914
|
+
now = new Date();
|
|
915
|
+
qualityPayload = {
|
|
916
|
+
status: decision.status,
|
|
917
|
+
reason: decision.reason,
|
|
918
|
+
code: decision.code,
|
|
919
|
+
checked_at: now,
|
|
920
|
+
worker_index: normalizeOptionalString(process.env.WORKER_INDEX),
|
|
921
|
+
worker_instance: normalizeOptionalString(process.env.NODE_APP_INSTANCE)
|
|
922
|
+
};
|
|
923
|
+
if (issueReportId) {
|
|
924
|
+
qualityPayload.id_issue_report = issueReportId;
|
|
925
|
+
}
|
|
926
|
+
return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: messageId }, {
|
|
927
|
+
$set: {
|
|
928
|
+
'metadata.quality_manager': qualityPayload,
|
|
929
|
+
updatedAt: now
|
|
930
|
+
}
|
|
931
|
+
})];
|
|
932
|
+
case 1:
|
|
933
|
+
_a.sent();
|
|
934
|
+
if (this.config.debug) {
|
|
935
|
+
console.log(new Date(), '[AI Assistant Codex Manager] checked message', {
|
|
936
|
+
id_message: messageId,
|
|
937
|
+
status: decision.status,
|
|
938
|
+
code: decision.code,
|
|
939
|
+
id_issue_report: issueReportId || null
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
return [2 /*return*/];
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
});
|
|
946
|
+
};
|
|
947
|
+
AiAssistantCodexManager.prototype.resolveClosestUserPrompt = function (conversationId, assistantCreatedAt) {
|
|
948
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
949
|
+
var query, createdAt, userMessage;
|
|
950
|
+
return __generator(this, function (_a) {
|
|
951
|
+
switch (_a.label) {
|
|
952
|
+
case 0:
|
|
953
|
+
query = {
|
|
954
|
+
id_conversation: conversationId,
|
|
955
|
+
role: 'user'
|
|
956
|
+
};
|
|
957
|
+
createdAt = assistantCreatedAt ? new Date(assistantCreatedAt) : null;
|
|
958
|
+
if (createdAt && Number.isFinite(createdAt.getTime())) {
|
|
959
|
+
query.createdAt = { $lte: createdAt };
|
|
960
|
+
}
|
|
961
|
+
return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.findOne(query, { sort: { createdAt: -1 } })];
|
|
962
|
+
case 1:
|
|
963
|
+
userMessage = _a.sent();
|
|
964
|
+
return [2 /*return*/, normalizeOptionalString(userMessage === null || userMessage === void 0 ? void 0 : userMessage.content)];
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
AiAssistantCodexManager.prototype.writeRemediationContextFile = function (issue, options) {
|
|
970
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
971
|
+
var issueId, filePath, payload;
|
|
972
|
+
return __generator(this, function (_a) {
|
|
973
|
+
switch (_a.label) {
|
|
974
|
+
case 0:
|
|
975
|
+
issueId = normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue._id);
|
|
976
|
+
filePath = path.join(os.tmpdir(), "resolveio-ai-assistant-remediation-".concat(issueId, "-").concat(Date.now(), ".json"));
|
|
977
|
+
payload = {
|
|
978
|
+
created_at: new Date().toISOString(),
|
|
979
|
+
issue_report: {
|
|
980
|
+
_id: issueId,
|
|
981
|
+
status: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.status),
|
|
982
|
+
source: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.source),
|
|
983
|
+
reason: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.reason),
|
|
984
|
+
id_conversation: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_conversation),
|
|
985
|
+
id_message: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_message),
|
|
986
|
+
id_client: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_client),
|
|
987
|
+
id_app: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_app),
|
|
988
|
+
id_user: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_user),
|
|
989
|
+
request_id: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.request_id),
|
|
990
|
+
user_prompt: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.user_prompt),
|
|
991
|
+
assistant_content: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.assistant_content)
|
|
992
|
+
},
|
|
993
|
+
remediation: {
|
|
994
|
+
source: normalizeOptionalString(options === null || options === void 0 ? void 0 : options.source),
|
|
995
|
+
trigger: normalizeOptionalString(options === null || options === void 0 ? void 0 : options.trigger),
|
|
996
|
+
attempt_count: Number(options === null || options === void 0 ? void 0 : options.attemptCount) || 0,
|
|
997
|
+
max_attempts: this.config.remediationMaxAttemptsPerIssue,
|
|
998
|
+
cooldown_minutes: this.config.remediationCooldownMinutes
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
return [4 /*yield*/, fs_1.promises.writeFile(filePath, JSON.stringify(payload, null, 2), 'utf8')];
|
|
1002
|
+
case 1:
|
|
1003
|
+
_a.sent();
|
|
1004
|
+
return [2 /*return*/, filePath];
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
};
|
|
1009
|
+
AiAssistantCodexManager.prototype.writeReplayContextFile = function (issue, options) {
|
|
1010
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1011
|
+
var issueId, metadata, qualityManager, remediation, filePath, payload;
|
|
1012
|
+
return __generator(this, function (_a) {
|
|
1013
|
+
switch (_a.label) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
issueId = normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue._id);
|
|
1016
|
+
metadata = this.normalizeMetadata(issue === null || issue === void 0 ? void 0 : issue.metadata);
|
|
1017
|
+
qualityManager = this.normalizeMetadata(metadata.quality_manager);
|
|
1018
|
+
remediation = this.normalizeMetadata(qualityManager.remediation);
|
|
1019
|
+
filePath = path.join(os.tmpdir(), "resolveio-ai-assistant-replay-".concat(issueId, "-").concat(Date.now(), ".json"));
|
|
1020
|
+
payload = {
|
|
1021
|
+
created_at: new Date().toISOString(),
|
|
1022
|
+
issue_report: {
|
|
1023
|
+
_id: issueId,
|
|
1024
|
+
status: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.status),
|
|
1025
|
+
source: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.source),
|
|
1026
|
+
reason: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.reason),
|
|
1027
|
+
id_conversation: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_conversation),
|
|
1028
|
+
id_message: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_message),
|
|
1029
|
+
id_client: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_client),
|
|
1030
|
+
id_app: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_app),
|
|
1031
|
+
id_user: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.id_user),
|
|
1032
|
+
request_id: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.request_id),
|
|
1033
|
+
user_prompt: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.user_prompt),
|
|
1034
|
+
assistant_content: normalizeOptionalString(issue === null || issue === void 0 ? void 0 : issue.assistant_content)
|
|
1035
|
+
},
|
|
1036
|
+
remediation: {
|
|
1037
|
+
status: normalizeOptionalString(remediation.status),
|
|
1038
|
+
last_attempt_at: remediation.last_attempt_at || null,
|
|
1039
|
+
last_success_at: remediation.last_success_at || null,
|
|
1040
|
+
last_error: normalizeOptionalString(remediation.last_error),
|
|
1041
|
+
attempt_count: Number(remediation.attempt_count) || 0
|
|
1042
|
+
},
|
|
1043
|
+
replay: {
|
|
1044
|
+
source: normalizeOptionalString(options === null || options === void 0 ? void 0 : options.source),
|
|
1045
|
+
trigger: normalizeOptionalString(options === null || options === void 0 ? void 0 : options.trigger),
|
|
1046
|
+
attempt_count: Number(options === null || options === void 0 ? void 0 : options.attemptCount) || 0,
|
|
1047
|
+
max_attempts: this.config.replayMaxAttemptsPerIssue,
|
|
1048
|
+
cooldown_minutes: this.config.replayCooldownMinutes,
|
|
1049
|
+
command: this.config.replayCommand
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
return [4 /*yield*/, fs_1.promises.writeFile(filePath, JSON.stringify(payload, null, 2), 'utf8')];
|
|
1053
|
+
case 1:
|
|
1054
|
+
_a.sent();
|
|
1055
|
+
return [2 /*return*/, filePath];
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
};
|
|
1060
|
+
AiAssistantCodexManager.prototype.parseOutputJson = function (stdout) {
|
|
1061
|
+
var text = normalizeOptionalString(stdout);
|
|
1062
|
+
if (!text) {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
var firstChar = text.charAt(0);
|
|
1066
|
+
if (firstChar !== '{' && firstChar !== '[') {
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
try {
|
|
1070
|
+
var parsed = JSON.parse(text);
|
|
1071
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
1072
|
+
return null;
|
|
1073
|
+
}
|
|
1074
|
+
return parsed;
|
|
1075
|
+
}
|
|
1076
|
+
catch (_a) {
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
AiAssistantCodexManager.prototype.toSafeOutput = function (value) {
|
|
1081
|
+
var asString = typeof value === 'string'
|
|
1082
|
+
? value
|
|
1083
|
+
: (Buffer.isBuffer(value) ? value.toString('utf8') : String(value || ''));
|
|
1084
|
+
var normalized = asString.trim();
|
|
1085
|
+
if (!normalized) {
|
|
1086
|
+
return '';
|
|
1087
|
+
}
|
|
1088
|
+
if (normalized.length <= MAX_STORED_OUTPUT_CHARS) {
|
|
1089
|
+
return normalized;
|
|
1090
|
+
}
|
|
1091
|
+
return normalized.slice(0, MAX_STORED_OUTPUT_CHARS);
|
|
1092
|
+
};
|
|
1093
|
+
AiAssistantCodexManager.prototype.parseDate = function (value) {
|
|
1094
|
+
if (!value) {
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
var date = value instanceof Date ? value : new Date(value);
|
|
1098
|
+
if (!Number.isFinite(date.getTime())) {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
return date;
|
|
1102
|
+
};
|
|
1103
|
+
AiAssistantCodexManager.prototype.normalizeMetadata = function (value) {
|
|
1104
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1105
|
+
return {};
|
|
1106
|
+
}
|
|
1107
|
+
return value;
|
|
1108
|
+
};
|
|
1109
|
+
return AiAssistantCodexManager;
|
|
1110
|
+
}());
|
|
1111
|
+
exports.AiAssistantCodexManager = AiAssistantCodexManager;
|
|
1112
|
+
|
|
1113
|
+
//# sourceMappingURL=ai-assistant-codex-manager.manager.js.map
|