@resolveio/server-lib 22.3.148 → 22.3.150
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/.nodemon.json +5 -0
- package/.vscode/settings.json +21 -0
- package/AGENTS.md +195 -0
- package/README.md +22 -0
- package/build_package.sh +5 -0
- package/compileDTS.pl +64 -0
- package/docs/ai-assistant-nightly-eval.md +65 -0
- package/docs/ai-assistant-preflight-checklist.md +23 -0
- package/docs/ai-assistant-report-builder-bridge-playbook.md +115 -0
- package/eslint-plugin-custom/index.js +7 -0
- package/eslint-plugin-custom/rules/no-filter-zero-index.js +44 -0
- package/eslint.config.js +103 -0
- package/gulpfile.js +216 -0
- package/methodAndPublicationListGenerator.py +375 -0
- package/mongodbensurers.js +2 -0
- package/mongostop.js +3 -0
- package/package.json +1 -1
- package/scripts/cleanup-bypassed-callmethod-logs.js +616 -0
- package/settings.development.json +25 -0
- package/settings.development.redacted.json +25 -0
- package/src/.env +12 -0
- package/src/ai/assistant-core-heuristics.ts +379 -0
- package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +185 -0
- package/src/ai/resolveio-platform-intelligence-memory.ts +325 -0
- package/{ai/resolveio-platform-intelligence-types.d.ts → src/ai/resolveio-platform-intelligence-types.ts} +20 -15
- package/src/ai/resolveio-platform-intelligence.ts +462 -0
- package/src/client-server-app.ts +12 -0
- package/src/collections/ai-run.collection.ts +117 -0
- package/src/collections/ai-terminal-conversation.collection.ts +91 -0
- package/src/collections/ai-terminal-issue-report.collection.ts +99 -0
- package/src/collections/ai-terminal-message.collection.ts +77 -0
- package/src/collections/app-setting.collection.ts +104 -0
- package/src/collections/app-status.collection.ts +58 -0
- package/src/collections/communication-metric.collection.ts +84 -0
- package/src/collections/counter.collection.ts +56 -0
- package/src/collections/cron-job-history.collection.ts +94 -0
- package/src/collections/cron-job.collection.ts +92 -0
- package/src/collections/customer-notification.collection.ts +131 -0
- package/src/collections/customer-portal-password.collection.ts +76 -0
- package/src/collections/email-history.collection.ts +134 -0
- package/src/collections/email-verified.collection.ts +62 -0
- package/src/collections/file.collection.ts +74 -0
- package/src/collections/flag-update.collection.ts +57 -0
- package/src/collections/flag.collection.ts +57 -0
- package/src/collections/log-method-latency.collection.ts +77 -0
- package/src/collections/log-subscription.collection.ts +80 -0
- package/src/collections/log.collection.ts +93 -0
- package/src/collections/logged-in-users.collection.ts +67 -0
- package/src/collections/monitor-cpu.collection.ts +65 -0
- package/src/collections/monitor-function.collection.ts +74 -0
- package/src/collections/monitor-memory.collection.ts +77 -0
- package/src/collections/monitor-mongo.collection.ts +71 -0
- package/src/collections/notification.collection.ts +57 -0
- package/src/collections/openai-usage-ledger.collection.ts +131 -0
- package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
- package/src/collections/report-builder-library.collection.ts +89 -0
- package/src/collections/report-builder-report.collection.ts +184 -0
- package/src/collections/user-group.collection.ts +89 -0
- package/src/collections/user-guide.collection.ts +57 -0
- package/src/collections/user.collection.ts +181 -0
- package/src/cron/cron.ts +117 -0
- package/src/fixtures/cron-jobs.ts +95 -0
- package/src/fixtures/init.ts +35 -0
- package/src/http/auth.ts +818 -0
- package/src/http/health.ts +7 -0
- package/src/http/home.ts +90 -0
- package/src/http/slow-query-publication.ts +49 -0
- package/src/index.ts +1 -0
- package/src/managers/ai-assistant-codex-manager.manager.ts +1131 -0
- package/src/managers/ai-run-evidence.manager.ts +264 -0
- package/src/managers/communication-metric.manager.ts +82 -0
- package/src/managers/cron.manager.ts +333 -0
- package/src/managers/customer-notification-content.manager.ts +236 -0
- package/src/managers/diagnostic-manager-bootstrap.ts +165 -0
- package/src/managers/error-auto-fix.manager.ts +2767 -0
- package/src/managers/local-log.manager.ts +113 -0
- package/src/managers/method.manager.ts +1857 -0
- package/src/managers/mongo.manager.ts +4575 -0
- package/src/managers/monitor.manager.ts +507 -0
- package/src/managers/openai-usage-ledger.manager.ts +112 -0
- package/src/managers/slow-query-verifier.manager.ts +3590 -0
- package/src/managers/slow-query.manager.ts +519 -0
- package/src/managers/subscription.manager.ts +3128 -0
- package/src/managers/websocket.manager.ts +746 -0
- package/src/managers/worker-dispatcher.manager.ts +1360 -0
- package/src/managers/worker-server.manager.ts +536 -0
- package/src/methods/accounts.ts +532 -0
- package/src/methods/ai-terminal.ts +23524 -0
- package/src/methods/app-settings.ts +114 -0
- package/src/methods/aws.ts +649 -0
- package/src/methods/collections.ts +641 -0
- package/src/methods/counters.ts +69 -0
- package/src/methods/cron-jobs.ts +2614 -0
- package/src/methods/customer-notifications.ts +458 -0
- package/src/methods/diagnostics.ts +616 -0
- package/src/methods/flag-updates.ts +7 -0
- package/src/methods/flags.ts +7 -0
- package/src/methods/logs.ts +657 -0
- package/src/methods/mongo-explorer.ts +1880 -0
- package/src/methods/monitor.ts +540 -0
- package/src/methods/pdf.ts +1236 -0
- package/src/methods/publications.ts +129 -0
- package/src/methods/report-builder.ts +3300 -0
- package/src/methods/support.ts +335 -0
- package/src/models/ai-run.model.ts +27 -0
- package/src/models/ai-terminal-conversation.model.ts +19 -0
- package/src/models/ai-terminal-issue-report.model.ts +21 -0
- package/src/models/ai-terminal-message.model.ts +24 -0
- package/src/models/app-setting.model.ts +17 -0
- package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
- package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
- package/src/models/collection-document.model.ts +24 -0
- package/src/models/communication-metric.model.ts +23 -0
- package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
- package/src/models/cron-job-history.model.ts +16 -0
- package/src/models/cron-job.model.ts +15 -0
- package/src/models/customer-notification.model.ts +28 -0
- package/src/models/customer-portal-password.model.ts +12 -0
- package/src/models/dialog.model.ts +25 -0
- package/{models/email-history.model.js → src/models/email-history.model.ts} +36 -4
- package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
- package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
- package/{models/flag-update.model.d.ts → src/models/flag-update.model.ts} +4 -3
- package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
- package/src/models/log-method-latency.model.ts +11 -0
- package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +11 -9
- package/src/models/log.model.ts +19 -0
- package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
- package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
- package/src/models/method.model.ts +25 -0
- package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
- package/src/models/monitor-function.model.ts +16 -0
- package/src/models/monitor-memory.model.ts +17 -0
- package/src/models/monitor-mongo.model.ts +15 -0
- package/{models/notification.model.d.ts → src/models/notification.model.ts} +6 -4
- package/src/models/openai-usage-ledger.model.ts +56 -0
- package/src/models/pagination.model.ts +35 -0
- package/src/models/permission.model.ts +14 -0
- package/src/models/report-builder-dashboard-builder.model.ts +29 -0
- package/src/models/report-builder-library.model.ts +20 -0
- package/src/models/report-builder-report.model.ts +136 -0
- package/src/models/report-builder.model.ts +68 -0
- package/src/models/select-data-label.model.ts +9 -0
- package/src/models/server-message.model.ts +31 -0
- package/src/models/slow-query-report.model.ts +23 -0
- package/src/models/subscription.model.ts +73 -0
- package/src/models/support-ticket.model.ts +104 -0
- package/src/models/user-group.model.ts +24 -0
- package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
- package/src/models/user.model.ts +96 -0
- package/src/private/images/ResolveIO.png +0 -0
- package/src/publications/ai-terminal.ts +73 -0
- package/src/publications/app-settings.ts +25 -0
- package/src/publications/app-status.ts +13 -0
- package/src/publications/cron-jobs.ts +40 -0
- package/src/publications/customer-notifications.ts +101 -0
- package/src/publications/files.ts +33 -0
- package/src/publications/flags-update.ts +19 -0
- package/src/publications/flags.ts +19 -0
- package/src/publications/logs.ts +163 -0
- package/src/publications/notifications.ts +13 -0
- package/src/publications/report-builder-dashboard-builders.ts +39 -0
- package/src/publications/report-builder-libraries.ts +41 -0
- package/src/publications/report-builder-reports.ts +47 -0
- package/src/publications/super-admin.ts +13 -0
- package/src/publications/user-groups.ts +12 -0
- package/src/publications/user-guides.ts +12 -0
- package/src/resolveio-server-app.ts +617 -0
- package/src/server-app.ts +3354 -0
- package/src/services/codex-client.ts +1231 -0
- package/src/services/openai-client.ts +265 -0
- package/src/types/error-report.ts +26 -0
- package/src/types/js-tiktoken.d.ts +11 -0
- package/src/types/slow-query-report.ts +28 -0
- package/src/util/ai-qa-policy.ts +925 -0
- package/src/util/ai-run-evidence-adapters.ts +684 -0
- package/src/util/ai-run-evidence-dashboard.ts +313 -0
- package/src/util/ai-run-evidence-eval.ts +885 -0
- package/src/util/ai-run-evidence.ts +1058 -0
- package/src/util/ai-runner-artifacts.ts +586 -0
- package/src/util/ai-runner-manager-autopilot.ts +434 -0
- package/src/util/ai-runner-manager-policy.ts +2733 -0
- package/src/util/ai-runner-qa-auth.ts +821 -0
- package/src/util/ai-runner-qa-tools.ts +3045 -0
- package/src/util/aicoder-runner-v6.ts +875 -0
- package/src/util/common.ts +649 -0
- package/src/util/customer-portal-password.ts +183 -0
- package/src/util/error-reporter.ts +332 -0
- package/src/util/error-tracking.ts +79 -0
- package/src/util/openai-usage-cost.ts +114 -0
- package/src/util/report-builder-unwinds.ts +180 -0
- package/src/util/runner-process-janitor.ts +219 -0
- package/src/util/schema-report-builder.ts +448 -0
- package/src/util/slow-query-reporter.ts +216 -0
- package/src/util/subscription-dependency-context.ts +1096 -0
- package/src/util/support-runner-v5.ts +2167 -0
- package/src/util/tokenizer.ts +38 -0
- package/src/workers/codex-runner.worker.ts +142 -0
- package/start_server.sh +5 -0
- package/tests/ai-assistant-corpus-build.ts +484 -0
- package/tests/ai-assistant-corpus-replay-e2e.ts +774 -0
- package/tests/ai-assistant-data-parity-e2e.ts +1989 -0
- package/tests/ai-assistant-eval-triage.ts +831 -0
- package/tests/ai-assistant-openai-e2e.ts +1061 -0
- package/tests/ai-assistant-openai-git-e2e.ts +155 -0
- package/tests/ai-assistant-preflight-matrix.ts +215 -0
- package/tests/ai-assistant-routing-eval.test.ts +560 -0
- package/tests/ai-assistant-snf-live-eval.ts +975 -0
- package/tests/ai-assistant-utils.test.ts +2968 -0
- package/tests/ai-manager-autopilot-snapshot.test.ts +177 -0
- package/tests/ai-manager-recovery-checkpoint.test.ts +595 -0
- package/tests/ai-run-eval.test.ts +88 -0
- package/tests/ai-run-evidence.test.ts +348 -0
- package/tests/ai-runner-contract.test.ts +488 -0
- package/tests/aicoder-runner-v6.test.ts +298 -0
- package/tests/error-reporter.test.ts +145 -0
- package/tests/method-publication-generator.test.ts +46 -0
- package/tests/report-builder-linking.test.ts +79 -0
- package/tests/resolveio-platform-intelligence.test.ts +352 -0
- package/tests/server-app-cron-owner.test.ts +127 -0
- package/tests/subscription-connect-race.test.ts +158 -0
- package/tests/subscription-dependency-context.test.ts +324 -0
- package/tests/subscription-manager-collection-tracking.test.ts +86 -0
- package/tests/subscription-manager-invalidation.test.ts +86 -0
- package/tests/support-runner-v5.test.ts +488 -0
- package/tsconfig.json +34 -0
- package/ai/assistant-core-heuristics.d.ts +0 -11
- package/ai/assistant-core-heuristics.js +0 -356
- package/ai/assistant-core-heuristics.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +0 -3
- package/ai/resolveio-platform-intelligence-memory-corpus.js +0 -214
- package/ai/resolveio-platform-intelligence-memory-corpus.js.map +0 -1
- package/ai/resolveio-platform-intelligence-memory.d.ts +0 -20
- package/ai/resolveio-platform-intelligence-memory.js +0 -341
- package/ai/resolveio-platform-intelligence-memory.js.map +0 -1
- package/ai/resolveio-platform-intelligence-types.js +0 -4
- package/ai/resolveio-platform-intelligence-types.js.map +0 -1
- package/ai/resolveio-platform-intelligence.d.ts +0 -6
- package/ai/resolveio-platform-intelligence.js +0 -463
- package/ai/resolveio-platform-intelligence.js.map +0 -1
- package/client-server-app.d.ts +0 -1
- package/client-server-app.js +0 -68
- package/client-server-app.js.map +0 -1
- package/collections/ai-run.collection.d.ts +0 -3
- package/collections/ai-run.collection.js +0 -170
- package/collections/ai-run.collection.js.map +0 -1
- package/collections/ai-terminal-conversation.collection.d.ts +0 -2
- package/collections/ai-terminal-conversation.collection.js +0 -140
- package/collections/ai-terminal-conversation.collection.js.map +0 -1
- package/collections/ai-terminal-issue-report.collection.d.ts +0 -2
- package/collections/ai-terminal-issue-report.collection.js +0 -148
- package/collections/ai-terminal-issue-report.collection.js.map +0 -1
- package/collections/ai-terminal-message.collection.d.ts +0 -2
- package/collections/ai-terminal-message.collection.js +0 -121
- package/collections/ai-terminal-message.collection.js.map +0 -1
- package/collections/app-setting.collection.d.ts +0 -3
- package/collections/app-setting.collection.js +0 -103
- package/collections/app-setting.collection.js.map +0 -1
- package/collections/app-status.collection.d.ts +0 -3
- package/collections/app-status.collection.js +0 -57
- package/collections/app-status.collection.js.map +0 -1
- package/collections/communication-metric.collection.d.ts +0 -2
- package/collections/communication-metric.collection.js +0 -133
- package/collections/communication-metric.collection.js.map +0 -1
- package/collections/counter.collection.d.ts +0 -3
- package/collections/counter.collection.js +0 -56
- package/collections/counter.collection.js.map +0 -1
- package/collections/cron-job-history.collection.d.ts +0 -3
- package/collections/cron-job-history.collection.js +0 -137
- package/collections/cron-job-history.collection.js.map +0 -1
- package/collections/cron-job.collection.d.ts +0 -3
- package/collections/cron-job.collection.js +0 -92
- package/collections/cron-job.collection.js.map +0 -1
- package/collections/customer-notification.collection.d.ts +0 -3
- package/collections/customer-notification.collection.js +0 -130
- package/collections/customer-notification.collection.js.map +0 -1
- package/collections/customer-portal-password.collection.d.ts +0 -3
- package/collections/customer-portal-password.collection.js +0 -75
- package/collections/customer-portal-password.collection.js.map +0 -1
- package/collections/email-history.collection.d.ts +0 -3
- package/collections/email-history.collection.js +0 -134
- package/collections/email-history.collection.js.map +0 -1
- package/collections/email-verified.collection.d.ts +0 -3
- package/collections/email-verified.collection.js +0 -62
- package/collections/email-verified.collection.js.map +0 -1
- package/collections/file.collection.d.ts +0 -3
- package/collections/file.collection.js +0 -74
- package/collections/file.collection.js.map +0 -1
- package/collections/flag-update.collection.d.ts +0 -3
- package/collections/flag-update.collection.js +0 -57
- package/collections/flag-update.collection.js.map +0 -1
- package/collections/flag.collection.d.ts +0 -3
- package/collections/flag.collection.js +0 -57
- package/collections/flag.collection.js.map +0 -1
- package/collections/log-method-latency.collection.d.ts +0 -3
- package/collections/log-method-latency.collection.js +0 -77
- package/collections/log-method-latency.collection.js.map +0 -1
- package/collections/log-subscription.collection.d.ts +0 -3
- package/collections/log-subscription.collection.js +0 -80
- package/collections/log-subscription.collection.js.map +0 -1
- package/collections/log.collection.d.ts +0 -3
- package/collections/log.collection.js +0 -93
- package/collections/log.collection.js.map +0 -1
- package/collections/logged-in-users.collection.d.ts +0 -3
- package/collections/logged-in-users.collection.js +0 -67
- package/collections/logged-in-users.collection.js.map +0 -1
- package/collections/monitor-cpu.collection.d.ts +0 -3
- package/collections/monitor-cpu.collection.js +0 -65
- package/collections/monitor-cpu.collection.js.map +0 -1
- package/collections/monitor-function.collection.d.ts +0 -3
- package/collections/monitor-function.collection.js +0 -74
- package/collections/monitor-function.collection.js.map +0 -1
- package/collections/monitor-memory.collection.d.ts +0 -3
- package/collections/monitor-memory.collection.js +0 -77
- package/collections/monitor-memory.collection.js.map +0 -1
- package/collections/monitor-mongo.collection.d.ts +0 -3
- package/collections/monitor-mongo.collection.js +0 -71
- package/collections/monitor-mongo.collection.js.map +0 -1
- package/collections/notification.collection.d.ts +0 -3
- package/collections/notification.collection.js +0 -57
- package/collections/notification.collection.js.map +0 -1
- package/collections/openai-usage-ledger.collection.d.ts +0 -2
- package/collections/openai-usage-ledger.collection.js +0 -188
- package/collections/openai-usage-ledger.collection.js.map +0 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
- package/collections/report-builder-dashboard-builder.collection.js +0 -109
- package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
- package/collections/report-builder-library.collection.d.ts +0 -3
- package/collections/report-builder-library.collection.js +0 -87
- package/collections/report-builder-library.collection.js.map +0 -1
- package/collections/report-builder-report.collection.d.ts +0 -4
- package/collections/report-builder-report.collection.js +0 -184
- package/collections/report-builder-report.collection.js.map +0 -1
- package/collections/user-group.collection.d.ts +0 -4
- package/collections/user-group.collection.js +0 -89
- package/collections/user-group.collection.js.map +0 -1
- package/collections/user-guide.collection.d.ts +0 -3
- package/collections/user-guide.collection.js +0 -57
- package/collections/user-guide.collection.js.map +0 -1
- package/collections/user.collection.d.ts +0 -4
- package/collections/user.collection.js +0 -180
- package/collections/user.collection.js.map +0 -1
- package/cron/cron.d.ts +0 -14
- package/cron/cron.js +0 -216
- package/cron/cron.js.map +0 -1
- package/fixtures/cron-jobs.d.ts +0 -1
- package/fixtures/cron-jobs.js +0 -150
- package/fixtures/cron-jobs.js.map +0 -1
- package/fixtures/init.d.ts +0 -1
- package/fixtures/init.js +0 -91
- package/fixtures/init.js.map +0 -1
- package/http/auth.d.ts +0 -2
- package/http/auth.js +0 -951
- package/http/auth.js.map +0 -1
- package/http/health.d.ts +0 -1
- package/http/health.js +0 -11
- package/http/health.js.map +0 -1
- package/http/home.d.ts +0 -1
- package/http/home.js +0 -134
- package/http/home.js.map +0 -1
- package/http/slow-query-publication.d.ts +0 -2
- package/http/slow-query-publication.js +0 -99
- package/http/slow-query-publication.js.map +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -19
- package/index.js.map +0 -1
- package/managers/ai-assistant-codex-manager.manager.d.ts +0 -67
- package/managers/ai-assistant-codex-manager.manager.js +0 -1113
- package/managers/ai-assistant-codex-manager.manager.js.map +0 -1
- package/managers/ai-run-evidence.manager.d.ts +0 -36
- package/managers/ai-run-evidence.manager.js +0 -377
- package/managers/ai-run-evidence.manager.js.map +0 -1
- package/managers/communication-metric.manager.d.ts +0 -16
- package/managers/communication-metric.manager.js +0 -134
- package/managers/communication-metric.manager.js.map +0 -1
- package/managers/cron.manager.d.ts +0 -20
- package/managers/cron.manager.js +0 -534
- package/managers/cron.manager.js.map +0 -1
- package/managers/customer-notification-content.manager.d.ts +0 -55
- package/managers/customer-notification-content.manager.js +0 -158
- package/managers/customer-notification-content.manager.js.map +0 -1
- package/managers/diagnostic-manager-bootstrap.d.ts +0 -9
- package/managers/diagnostic-manager-bootstrap.js +0 -260
- package/managers/diagnostic-manager-bootstrap.js.map +0 -1
- package/managers/error-auto-fix.manager.d.ts +0 -149
- package/managers/error-auto-fix.manager.js +0 -3064
- package/managers/error-auto-fix.manager.js.map +0 -1
- package/managers/local-log.manager.d.ts +0 -18
- package/managers/local-log.manager.js +0 -88
- package/managers/local-log.manager.js.map +0 -1
- package/managers/method.manager.d.ts +0 -84
- package/managers/method.manager.js +0 -1964
- package/managers/method.manager.js.map +0 -1
- package/managers/mongo.manager.d.ts +0 -224
- package/managers/mongo.manager.js +0 -5000
- package/managers/mongo.manager.js.map +0 -1
- package/managers/monitor.manager.d.ts +0 -70
- package/managers/monitor.manager.js +0 -550
- package/managers/monitor.manager.js.map +0 -1
- package/managers/openai-usage-ledger.manager.d.ts +0 -30
- package/managers/openai-usage-ledger.manager.js +0 -142
- package/managers/openai-usage-ledger.manager.js.map +0 -1
- package/managers/slow-query-verifier.manager.d.ts +0 -144
- package/managers/slow-query-verifier.manager.js +0 -3857
- package/managers/slow-query-verifier.manager.js.map +0 -1
- package/managers/slow-query.manager.d.ts +0 -28
- package/managers/slow-query.manager.js +0 -468
- package/managers/slow-query.manager.js.map +0 -1
- package/managers/subscription.manager.d.ts +0 -169
- package/managers/subscription.manager.js +0 -3434
- package/managers/subscription.manager.js.map +0 -1
- package/managers/websocket.manager.d.ts +0 -73
- package/managers/websocket.manager.js +0 -673
- package/managers/websocket.manager.js.map +0 -1
- package/managers/worker-dispatcher.manager.d.ts +0 -120
- package/managers/worker-dispatcher.manager.js +0 -1266
- package/managers/worker-dispatcher.manager.js.map +0 -1
- package/managers/worker-server.manager.d.ts +0 -35
- package/managers/worker-server.manager.js +0 -582
- package/managers/worker-server.manager.js.map +0 -1
- package/methods/accounts.d.ts +0 -2
- package/methods/accounts.js +0 -624
- package/methods/accounts.js.map +0 -1
- package/methods/ai-terminal.d.ts +0 -337
- package/methods/ai-terminal.js +0 -23193
- package/methods/ai-terminal.js.map +0 -1
- package/methods/app-settings.d.ts +0 -2
- package/methods/app-settings.js +0 -169
- package/methods/app-settings.js.map +0 -1
- package/methods/aws.d.ts +0 -2
- package/methods/aws.js +0 -877
- package/methods/aws.js.map +0 -1
- package/methods/collections.d.ts +0 -2
- package/methods/collections.js +0 -719
- package/methods/collections.js.map +0 -1
- package/methods/counters.d.ts +0 -2
- package/methods/counters.js +0 -113
- package/methods/counters.js.map +0 -1
- package/methods/cron-jobs.d.ts +0 -2
- package/methods/cron-jobs.js +0 -2475
- package/methods/cron-jobs.js.map +0 -1
- package/methods/customer-notifications.d.ts +0 -2
- package/methods/customer-notifications.js +0 -528
- package/methods/customer-notifications.js.map +0 -1
- package/methods/diagnostics.d.ts +0 -2
- package/methods/diagnostics.js +0 -703
- package/methods/diagnostics.js.map +0 -1
- package/methods/flag-updates.d.ts +0 -2
- package/methods/flag-updates.js +0 -8
- package/methods/flag-updates.js.map +0 -1
- package/methods/flags.d.ts +0 -2
- package/methods/flags.js +0 -8
- package/methods/flags.js.map +0 -1
- package/methods/logs.d.ts +0 -2
- package/methods/logs.js +0 -751
- package/methods/logs.js.map +0 -1
- package/methods/mongo-explorer.d.ts +0 -2
- package/methods/mongo-explorer.js +0 -1808
- package/methods/mongo-explorer.js.map +0 -1
- package/methods/monitor.d.ts +0 -2
- package/methods/monitor.js +0 -543
- package/methods/monitor.js.map +0 -1
- package/methods/pdf.d.ts +0 -2
- package/methods/pdf.js +0 -1216
- package/methods/pdf.js.map +0 -1
- package/methods/publications.d.ts +0 -1
- package/methods/publications.js +0 -183
- package/methods/publications.js.map +0 -1
- package/methods/report-builder.d.ts +0 -2
- package/methods/report-builder.js +0 -3094
- package/methods/report-builder.js.map +0 -1
- package/methods/support.d.ts +0 -2
- package/methods/support.js +0 -430
- package/methods/support.js.map +0 -1
- package/models/ai-run.model.d.ts +0 -19
- package/models/ai-run.model.js +0 -4
- package/models/ai-run.model.js.map +0 -1
- package/models/ai-terminal-conversation.model.d.ts +0 -17
- package/models/ai-terminal-conversation.model.js +0 -4
- package/models/ai-terminal-conversation.model.js.map +0 -1
- package/models/ai-terminal-issue-report.model.d.ts +0 -19
- package/models/ai-terminal-issue-report.model.js +0 -4
- package/models/ai-terminal-issue-report.model.js.map +0 -1
- package/models/ai-terminal-message.model.d.ts +0 -22
- package/models/ai-terminal-message.model.js +0 -4
- package/models/ai-terminal-message.model.js.map +0 -1
- package/models/app-setting.model.d.ts +0 -16
- package/models/app-setting.model.js +0 -4
- package/models/app-setting.model.js.map +0 -1
- package/models/app-status.model.js +0 -4
- package/models/app-status.model.js.map +0 -1
- package/models/billing-logged-in-users.model.js +0 -4
- package/models/billing-logged-in-users.model.js.map +0 -1
- package/models/collection-document.model.d.ts +0 -21
- package/models/collection-document.model.js +0 -4
- package/models/collection-document.model.js.map +0 -1
- package/models/communication-metric.model.d.ts +0 -20
- package/models/communication-metric.model.js +0 -4
- package/models/communication-metric.model.js.map +0 -1
- package/models/counter.model.js +0 -4
- package/models/counter.model.js.map +0 -1
- package/models/cron-job-history.model.d.ts +0 -15
- package/models/cron-job-history.model.js +0 -4
- package/models/cron-job-history.model.js.map +0 -1
- package/models/cron-job.model.d.ts +0 -14
- package/models/cron-job.model.js +0 -4
- package/models/cron-job.model.js.map +0 -1
- package/models/customer-notification.model.d.ts +0 -26
- package/models/customer-notification.model.js +0 -4
- package/models/customer-notification.model.js.map +0 -1
- package/models/customer-portal-password.model.d.ts +0 -11
- package/models/customer-portal-password.model.js +0 -4
- package/models/customer-portal-password.model.js.map +0 -1
- package/models/dialog.model.d.ts +0 -23
- package/models/dialog.model.js +0 -4
- package/models/dialog.model.js.map +0 -1
- package/models/email-history.model.d.ts +0 -32
- package/models/email-history.model.js.map +0 -1
- package/models/email-verified.model.js +0 -4
- package/models/email-verified.model.js.map +0 -1
- package/models/file.model.js +0 -4
- package/models/file.model.js.map +0 -1
- package/models/flag-update.model.js +0 -4
- package/models/flag-update.model.js.map +0 -1
- package/models/flag.model.js +0 -4
- package/models/flag.model.js.map +0 -1
- package/models/log-method-latency.model.d.ts +0 -10
- package/models/log-method-latency.model.js +0 -4
- package/models/log-method-latency.model.js.map +0 -1
- package/models/log-subscription.model.js +0 -4
- package/models/log-subscription.model.js.map +0 -1
- package/models/log.model.d.ts +0 -17
- package/models/log.model.js +0 -4
- package/models/log.model.js.map +0 -1
- package/models/logged-in-users.model.js +0 -4
- package/models/logged-in-users.model.js.map +0 -1
- package/models/method-response.model.js +0 -4
- package/models/method-response.model.js.map +0 -1
- package/models/method.model.d.ts +0 -26
- package/models/method.model.js +0 -4
- package/models/method.model.js.map +0 -1
- package/models/monitor-cpu.model.js +0 -4
- package/models/monitor-cpu.model.js.map +0 -1
- package/models/monitor-function.model.d.ts +0 -14
- package/models/monitor-function.model.js +0 -4
- package/models/monitor-function.model.js.map +0 -1
- package/models/monitor-memory.model.d.ts +0 -15
- package/models/monitor-memory.model.js +0 -4
- package/models/monitor-memory.model.js.map +0 -1
- package/models/monitor-mongo.model.d.ts +0 -13
- package/models/monitor-mongo.model.js +0 -4
- package/models/monitor-mongo.model.js.map +0 -1
- package/models/notification.model.js +0 -4
- package/models/notification.model.js.map +0 -1
- package/models/openai-usage-ledger.model.d.ts +0 -30
- package/models/openai-usage-ledger.model.js +0 -4
- package/models/openai-usage-ledger.model.js.map +0 -1
- package/models/pagination.model.d.ts +0 -11
- package/models/pagination.model.js +0 -28
- package/models/pagination.model.js.map +0 -1
- package/models/permission.model.d.ts +0 -12
- package/models/permission.model.js +0 -4
- package/models/permission.model.js.map +0 -1
- package/models/report-builder-dashboard-builder.model.d.ts +0 -25
- package/models/report-builder-dashboard-builder.model.js +0 -4
- package/models/report-builder-dashboard-builder.model.js.map +0 -1
- package/models/report-builder-library.model.d.ts +0 -17
- package/models/report-builder-library.model.js +0 -4
- package/models/report-builder-library.model.js.map +0 -1
- package/models/report-builder-report.model.d.ts +0 -121
- package/models/report-builder-report.model.js +0 -4
- package/models/report-builder-report.model.js.map +0 -1
- package/models/report-builder.model.d.ts +0 -61
- package/models/report-builder.model.js +0 -4
- package/models/report-builder.model.js.map +0 -1
- package/models/select-data-label.model.d.ts +0 -9
- package/models/select-data-label.model.js +0 -4
- package/models/select-data-label.model.js.map +0 -1
- package/models/server-message.model.d.ts +0 -32
- package/models/server-message.model.js +0 -4
- package/models/server-message.model.js.map +0 -1
- package/models/slow-query-report.model.d.ts +0 -23
- package/models/slow-query-report.model.js +0 -4
- package/models/slow-query-report.model.js.map +0 -1
- package/models/subscription.model.d.ts +0 -31
- package/models/subscription.model.js +0 -4
- package/models/subscription.model.js.map +0 -1
- package/models/support-ticket.model.d.ts +0 -87
- package/models/support-ticket.model.js +0 -4
- package/models/support-ticket.model.js.map +0 -1
- package/models/user-group.model.d.ts +0 -20
- package/models/user-group.model.js +0 -4
- package/models/user-group.model.js.map +0 -1
- package/models/user-guide.model.js +0 -4
- package/models/user-guide.model.js.map +0 -1
- package/models/user.model.d.ts +0 -84
- package/models/user.model.js +0 -4
- package/models/user.model.js.map +0 -1
- package/private/images/ResolveIO.png +0 -0
- package/public_api.js +0 -127
- package/public_api.js.map +0 -1
- package/publications/ai-terminal.d.ts +0 -1
- package/publications/ai-terminal.js +0 -122
- package/publications/ai-terminal.js.map +0 -1
- package/publications/app-settings.d.ts +0 -2
- package/publications/app-settings.js +0 -28
- package/publications/app-settings.js.map +0 -1
- package/publications/app-status.d.ts +0 -2
- package/publications/app-status.js +0 -16
- package/publications/app-status.js.map +0 -1
- package/publications/cron-jobs.d.ts +0 -2
- package/publications/cron-jobs.js +0 -88
- package/publications/cron-jobs.js.map +0 -1
- package/publications/customer-notifications.d.ts +0 -2
- package/publications/customer-notifications.js +0 -161
- package/publications/customer-notifications.js.map +0 -1
- package/publications/files.d.ts +0 -2
- package/publications/files.js +0 -36
- package/publications/files.js.map +0 -1
- package/publications/flags-update.d.ts +0 -2
- package/publications/flags-update.js +0 -22
- package/publications/flags-update.js.map +0 -1
- package/publications/flags.d.ts +0 -2
- package/publications/flags.js +0 -22
- package/publications/flags.js.map +0 -1
- package/publications/logs.d.ts +0 -2
- package/publications/logs.js +0 -164
- package/publications/logs.js.map +0 -1
- package/publications/notifications.d.ts +0 -2
- package/publications/notifications.js +0 -16
- package/publications/notifications.js.map +0 -1
- package/publications/report-builder-dashboard-builders.d.ts +0 -2
- package/publications/report-builder-dashboard-builders.js +0 -42
- package/publications/report-builder-dashboard-builders.js.map +0 -1
- package/publications/report-builder-libraries.d.ts +0 -2
- package/publications/report-builder-libraries.js +0 -90
- package/publications/report-builder-libraries.js.map +0 -1
- package/publications/report-builder-reports.d.ts +0 -2
- package/publications/report-builder-reports.js +0 -50
- package/publications/report-builder-reports.js.map +0 -1
- package/publications/super-admin.d.ts +0 -2
- package/publications/super-admin.js +0 -16
- package/publications/super-admin.js.map +0 -1
- package/publications/user-groups.d.ts +0 -1
- package/publications/user-groups.js +0 -16
- package/publications/user-groups.js.map +0 -1
- package/publications/user-guides.d.ts +0 -1
- package/publications/user-guides.js +0 -16
- package/publications/user-guides.js.map +0 -1
- package/resolveio-server-app.d.ts +0 -70
- package/resolveio-server-app.js +0 -801
- package/resolveio-server-app.js.map +0 -1
- package/server-app.d.ts +0 -228
- package/server-app.js +0 -3566
- package/server-app.js.map +0 -1
- package/services/codex-client.d.ts +0 -128
- package/services/codex-client.js +0 -1629
- package/services/codex-client.js.map +0 -1
- package/services/openai-client.d.ts +0 -46
- package/services/openai-client.js +0 -318
- package/services/openai-client.js.map +0 -1
- package/types/error-report.d.ts +0 -25
- package/types/error-report.js +0 -4
- package/types/error-report.js.map +0 -1
- package/types/slow-query-report.d.ts +0 -27
- package/types/slow-query-report.js +0 -6
- package/types/slow-query-report.js.map +0 -1
- package/util/ai-qa-policy.d.ts +0 -124
- package/util/ai-qa-policy.js +0 -736
- package/util/ai-qa-policy.js.map +0 -1
- package/util/ai-run-evidence-adapters.d.ts +0 -33
- package/util/ai-run-evidence-adapters.js +0 -838
- package/util/ai-run-evidence-adapters.js.map +0 -1
- package/util/ai-run-evidence-dashboard.d.ts +0 -84
- package/util/ai-run-evidence-dashboard.js +0 -336
- package/util/ai-run-evidence-dashboard.js.map +0 -1
- package/util/ai-run-evidence-eval.d.ts +0 -86
- package/util/ai-run-evidence-eval.js +0 -854
- package/util/ai-run-evidence-eval.js.map +0 -1
- package/util/ai-run-evidence.d.ts +0 -244
- package/util/ai-run-evidence.js +0 -731
- package/util/ai-run-evidence.js.map +0 -1
- package/util/ai-runner-artifacts.d.ts +0 -82
- package/util/ai-runner-artifacts.js +0 -713
- package/util/ai-runner-artifacts.js.map +0 -1
- package/util/ai-runner-manager-autopilot.d.ts +0 -112
- package/util/ai-runner-manager-autopilot.js +0 -313
- package/util/ai-runner-manager-autopilot.js.map +0 -1
- package/util/ai-runner-manager-policy.d.ts +0 -403
- package/util/ai-runner-manager-policy.js +0 -1763
- package/util/ai-runner-manager-policy.js.map +0 -1
- package/util/ai-runner-qa-auth.d.ts +0 -5
- package/util/ai-runner-qa-auth.js +0 -822
- package/util/ai-runner-qa-auth.js.map +0 -1
- package/util/ai-runner-qa-tools.d.ts +0 -26
- package/util/ai-runner-qa-tools.js +0 -3029
- package/util/ai-runner-qa-tools.js.map +0 -1
- package/util/aicoder-runner-v6.d.ts +0 -214
- package/util/aicoder-runner-v6.js +0 -507
- package/util/aicoder-runner-v6.js.map +0 -1
- package/util/common.d.ts +0 -31
- package/util/common.js +0 -683
- package/util/common.js.map +0 -1
- package/util/customer-portal-password.d.ts +0 -13
- package/util/customer-portal-password.js +0 -209
- package/util/customer-portal-password.js.map +0 -1
- package/util/error-reporter.d.ts +0 -52
- package/util/error-reporter.js +0 -326
- package/util/error-reporter.js.map +0 -1
- package/util/error-tracking.d.ts +0 -13
- package/util/error-tracking.js +0 -120
- package/util/error-tracking.js.map +0 -1
- package/util/openai-usage-cost.d.ts +0 -6
- package/util/openai-usage-cost.js +0 -103
- package/util/openai-usage-cost.js.map +0 -1
- package/util/report-builder-unwinds.d.ts +0 -15
- package/util/report-builder-unwinds.js +0 -156
- package/util/report-builder-unwinds.js.map +0 -1
- package/util/runner-process-janitor.d.ts +0 -27
- package/util/runner-process-janitor.js +0 -208
- package/util/runner-process-janitor.js.map +0 -1
- package/util/schema-report-builder.d.ts +0 -6
- package/util/schema-report-builder.js +0 -481
- package/util/schema-report-builder.js.map +0 -1
- package/util/slow-query-reporter.d.ts +0 -28
- package/util/slow-query-reporter.js +0 -226
- package/util/slow-query-reporter.js.map +0 -1
- package/util/subscription-dependency-context.d.ts +0 -34
- package/util/subscription-dependency-context.js +0 -1283
- package/util/subscription-dependency-context.js.map +0 -1
- package/util/support-runner-v5.d.ts +0 -415
- package/util/support-runner-v5.js +0 -1445
- package/util/support-runner-v5.js.map +0 -1
- package/util/tokenizer.d.ts +0 -5
- package/util/tokenizer.js +0 -41
- package/util/tokenizer.js.map +0 -1
- package/workers/codex-runner.worker.d.ts +0 -1
- package/workers/codex-runner.worker.js +0 -192
- package/workers/codex-runner.worker.js.map +0 -1
- /package/{private → src/private}/email-templates/enrollment.html +0 -0
- /package/{private → src/private}/email-templates/forgot-password.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
- /package/{private → src/private}/email-templates/support-ticket.html +0 -0
- /package/{public_api.d.ts → src/public_api.ts} +0 -0
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
export type AIRunSource =
|
|
2
|
+
| 'support_ticket'
|
|
3
|
+
| 'aicoder_app'
|
|
4
|
+
| 'ai_assistant'
|
|
5
|
+
| 'qa_runner'
|
|
6
|
+
| 'unknown';
|
|
7
|
+
|
|
8
|
+
export type AIRunOutcomeLabel =
|
|
9
|
+
| 'accepted'
|
|
10
|
+
| 'rejected'
|
|
11
|
+
| 'qa_incomplete'
|
|
12
|
+
| 'qa_infra_failed'
|
|
13
|
+
| 'build_failed'
|
|
14
|
+
| 'release_blocked'
|
|
15
|
+
| 'manual_handoff'
|
|
16
|
+
| 'false_pass'
|
|
17
|
+
| 'stopped'
|
|
18
|
+
| 'unknown';
|
|
19
|
+
|
|
20
|
+
export type AIRunEventType =
|
|
21
|
+
| 'model_call'
|
|
22
|
+
| 'log'
|
|
23
|
+
| 'qa_infra'
|
|
24
|
+
| 'qa_compile'
|
|
25
|
+
| 'qa_route_probe'
|
|
26
|
+
| 'qa_business_assertion'
|
|
27
|
+
| 'scorecard'
|
|
28
|
+
| 'deploy'
|
|
29
|
+
| 'publish'
|
|
30
|
+
| 'assistant_message'
|
|
31
|
+
| 'git_commit'
|
|
32
|
+
| 'usage'
|
|
33
|
+
| 'human_intervention';
|
|
34
|
+
|
|
35
|
+
export type AIRunGateStatus = 'pass' | 'fail' | 'warn' | 'blocked' | 'skipped';
|
|
36
|
+
|
|
37
|
+
export type AIQaCheckStatus = 'pass' | 'fail' | 'blocked' | 'warn' | 'skipped' | 'unknown';
|
|
38
|
+
|
|
39
|
+
export type AIQaCompileStatus = 'pass' | 'fail' | 'blocked' | 'stale' | 'skipped' | 'unknown';
|
|
40
|
+
|
|
41
|
+
export type AIQaOutcome =
|
|
42
|
+
| 'infra_failed'
|
|
43
|
+
| 'compile_failed'
|
|
44
|
+
| 'route_failed'
|
|
45
|
+
| 'route_only_pass'
|
|
46
|
+
| 'business_assertion_passed'
|
|
47
|
+
| 'business_assertion_failed'
|
|
48
|
+
| 'incomplete';
|
|
49
|
+
|
|
50
|
+
export interface AIRunEvent {
|
|
51
|
+
id?: string;
|
|
52
|
+
type: AIRunEventType;
|
|
53
|
+
source?: AIRunSource | string;
|
|
54
|
+
message?: string;
|
|
55
|
+
category?: string;
|
|
56
|
+
artifactPaths?: string[];
|
|
57
|
+
metadata?: Record<string, any>;
|
|
58
|
+
recordedAt?: Date | string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface AIRunGateResult {
|
|
62
|
+
key: string;
|
|
63
|
+
label: string;
|
|
64
|
+
status: AIRunGateStatus;
|
|
65
|
+
reason: string;
|
|
66
|
+
evidenceRefs: string[];
|
|
67
|
+
recordedAt: string;
|
|
68
|
+
metadata?: Record<string, any>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface AIRunCost {
|
|
72
|
+
inputTokens: number;
|
|
73
|
+
cachedInputTokens: number;
|
|
74
|
+
outputTokens: number;
|
|
75
|
+
totalTokens: number;
|
|
76
|
+
estimatedUsd: number;
|
|
77
|
+
models: string[];
|
|
78
|
+
categories: Record<string, {
|
|
79
|
+
inputTokens: number;
|
|
80
|
+
cachedInputTokens: number;
|
|
81
|
+
outputTokens: number;
|
|
82
|
+
totalTokens: number;
|
|
83
|
+
estimatedUsd: number;
|
|
84
|
+
count: number;
|
|
85
|
+
}>;
|
|
86
|
+
sources?: Record<string, {
|
|
87
|
+
inputTokens: number;
|
|
88
|
+
cachedInputTokens: number;
|
|
89
|
+
outputTokens: number;
|
|
90
|
+
totalTokens: number;
|
|
91
|
+
estimatedUsd: number;
|
|
92
|
+
count: number;
|
|
93
|
+
manualCount: number;
|
|
94
|
+
untrackedCount: number;
|
|
95
|
+
}>;
|
|
96
|
+
surfaces?: Record<string, {
|
|
97
|
+
totalTokens: number;
|
|
98
|
+
estimatedUsd: number;
|
|
99
|
+
count: number;
|
|
100
|
+
}>;
|
|
101
|
+
manualEstimatedUsd?: number;
|
|
102
|
+
untrackedEstimatedUsd?: number;
|
|
103
|
+
untrackedWarnings?: string[];
|
|
104
|
+
wallTimeMs?: number;
|
|
105
|
+
retries?: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface OpenAIUsageCostEntry {
|
|
109
|
+
model?: string;
|
|
110
|
+
category?: string;
|
|
111
|
+
id_request?: string;
|
|
112
|
+
idRequest?: string;
|
|
113
|
+
id_conversation?: string;
|
|
114
|
+
idConversation?: string;
|
|
115
|
+
timestamp?: Date | string;
|
|
116
|
+
input_tokens?: number;
|
|
117
|
+
inputTokens?: number;
|
|
118
|
+
cached_input_tokens?: number;
|
|
119
|
+
cachedInputTokens?: number;
|
|
120
|
+
output_tokens?: number;
|
|
121
|
+
outputTokens?: number;
|
|
122
|
+
total_tokens?: number;
|
|
123
|
+
totalTokens?: number;
|
|
124
|
+
cost_estimate?: number;
|
|
125
|
+
estimatedUsd?: number;
|
|
126
|
+
usage_source?: string;
|
|
127
|
+
usageSource?: string;
|
|
128
|
+
usage_surface?: string;
|
|
129
|
+
usageSurface?: string;
|
|
130
|
+
usage_phase?: string;
|
|
131
|
+
usagePhase?: string;
|
|
132
|
+
cost_basis?: string;
|
|
133
|
+
costBasis?: string;
|
|
134
|
+
is_manual?: boolean;
|
|
135
|
+
isManual?: boolean;
|
|
136
|
+
is_untracked?: boolean;
|
|
137
|
+
isUntracked?: boolean;
|
|
138
|
+
untracked_reason?: string;
|
|
139
|
+
untrackedReason?: string;
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface AIQaInfraCheck {
|
|
144
|
+
name: string;
|
|
145
|
+
status: AIQaCheckStatus;
|
|
146
|
+
message?: string;
|
|
147
|
+
path?: string;
|
|
148
|
+
durationMs?: number;
|
|
149
|
+
metadata?: Record<string, any>;
|
|
150
|
+
checkedAt?: Date | string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface AIQaCompileResult {
|
|
154
|
+
status: AIQaCompileStatus;
|
|
155
|
+
command?: string;
|
|
156
|
+
artifactPath?: string;
|
|
157
|
+
message?: string;
|
|
158
|
+
durationMs?: number;
|
|
159
|
+
staleEvidence?: boolean;
|
|
160
|
+
recordedAt?: Date | string;
|
|
161
|
+
metadata?: Record<string, any>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface AIQaRouteProbe {
|
|
165
|
+
route: string;
|
|
166
|
+
status: AIQaCheckStatus;
|
|
167
|
+
screenshot?: string;
|
|
168
|
+
caption?: string;
|
|
169
|
+
shellOnly?: boolean;
|
|
170
|
+
authenticated?: boolean;
|
|
171
|
+
consoleErrors?: string[];
|
|
172
|
+
networkErrors?: string[];
|
|
173
|
+
message?: string;
|
|
174
|
+
recordedAt?: Date | string;
|
|
175
|
+
metadata?: Record<string, any>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface AIQaBusinessAssertion {
|
|
179
|
+
assertion: string;
|
|
180
|
+
status: AIQaCheckStatus;
|
|
181
|
+
workflow?: string;
|
|
182
|
+
route?: string;
|
|
183
|
+
action?: string;
|
|
184
|
+
expected?: string;
|
|
185
|
+
observed?: string;
|
|
186
|
+
dataProof?: string;
|
|
187
|
+
mongoDelta?: Record<string, any>;
|
|
188
|
+
artifactPaths?: string[];
|
|
189
|
+
message?: string;
|
|
190
|
+
recordedAt?: Date | string;
|
|
191
|
+
metadata?: Record<string, any>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface AIQaArtifact {
|
|
195
|
+
type: 'screenshot' | 'trace' | 'console_log' | 'network_log' | 'coverage_matrix' | 'seed_data' | 'script' | 'other';
|
|
196
|
+
path?: string;
|
|
197
|
+
url?: string;
|
|
198
|
+
title?: string;
|
|
199
|
+
caption?: string;
|
|
200
|
+
metadata?: Record<string, any>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface AIQaRun {
|
|
204
|
+
outcome: AIQaOutcome;
|
|
205
|
+
infraChecks: AIQaInfraCheck[];
|
|
206
|
+
compile?: AIQaCompileResult;
|
|
207
|
+
routeProbes: AIQaRouteProbe[];
|
|
208
|
+
businessAssertions: AIQaBusinessAssertion[];
|
|
209
|
+
artifacts: AIQaArtifact[];
|
|
210
|
+
gateResults: AIRunGateResult[];
|
|
211
|
+
updatedAt: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface AIRun {
|
|
215
|
+
id?: string;
|
|
216
|
+
source: AIRunSource;
|
|
217
|
+
sourceIds: Record<string, string>;
|
|
218
|
+
title?: string;
|
|
219
|
+
status?: string;
|
|
220
|
+
phase?: string;
|
|
221
|
+
startedAt?: Date | string;
|
|
222
|
+
completedAt?: Date | string;
|
|
223
|
+
outcome: AIRunOutcomeLabel;
|
|
224
|
+
events: AIRunEvent[];
|
|
225
|
+
gates: AIRunGateResult[];
|
|
226
|
+
qa?: AIQaRun;
|
|
227
|
+
cost?: AIRunCost;
|
|
228
|
+
nextAction?: string;
|
|
229
|
+
warnings?: string[];
|
|
230
|
+
metadata?: Record<string, any>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface AIRunTrainingExample {
|
|
234
|
+
runId: string;
|
|
235
|
+
source: AIRunSource;
|
|
236
|
+
inputSummary: string;
|
|
237
|
+
actionSummary: string;
|
|
238
|
+
outcome: AIRunOutcomeLabel;
|
|
239
|
+
evidence: string[];
|
|
240
|
+
cost?: AIRunCost;
|
|
241
|
+
metadata?: Record<string, any>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface AIQaEvaluationInput {
|
|
245
|
+
infraChecks?: AIQaInfraCheck[];
|
|
246
|
+
compile?: AIQaCompileResult;
|
|
247
|
+
routeProbes?: AIQaRouteProbe[];
|
|
248
|
+
businessAssertions?: AIQaBusinessAssertion[];
|
|
249
|
+
artifacts?: AIQaArtifact[];
|
|
250
|
+
now?: Date | string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface AIRunOutcomeInput {
|
|
254
|
+
source?: AIRunSource;
|
|
255
|
+
status?: string;
|
|
256
|
+
phase?: string;
|
|
257
|
+
qa?: AIQaRun | AIQaEvaluationInput;
|
|
258
|
+
gates?: AIRunGateResult[];
|
|
259
|
+
scorecardPassed?: boolean;
|
|
260
|
+
scorecardStatus?: string;
|
|
261
|
+
deployStatus?: string;
|
|
262
|
+
publishStatus?: string;
|
|
263
|
+
sampleDataStatus?: string;
|
|
264
|
+
manualHandoff?: boolean;
|
|
265
|
+
stopped?: boolean;
|
|
266
|
+
rejected?: boolean;
|
|
267
|
+
explicitAccepted?: boolean;
|
|
268
|
+
terminal?: boolean;
|
|
269
|
+
now?: Date | string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface AIRunOutcomeDecision {
|
|
273
|
+
outcome: AIRunOutcomeLabel;
|
|
274
|
+
reason: string;
|
|
275
|
+
nextAction: string;
|
|
276
|
+
gates: AIRunGateResult[];
|
|
277
|
+
warnings: string[];
|
|
278
|
+
recordedAt: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function isoNow(value?: Date | string): string {
|
|
282
|
+
if (value instanceof Date) {
|
|
283
|
+
return value.toISOString();
|
|
284
|
+
}
|
|
285
|
+
const parsed = value ? new Date(value) : new Date();
|
|
286
|
+
if (Number.isFinite(parsed.getTime())) {
|
|
287
|
+
return parsed.toISOString();
|
|
288
|
+
}
|
|
289
|
+
return new Date().toISOString();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function cleanText(value: any, max = 1000): string {
|
|
293
|
+
return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function cleanUsageNumber(value: any): number {
|
|
297
|
+
const parsed = Number(value);
|
|
298
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function cleanUsageDate(value: any): Date | undefined {
|
|
302
|
+
if (!value) {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
306
|
+
return Number.isFinite(date.getTime()) ? date : undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export function isCumulativeCodexUsageEntry(entry: OpenAIUsageCostEntry): boolean {
|
|
310
|
+
return cleanText(entry?.category, 180).toLowerCase().startsWith('ai-dashboard-codex:');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export function resolveOpenAIUsageThreadKey(entry: OpenAIUsageCostEntry): string {
|
|
314
|
+
const conversationId = cleanText(entry?.id_conversation ?? entry?.idConversation, 240);
|
|
315
|
+
if (conversationId) {
|
|
316
|
+
return conversationId;
|
|
317
|
+
}
|
|
318
|
+
return cleanText(entry?.id_request ?? entry?.idRequest, 240);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export function normalizeOpenAIUsageRowsForCosting<T extends OpenAIUsageCostEntry>(rows: T[] = []): T[] {
|
|
322
|
+
if (!Array.isArray(rows) || !rows.length) {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
const sortedRows = rows
|
|
326
|
+
.map((row, index) => ({
|
|
327
|
+
...row,
|
|
328
|
+
_sortIndex: index
|
|
329
|
+
}))
|
|
330
|
+
.sort((a, b) => {
|
|
331
|
+
const timeA = cleanUsageDate(a.timestamp)?.getTime() || 0;
|
|
332
|
+
const timeB = cleanUsageDate(b.timestamp)?.getTime() || 0;
|
|
333
|
+
if (timeA !== timeB) {
|
|
334
|
+
return timeA - timeB;
|
|
335
|
+
}
|
|
336
|
+
const requestCompare = cleanText(a.id_request ?? a.idRequest, 240)
|
|
337
|
+
.localeCompare(cleanText(b.id_request ?? b.idRequest, 240));
|
|
338
|
+
if (requestCompare) {
|
|
339
|
+
return requestCompare;
|
|
340
|
+
}
|
|
341
|
+
const conversationCompare = cleanText(a.id_conversation ?? a.idConversation, 240)
|
|
342
|
+
.localeCompare(cleanText(b.id_conversation ?? b.idConversation, 240));
|
|
343
|
+
if (conversationCompare) {
|
|
344
|
+
return conversationCompare;
|
|
345
|
+
}
|
|
346
|
+
return cleanUsageNumber(a._sortIndex) - cleanUsageNumber(b._sortIndex);
|
|
347
|
+
});
|
|
348
|
+
const previousByThread = new Map<string, {
|
|
349
|
+
inputTokens: number;
|
|
350
|
+
cachedInputTokens: number;
|
|
351
|
+
outputTokens: number;
|
|
352
|
+
totalTokens: number;
|
|
353
|
+
estimatedUsd: number;
|
|
354
|
+
}>();
|
|
355
|
+
return sortedRows.map((row) => {
|
|
356
|
+
const inputTokens = cleanUsageNumber(row.input_tokens ?? row.inputTokens);
|
|
357
|
+
const cachedInputTokens = cleanUsageNumber(row.cached_input_tokens ?? row.cachedInputTokens);
|
|
358
|
+
const outputTokens = cleanUsageNumber(row.output_tokens ?? row.outputTokens);
|
|
359
|
+
const totalTokens = cleanUsageNumber(row.total_tokens ?? row.totalTokens ?? (inputTokens + outputTokens));
|
|
360
|
+
const estimatedUsd = cleanUsageNumber(row.cost_estimate ?? row.estimatedUsd);
|
|
361
|
+
const threadKey = isCumulativeCodexUsageEntry(row) ? resolveOpenAIUsageThreadKey(row) : '';
|
|
362
|
+
let normalizedInputTokens = inputTokens;
|
|
363
|
+
let normalizedCachedInputTokens = cachedInputTokens;
|
|
364
|
+
let normalizedOutputTokens = outputTokens;
|
|
365
|
+
let normalizedTotalTokens = totalTokens;
|
|
366
|
+
let normalizedEstimatedUsd = estimatedUsd;
|
|
367
|
+
if (threadKey) {
|
|
368
|
+
const previous = previousByThread.get(threadKey);
|
|
369
|
+
if (previous
|
|
370
|
+
&& inputTokens >= previous.inputTokens
|
|
371
|
+
&& cachedInputTokens >= previous.cachedInputTokens
|
|
372
|
+
&& outputTokens >= previous.outputTokens
|
|
373
|
+
&& totalTokens >= previous.totalTokens
|
|
374
|
+
&& estimatedUsd >= previous.estimatedUsd
|
|
375
|
+
) {
|
|
376
|
+
normalizedInputTokens = Math.max(0, inputTokens - previous.inputTokens);
|
|
377
|
+
normalizedCachedInputTokens = Math.max(0, cachedInputTokens - previous.cachedInputTokens);
|
|
378
|
+
normalizedOutputTokens = Math.max(0, outputTokens - previous.outputTokens);
|
|
379
|
+
normalizedTotalTokens = Math.max(0, totalTokens - previous.totalTokens);
|
|
380
|
+
normalizedEstimatedUsd = Math.max(0, estimatedUsd - previous.estimatedUsd);
|
|
381
|
+
}
|
|
382
|
+
previousByThread.set(threadKey, {
|
|
383
|
+
inputTokens,
|
|
384
|
+
cachedInputTokens,
|
|
385
|
+
outputTokens,
|
|
386
|
+
totalTokens,
|
|
387
|
+
estimatedUsd
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
const resolvedTotalTokens = normalizedTotalTokens || (normalizedInputTokens + normalizedOutputTokens);
|
|
391
|
+
const resolvedEstimatedUsd = Number(normalizedEstimatedUsd.toFixed(6));
|
|
392
|
+
return {
|
|
393
|
+
...row,
|
|
394
|
+
input_tokens: normalizedInputTokens,
|
|
395
|
+
inputTokens: normalizedInputTokens,
|
|
396
|
+
cached_input_tokens: normalizedCachedInputTokens,
|
|
397
|
+
cachedInputTokens: normalizedCachedInputTokens,
|
|
398
|
+
output_tokens: normalizedOutputTokens,
|
|
399
|
+
outputTokens: normalizedOutputTokens,
|
|
400
|
+
total_tokens: resolvedTotalTokens,
|
|
401
|
+
totalTokens: resolvedTotalTokens,
|
|
402
|
+
cost_estimate: resolvedEstimatedUsd,
|
|
403
|
+
estimatedUsd: resolvedEstimatedUsd
|
|
404
|
+
} as T;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function cleanList(values: any, limit = 20, max = 500): string[] {
|
|
409
|
+
if (!Array.isArray(values)) {
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
const result: string[] = [];
|
|
413
|
+
for (const value of values) {
|
|
414
|
+
const normalized = cleanText(value, max);
|
|
415
|
+
if (normalized && !result.includes(normalized)) {
|
|
416
|
+
result.push(normalized);
|
|
417
|
+
}
|
|
418
|
+
if (result.length >= limit) {
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function normalizeCheckStatus(value: any): AIQaCheckStatus {
|
|
426
|
+
const normalized = cleanText(value, 40).toLowerCase().replace(/[_\s-]+/g, '_');
|
|
427
|
+
if (normalized === 'passed' || normalized === 'ok' || normalized === 'ready') {
|
|
428
|
+
return 'pass';
|
|
429
|
+
}
|
|
430
|
+
if (normalized === 'failed' || normalized === 'error' || normalized === 'fail') {
|
|
431
|
+
return 'fail';
|
|
432
|
+
}
|
|
433
|
+
if (normalized === 'blocked' || normalized === 'dependency_blocked') {
|
|
434
|
+
return 'blocked';
|
|
435
|
+
}
|
|
436
|
+
if (normalized === 'warning') {
|
|
437
|
+
return 'warn';
|
|
438
|
+
}
|
|
439
|
+
if (normalized === 'skipped' || normalized === 'not_applicable') {
|
|
440
|
+
return 'skipped';
|
|
441
|
+
}
|
|
442
|
+
return normalized === 'pass' || normalized === 'warn' ? normalized : 'unknown';
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function normalizeCompileStatus(value: any): AIQaCompileStatus {
|
|
446
|
+
const normalized = cleanText(value, 40).toLowerCase().replace(/[_\s-]+/g, '_');
|
|
447
|
+
if (normalized === 'passed' || normalized === 'ok') {
|
|
448
|
+
return 'pass';
|
|
449
|
+
}
|
|
450
|
+
if (normalized === 'failed' || normalized === 'error') {
|
|
451
|
+
return 'fail';
|
|
452
|
+
}
|
|
453
|
+
if (normalized === 'blocked') {
|
|
454
|
+
return 'blocked';
|
|
455
|
+
}
|
|
456
|
+
if (normalized === 'stale' || normalized === 'stale_evidence') {
|
|
457
|
+
return 'stale';
|
|
458
|
+
}
|
|
459
|
+
if (normalized === 'skipped' || normalized === 'not_applicable') {
|
|
460
|
+
return 'skipped';
|
|
461
|
+
}
|
|
462
|
+
return normalized === 'pass' || normalized === 'fail' ? normalized : 'unknown';
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function makeGate(
|
|
466
|
+
key: string,
|
|
467
|
+
label: string,
|
|
468
|
+
status: AIRunGateStatus,
|
|
469
|
+
reason: string,
|
|
470
|
+
evidenceRefs: string[] = [],
|
|
471
|
+
now?: Date | string,
|
|
472
|
+
metadata?: Record<string, any>
|
|
473
|
+
): AIRunGateResult {
|
|
474
|
+
return {
|
|
475
|
+
key,
|
|
476
|
+
label,
|
|
477
|
+
status,
|
|
478
|
+
reason: cleanText(reason, 1400),
|
|
479
|
+
evidenceRefs: cleanList(evidenceRefs, 20, 500),
|
|
480
|
+
recordedAt: isoNow(now),
|
|
481
|
+
...(metadata ? { metadata } : {})
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function failedOrBlocked(status: AIQaCheckStatus | AIQaCompileStatus): boolean {
|
|
486
|
+
return status === 'fail' || status === 'blocked';
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function passed(status: AIQaCheckStatus | AIQaCompileStatus): boolean {
|
|
490
|
+
return status === 'pass';
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function normalizeInfraChecks(values: AIQaInfraCheck[] | undefined): AIQaInfraCheck[] {
|
|
494
|
+
return (Array.isArray(values) ? values : []).map((entry) => ({
|
|
495
|
+
...entry,
|
|
496
|
+
name: cleanText(entry?.name, 120) || 'infra_check',
|
|
497
|
+
status: normalizeCheckStatus(entry?.status),
|
|
498
|
+
message: cleanText(entry?.message, 1000),
|
|
499
|
+
path: cleanText(entry?.path, 500)
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function normalizeRouteProbes(values: AIQaRouteProbe[] | undefined): AIQaRouteProbe[] {
|
|
504
|
+
return (Array.isArray(values) ? values : []).map((entry) => ({
|
|
505
|
+
...entry,
|
|
506
|
+
route: cleanText(entry?.route, 500) || '/',
|
|
507
|
+
status: normalizeCheckStatus(entry?.status),
|
|
508
|
+
screenshot: cleanText(entry?.screenshot, 500),
|
|
509
|
+
caption: cleanText(entry?.caption, 1000),
|
|
510
|
+
message: cleanText(entry?.message, 1000),
|
|
511
|
+
consoleErrors: cleanList(entry?.consoleErrors, 30, 500),
|
|
512
|
+
networkErrors: cleanList(entry?.networkErrors, 30, 500)
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function normalizeBusinessAssertions(values: AIQaBusinessAssertion[] | undefined): AIQaBusinessAssertion[] {
|
|
517
|
+
return (Array.isArray(values) ? values : []).map((entry) => ({
|
|
518
|
+
...entry,
|
|
519
|
+
assertion: cleanText(entry?.assertion, 1000) || 'business assertion',
|
|
520
|
+
status: normalizeCheckStatus(entry?.status),
|
|
521
|
+
workflow: cleanText(entry?.workflow, 400),
|
|
522
|
+
route: cleanText(entry?.route, 500),
|
|
523
|
+
action: cleanText(entry?.action, 500),
|
|
524
|
+
expected: cleanText(entry?.expected, 1000),
|
|
525
|
+
observed: cleanText(entry?.observed, 1000),
|
|
526
|
+
dataProof: cleanText(entry?.dataProof, 1400),
|
|
527
|
+
artifactPaths: cleanList(entry?.artifactPaths, 30, 500),
|
|
528
|
+
message: cleanText(entry?.message, 1000)
|
|
529
|
+
}));
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function collectBusinessAssertionArtifactPaths(assertions: AIQaBusinessAssertion[]): string[] {
|
|
533
|
+
const paths: string[] = [];
|
|
534
|
+
for (const assertion of assertions) {
|
|
535
|
+
for (const artifactPath of assertion.artifactPaths || []) {
|
|
536
|
+
if (artifactPath && !paths.includes(artifactPath)) {
|
|
537
|
+
paths.push(artifactPath);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return paths;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function buildAIQaRun(input: AIQaEvaluationInput = {}): AIQaRun {
|
|
545
|
+
const now = isoNow(input.now);
|
|
546
|
+
const infraChecks = normalizeInfraChecks(input.infraChecks);
|
|
547
|
+
const compile = input.compile
|
|
548
|
+
? {
|
|
549
|
+
...input.compile,
|
|
550
|
+
status: normalizeCompileStatus(input.compile.status),
|
|
551
|
+
command: cleanText(input.compile.command, 500),
|
|
552
|
+
artifactPath: cleanText(input.compile.artifactPath, 500),
|
|
553
|
+
message: cleanText(input.compile.message, 1000)
|
|
554
|
+
}
|
|
555
|
+
: undefined;
|
|
556
|
+
const routeProbes = normalizeRouteProbes(input.routeProbes);
|
|
557
|
+
const businessAssertions = normalizeBusinessAssertions(input.businessAssertions);
|
|
558
|
+
const artifacts = Array.isArray(input.artifacts) ? input.artifacts : [];
|
|
559
|
+
const gateResults: AIRunGateResult[] = [];
|
|
560
|
+
|
|
561
|
+
const failedInfra = infraChecks.filter((check) => failedOrBlocked(check.status));
|
|
562
|
+
if (failedInfra.length) {
|
|
563
|
+
gateResults.push(makeGate(
|
|
564
|
+
'qa_infra',
|
|
565
|
+
'QA infrastructure',
|
|
566
|
+
'blocked',
|
|
567
|
+
`QA infrastructure failed before model/business validation: ${failedInfra.map((check) => `${check.name}: ${check.message || check.status}`).join('; ')}`,
|
|
568
|
+
failedInfra.map((check) => check.path || '').filter(Boolean),
|
|
569
|
+
now,
|
|
570
|
+
{ failed_checks: failedInfra.map((check) => check.name) }
|
|
571
|
+
));
|
|
572
|
+
return { outcome: 'infra_failed', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
573
|
+
}
|
|
574
|
+
if (infraChecks.length) {
|
|
575
|
+
gateResults.push(makeGate('qa_infra', 'QA infrastructure', 'pass', 'QA infrastructure preflight checks passed.', [], now));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (compile && (failedOrBlocked(compile.status) || compile.status === 'stale' || compile.staleEvidence === true)) {
|
|
579
|
+
gateResults.push(makeGate(
|
|
580
|
+
'qa_compile',
|
|
581
|
+
'Compile/build',
|
|
582
|
+
'fail',
|
|
583
|
+
compile.status === 'stale' || compile.staleEvidence === true
|
|
584
|
+
? 'Compile/build evidence is stale and cannot be used for acceptance.'
|
|
585
|
+
: (compile.message || 'Compile/build failed before browser QA.'),
|
|
586
|
+
compile.artifactPath ? [compile.artifactPath] : [],
|
|
587
|
+
now,
|
|
588
|
+
{ command: compile.command || '' }
|
|
589
|
+
));
|
|
590
|
+
return { outcome: 'compile_failed', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
591
|
+
}
|
|
592
|
+
if (compile && passed(compile.status)) {
|
|
593
|
+
gateResults.push(makeGate('qa_compile', 'Compile/build', 'pass', 'Compile/build evidence passed.', compile.artifactPath ? [compile.artifactPath] : [], now));
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const failedRouteProbes = routeProbes.filter((probe) => failedOrBlocked(probe.status) || probe.shellOnly === true);
|
|
597
|
+
if (failedRouteProbes.length) {
|
|
598
|
+
gateResults.push(makeGate(
|
|
599
|
+
'qa_route_probe',
|
|
600
|
+
'Browser route probe',
|
|
601
|
+
'fail',
|
|
602
|
+
`Browser route probe failed or showed shell-only UI: ${failedRouteProbes.map((probe) => `${probe.route}: ${probe.message || probe.caption || probe.status}`).join('; ')}`,
|
|
603
|
+
failedRouteProbes.map((probe) => probe.screenshot || '').filter(Boolean),
|
|
604
|
+
now
|
|
605
|
+
));
|
|
606
|
+
return { outcome: 'route_failed', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
607
|
+
}
|
|
608
|
+
if (routeProbes.some((probe) => passed(probe.status))) {
|
|
609
|
+
gateResults.push(makeGate(
|
|
610
|
+
'qa_route_probe',
|
|
611
|
+
'Browser route probe',
|
|
612
|
+
'pass',
|
|
613
|
+
'Browser route reached authenticated application content. This is not business acceptance by itself.',
|
|
614
|
+
routeProbes.map((probe) => probe.screenshot || '').filter(Boolean),
|
|
615
|
+
now
|
|
616
|
+
));
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const failedBusinessAssertions = businessAssertions.filter((assertion) => failedOrBlocked(assertion.status));
|
|
620
|
+
if (failedBusinessAssertions.length) {
|
|
621
|
+
gateResults.push(makeGate(
|
|
622
|
+
'qa_business_assertion',
|
|
623
|
+
'Business assertion',
|
|
624
|
+
'fail',
|
|
625
|
+
`Issue-specific workflow assertion failed: ${failedBusinessAssertions.map((assertion) => assertion.message || assertion.observed || assertion.assertion).join('; ')}`,
|
|
626
|
+
collectBusinessAssertionArtifactPaths(failedBusinessAssertions),
|
|
627
|
+
now
|
|
628
|
+
));
|
|
629
|
+
return { outcome: 'business_assertion_failed', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const passedBusinessAssertions = businessAssertions.filter((assertion) => passed(assertion.status));
|
|
633
|
+
if (passedBusinessAssertions.length) {
|
|
634
|
+
gateResults.push(makeGate(
|
|
635
|
+
'qa_business_assertion',
|
|
636
|
+
'Business assertion',
|
|
637
|
+
'pass',
|
|
638
|
+
'At least one issue-specific workflow/data assertion passed.',
|
|
639
|
+
collectBusinessAssertionArtifactPaths(passedBusinessAssertions),
|
|
640
|
+
now,
|
|
641
|
+
{ passed_assertions: passedBusinessAssertions.map((assertion) => assertion.assertion) }
|
|
642
|
+
));
|
|
643
|
+
return { outcome: 'business_assertion_passed', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (routeProbes.some((probe) => passed(probe.status))) {
|
|
647
|
+
gateResults.push(makeGate(
|
|
648
|
+
'qa_business_assertion',
|
|
649
|
+
'Business assertion',
|
|
650
|
+
'blocked',
|
|
651
|
+
'Browser route loaded, but no issue-specific business assertion passed. Route-only proof cannot accept the run.',
|
|
652
|
+
[],
|
|
653
|
+
now
|
|
654
|
+
));
|
|
655
|
+
return { outcome: 'route_only_pass', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
gateResults.push(makeGate(
|
|
659
|
+
'qa_business_assertion',
|
|
660
|
+
'Business assertion',
|
|
661
|
+
'blocked',
|
|
662
|
+
'No issue-specific QA assertion was recorded.',
|
|
663
|
+
[],
|
|
664
|
+
now
|
|
665
|
+
));
|
|
666
|
+
return { outcome: 'incomplete', infraChecks, compile, routeProbes, businessAssertions, artifacts, gateResults, updatedAt: now };
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function normalizeQaRun(input?: AIQaRun | AIQaEvaluationInput): AIQaRun | undefined {
|
|
670
|
+
if (!input) {
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
if ((input as AIQaRun).outcome && Array.isArray((input as AIQaRun).gateResults)) {
|
|
674
|
+
return input as AIQaRun;
|
|
675
|
+
}
|
|
676
|
+
return buildAIQaRun(input as AIQaEvaluationInput);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function statusLooksFailed(value: any): boolean {
|
|
680
|
+
const normalized = cleanText(value, 120).toLowerCase();
|
|
681
|
+
return !!normalized && /(fail|failed|error|blocked|missing|empty|stale|skipped|not ready|not_ready|could not|cannot)/i.test(normalized);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function statusLooksPassed(value: any): boolean {
|
|
685
|
+
const normalized = cleanText(value, 120).toLowerCase();
|
|
686
|
+
return !!normalized && /(pass|passed|success|complete|completed|ready|published|deployed|live|merged)/i.test(normalized);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function addGateOnce(gates: AIRunGateResult[], gate: AIRunGateResult): void {
|
|
690
|
+
if (gates.some((entry) => entry.key === gate.key && entry.status === gate.status && entry.reason === gate.reason)) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
gates.push(gate);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export function classifyAIRunOutcome(input: AIRunOutcomeInput = {}): AIRunOutcomeDecision {
|
|
697
|
+
const now = isoNow(input.now);
|
|
698
|
+
const gates = Array.isArray(input.gates) ? [...input.gates] : [];
|
|
699
|
+
const warnings: string[] = [];
|
|
700
|
+
const qa = normalizeQaRun(input.qa);
|
|
701
|
+
if (qa) {
|
|
702
|
+
for (const gate of qa.gateResults) {
|
|
703
|
+
addGateOnce(gates, gate);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (input.manualHandoff === true) {
|
|
708
|
+
return {
|
|
709
|
+
outcome: 'manual_handoff',
|
|
710
|
+
reason: 'Run requires manual handoff.',
|
|
711
|
+
nextAction: 'Ask a human operator to resolve the blocked run.',
|
|
712
|
+
gates,
|
|
713
|
+
warnings,
|
|
714
|
+
recordedAt: now
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
if (input.stopped === true || /stop|stopped|cancel|cancelled|paused/i.test(`${input.status || ''} ${input.phase || ''}`)) {
|
|
718
|
+
return {
|
|
719
|
+
outcome: 'stopped',
|
|
720
|
+
reason: 'Run was stopped before accepted evidence was recorded.',
|
|
721
|
+
nextAction: 'Resume or restart only if the request is still active.',
|
|
722
|
+
gates,
|
|
723
|
+
warnings,
|
|
724
|
+
recordedAt: now
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
if (input.rejected === true) {
|
|
728
|
+
return {
|
|
729
|
+
outcome: 'rejected',
|
|
730
|
+
reason: 'Run was explicitly rejected.',
|
|
731
|
+
nextAction: 'Start a repair run from the failing evidence.',
|
|
732
|
+
gates,
|
|
733
|
+
warnings,
|
|
734
|
+
recordedAt: now
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (qa?.outcome === 'infra_failed') {
|
|
739
|
+
return {
|
|
740
|
+
outcome: 'qa_infra_failed',
|
|
741
|
+
reason: 'QA infrastructure failed before product validation.',
|
|
742
|
+
nextAction: 'Repair QA harness dependencies, ports, browser, Mongo, or startup before another model repair loop.',
|
|
743
|
+
gates,
|
|
744
|
+
warnings,
|
|
745
|
+
recordedAt: now
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
if (qa?.outcome === 'compile_failed') {
|
|
749
|
+
return {
|
|
750
|
+
outcome: 'build_failed',
|
|
751
|
+
reason: 'Compile/build evidence failed or was stale.',
|
|
752
|
+
nextAction: 'Repair compile/build first, then rerun QA from the same failed step.',
|
|
753
|
+
gates,
|
|
754
|
+
warnings,
|
|
755
|
+
recordedAt: now
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
if (qa?.outcome === 'route_failed') {
|
|
759
|
+
return {
|
|
760
|
+
outcome: 'qa_incomplete',
|
|
761
|
+
reason: 'Browser route probe failed before business proof.',
|
|
762
|
+
nextAction: 'Repair route/auth/startup issue and rerun the same browser route probe.',
|
|
763
|
+
gates,
|
|
764
|
+
warnings,
|
|
765
|
+
recordedAt: now
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
if (qa?.outcome === 'route_only_pass' || qa?.outcome === 'incomplete') {
|
|
769
|
+
return {
|
|
770
|
+
outcome: input.scorecardPassed === true ? 'false_pass' : 'qa_incomplete',
|
|
771
|
+
reason: input.scorecardPassed === true
|
|
772
|
+
? 'Scorecard or workflow status passed without issue-specific business assertion proof.'
|
|
773
|
+
: 'QA has not recorded issue-specific business assertion proof.',
|
|
774
|
+
nextAction: 'Add before/action/after workflow proof with screenshot/data assertions before acceptance.',
|
|
775
|
+
gates,
|
|
776
|
+
warnings,
|
|
777
|
+
recordedAt: now
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
if (qa?.outcome === 'business_assertion_failed') {
|
|
781
|
+
return {
|
|
782
|
+
outcome: input.terminal === true ? 'rejected' : 'qa_incomplete',
|
|
783
|
+
reason: 'Issue-specific business assertion failed.',
|
|
784
|
+
nextAction: 'Repair the product/data defect and rerun the failing assertion.',
|
|
785
|
+
gates,
|
|
786
|
+
warnings,
|
|
787
|
+
recordedAt: now
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
const hasBusinessPass = qa?.outcome === 'business_assertion_passed';
|
|
792
|
+
const scorecardPassed = input.scorecardPassed === true || statusLooksPassed(input.scorecardStatus);
|
|
793
|
+
const releaseBlockers: string[] = [];
|
|
794
|
+
if (statusLooksFailed(input.deployStatus)) {
|
|
795
|
+
releaseBlockers.push(`deploy=${cleanText(input.deployStatus, 120)}`);
|
|
796
|
+
}
|
|
797
|
+
if (statusLooksFailed(input.publishStatus)) {
|
|
798
|
+
releaseBlockers.push(`publish=${cleanText(input.publishStatus, 120)}`);
|
|
799
|
+
}
|
|
800
|
+
if (statusLooksFailed(input.sampleDataStatus)) {
|
|
801
|
+
releaseBlockers.push(`sample_data=${cleanText(input.sampleDataStatus, 120)}`);
|
|
802
|
+
}
|
|
803
|
+
if (releaseBlockers.length && (scorecardPassed || hasBusinessPass)) {
|
|
804
|
+
addGateOnce(gates, makeGate(
|
|
805
|
+
'release',
|
|
806
|
+
'Release/deploy',
|
|
807
|
+
'fail',
|
|
808
|
+
`Final acceptance is blocked after QA/scorecard because release gates failed: ${releaseBlockers.join(', ')}.`,
|
|
809
|
+
[],
|
|
810
|
+
now
|
|
811
|
+
));
|
|
812
|
+
return {
|
|
813
|
+
outcome: 'release_blocked',
|
|
814
|
+
reason: `Release gates failed after QA/scorecard: ${releaseBlockers.join(', ')}.`,
|
|
815
|
+
nextAction: 'Repair deploy/publish/sample-data coverage before marking the run accepted.',
|
|
816
|
+
gates,
|
|
817
|
+
warnings,
|
|
818
|
+
recordedAt: now
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (scorecardPassed && !hasBusinessPass) {
|
|
823
|
+
warnings.push('scorecard_pass_without_business_assertion');
|
|
824
|
+
addGateOnce(gates, makeGate(
|
|
825
|
+
'business_assertion_required',
|
|
826
|
+
'Business assertion',
|
|
827
|
+
'blocked',
|
|
828
|
+
'Scorecard passed, but no issue-specific business assertion proof was recorded.',
|
|
829
|
+
[],
|
|
830
|
+
now
|
|
831
|
+
));
|
|
832
|
+
return {
|
|
833
|
+
outcome: 'false_pass',
|
|
834
|
+
reason: 'Scorecard-only proof is not acceptance.',
|
|
835
|
+
nextAction: 'Record issue-specific workflow/data proof, then reclassify the run.',
|
|
836
|
+
gates,
|
|
837
|
+
warnings,
|
|
838
|
+
recordedAt: now
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const statusPhase = `${input.status || ''} ${input.phase || ''}`;
|
|
843
|
+
if ((input.explicitAccepted === true || statusLooksPassed(statusPhase) || scorecardPassed) && hasBusinessPass) {
|
|
844
|
+
return {
|
|
845
|
+
outcome: 'accepted',
|
|
846
|
+
reason: 'Run has terminal success signal and issue-specific business assertion proof.',
|
|
847
|
+
nextAction: 'No repair action required.',
|
|
848
|
+
gates,
|
|
849
|
+
warnings,
|
|
850
|
+
recordedAt: now
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (statusLooksFailed(statusPhase)) {
|
|
855
|
+
return {
|
|
856
|
+
outcome: 'rejected',
|
|
857
|
+
reason: 'Run ended with a failure status and no accepted proof.',
|
|
858
|
+
nextAction: 'Classify the failing gate and rerun the smallest repair step.',
|
|
859
|
+
gates,
|
|
860
|
+
warnings,
|
|
861
|
+
recordedAt: now
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
return {
|
|
866
|
+
outcome: 'unknown',
|
|
867
|
+
reason: 'Run does not have enough normalized evidence for a terminal label.',
|
|
868
|
+
nextAction: 'Ingest QA, deploy, assistant, usage, and commit evidence before using this run for training.',
|
|
869
|
+
gates,
|
|
870
|
+
warnings,
|
|
871
|
+
recordedAt: now
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export function buildAIRun(input: Omit<AIRun, 'outcome' | 'gates'> & {
|
|
876
|
+
outcome?: AIRunOutcomeLabel;
|
|
877
|
+
gates?: AIRunGateResult[];
|
|
878
|
+
scorecardPassed?: boolean;
|
|
879
|
+
deployStatus?: string;
|
|
880
|
+
publishStatus?: string;
|
|
881
|
+
sampleDataStatus?: string;
|
|
882
|
+
manualHandoff?: boolean;
|
|
883
|
+
stopped?: boolean;
|
|
884
|
+
rejected?: boolean;
|
|
885
|
+
explicitAccepted?: boolean;
|
|
886
|
+
terminal?: boolean;
|
|
887
|
+
now?: Date | string;
|
|
888
|
+
}): AIRun {
|
|
889
|
+
const decision = input.outcome
|
|
890
|
+
? {
|
|
891
|
+
outcome: input.outcome,
|
|
892
|
+
gates: input.gates || [],
|
|
893
|
+
warnings: input.warnings || [],
|
|
894
|
+
nextAction: input.nextAction || '',
|
|
895
|
+
reason: '',
|
|
896
|
+
recordedAt: isoNow(input.now)
|
|
897
|
+
}
|
|
898
|
+
: classifyAIRunOutcome({
|
|
899
|
+
source: input.source,
|
|
900
|
+
status: input.status,
|
|
901
|
+
phase: input.phase,
|
|
902
|
+
qa: input.qa,
|
|
903
|
+
gates: input.gates,
|
|
904
|
+
scorecardPassed: input.scorecardPassed,
|
|
905
|
+
deployStatus: input.deployStatus,
|
|
906
|
+
publishStatus: input.publishStatus,
|
|
907
|
+
sampleDataStatus: input.sampleDataStatus,
|
|
908
|
+
manualHandoff: input.manualHandoff,
|
|
909
|
+
stopped: input.stopped,
|
|
910
|
+
rejected: input.rejected,
|
|
911
|
+
explicitAccepted: input.explicitAccepted,
|
|
912
|
+
terminal: input.terminal,
|
|
913
|
+
now: input.now
|
|
914
|
+
});
|
|
915
|
+
return {
|
|
916
|
+
id: input.id,
|
|
917
|
+
source: input.source || 'unknown',
|
|
918
|
+
sourceIds: input.sourceIds || {},
|
|
919
|
+
title: input.title,
|
|
920
|
+
status: input.status,
|
|
921
|
+
phase: input.phase,
|
|
922
|
+
startedAt: input.startedAt,
|
|
923
|
+
completedAt: input.completedAt,
|
|
924
|
+
outcome: decision.outcome,
|
|
925
|
+
events: Array.isArray(input.events) ? input.events : [],
|
|
926
|
+
gates: decision.gates,
|
|
927
|
+
qa: normalizeQaRun(input.qa),
|
|
928
|
+
cost: input.cost,
|
|
929
|
+
nextAction: decision.nextAction,
|
|
930
|
+
warnings: decision.warnings,
|
|
931
|
+
metadata: input.metadata
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
export function buildAIRunCost(entries: OpenAIUsageCostEntry[] = []): AIRunCost {
|
|
936
|
+
const cost: AIRunCost = {
|
|
937
|
+
inputTokens: 0,
|
|
938
|
+
cachedInputTokens: 0,
|
|
939
|
+
outputTokens: 0,
|
|
940
|
+
totalTokens: 0,
|
|
941
|
+
estimatedUsd: 0,
|
|
942
|
+
models: [],
|
|
943
|
+
categories: {},
|
|
944
|
+
sources: {},
|
|
945
|
+
surfaces: {},
|
|
946
|
+
manualEstimatedUsd: 0,
|
|
947
|
+
untrackedEstimatedUsd: 0,
|
|
948
|
+
untrackedWarnings: []
|
|
949
|
+
};
|
|
950
|
+
for (const entry of normalizeOpenAIUsageRowsForCosting(entries)) {
|
|
951
|
+
const category = cleanText(entry.category, 120) || 'unknown';
|
|
952
|
+
const source = cleanText(entry.usage_source ?? entry.usageSource, 80) || 'unknown';
|
|
953
|
+
const surface = cleanText(entry.usage_surface ?? entry.usageSurface, 80) || 'unknown';
|
|
954
|
+
const isManual = entry.is_manual === true || entry.isManual === true || source === 'manual_codex';
|
|
955
|
+
const isUntracked = entry.is_untracked === true || entry.isUntracked === true;
|
|
956
|
+
const untrackedReason = cleanText(entry.untracked_reason ?? entry.untrackedReason, 500);
|
|
957
|
+
const model = cleanText(entry.model, 120);
|
|
958
|
+
const inputTokens = Number(entry.input_tokens ?? entry.inputTokens ?? 0) || 0;
|
|
959
|
+
const cachedInputTokens = Number(entry.cached_input_tokens ?? entry.cachedInputTokens ?? 0) || 0;
|
|
960
|
+
const outputTokens = Number(entry.output_tokens ?? entry.outputTokens ?? 0) || 0;
|
|
961
|
+
const totalTokens = Number(entry.total_tokens ?? entry.totalTokens ?? (inputTokens + outputTokens)) || 0;
|
|
962
|
+
const estimatedUsd = Number(entry.cost_estimate ?? entry.estimatedUsd ?? 0) || 0;
|
|
963
|
+
cost.inputTokens += inputTokens;
|
|
964
|
+
cost.cachedInputTokens += cachedInputTokens;
|
|
965
|
+
cost.outputTokens += outputTokens;
|
|
966
|
+
cost.totalTokens += totalTokens;
|
|
967
|
+
cost.estimatedUsd += estimatedUsd;
|
|
968
|
+
if (isManual) {
|
|
969
|
+
cost.manualEstimatedUsd = Number(cost.manualEstimatedUsd || 0) + estimatedUsd;
|
|
970
|
+
}
|
|
971
|
+
if (isUntracked) {
|
|
972
|
+
cost.untrackedEstimatedUsd = Number(cost.untrackedEstimatedUsd || 0) + estimatedUsd;
|
|
973
|
+
const warning = untrackedReason || `${source} usage is an estimate outside managed runner telemetry.`;
|
|
974
|
+
if (warning && !cost.untrackedWarnings?.includes(warning)) {
|
|
975
|
+
cost.untrackedWarnings?.push(warning);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
if (model && !cost.models.includes(model)) {
|
|
979
|
+
cost.models.push(model);
|
|
980
|
+
}
|
|
981
|
+
if (!cost.categories[category]) {
|
|
982
|
+
cost.categories[category] = {
|
|
983
|
+
inputTokens: 0,
|
|
984
|
+
cachedInputTokens: 0,
|
|
985
|
+
outputTokens: 0,
|
|
986
|
+
totalTokens: 0,
|
|
987
|
+
estimatedUsd: 0,
|
|
988
|
+
count: 0
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
cost.categories[category].inputTokens += inputTokens;
|
|
992
|
+
cost.categories[category].cachedInputTokens += cachedInputTokens;
|
|
993
|
+
cost.categories[category].outputTokens += outputTokens;
|
|
994
|
+
cost.categories[category].totalTokens += totalTokens;
|
|
995
|
+
cost.categories[category].estimatedUsd += estimatedUsd;
|
|
996
|
+
cost.categories[category].count += 1;
|
|
997
|
+
if (!cost.sources?.[source]) {
|
|
998
|
+
cost.sources![source] = {
|
|
999
|
+
inputTokens: 0,
|
|
1000
|
+
cachedInputTokens: 0,
|
|
1001
|
+
outputTokens: 0,
|
|
1002
|
+
totalTokens: 0,
|
|
1003
|
+
estimatedUsd: 0,
|
|
1004
|
+
count: 0,
|
|
1005
|
+
manualCount: 0,
|
|
1006
|
+
untrackedCount: 0
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
cost.sources[source].inputTokens += inputTokens;
|
|
1010
|
+
cost.sources[source].cachedInputTokens += cachedInputTokens;
|
|
1011
|
+
cost.sources[source].outputTokens += outputTokens;
|
|
1012
|
+
cost.sources[source].totalTokens += totalTokens;
|
|
1013
|
+
cost.sources[source].estimatedUsd += estimatedUsd;
|
|
1014
|
+
cost.sources[source].count += 1;
|
|
1015
|
+
if (isManual) {
|
|
1016
|
+
cost.sources[source].manualCount += 1;
|
|
1017
|
+
}
|
|
1018
|
+
if (isUntracked) {
|
|
1019
|
+
cost.sources[source].untrackedCount += 1;
|
|
1020
|
+
}
|
|
1021
|
+
if (!cost.surfaces?.[surface]) {
|
|
1022
|
+
cost.surfaces![surface] = {
|
|
1023
|
+
totalTokens: 0,
|
|
1024
|
+
estimatedUsd: 0,
|
|
1025
|
+
count: 0
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
cost.surfaces[surface].totalTokens += totalTokens;
|
|
1029
|
+
cost.surfaces[surface].estimatedUsd += estimatedUsd;
|
|
1030
|
+
cost.surfaces[surface].count += 1;
|
|
1031
|
+
}
|
|
1032
|
+
cost.estimatedUsd = Number(cost.estimatedUsd.toFixed(6));
|
|
1033
|
+
cost.manualEstimatedUsd = Number(Number(cost.manualEstimatedUsd || 0).toFixed(6));
|
|
1034
|
+
cost.untrackedEstimatedUsd = Number(Number(cost.untrackedEstimatedUsd || 0).toFixed(6));
|
|
1035
|
+
for (const category of Object.keys(cost.categories)) {
|
|
1036
|
+
cost.categories[category].estimatedUsd = Number(cost.categories[category].estimatedUsd.toFixed(6));
|
|
1037
|
+
}
|
|
1038
|
+
for (const source of Object.keys(cost.sources || {})) {
|
|
1039
|
+
cost.sources![source].estimatedUsd = Number(cost.sources![source].estimatedUsd.toFixed(6));
|
|
1040
|
+
}
|
|
1041
|
+
for (const surface of Object.keys(cost.surfaces || {})) {
|
|
1042
|
+
cost.surfaces![surface].estimatedUsd = Number(cost.surfaces![surface].estimatedUsd.toFixed(6));
|
|
1043
|
+
}
|
|
1044
|
+
return cost;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
export function redactAIRunTrainingExample(example: AIRunTrainingExample): AIRunTrainingExample {
|
|
1048
|
+
const redact = (value: string): string => cleanText(value, 5000)
|
|
1049
|
+
.replace(/mongodb(?:\+srv)?:\/\/[^\s"'<>]+/ig, '[redacted-mongo-url]')
|
|
1050
|
+
.replace(/\b(?:sk|ghp|xoxb|AKIA)[A-Za-z0-9_\-]{12,}\b/g, '[redacted-secret]')
|
|
1051
|
+
.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z]{2,}\b/ig, '[redacted-email]');
|
|
1052
|
+
return {
|
|
1053
|
+
...example,
|
|
1054
|
+
inputSummary: redact(example.inputSummary),
|
|
1055
|
+
actionSummary: redact(example.actionSummary),
|
|
1056
|
+
evidence: cleanList(example.evidence, 80, 5000).map(redact)
|
|
1057
|
+
};
|
|
1058
|
+
}
|