@zaip-ai/cli 1.0.7 → 1.0.8
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/README.md +6 -4
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +15 -5
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/adapters.test.js +1 -1
- package/dist/services/agent-adapters.d.ts +9 -0
- package/dist/services/agent-adapters.d.ts.map +1 -1
- package/dist/services/agent-adapters.js +38 -3
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-adapters.test.js +8 -1
- package/dist/services/agent-adapters.test.js.map +1 -1
- package/dist/services/codex-config-template.d.ts +2 -1
- package/dist/services/codex-config-template.d.ts.map +1 -1
- package/dist/services/codex-config-template.js +13 -2
- package/dist/services/codex-config-template.js.map +1 -1
- package/dist/services/codex-rules.d.ts +1 -1
- package/dist/services/codex-rules.d.ts.map +1 -1
- package/dist/services/codex-rules.js +31 -7
- package/dist/services/codex-rules.js.map +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts.map +1 -1
- package/dist/services/codex-subagent-hook-template.js +4 -1
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +3 -1
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/global-codex-config.d.ts +6 -3
- package/dist/services/global-codex-config.d.ts.map +1 -1
- package/dist/services/global-codex-config.js +82 -13
- package/dist/services/global-codex-config.js.map +1 -1
- package/dist/services/global-codex-config.test.js +57 -10
- package/dist/services/global-codex-config.test.js.map +1 -1
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +15 -2
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/logger.js +1 -1
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +3 -3
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/runtime-template.test.js +21 -5
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/template-manifest.d.ts.map +1 -1
- package/dist/services/template-manifest.js +2 -0
- package/dist/services/template-manifest.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/config/agents/catalog.yaml +310 -10
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +5 -5
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +8 -8
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +5 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +30 -0
- package/templates/.agents/config/project.yaml +1 -1
- package/templates/.agents/dashboard/.zaip-managed.json +659 -163
- package/templates/.agents/dashboard/DATA-DICTIONARY.md +2227 -0
- package/templates/.agents/dashboard/README.md +48 -97
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-Z60df2r-.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cv-JcoxP.js → DashboardHelpDialog-Cs6dzDmW.js} +294 -109
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-Coc6pA-1.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-QE1k9yZB.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-_Pf5DA_A.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BVlz3DLZ.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-CaKwQP43.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-BZ5WdaMN.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Cf9ctPVt.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-C98LGC-Q.js → dashboard-localization-CLJ0lT9v.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/icons-vendor-DFBuc_qp.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8A4DcNXM.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DK_enB5Z.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/react-vendor-CCQOHdVI.js +9 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/rolldown-runtime-D9-fqq9M.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-DFY7ZDlu.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-pC2_0J8x.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +9 -2
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/App.tsx +952 -595
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingBoundary.tsx +48 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingPanels.tsx +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +247 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppRequestGuards.tsx +95 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppSetupRoutes.tsx +87 -0
- package/templates/.agents/dashboard/apps/frontend/src/CostCalculationGuidePage.tsx +641 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +159 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardCapabilityNav.tsx +13 -13
- package/templates/.agents/dashboard/apps/frontend/src/DashboardGlobalSettings.tsx +56 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +257 -313
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +149 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +35 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +111 -12
- package/templates/.agents/dashboard/apps/frontend/src/app-preferences.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/app-session-token.ts +20 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.css +267 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.test.ts +69 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +70 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +111 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +432 -13
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/main.tsx +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.test.ts +55 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.ts +36 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.test.ts +126 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.ts +181 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-contract.test.ts +138 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +105 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.test.ts +6 -3
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.ts +9 -5
- package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +24 -0
- package/templates/.agents/dashboard/apps/frontend/src/period-transition-overlay.css +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +121 -62
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +471 -2
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +84 -17
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +196 -39
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-notice.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-cost-adapters.ts +26 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles.css +14 -2
- package/templates/.agents/dashboard/apps/frontend/src/traceability-workspace.css +38 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +187 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +190 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +121 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-operations-pages.ts +398 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +141 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-idle-cost-prefetch.ts +45 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +46 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.ts +37 -0
- package/templates/.agents/dashboard/apps/frontend/vite.config.ts +55 -5
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +47 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/duration-estimate.ts +13 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +64 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +275 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.test.ts +100 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.tsx +131 -40
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +137 -19
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.test.ts +2 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.tsx +13 -10
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +303 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +226 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +479 -402
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostSummary.tsx +5 -13
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +312 -72
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +373 -321
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +25 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-copy.ts +0 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-helpers.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-responsive.css +6 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-row-filters.ts +123 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-summary.ts +8 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-views.ts +32 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor.css +52 -14
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-presentation.ts +121 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/index.ts +3 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.test.ts +68 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +32 -5
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +108 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.test.ts +12 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +106 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.ts +5 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-pricing-fallback.test.ts +53 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.basics.test.ts +34 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +168 -137
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +188 -29
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +956 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +775 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-terminal-day.test.ts +95 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/index.ts +1 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/refactor-map-xr9l.json +61 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.test.ts +41 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.ts +55 -11
- package/templates/.agents/dashboard/modules/operations/package.json +2 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +182 -0
- package/templates/.agents/dashboard/modules/operations/src/duration-population.test.ts +63 -1
- package/templates/.agents/dashboard/modules/operations/src/duration-population.ts +60 -5
- package/templates/.agents/dashboard/modules/operations/src/react/EntityDetailsDialog.tsx +14 -3
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.test.ts +44 -1
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +325 -18
- package/templates/.agents/dashboard/modules/operations/src/react/MacroPlanningDialog.tsx +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.test.ts +9 -5
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.tsx +2 -2
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsMainContent.tsx +168 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +95 -6
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +365 -14
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +532 -131
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +314 -358
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageNavigation.tsx +68 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +169 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PeriodSummaryTable.tsx +51 -8
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.test.tsx +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.tsx +62 -6
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.test.ts +55 -0
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.tsx +27 -19
- package/templates/.agents/dashboard/modules/operations/src/react/TaskDetailsDialog.tsx +99 -42
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.priority.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.tsx +255 -34
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +163 -8
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +101 -68
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.test.ts +72 -1
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.ts +78 -16
- package/templates/.agents/dashboard/modules/operations/src/react/execution-metrics.ts +6 -4
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +50 -1
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +143 -9
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +29 -4
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog-content.css +49 -0
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog.css +93 -50
- package/templates/.agents/dashboard/modules/operations/src/react/manual-work-priority.test.ts +82 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.test.ts +29 -2
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.ts +22 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.test.ts +77 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.ts +65 -5
- package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-global-filters.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +149 -12
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.status-cards.test.ts +27 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +136 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.test.ts +160 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.ts +47 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-query.ts +10 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-responsive.css +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-labels.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +24 -7
- package/templates/.agents/dashboard/modules/operations/src/react/operations.css +42 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.ts +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.test.ts +165 -6
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.ts +148 -6
- package/templates/.agents/dashboard/modules/operations/src/react/popup-localization.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css +132 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css.test.ts +13 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.header.test.ts +16 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-infinite-column.ts +11 -5
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +5 -3
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +4 -83
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.test.ts +291 -15
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.ts +182 -472
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.test.ts +40 -0
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.ts +19 -6
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-run-projection.ts +31 -6
- package/templates/.agents/dashboard/modules/operations/src/server/daily-duration-projection.ts +220 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-duration-projection.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.test.ts +27 -2
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.ts +22 -13
- package/templates/.agents/dashboard/modules/operations/src/server/filter.test.ts +3 -3
- package/templates/.agents/dashboard/modules/operations/src/server/filter.ts +7 -2
- package/templates/.agents/dashboard/modules/operations/src/server/index.ts +3 -0
- package/templates/.agents/dashboard/modules/operations/src/server/macro.ts +3 -12
- package/templates/.agents/dashboard/modules/operations/src/server/manifest-usage.ts +65 -0
- package/templates/.agents/dashboard/modules/operations/src/server/operations-projection-aggregates.ts +297 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-daily-operations-projection.ts +324 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.test.ts +505 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.ts +609 -0
- package/templates/.agents/dashboard/modules/operations/src/server/runs.ts +18 -19
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +76 -0
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/modules/traceability/src/server/build-task-trace.ts +3 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/src/index.ts +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/src/index.ts +1 -0
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +1756 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +1608 -0
- package/templates/.agents/dashboard/packages/local-runtime/package.json +8 -3
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-dashboard.mjs +12 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +83 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +28 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +262 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-unix-launchers.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +105 -0
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +1643 -107
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-adapter-sync.ts +30 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.test.ts +3 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.ts +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/manifest-runs.ts +72 -33
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +335 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +392 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/runtime.mjs +5 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +71 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +179 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-cross-layer-parity.test.ts +245 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models-route.ts +64 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.test.ts +204 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.ts +194 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +163 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +354 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.test.ts +74 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +113 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-overview.test.ts +68 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-period.ts +47 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +483 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-settings.test.ts +5 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +163 -84
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +145 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +551 -266
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +1145 -308
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.test.ts +53 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.ts +708 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +2232 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +6151 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/work-priority-contract.test.ts +33 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +210 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +437 -190
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +299 -24
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/packages/windows-launcher/LauncherVerificationBehaviorTests.cs +206 -0
- package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +95 -8
- package/templates/.agents/dashboard/packages/windows-launcher/build-dashboard-launcher.ps1 +2 -2
- package/templates/.agents/dashboard/packages/windows-launcher/run-launcher-verification-tests.ps1 +22 -0
- package/templates/.agents/dashboard/read-model.dbml +2201 -0
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +1 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +214 -41
- package/templates/.agents/dashboard/work-priority.json +34 -0
- package/templates/.agents/dashboard/zaip-dashboard-linux.sh +45 -0
- package/templates/.agents/dashboard/zaip-dashboard-mac.command +3 -0
- package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
- package/templates/.agents/design/.zaip-managed.json +3 -3
- package/templates/.agents/design/apps/catalog/package.json +1 -1
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.md +1 -1
- package/templates/.agents/requirements/comparative-audit.md +1 -1
- package/templates/.agents/requirements/context-engine.md +1 -1
- package/templates/.agents/requirements/cost-observability.md +1 -1
- package/templates/.agents/requirements/dashboard-launch.md +24 -0
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +1 -1
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +4 -3
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +9 -6
- package/templates/.agents/requirements/software-architecture.md +1 -1
- package/templates/.agents/requirements/strategic-improvements.md +1 -1
- package/templates/.agents/requirements/work-lifecycle.md +9 -3
- package/templates/.agents/requirements/zaip-strategic-95.md +4 -4
- package/templates/.agents/rules/autonomy-decision.md +15 -0
- package/templates/.agents/rules/core.md +1 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +1 -1
- package/templates/.agents/rules/specialist-routing.md +19 -0
- package/templates/.agents/rules/workflow.md +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +114 -64
- package/templates/.agents/runtime/checksums.sha256 +6 -4
- package/templates/.agents/runtime/manifest.json +3 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -0
- package/templates/.agents/runtime/provenance.json +11 -0
- package/templates/.agents/runtime/sbom.cdx.json +1929 -39
- package/templates/.agents/skills/zaip-aios/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-standards.md +30 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/SKILL.md +25 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.mjs +71 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.test.mjs +60 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/scheduled-ready-queue-contract.test.mjs +111 -0
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +2 -2
- package/templates/.agents/skills/zaip-skill-frontend-launcher/references/launcher-contract.md +3 -1
- package/templates/.agents/skills/zaip-skill-general-operations/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-general-operations/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +9 -7
- package/templates/.agents/skills/zaip-skill-github-deploy/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +11 -38
- package/templates/.agents/skills/zaip-skill-governance-compliance/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-governance-compliance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/references/growth-revops-framework.md +25 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/SKILL.md +17 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +76 -27
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +128 -24
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +122 -4
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +66 -19
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +193 -7
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/references/sales-process-framework.md +77 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +5 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +96 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/scripts/ensure-node.mjs +18 -0
- package/templates/.agents/zaip-aios/INDEX.md +1 -0
- package/templates/.agents/zaip-aios/README.md +37 -8
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/09-agentes-e-squads.md +43 -6
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +21 -7
- package/templates/.agents/zaip-aios/guides/17-como-o-custo-e-calculado.md +32 -0
- package/templates/template-manifest.json +945 -214
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-CLYIi7Vo.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-DTDNVQGX.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-CzEggcRb.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-05YKn6Z4.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-YO3yqtgV.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8AzCnl3a.js +0 -77
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DdBYQ_8D.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/src/AgentCatalogSettingsPage.tsx +0 -617
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings-page.css +0 -660
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings.test.ts +0 -249
- package/templates/.agents/dashboard/dashboard.config.json +0 -4
- package/templates/.agents/dashboard/zaip-dashboard.exe +0 -0
|
@@ -3,47 +3,59 @@ import {
|
|
|
3
3
|
type RunProjection,
|
|
4
4
|
saoPauloPeriodKey,
|
|
5
5
|
} from "@zaip-ai/dashboard-operations/contracts";
|
|
6
|
-
import {
|
|
7
|
-
EntityDetailsDialog,
|
|
8
|
-
ExcelExportAction,
|
|
9
|
-
ExecutionTable,
|
|
10
|
-
} from "@zaip-ai/dashboard-operations/react";
|
|
6
|
+
import { EntityDetailsDialog, ExcelExportAction } from "@zaip-ai/dashboard-operations/react";
|
|
11
7
|
import { DashboardHeader } from "@zaip-ai/dashboard-ui";
|
|
12
|
-
import { type ReactNode, useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
|
|
13
9
|
import { includeConfiguredAgentGroups } from "../agent-groups.js";
|
|
14
|
-
import {
|
|
15
|
-
aggregateDurationCoverage,
|
|
16
|
-
type CostGroupRow,
|
|
17
|
-
type CostMonitorProjection,
|
|
18
|
-
type CostRunRow,
|
|
19
|
-
sumKnown,
|
|
20
|
-
} from "../contracts.js";
|
|
10
|
+
import type { CostMonitorProjection } from "../contracts.js";
|
|
21
11
|
import { normalizeCostProvider } from "../provider.js";
|
|
22
12
|
import { aggregateTaskCostRows } from "../task-cost-groups.js";
|
|
23
|
-
import {
|
|
13
|
+
import { withTokenBackedCompactDuration } from "./CompactLifecycleCostTable.js";
|
|
24
14
|
import {
|
|
25
15
|
type CostFilterState,
|
|
26
16
|
CostFilters,
|
|
27
17
|
type CostPeriod,
|
|
18
|
+
costPeriodDateRange,
|
|
28
19
|
defaultCostPeriod,
|
|
29
20
|
emptyCostFilters,
|
|
21
|
+
loadCostMonitorDetail,
|
|
30
22
|
loadCostMonitorPeriod,
|
|
23
|
+
type loadCostMonitorRunPage,
|
|
31
24
|
useCostMonitorPeriod,
|
|
32
25
|
} from "./CostFilters.js";
|
|
26
|
+
import { CostMonitorContent } from "./CostMonitorContent.js";
|
|
33
27
|
import { ChevronDownIcon, ListFilterIcon, LocaleFlag, SettingsIcon } from "./CostMonitorIcons.js";
|
|
34
|
-
import { CostPeriodAverageCards } from "./CostPeriodAverageCards.js";
|
|
35
28
|
import { CostSummary } from "./CostSummary.js";
|
|
36
|
-
import {
|
|
37
|
-
|
|
29
|
+
import {
|
|
30
|
+
groupRows,
|
|
31
|
+
matches,
|
|
32
|
+
matchesGlobalFilters,
|
|
33
|
+
matchesPeriodEntity,
|
|
34
|
+
} from "./cost-monitor-row-filters.js";
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
groupRows,
|
|
38
|
+
matchesGlobalFilters,
|
|
39
|
+
matchesPeriodEntity,
|
|
40
|
+
} from "./cost-monitor-row-filters.js";
|
|
41
|
+
|
|
38
42
|
import {
|
|
39
43
|
type CostCurrency,
|
|
40
44
|
type CostLocale,
|
|
41
45
|
costCopy,
|
|
42
46
|
localeCurrency,
|
|
43
47
|
} from "./cost-monitor-copy.js";
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
48
|
+
import { findRunDetails, selectDimensionalCostRows } from "./cost-monitor-page-helpers.js";
|
|
49
|
+
import { summarizeCostRows } from "./cost-monitor-summary.js";
|
|
50
|
+
import { COST_VIEW_ORDER, type CostView, DEFAULT_COST_VIEW } from "./cost-monitor-views.js";
|
|
46
51
|
import { enrichPeriodCostGroups } from "./period-cost-groups.js";
|
|
52
|
+
import {
|
|
53
|
+
compactReadModelKind,
|
|
54
|
+
type LoadCompactCostPage,
|
|
55
|
+
useCompactCostPage,
|
|
56
|
+
} from "./use-compact-cost-page.js";
|
|
57
|
+
import { type LoadCostGroupPage, useCostGroupPage } from "./use-cost-group-page.js";
|
|
58
|
+
import { useCostRunPage } from "./use-cost-run-page.js";
|
|
47
59
|
import "./cost-monitor.css";
|
|
48
60
|
import "./cost-monitor-responsive.css";
|
|
49
61
|
import "./cost-run-origin.css";
|
|
@@ -51,43 +63,76 @@ import "./cost-monitor-embedded.css";
|
|
|
51
63
|
|
|
52
64
|
const zaipLogoUrl = new URL("../../../../../config/src/logo_novo_azul.png", import.meta.url).href;
|
|
53
65
|
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
type AgentCallKind = "all" | "run" | "subrun";
|
|
85
|
-
export function findRunDetails<T extends { id: string }>(
|
|
86
|
-
runs: readonly T[],
|
|
87
|
-
runId: string,
|
|
88
|
-
): T | null {
|
|
89
|
-
return runs.find((run) => run.id === runId) ?? null;
|
|
66
|
+
export {
|
|
67
|
+
findRunDetails,
|
|
68
|
+
isCurrentCostRunPageGeneration,
|
|
69
|
+
selectDimensionalCostRows,
|
|
70
|
+
} from "./cost-monitor-page-helpers.js";
|
|
71
|
+
export {
|
|
72
|
+
COST_VIEW_ORDER,
|
|
73
|
+
type CostView,
|
|
74
|
+
DEFAULT_COST_VIEW,
|
|
75
|
+
} from "./cost-monitor-views.js";
|
|
76
|
+
|
|
77
|
+
export type { LoadCompactCostPage } from "./use-compact-cost-page.js";
|
|
78
|
+
export type { LoadCostGroupPage } from "./use-cost-group-page.js";
|
|
79
|
+
export type LoadCostMonitorDetail = typeof loadCostMonitorDetail;
|
|
80
|
+
export type LoadCostRunPage = typeof loadCostMonitorRunPage;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The Cost period request filters Runs, while Operations is the global snapshot
|
|
84
|
+
* used for shared entity detail. Keep the Executions tab on that same active
|
|
85
|
+
* Run population instead of accidentally showing an unfiltered empty/stale
|
|
86
|
+
* Operations table.
|
|
87
|
+
*/
|
|
88
|
+
export function visibleExecutionRows<T extends { id: string }>(
|
|
89
|
+
executions: readonly T[],
|
|
90
|
+
rows: readonly Pick<CostMonitorProjection["runs"][number], "execution_id">[],
|
|
91
|
+
): T[] {
|
|
92
|
+
const visibleIds = new Set(
|
|
93
|
+
rows.flatMap((row) => (row.execution_id === null ? [] : [row.execution_id])),
|
|
94
|
+
);
|
|
95
|
+
return executions.filter((execution) => visibleIds.has(execution.id));
|
|
90
96
|
}
|
|
97
|
+
|
|
98
|
+
/** Only filters represented by the partial Runs endpoint may use page-only data. */
|
|
99
|
+
export function isServerCostRunPagingEligible(filters: CostFilterState, globalQuery = ""): boolean {
|
|
100
|
+
return (
|
|
101
|
+
(globalQuery === "" || filters.query === "") &&
|
|
102
|
+
filters.priority === "" &&
|
|
103
|
+
filters.risk === "" &&
|
|
104
|
+
filters.origin === "" &&
|
|
105
|
+
filters.workType === ""
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The embedded default view is backed by the App's all-time atomic snapshot.
|
|
111
|
+
* Keep the group pager on that same population until a period, global date, or
|
|
112
|
+
* local Cost filter explicitly narrows it.
|
|
113
|
+
*/
|
|
114
|
+
export function resolveCostGroupPageRange({
|
|
115
|
+
embedded,
|
|
116
|
+
globalDateRange,
|
|
117
|
+
hasLocalCostFilters,
|
|
118
|
+
period,
|
|
119
|
+
runPageRange,
|
|
120
|
+
}: {
|
|
121
|
+
embedded: boolean;
|
|
122
|
+
globalDateRange: { start: string; end: string } | undefined;
|
|
123
|
+
hasLocalCostFilters: boolean;
|
|
124
|
+
period: CostPeriod;
|
|
125
|
+
runPageRange: { from: string; to: string } | undefined;
|
|
126
|
+
}): { from: string; to: string } | undefined {
|
|
127
|
+
if (
|
|
128
|
+
embedded &&
|
|
129
|
+
globalDateRange === undefined &&
|
|
130
|
+
period === defaultCostPeriod &&
|
|
131
|
+
!hasLocalCostFilters
|
|
132
|
+
) return undefined;
|
|
133
|
+
return runPageRange;
|
|
134
|
+
}
|
|
135
|
+
|
|
91
136
|
export function CostMonitorPage({
|
|
92
137
|
capabilityNavigation,
|
|
93
138
|
data,
|
|
@@ -97,10 +142,15 @@ export function CostMonitorPage({
|
|
|
97
142
|
lastUpdatedAt,
|
|
98
143
|
locale,
|
|
99
144
|
loading,
|
|
145
|
+
onLoadingChange,
|
|
100
146
|
onLocaleChange,
|
|
101
147
|
onOpenTrace,
|
|
102
148
|
onActiveDataChange,
|
|
103
149
|
onRefresh,
|
|
150
|
+
loadDetail = loadCostMonitorDetail,
|
|
151
|
+
loadRunPage,
|
|
152
|
+
loadReadModelPage,
|
|
153
|
+
loadGroupPage,
|
|
104
154
|
loadPeriod = loadCostMonitorPeriod,
|
|
105
155
|
operations,
|
|
106
156
|
repositoryName,
|
|
@@ -119,18 +169,30 @@ export function CostMonitorPage({
|
|
|
119
169
|
lastUpdatedAt: string | null;
|
|
120
170
|
locale: CostLocale;
|
|
121
171
|
loading: boolean;
|
|
172
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
122
173
|
onLocaleChange: (locale: CostLocale) => void;
|
|
123
174
|
onOpenTrace: (taskId: string) => void;
|
|
124
175
|
onActiveDataChange?: (data: CostMonitorProjection) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Retained for host compatibility. Cost views must use bounded summary or
|
|
178
|
+
* page routes; activating a tab never requests the historical detail blob.
|
|
179
|
+
*/
|
|
180
|
+
onDetailDataRequest?: () => void;
|
|
125
181
|
onRefresh: () => void;
|
|
182
|
+
loadDetail?: LoadCostMonitorDetail;
|
|
183
|
+
loadRunPage?: LoadCostRunPage;
|
|
184
|
+
loadReadModelPage?: LoadCompactCostPage;
|
|
185
|
+
loadGroupPage?: LoadCostGroupPage;
|
|
126
186
|
loadPeriod?: typeof loadCostMonitorPeriod;
|
|
127
|
-
operations?: Pick<
|
|
187
|
+
operations?: Pick<
|
|
188
|
+
OperationsProjection,
|
|
189
|
+
"runs" | "specs" | "tasks" | "executions" | "evidences" | "validations" | "summary"
|
|
190
|
+
>;
|
|
128
191
|
repositoryName?: string;
|
|
129
192
|
currency?: CostCurrency;
|
|
130
193
|
onCurrencyChange?: (currency: CostCurrency) => void;
|
|
131
194
|
}) {
|
|
132
195
|
const [view, setView] = useState<CostView>(DEFAULT_COST_VIEW);
|
|
133
|
-
const [agentCallKind, setAgentCallKind] = useState<AgentCallKind>("all");
|
|
134
196
|
const [filters, setFilters] = useState<CostFilterState>(emptyCostFilters);
|
|
135
197
|
const [localCurrency, setLocalCurrency] = useState<CostCurrency>("BRL");
|
|
136
198
|
const currency = controlledCurrency ?? localCurrency;
|
|
@@ -143,6 +205,12 @@ export function CostMonitorPage({
|
|
|
143
205
|
const [localeOpen, setLocaleOpen] = useState(false);
|
|
144
206
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
145
207
|
const [selectedRun, setSelectedRun] = useState<RunProjection | null>(null);
|
|
208
|
+
const [detailData, setDetailData] = useState<CostMonitorProjection | null>(null);
|
|
209
|
+
const [detailLoading, setDetailLoading] = useState(false);
|
|
210
|
+
const [detailError, setDetailError] = useState<string | null>(null);
|
|
211
|
+
const [detailAttempt, setDetailAttempt] = useState(0);
|
|
212
|
+
const loadDetailRef = useRef(loadDetail);
|
|
213
|
+
loadDetailRef.current = loadDetail;
|
|
146
214
|
const text = costCopy[locale];
|
|
147
215
|
const { activeData, periodError, periodLoading } = useCostMonitorPeriod({
|
|
148
216
|
currency,
|
|
@@ -155,6 +223,78 @@ export function CostMonitorPage({
|
|
|
155
223
|
snapshotBacked: embedded,
|
|
156
224
|
});
|
|
157
225
|
const hasLocalCostFilters = Object.values(filters).some((value) => value !== "");
|
|
226
|
+
const runPageRange =
|
|
227
|
+
globalFilters?.dateRange === undefined
|
|
228
|
+
? costPeriodDateRange(period)
|
|
229
|
+
: { from: globalFilters.dateRange.start, to: globalFilters.dateRange.end };
|
|
230
|
+
const groupPageRange = resolveCostGroupPageRange({
|
|
231
|
+
embedded,
|
|
232
|
+
globalDateRange: globalFilters?.dateRange,
|
|
233
|
+
hasLocalCostFilters,
|
|
234
|
+
period,
|
|
235
|
+
runPageRange,
|
|
236
|
+
});
|
|
237
|
+
const costGroupViewName = (
|
|
238
|
+
candidate: CostView,
|
|
239
|
+
): "daily" | "monthly" | "annual" | "agents" | "models" | "providers" | null =>
|
|
240
|
+
candidate === "daily" ||
|
|
241
|
+
candidate === "monthly" ||
|
|
242
|
+
candidate === "annual" ||
|
|
243
|
+
candidate === "agents" ||
|
|
244
|
+
candidate === "models" ||
|
|
245
|
+
candidate === "providers"
|
|
246
|
+
? candidate
|
|
247
|
+
: null;
|
|
248
|
+
const groupView = costGroupViewName(view);
|
|
249
|
+
const groupPageState = useCostGroupPage({
|
|
250
|
+
view: groupView ?? "daily",
|
|
251
|
+
...(groupPageRange === undefined ? {} : { range: groupPageRange }),
|
|
252
|
+
globalQuery: globalFilters?.query ?? "",
|
|
253
|
+
filters,
|
|
254
|
+
...(groupView === null ? {} : { load: loadGroupPage }),
|
|
255
|
+
});
|
|
256
|
+
const {
|
|
257
|
+
compactPageOffset,
|
|
258
|
+
setCompactPageOffset,
|
|
259
|
+
compactPage,
|
|
260
|
+
compactPageLoading,
|
|
261
|
+
compactPageError,
|
|
262
|
+
retryCompactPage,
|
|
263
|
+
} = useCompactCostPage({
|
|
264
|
+
view,
|
|
265
|
+
load: loadReadModelPage,
|
|
266
|
+
range: runPageRange,
|
|
267
|
+
query: globalFilters?.query,
|
|
268
|
+
filters,
|
|
269
|
+
});
|
|
270
|
+
// Server pagination is safe only when every active Run filter is part of the
|
|
271
|
+
// endpoint contract. Unsupported local text/metadata filters retain the
|
|
272
|
+
// complete active snapshot so a page cannot omit matching Runs.
|
|
273
|
+
const serverPagingEligible = isServerCostRunPagingEligible(filters, globalFilters?.query ?? "");
|
|
274
|
+
const {
|
|
275
|
+
runPageOffset,
|
|
276
|
+
setRunPageOffset,
|
|
277
|
+
runPageData,
|
|
278
|
+
runPageLoading,
|
|
279
|
+
runPageError,
|
|
280
|
+
retryRunPage,
|
|
281
|
+
} = useCostRunPage({
|
|
282
|
+
view,
|
|
283
|
+
eligible: view === "agentCalls" && serverPagingEligible,
|
|
284
|
+
currency,
|
|
285
|
+
filters,
|
|
286
|
+
globalQuery: globalFilters?.query ?? "",
|
|
287
|
+
range: runPageRange,
|
|
288
|
+
refresh: lastUpdatedAt,
|
|
289
|
+
load: loadRunPage,
|
|
290
|
+
});
|
|
291
|
+
useEffect(
|
|
292
|
+
() =>
|
|
293
|
+
onLoadingChange?.(
|
|
294
|
+
loading || periodLoading || runPageLoading || groupPageState.loading || compactPageLoading || detailLoading,
|
|
295
|
+
),
|
|
296
|
+
[compactPageLoading, detailLoading, groupPageState.loading, loading, onLoadingChange, periodLoading, runPageLoading],
|
|
297
|
+
);
|
|
158
298
|
useEffect(() => {
|
|
159
299
|
if (!hasLocalCostFilters) onActiveDataChange?.(activeData);
|
|
160
300
|
}, [activeData, hasLocalCostFilters, onActiveDataChange]);
|
|
@@ -169,6 +309,59 @@ export function CostMonitorPage({
|
|
|
169
309
|
.filter((row) => matches(row, filters) && matchesGlobalFilters(row, globalFilters))
|
|
170
310
|
.sort((left, right) => right.started_at.localeCompare(left.started_at));
|
|
171
311
|
}, [activeData.runs, filters, globalFilters]);
|
|
312
|
+
// Summary carries exact compact group aggregates. Full Run detail is only
|
|
313
|
+
// for an explicit trace, never a prerequisite for opening a Cost tab.
|
|
314
|
+
const needsDimensionalDetail = false;
|
|
315
|
+
const runPageFrom = runPageRange?.from;
|
|
316
|
+
const runPageTo = runPageRange?.to;
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
void detailAttempt;
|
|
319
|
+
if (!needsDimensionalDetail) {
|
|
320
|
+
setDetailData(null);
|
|
321
|
+
setDetailLoading(false);
|
|
322
|
+
setDetailError(null);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const controller = new AbortController();
|
|
326
|
+
setDetailData(null);
|
|
327
|
+
setDetailLoading(true);
|
|
328
|
+
setDetailError(null);
|
|
329
|
+
void loadDetailRef
|
|
330
|
+
.current({
|
|
331
|
+
currency,
|
|
332
|
+
filters,
|
|
333
|
+
...(runPageFrom === undefined || runPageTo === undefined
|
|
334
|
+
? {}
|
|
335
|
+
: { from: runPageFrom, to: runPageTo }),
|
|
336
|
+
refresh: lastUpdatedAt,
|
|
337
|
+
signal: controller.signal,
|
|
338
|
+
})
|
|
339
|
+
.then(setDetailData)
|
|
340
|
+
.catch((cause: unknown) => {
|
|
341
|
+
if (!controller.signal.aborted)
|
|
342
|
+
setDetailError(cause instanceof Error ? cause.message : String(cause));
|
|
343
|
+
})
|
|
344
|
+
.finally(() => {
|
|
345
|
+
if (!controller.signal.aborted) setDetailLoading(false);
|
|
346
|
+
});
|
|
347
|
+
return () => controller.abort();
|
|
348
|
+
}, [currency, detailAttempt, filters, lastUpdatedAt, runPageFrom, runPageTo]);
|
|
349
|
+
const pagedRunRows = useMemo(
|
|
350
|
+
() =>
|
|
351
|
+
(runPageData?.runs ?? []).filter(
|
|
352
|
+
(row) => matches(row, filters) && matchesGlobalFilters(row, globalFilters),
|
|
353
|
+
),
|
|
354
|
+
[filters, globalFilters, runPageData?.runs],
|
|
355
|
+
);
|
|
356
|
+
const dimensionalRows = useMemo(
|
|
357
|
+
() =>
|
|
358
|
+
selectDimensionalCostRows(rows, detailData?.runs)
|
|
359
|
+
.filter((row) => matches(row, filters) && matchesGlobalFilters(row, globalFilters))
|
|
360
|
+
.sort((left, right) => right.started_at.localeCompare(left.started_at)),
|
|
361
|
+
[detailData?.runs, filters, globalFilters, rows],
|
|
362
|
+
);
|
|
363
|
+
const dimensionalDetailPending =
|
|
364
|
+
needsDimensionalDetail && detailData === null && detailError === null;
|
|
172
365
|
const macroDetails = useMemo(() => {
|
|
173
366
|
if (operations === undefined) return undefined;
|
|
174
367
|
const visibleRunIds = new Set(rows.map((row) => row.run_id));
|
|
@@ -177,108 +370,205 @@ export function CostMonitorPage({
|
|
|
177
370
|
runs: operations.runs.filter((run) => visibleRunIds.has(run.id)),
|
|
178
371
|
};
|
|
179
372
|
}, [operations, rows]);
|
|
180
|
-
const
|
|
181
|
-
() =>
|
|
182
|
-
[activeData.prds, globalFilters],
|
|
183
|
-
);
|
|
184
|
-
const visibleSpecs = useMemo(
|
|
185
|
-
() => activeData.specs.filter((spec) => matchesPeriodEntity(spec, globalFilters)),
|
|
186
|
-
[activeData.specs, globalFilters],
|
|
187
|
-
);
|
|
188
|
-
const groups = useMemo(() => {
|
|
189
|
-
const legacy =
|
|
190
|
-
!hasLocalCostFilters &&
|
|
191
|
-
(globalFilters === undefined ||
|
|
192
|
-
(globalFilters.query === "" && globalFilters.datePreset === "all"))
|
|
193
|
-
? (activeData.legacy_effort_baseline ?? null)
|
|
194
|
-
: null;
|
|
195
|
-
const periodEntities = {
|
|
373
|
+
const periodEntities = useMemo(
|
|
374
|
+
() => ({
|
|
196
375
|
prds: activeData.prds.filter((prd) => matchesPeriodEntity(prd, globalFilters)),
|
|
197
376
|
specs: activeData.specs.filter((spec) => matchesPeriodEntity(spec, globalFilters)),
|
|
198
377
|
tasks: (operations?.tasks ?? []).filter((task) => matchesPeriodEntity(task, globalFilters)),
|
|
199
|
-
|
|
378
|
+
evidences: (operations?.evidences ?? []).filter((evidence) =>
|
|
379
|
+
matchesPeriodEntity({ created_at: evidence.observed_at }, globalFilters),
|
|
380
|
+
),
|
|
381
|
+
validations: (operations?.validations ?? []).filter((validation) =>
|
|
382
|
+
matchesPeriodEntity({ created_at: validation.executed_at }, globalFilters),
|
|
383
|
+
),
|
|
384
|
+
}),
|
|
385
|
+
[
|
|
386
|
+
activeData.prds,
|
|
387
|
+
activeData.specs,
|
|
388
|
+
globalFilters,
|
|
389
|
+
operations?.evidences,
|
|
390
|
+
operations?.tasks,
|
|
391
|
+
operations?.validations,
|
|
392
|
+
],
|
|
393
|
+
);
|
|
394
|
+
const visiblePrds = periodEntities.prds;
|
|
395
|
+
const visibleSpecs = periodEntities.specs;
|
|
396
|
+
const useAggregateGroups =
|
|
397
|
+
activeData.aggregate_only === true && dimensionalRows.length === 0 && !hasLocalCostFilters;
|
|
398
|
+
const groups = useMemo(() => {
|
|
399
|
+
if (useAggregateGroups) return activeData.groups;
|
|
200
400
|
return {
|
|
201
401
|
conversations: groupRows(
|
|
202
|
-
|
|
402
|
+
dimensionalRows,
|
|
203
403
|
(row) => row.conversation_id ?? row.task_title ?? row.run_id,
|
|
204
404
|
undefined,
|
|
205
405
|
"all_invocations",
|
|
206
406
|
),
|
|
207
|
-
tasks: aggregateTaskCostRows(periodEntities.tasks,
|
|
407
|
+
tasks: aggregateTaskCostRows(periodEntities.tasks, dimensionalRows),
|
|
208
408
|
providers: groupRows(
|
|
209
|
-
|
|
409
|
+
dimensionalRows,
|
|
210
410
|
(row) => normalizeCostProvider(row.provider),
|
|
211
411
|
undefined,
|
|
212
412
|
"all_invocations",
|
|
213
413
|
),
|
|
214
414
|
agents: includeConfiguredAgentGroups(
|
|
215
|
-
groupRows(
|
|
415
|
+
groupRows(dimensionalRows, (row) => row.agent_name),
|
|
216
416
|
activeData.configured_agents,
|
|
217
417
|
),
|
|
218
|
-
models: groupRows(
|
|
219
|
-
daily:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
418
|
+
models: groupRows(dimensionalRows, (row) => row.model),
|
|
419
|
+
daily: enrichPeriodCostGroups(
|
|
420
|
+
groupRows(
|
|
421
|
+
rows,
|
|
422
|
+
(row) => {
|
|
423
|
+
const timestamp = row.finished_at ?? row.started_at;
|
|
424
|
+
return saoPauloPeriodKey(timestamp, "day") ?? timestamp.slice(0, 10);
|
|
425
|
+
},
|
|
426
|
+
undefined,
|
|
427
|
+
"all_invocations",
|
|
227
428
|
),
|
|
228
|
-
|
|
229
|
-
"
|
|
230
|
-
legacy,
|
|
429
|
+
periodEntities,
|
|
430
|
+
"daily",
|
|
231
431
|
),
|
|
232
|
-
monthly:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
432
|
+
monthly: enrichPeriodCostGroups(
|
|
433
|
+
groupRows(
|
|
434
|
+
rows,
|
|
435
|
+
(row) => {
|
|
436
|
+
const timestamp = row.finished_at ?? row.started_at;
|
|
437
|
+
return saoPauloPeriodKey(timestamp, "month") ?? timestamp.slice(0, 7);
|
|
438
|
+
},
|
|
439
|
+
undefined,
|
|
440
|
+
"all_invocations",
|
|
240
441
|
),
|
|
241
|
-
|
|
242
|
-
"
|
|
243
|
-
legacy,
|
|
442
|
+
periodEntities,
|
|
443
|
+
"monthly",
|
|
244
444
|
),
|
|
245
|
-
annual:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
445
|
+
annual: enrichPeriodCostGroups(
|
|
446
|
+
groupRows(
|
|
447
|
+
rows,
|
|
448
|
+
(row) => {
|
|
449
|
+
const timestamp = row.finished_at ?? row.started_at;
|
|
450
|
+
return saoPauloPeriodKey(timestamp, "year") ?? timestamp.slice(0, 4);
|
|
451
|
+
},
|
|
452
|
+
undefined,
|
|
453
|
+
"all_invocations",
|
|
253
454
|
),
|
|
254
|
-
|
|
255
|
-
"
|
|
256
|
-
legacy,
|
|
455
|
+
periodEntities,
|
|
456
|
+
"annual",
|
|
257
457
|
),
|
|
258
458
|
};
|
|
259
459
|
}, [
|
|
260
460
|
activeData.configured_agents,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
globalFilters,
|
|
264
|
-
operations?.tasks,
|
|
461
|
+
periodEntities,
|
|
462
|
+
dimensionalRows,
|
|
265
463
|
rows,
|
|
266
|
-
|
|
267
|
-
activeData.
|
|
464
|
+
useAggregateGroups,
|
|
465
|
+
activeData.groups,
|
|
268
466
|
]);
|
|
269
|
-
const
|
|
467
|
+
const displayGroups = useMemo(
|
|
468
|
+
() =>
|
|
469
|
+
groupView === null
|
|
470
|
+
? groups
|
|
471
|
+
: {
|
|
472
|
+
...groups,
|
|
473
|
+
[groupView]:
|
|
474
|
+
groupPageState.page === null
|
|
475
|
+
? []
|
|
476
|
+
: groupView === "agents"
|
|
477
|
+
? includeConfiguredAgentGroups(groupPageState.page.rows, activeData.configured_agents)
|
|
478
|
+
: [...groupPageState.page.rows],
|
|
479
|
+
},
|
|
480
|
+
[activeData.configured_agents, groups, groupPageState.page, groupView],
|
|
481
|
+
);
|
|
482
|
+
const overview = useAggregateGroups
|
|
483
|
+
? activeData.overview
|
|
484
|
+
: {
|
|
485
|
+
...summarizeCostRows(rows, activeData.overview),
|
|
486
|
+
task_count: periodEntities.tasks.length,
|
|
487
|
+
};
|
|
488
|
+
const canonicalDurationTotal = groups.annual.reduce(
|
|
489
|
+
(total, row) => total + row.duration.known_sum,
|
|
490
|
+
0,
|
|
491
|
+
);
|
|
492
|
+
// Model/provider rows intentionally omit untrusted dimensions. Their footer
|
|
493
|
+
// remains the canonical card population for the same filters, never the
|
|
494
|
+
// visible subset or its paginated SQLite total.
|
|
495
|
+
const cardMetrics = operations?.summary.overview_metrics;
|
|
496
|
+
const cardDurationTotal = cardMetrics ? cardMetrics.duration_ms : canonicalDurationTotal;
|
|
497
|
+
const summaryTotals = {
|
|
498
|
+
run_count: overview.run_count,
|
|
499
|
+
task_count: cardMetrics?.task_count ?? overview.task_count,
|
|
500
|
+
prd_count: cardMetrics?.prd_count ?? cardMetrics?.selected_counts?.prds ?? 0,
|
|
501
|
+
spec_count: cardMetrics?.spec_count ?? cardMetrics?.selected_counts?.specs ?? 0,
|
|
502
|
+
evidence_count: 0,
|
|
503
|
+
test_count: 0,
|
|
504
|
+
event_count: overview.event_count,
|
|
505
|
+
total_tokens: cardMetrics?.tokens ?? overview.total_tokens,
|
|
506
|
+
estimated_usd: overview.estimated_usd,
|
|
507
|
+
estimated_brl: cardMetrics?.cost_brl ?? overview.estimated_brl,
|
|
508
|
+
duration_ms: cardDurationTotal,
|
|
509
|
+
duration: {
|
|
510
|
+
known_sum: cardDurationTotal ?? 0,
|
|
511
|
+
unknown: cardDurationTotal === null ? 1 : 0,
|
|
512
|
+
complete: cardDurationTotal !== null,
|
|
513
|
+
coverage_ratio: cardDurationTotal === null ? 0 : 1,
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
const visibleExecutions = useMemo(
|
|
517
|
+
() => visibleExecutionRows(operations?.executions ?? [], rows),
|
|
518
|
+
[operations?.executions, rows],
|
|
519
|
+
);
|
|
520
|
+
const compactKind = compactReadModelKind(view);
|
|
521
|
+
const usingCompactPage = compactKind !== null && loadReadModelPage !== undefined;
|
|
270
522
|
const exportRows = useMemo(() => {
|
|
271
|
-
if (
|
|
523
|
+
if (usingCompactPage) return compactPage?.rows ?? [];
|
|
524
|
+
if (view === "executions") return visibleExecutions;
|
|
272
525
|
if (view === "conversations") return groups.conversations;
|
|
273
526
|
if (view === "tasks") return groups.tasks;
|
|
274
527
|
if (view === "prds") return visiblePrds;
|
|
275
528
|
if (view === "specs") return visibleSpecs;
|
|
276
529
|
if (view === "providers" || view === "agents") return groups[view];
|
|
277
530
|
if (view === "daily" || view === "monthly" || view === "annual") return groups[view];
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
531
|
+
return rows;
|
|
532
|
+
}, [
|
|
533
|
+
compactPage?.rows,
|
|
534
|
+
groups,
|
|
535
|
+
rows,
|
|
536
|
+
usingCompactPage,
|
|
537
|
+
view,
|
|
538
|
+
visibleExecutions,
|
|
539
|
+
visiblePrds,
|
|
540
|
+
visibleSpecs,
|
|
541
|
+
]);
|
|
542
|
+
const compactExportSource =
|
|
543
|
+
usingCompactPage &&
|
|
544
|
+
compactKind !== null &&
|
|
545
|
+
compactPage !== null &&
|
|
546
|
+
loadReadModelPage !== undefined
|
|
547
|
+
? {
|
|
548
|
+
totalRows: compactPage.total,
|
|
549
|
+
pages: async function* () {
|
|
550
|
+
const seen = new Set<string>();
|
|
551
|
+
for (let offset = 0; offset < compactPage.total; offset += compactPage.limit) {
|
|
552
|
+
const page = await loadReadModelPage({
|
|
553
|
+
kind: compactKind,
|
|
554
|
+
offset,
|
|
555
|
+
limit: compactPage.limit,
|
|
556
|
+
filters,
|
|
557
|
+
...(runPageRange === undefined ? {} : runPageRange),
|
|
558
|
+
...(globalFilters?.query ? { query: globalFilters.query } : {}),
|
|
559
|
+
});
|
|
560
|
+
const unique = page.rows
|
|
561
|
+
.filter((row) => {
|
|
562
|
+
if (seen.has(row.id)) return false;
|
|
563
|
+
seen.add(row.id);
|
|
564
|
+
return true;
|
|
565
|
+
})
|
|
566
|
+
.map(withTokenBackedCompactDuration);
|
|
567
|
+
if (unique.length > 0) yield unique as unknown as readonly Record<string, unknown>[];
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
}
|
|
571
|
+
: undefined;
|
|
282
572
|
const changeLocale = (next: CostLocale) => {
|
|
283
573
|
onLocaleChange(next);
|
|
284
574
|
setCurrency(localeCurrency(next));
|
|
@@ -480,162 +770,76 @@ export function CostMonitorPage({
|
|
|
480
770
|
{embedded ? null : (
|
|
481
771
|
<>
|
|
482
772
|
<CostSummary currency={currency} locale={locale} overview={overview} />
|
|
483
|
-
<div className="cost-coverage-note">
|
|
484
|
-
<span>.agents/records/lifecycle + telemetry manifests</span>
|
|
485
|
-
<strong>
|
|
486
|
-
{overview.coverage.tokens}/{overview.coverage.events} eventos com tokens ·{" "}
|
|
487
|
-
{overview.coverage.brl}/{overview.coverage.events} com custo
|
|
488
|
-
</strong>
|
|
489
|
-
</div>
|
|
490
773
|
{capabilityNavigation}
|
|
491
774
|
</>
|
|
492
775
|
)}
|
|
493
|
-
<
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
<ExcelExportAction
|
|
505
|
-
filters={{ ...filters, ...globalFilters, period, agentCallKind }}
|
|
506
|
-
rows={exportRows as unknown as readonly Record<string, unknown>[]}
|
|
507
|
-
view={`cost-${view}`}
|
|
508
|
-
/>
|
|
509
|
-
</nav>
|
|
510
|
-
<section
|
|
511
|
-
className={`cost-content cost-content-${view} ${view === "overview" ? "cost-content-overview" : ""}`}
|
|
512
|
-
>
|
|
513
|
-
{view === "overview" ? (
|
|
514
|
-
<CostCharts
|
|
515
|
-
currency={currency}
|
|
516
|
-
daily={groups.daily}
|
|
517
|
-
locale={locale}
|
|
518
|
-
models={groups.models}
|
|
519
|
-
rows={rows}
|
|
520
|
-
/>
|
|
521
|
-
) : null}
|
|
522
|
-
{view === "agentCalls" ? (
|
|
523
|
-
<>
|
|
524
|
-
<nav
|
|
525
|
-
aria-label={locale === "pt-BR" ? "Tipo de chamada de agente" : "Agent call type"}
|
|
526
|
-
className="cost-run-kind-toolbar"
|
|
776
|
+
<div className="cost-tabs-bar">
|
|
777
|
+
<nav aria-label="Visões de custo" className="cost-tabs">
|
|
778
|
+
{COST_VIEW_ORDER.map((key) => (
|
|
779
|
+
<button
|
|
780
|
+
aria-pressed={view === key}
|
|
781
|
+
className={view === key ? "is-active" : undefined}
|
|
782
|
+
key={key}
|
|
783
|
+
onClick={() => {
|
|
784
|
+
setView(key);
|
|
785
|
+
}}
|
|
786
|
+
type="button"
|
|
527
787
|
>
|
|
528
|
-
{
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
? "Todos"
|
|
539
|
-
: "All"
|
|
540
|
-
: kind === "run"
|
|
541
|
-
? locale === "pt-BR"
|
|
542
|
-
? "Invocações do orquestrador"
|
|
543
|
-
: "Orchestrator invocations"
|
|
544
|
-
: locale === "pt-BR"
|
|
545
|
-
? "Invocações delegadas"
|
|
546
|
-
: "Delegated invocations"}
|
|
547
|
-
</button>
|
|
548
|
-
))}
|
|
549
|
-
</nav>
|
|
550
|
-
<CostRunsTable
|
|
551
|
-
currency={currency}
|
|
552
|
-
locale={locale}
|
|
553
|
-
onOpenRun={openRunDetails}
|
|
554
|
-
rows={
|
|
555
|
-
agentCallKind === "all"
|
|
556
|
-
? rows
|
|
557
|
-
: rows.filter((row) => row.run_kind === agentCallKind)
|
|
558
|
-
}
|
|
559
|
-
/>
|
|
560
|
-
</>
|
|
561
|
-
) : null}
|
|
562
|
-
{view === "executions" ? (
|
|
563
|
-
<ExecutionTable locale={locale} rows={operations?.executions ?? []} />
|
|
564
|
-
) : null}
|
|
565
|
-
{view === "conversations" ? (
|
|
566
|
-
<CostGroupsTable
|
|
567
|
-
currency={currency}
|
|
568
|
-
labelHeading={locale === "pt-BR" ? "Conversa" : "Conversation"}
|
|
569
|
-
locale={locale}
|
|
570
|
-
rows={groups.conversations}
|
|
571
|
-
/>
|
|
572
|
-
) : null}
|
|
573
|
-
{view === "tasks" ? (
|
|
574
|
-
<CostGroupsTable
|
|
575
|
-
currency={currency}
|
|
576
|
-
dateHeading={locale === "pt-BR" ? "Criada em" : "Created at"}
|
|
577
|
-
labelHeading={locale === "pt-BR" ? "Tarefa" : "Task"}
|
|
578
|
-
locale={locale}
|
|
579
|
-
onOpenTrace={onOpenTrace}
|
|
580
|
-
rows={groups.tasks}
|
|
581
|
-
/>
|
|
582
|
-
) : null}
|
|
583
|
-
{view === "prds" ? (
|
|
584
|
-
<MacroCostTable
|
|
585
|
-
currency={currency}
|
|
586
|
-
locale={locale}
|
|
587
|
-
onOpenTrace={onOpenTrace}
|
|
588
|
-
rows={visiblePrds}
|
|
589
|
-
{...(macroDetails ? { details: macroDetails } : {})}
|
|
788
|
+
{text.tabs[key]}
|
|
789
|
+
</button>
|
|
790
|
+
))}
|
|
791
|
+
</nav>
|
|
792
|
+
<div className="cost-tab-export">
|
|
793
|
+
<ExcelExportAction
|
|
794
|
+
filters={{ ...filters, ...globalFilters, period }}
|
|
795
|
+
{...(compactExportSource === undefined ? {} : { pageSource: compactExportSource })}
|
|
796
|
+
rows={exportRows as unknown as readonly Record<string, unknown>[]}
|
|
797
|
+
view={`cost-${view}`}
|
|
590
798
|
/>
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
{
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
/>
|
|
636
|
-
</>
|
|
637
|
-
) : null}
|
|
638
|
-
</section>
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
{/* CostMonitorContent owns `view === "models" && useAggregateGroups ? (` and `rows={groups.models}`. */}
|
|
802
|
+
<CostMonitorContent
|
|
803
|
+
canonicalDurationTotal={canonicalDurationTotal}
|
|
804
|
+
compactPage={compactPage}
|
|
805
|
+
compactPageError={compactPageError}
|
|
806
|
+
compactPageLoading={compactPageLoading}
|
|
807
|
+
compactPageOffset={compactPageOffset}
|
|
808
|
+
currency={currency}
|
|
809
|
+
detailError={detailError}
|
|
810
|
+
detailLoading={detailLoading}
|
|
811
|
+
dimensionalDetailPending={dimensionalDetailPending}
|
|
812
|
+
dimensionalRows={dimensionalRows}
|
|
813
|
+
groups={displayGroups}
|
|
814
|
+
groupPage={groupView === null ? null : groupPageState.page}
|
|
815
|
+
groupPageLoading={groupView === null ? false : groupPageState.loading}
|
|
816
|
+
groupPageOffset={groupPageState.offset}
|
|
817
|
+
setGroupPageOffset={groupPageState.setOffset}
|
|
818
|
+
locale={locale}
|
|
819
|
+
macroDetails={macroDetails}
|
|
820
|
+
onOpenRun={openRunDetails}
|
|
821
|
+
onOpenTrace={onOpenTrace}
|
|
822
|
+
pagedRunRows={pagedRunRows}
|
|
823
|
+
retryCompactPage={retryCompactPage}
|
|
824
|
+
retryRunPage={retryRunPage}
|
|
825
|
+
rows={rows}
|
|
826
|
+
runPageData={runPageData}
|
|
827
|
+
runPageError={runPageError}
|
|
828
|
+
runPageLoading={runPageLoading}
|
|
829
|
+
runPageOffset={runPageOffset}
|
|
830
|
+
serverPagingEligible={serverPagingEligible}
|
|
831
|
+
setCompactPageOffset={setCompactPageOffset}
|
|
832
|
+
setDetailAttempt={setDetailAttempt}
|
|
833
|
+
setRunPageOffset={setRunPageOffset}
|
|
834
|
+
summaryUsage={activeData.usage}
|
|
835
|
+
summaryTotals={summaryTotals}
|
|
836
|
+
useAggregateGroups={useAggregateGroups}
|
|
837
|
+
usingCompactPage={usingCompactPage}
|
|
838
|
+
view={view}
|
|
839
|
+
visibleExecutions={visibleExecutions}
|
|
840
|
+
visiblePrds={visiblePrds}
|
|
841
|
+
visibleSpecs={visibleSpecs}
|
|
842
|
+
/>
|
|
639
843
|
{selectedRun ? (
|
|
640
844
|
<EntityDetailsDialog
|
|
641
845
|
details={{ kind: "run", row: selectedRun }}
|
|
@@ -646,130 +850,3 @@ export function CostMonitorPage({
|
|
|
646
850
|
</Root>
|
|
647
851
|
);
|
|
648
852
|
}
|
|
649
|
-
|
|
650
|
-
function matches(row: CostRunRow, filter: CostFilterState): boolean {
|
|
651
|
-
const query = filter.query.trim().toLowerCase();
|
|
652
|
-
return (
|
|
653
|
-
(!query ||
|
|
654
|
-
[row.run_id, row.task_title, row.model, row.requested_model, row.agent, row.agent_name].some(
|
|
655
|
-
(value) => value.toLowerCase().includes(query),
|
|
656
|
-
)) &&
|
|
657
|
-
(!filter.provider || normalizeCostProvider(row.provider) === filter.provider) &&
|
|
658
|
-
(!filter.agent || row.agent_name === filter.agent) &&
|
|
659
|
-
(!filter.model || row.model === filter.model) &&
|
|
660
|
-
(!filter.status || row.task_status === filter.status) &&
|
|
661
|
-
(!filter.priority || row.priority === filter.priority) &&
|
|
662
|
-
(!filter.risk || row.risk === filter.risk) &&
|
|
663
|
-
(!filter.phase || row.phase === filter.phase) &&
|
|
664
|
-
(!filter.origin || row.origin === filter.origin) &&
|
|
665
|
-
(!filter.workType || row.work_type === filter.workType)
|
|
666
|
-
);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
export function matchesGlobalFilters(
|
|
670
|
-
row: CostRunRow,
|
|
671
|
-
filters: { query: string; dateRange?: { start: string; end: string } } | undefined,
|
|
672
|
-
): boolean {
|
|
673
|
-
if (!filters) return true;
|
|
674
|
-
const query = filters.query.trim().toLocaleLowerCase();
|
|
675
|
-
if (filters.dateRange === undefined) {
|
|
676
|
-
return (
|
|
677
|
-
!query ||
|
|
678
|
-
[
|
|
679
|
-
row.run_id,
|
|
680
|
-
row.task_id,
|
|
681
|
-
row.task_title,
|
|
682
|
-
row.provider,
|
|
683
|
-
row.agent,
|
|
684
|
-
row.agent_name,
|
|
685
|
-
row.model,
|
|
686
|
-
row.requested_model,
|
|
687
|
-
row.phase,
|
|
688
|
-
].some((value) => value?.toLocaleLowerCase().includes(query))
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
const startedDate = saoPauloPeriodKey(row.started_at, "day") ?? row.started_at.slice(0, 10);
|
|
692
|
-
return (
|
|
693
|
-
startedDate >= filters.dateRange.start &&
|
|
694
|
-
startedDate <= filters.dateRange.end &&
|
|
695
|
-
(!query ||
|
|
696
|
-
[
|
|
697
|
-
row.run_id,
|
|
698
|
-
row.task_id,
|
|
699
|
-
row.task_title,
|
|
700
|
-
row.provider,
|
|
701
|
-
row.agent,
|
|
702
|
-
row.agent_name,
|
|
703
|
-
row.model,
|
|
704
|
-
row.requested_model,
|
|
705
|
-
row.phase,
|
|
706
|
-
].some((value) => value?.toLocaleLowerCase().includes(query)))
|
|
707
|
-
);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
export function groupRows(
|
|
711
|
-
rows: readonly CostRunRow[],
|
|
712
|
-
select: (row: CostRunRow) => string,
|
|
713
|
-
label: (row: CostRunRow) => string = select,
|
|
714
|
-
durationScope: "root_execution" | "all_execution" | "all_invocations" = "all_invocations",
|
|
715
|
-
): CostGroupRow[] {
|
|
716
|
-
const contributors = durationContributors(rows, durationScope);
|
|
717
|
-
const groups = new Map<string, CostRunRow[]>();
|
|
718
|
-
for (const row of rows) groups.set(select(row), [...(groups.get(select(row)) ?? []), row]);
|
|
719
|
-
return [...groups]
|
|
720
|
-
.map(([key, items]) => ({
|
|
721
|
-
...(() => {
|
|
722
|
-
const duration = aggregateDurationCoverage(
|
|
723
|
-
contributors.filter((candidate) => items.includes(candidate)),
|
|
724
|
-
durationScope === "all_execution" ? "all_execution" : "all_invocations",
|
|
725
|
-
);
|
|
726
|
-
return { duration_ms: duration.complete ? duration.known_sum : null, duration };
|
|
727
|
-
})(),
|
|
728
|
-
key,
|
|
729
|
-
label: label(items[0] as CostRunRow),
|
|
730
|
-
latest_started_at: items.reduce(
|
|
731
|
-
(latest, row) => (row.started_at > latest ? row.started_at : latest),
|
|
732
|
-
items[0]?.started_at ?? "",
|
|
733
|
-
),
|
|
734
|
-
run_count: items.length,
|
|
735
|
-
task_count: new Set(items.flatMap((row) => (row.task_id ? [row.task_id] : []))).size,
|
|
736
|
-
tasksActive: new Set(items.flatMap((row) => (row.task_id ? [row.task_id] : []))).size,
|
|
737
|
-
taskDaysActive: new Set(items.flatMap((row) => (row.task_id ? [row.task_id] : []))).size,
|
|
738
|
-
prd_count: 0,
|
|
739
|
-
spec_count: 0,
|
|
740
|
-
evidence_count: 0,
|
|
741
|
-
test_count: 0,
|
|
742
|
-
event_count: items.reduce((sum, row) => sum + row.event_count, 0),
|
|
743
|
-
total_tokens: sumKnown(items.map((row) => row.total_tokens)),
|
|
744
|
-
estimated_usd: sumKnown(items.map((row) => row.estimated_usd)),
|
|
745
|
-
estimated_brl: sumKnown(items.map((row) => row.estimated_brl)),
|
|
746
|
-
coverage: items.reduce(
|
|
747
|
-
(sum, row) => ({
|
|
748
|
-
events: sum.events + row.coverage.events,
|
|
749
|
-
tokens: sum.tokens + row.coverage.tokens,
|
|
750
|
-
usd: sum.usd + row.coverage.usd,
|
|
751
|
-
brl: sum.brl + row.coverage.brl,
|
|
752
|
-
}),
|
|
753
|
-
{ events: 0, tokens: 0, usd: 0, brl: 0 },
|
|
754
|
-
),
|
|
755
|
-
}))
|
|
756
|
-
.sort((a, b) => b.latest_started_at.localeCompare(a.latest_started_at));
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
export function matchesPeriodEntity(
|
|
760
|
-
entity: { id?: string; title?: string; created_at: string | null },
|
|
761
|
-
filters: { query: string; dateRange?: { start: string; end: string } } | undefined,
|
|
762
|
-
): boolean {
|
|
763
|
-
if (filters === undefined) return true;
|
|
764
|
-
const query = filters.query.trim().toLowerCase();
|
|
765
|
-
if (
|
|
766
|
-
query &&
|
|
767
|
-
![entity.id ?? "", entity.title ?? ""].some((value) => value.toLowerCase().includes(query))
|
|
768
|
-
) {
|
|
769
|
-
return false;
|
|
770
|
-
}
|
|
771
|
-
if (filters.dateRange === undefined) return true;
|
|
772
|
-
if (entity.created_at === null) return false;
|
|
773
|
-
const date = saoPauloPeriodKey(entity.created_at, "day") ?? entity.created_at.slice(0, 10);
|
|
774
|
-
return date >= filters.dateRange.start && date <= filters.dateRange.end;
|
|
775
|
-
}
|